$(function() {
	create_slideshow();		//background slide show

if($.browser.msie && $.browser.version=='7.0'){ $('#middle2').css('margin-top','2px');}	//in ie7 this link is going down so we are shifting it up from 6px to 2px

	$(window).load(function() {
/*		$("div#makeMeScrollable").smoothDivScroll({ 
			autoScroll: "onstart" , 
			autoScrollDirection: "backandforth", 
			autoScrollStep: 1, 
			countOnlyClass: ".main_img",
			autoScrollInterval: 60,	
			startAtElementId: "startAtMe", 
			visibleHotSpots: "onstart",
			hotSpotsVisibleTime:	3
		});
		
		$("div#prev_fest_scroll").smoothDivScroll({ 
			autoScroll: "" , 
			autoScrollDirection: "backandforth", 
			autoScrollStep: 80, 
			countOnlyClass: ".festi",
			autoScrollInterval: 100,	
			startAtElementId: "startAtMe", 
			visibleHotSpots: ""
			
		});*/
		$("div#gal_year_scroll").smoothDivScroll({ 
			autoScroll: "" ,
			scrollingHotSpotLeft: "div.left_scr",
			scrollingHotSpotRight: "div.right_scr",
			autoScrollDirection: "backandforth", 
			autoScrollStep: 0, 
			autoScrollInterval: 300,	
			startAtElementId: "startAtMe"
			
		});
		$("div#sponsor_scroll").smoothDivScroll({ 
			autoScroll: "" ,
			autoScrollDirection: "backandforth", 
			autoScrollStep: 1, 
			autoScrollInterval: 300,	
			startAtElementId: "startAtMe",
			visibleHotSpots: ""
		});
	});
	//visibleHotSpots: "always"

/*$("div#makeMeScrollable").bind("mouseover", function() {
	$(this).smoothDivScroll("stopAutoScroll");
}).bind("mouseout", function() {
	$(this).smoothDivScroll("startAutoScroll");
});*/

	//code used to go to section according to the url #
	var pathname = window.location;
	pathname=String(pathname);
	pathname=pathname.split('#');
	var right=pathname[1];
	//alert(left);
	if(right!=null && right){
		//if(right=='home'){ajax_home()}
		if(right=='contactus'){ajax_contactus()}
		if(right=='join_mailing'){ajax_join_mailing()}
		if(right=='sponsors'){ajax_sponsors()}
		if(right=='palace'){ajax_palace(1)}
		if(right=='art_festival'){ajax_art_festival(1)}
		if(right=='prev_festival'){ajax_prev_festival()}
		if(right=='booking'){ajax_booking()}
		if(right=='gallery'){ajax_gallery()}
}
	//code used to go to section according to the url #


$('#middle1').hover(function(){$('#bottom_2').hide(); $('.bottom_menu').stop(true,false).animate({height:'25px'},200); $('#bottom_1').show();  }  );

$('#middle2').hover(function(){$('#bottom_1').hide(); $('.bottom_menu').stop(true,false).animate({height:'25px'},200); $('#bottom_2').show();  }  );

$('.container').hover( function(){ $('.bottom_menu').stop(true,false).animate({height:'0px'},300); $('#bottom_1, #bottom_2').hide();  } );
$('.top_menu').hover( function(){ $('.bottom_menu').stop(true,false).animate({height:'0px'},300); $('#bottom_1, #bottom_2').hide();  } );

$('#middle3, #middle4, #middle5 ').hover(function(){$('#bottom_1, #bottom_2').hide();  $('.bottom_menu').animate({height:'0px'},200);}  );

//$('#middle_menu_content div').hover(function(){ $('.bottom_menu').animate({height:'25px'},200);}  );


var hide=1;		//show hide right section

$('#top2').hover( function(){	$('#top2_img').attr('src','images/festivalprog_h.png');}, function(){
									if(hide==1){$('#top2_img').attr('src','images/festivalprog.png');}	}
				)
/*$('#top2, #prog_top').click( function(){//alert(hide);
						  if(hide==2){$('#prog_cont_new').animate({height:'1px'},400); $('#arrow').attr('src','images/u_arrow.png'); hide=1;
						  		$('#top2_img').attr('src','images/festivalprog.png');}
						  else if(hide==1){$('#prog_cont_new').animate({height:'487px'},400); $('#arrow').attr('src','images/d_arrow.png'); hide=2;
						  	$('#top2_img').attr('src','images/festivalprog_h.png');}
						  } 
				)*/
//Rollover hide right section
 $('#arrow, #prog_top').hover(function(){ if(hide==2){$('#arrow').attr('src','images/d_arrow_h.png');}  if(hide==1){$('#arrow').attr('src','images/u_arrow_h.png');}
								}, function(){
								if(hide==2){$('#arrow').attr('src','images/d_arrow.png');}	if(hide==1){$('#arrow').attr('src','images/u_arrow.png');}
							   }
					  ) 
 
 $('.close, .close_fest, .close_new').hover(function(){ $(this).attr('src','images/close_h.png');
								}, function(){
								$(this).attr('src','images/close.png');
							   }
					  )

/*var conter=1;
$('.main_img').hover( function(){ $("#makeMeScrollable").smoothDivScroll("stopAutoScroll");});
$('.main_img').click( function(){ 	
							   		if(conter==1){scroll_width=$('.scrollableArea').width();}
									
							   		curr_id=$(this).attr('id'); curr_id=curr_id.split('_'); curr_id=curr_id[1];
									sub_img_width=$('#subevent_'+curr_id).width();
									sub_img_height=$('#subevent_'+curr_id).height();
									
									new_scroll_width=scroll_width+sub_img_width;
									//alert(scroll_width);alert(sub_img_width);alert(new_scroll_width);
									$('.scrollableArea').css('width',new_scroll_width);
									
									$('.sub_img').hide();
									$('.close').hide();
									
									$('#close_'+curr_id).show();
									//$('#subevent_'+curr_id).animate({width:'0px', height:sub_img_height+'px'},0).show().animate({width:sub_img_width+'px'},300);
									$('#subevent_'+curr_id).slideDown();
									
									conter++;
							   })
$('.close').click( function(){ 		
									//alert(scroll_width);
									$('.scrollableArea').css('width',scroll_width);
									$('.sub_img').slideUp();
									$('.close').hide();

							   })*/


initialize_slider();
$('#li_arr').click( function(){ 		 		$('#sub_title img').attr('src','images/history_title.png')				   })
$('#ri_arr').click( function(){ 				$('#sub_title img').attr('src','images/get_to_title.png')    				})


$('#li_arr').hover( function(){ $(this).attr('src','images/history_sublink_h.png') },   function(){ $(this).attr('src','images/history_sublink.png') }  )
$('#ri_arr').hover( function(){ $(this).attr('src','images/get_to_sublink_h.png')	},   function(){ $(this).attr('src','images/get_to_sublink.png') }   )


$('.part_1').hover( function(){ $(this).attr('src','images/story_sublink_h.png') },   function(){ $(this).attr('src','images/story_sublink.png') }  )
$('.part_2').hover( function(){ $(this).attr('src','images/perf_sublink_h.png') },   function(){ $(this).attr('src','images/perf_sublink.png') }  )
$('.part_3').hover(function(){  $(this).attr('src','images/committee_sublink_h.png') },   function(){ $(this).attr('src','images/committee_sublink.png') }  )
$('#s_1, #s_3,#p_1, #p_2').hide();


	//SART to make the committee section work and rollover
var curr_img='exec';
var src=1;
var img=2;
$('#com_title img').hover(function(){ 
								   src=$(this).attr('src');
								   imgx=src.split('/');
								   imgx=imgx[1];
								   img=imgx.split('.');
								   img=img[0];
								   
								   //alert(curr_img);alert(img);
								   	if((curr_img+'_h')!=img ){
								   $(this).attr('src','images/'+img+'_h.png');
								   //alert(img);
										 }
								   },
					  function(){ if(curr_img!=img ) $(this).attr('src','images/'+img+'.png'); })
$('#com_title img').click(function(){ 
									 //alert(curr_img);
									 $('#curr_img').attr('src','images/'+curr_img+'.png');
									 $('#curr_img').attr('id','');
									 $(this).attr('id','curr_img');
									 curr_img=img;
								   })
	//END committee section



//scroller init and rollover
start_scrolling();


//animat the slide in and out in orev fest
/*var counter=1;
var prev_id=-1;
$('.festi').click( function(){ 		
							   		if(counter==1)scroll_width=$('.scrollableArea').width();
									
							   		curr_id=$(this).attr('id'); curr_id=curr_id.split('_'); curr_id=curr_id[1];
									if(prev_id==curr_id)return;
									//alert(curr_id);
									$('.festo').animate({width:'0px'},300);
									$('.close_fest').hide();
									
									$('#close_fest_'+curr_id).show();
									//$('#subevent_'+curr_id).animate({width:'0px', height:sub_img_height+'px'},0).show().animate({width:sub_img_width+'px'},300);
									$('#festo_'+curr_id).animate({width:'446px'},300);
									
									counter++;
									prev_id=curr_id;
							   })
$('.close_fest').click( function(){ 		
									//alert(scroll_width);
									$('.festo').animate({width:'0px'},300);
									$('.close_fest').hide();
									prev_id=-1;

							   })*/


//start_pirobox();

$('#join_button').hover( function(){$(this).attr('src','images/join_h.png')} , function(){$(this).attr('src','images/join.png')}  );

//sponsors section
$('.wraptocenter').hover( function(){ 
										spons_id=$(this).find('.sponser_img').attr('id');
										//alert(spons_id);
									//spons_id=$(this).attr('id');
									
									saturate(spons_id);
										} , function(){
									desaturate(spons_id);
										}  );
$('.mini_wraptocenter').hover( function(){ 
										mini_spons_id=$(this).find('.mini_sponser_img').attr('id');
										//alert(spons_id);
									//spons_id=$(this).attr('id');
									
									saturate(mini_spons_id);
										} , function(){
									desaturate(mini_spons_id);
										}  );

//desaturate('home_imago');
//$('#home_imago').click(function(){saturate('home_imago');})


$('.sponsor_bigbox').hover(function(){ //alert('rob'); 
										   //return;
							   	 $(this).find('.text_box').slideDown();
							   //$(this).find('#type_box').css('border-top','1px solid #2A99C1'); $(this).find('.text_box').css({'background-color':'#096584', 'color':'#fff'}); 
							   } ,function(){  
								$(this).find('.text_box').slideUp();
								//$(this).find('#type_box').css('border-top','0px');; $(this).find('.text_box').css({'background-color':'#fff', 'color':'#054666'});  
									})



$('.main_img_new').click( function(){	//we should change the box with according to the number of elements
							   		curr_id=$(this).attr('id'); curr_id=curr_id.split('_'); curr_id=curr_id[1];
									if(prev_id==curr_id)return;
									var sub_prog_cont=$('#sub_prog_cont').width();
									
									//sub_img_width=$('#subevent_'+curr_id).width();
									//sub_img_height=$('#subevent_'+curr_id).height();
									
									//new_scroll_width=scroll_width+sub_img_width;
									//alert(scroll_width);alert(sub_img_width);alert(new_scroll_width);
									//$('.scrollableArea').css('width',new_scroll_width);
									$('.event_info_new').animate({width:'0px'},300);
									$('.close_new').hide();
									
									miz=$('#sub_prog_cont').css('left');
									//alert(sub_prog_cont);
									
									//alert(step);
										
										box_hight=196;
										if(curr_id>=2){
											if(curr_id==2){ value=box_hight*1;}
											if(curr_id==3){ value=box_hight*2;}
											if(curr_id==4){ value=box_hight*3;}
											if(curr_id==5){ value=box_hight*4;}
											if(curr_id==6){ value=box_hight*5;}
											if(curr_id==7){ value=box_hight*6; }
											if(curr_id==8){ value=box_hight*7; }
											if(curr_id==9){ value=(box_hight*8)-105; }
											
											$('#sub_prog_cont').animate({'left':'-'+value+'px'},400);
											$('#sub_prog_cont').width('2306px');
											stoper=1340; step=-value;
										}
											 
										
											$('#close_'+curr_id).fadeIn();
											$('#event_info_new_'+curr_id).animate({width:'310px'},600);
									
									prev_id=curr_id;
							   })
$('.close_new').click( function(){ 		
									$('.event_info_new').animate({width:'0px'},400);//slideUp();
									  stoper=1146; 
									 //alert(curr_id);
									if(curr_id==8 || curr_id==9 ){step=step+310; $('#sub_prog_cont').animate({'left':step+'px'},400);}
									 $('#sub_prog_cont').animate({width:'1996px'},300);
									$('.close').hide();
									prev_id=-1;
							   })

//put the light cover in prev fest	, prev fest area
$(".festi").hover( function(){$(this).find('.layer').show(); $(this).find('.year').css({'color':'#fff', 'text-decoration':'underline'}); }, function(){
								 $(this).find('.layer').hide(); $(this).find('.year').css({'color':'#1d1d1d', 'text-decoration':'none'});})
var counter=1;
var prev_id=-1;
$('.festi').click( function(){ 		
									curr_id=$(this).attr('id'); curr_id=curr_id.split('_'); curr_id=curr_id[1];
									if(prev_id==curr_id)return;
									count_of_fest=$('.festi').attr('lang');
									count_of_fest=parseInt(count_of_fest)
									new_widtho=	145*( (count_of_fest+1.2) );
									$('#sub_prev_fest').width(new_widtho+'px');//we should change the box with according to the number of elements
									
						
									$('.festo').animate({width:'0px'},300);
									$('.close_fest').hide();
									$('.year').animate({left:'86px'},300).css('color','#1d1d1d');
									
									box_width=156;
									width_after_open=new_widtho+450;
									if(curr_id>=1){
											for(i=3;i<count_of_fest;i++){
												if(curr_id==i){	value=267+(box_width*(i-2));}
											}
											if(curr_id==1){value=100;}
											if(curr_id==2){value=267;}
											
										$('#sub_prev_fest').animate({'left':'-'+value+'px'},400);
										$('#sub_prev_fest').width(width_after_open+'px');
										//stoper_p=1260;
										stoper_p=145*(count_of_fest-4+0.25)+450;
										step_p=-value
									}
									
									$('#year_'+curr_id).animate({left:'537px'},300).css('color','#fff');
									
									$('#close_fest_'+curr_id).fadeIn();
									$('#festo_'+curr_id).animate({width:'446px'},300);
									
									prev_id=curr_id;
							   })
$('.close_fest').click( function(){ 		
									//alert(scroll_width);
									$('.festo').animate({width:'0px'},300);
									$('.year').animate({left:'86px'},300).css('color','#1d1d1d');
									
									stoper_p=145*(count_of_fest-4+0.25); //step_p=step_p;
									if(curr_id==(count_of_fest-1) || curr_id==(count_of_fest-2) ){
										step_p=parseInt(step_p);
										step_p=step_p+(120*4);
										$('#sub_prev_fest').animate({'left':step_p+'px'},400);
									}
									 $('#sub_prev_fest').animate({width:new_widtho+'px'},300);
									
									$('.close_fest').hide();
									prev_id=-1;

							   })


$(".main_img_new").hover( function(){$(this).find('.layer_prog').show(); }, function(){$(this).find('.layer_prog').hide();})


start_fancy();
	
		/*$(document).ready(function() {


			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});



		});*/
	
//menu_previous_img='gg';
old_image='jj';	
here='dd';
$('.menu_links').hover( function(){ 
								  src_i=$(this).find('img').attr('src');
									   img_i=src_i.split('/');
									   //alert(img_i.length)
									   img_i=img_i[img_i.length-1];
									   menu_current_img=img_i.split('.');
									   menu_current_img=menu_current_img[0];
									   
								 if(current_img+'_h'!=menu_current_img){
									 $(this).find('img').attr('src','images/'+menu_current_img+'_h.png');
								 }
								 
						},function(){//alert(current_img); alert(menu_current_img);
								if(current_img!=menu_current_img){$(this).find('img').attr('src','images/'+menu_current_img+'.png');}
								 });

$('.menu_links').click(function(){ 

								if(old_image+'_h'==menu_current_img)return;
								$('#here').attr('src','images/'+old_image+'.png');
								$(this).find('img').attr('src','images/'+menu_current_img+'_h.png');
								current_img=menu_current_img;
								
								$('#curr_img').attr('src','images/'+curr_img+'.png');
								$('#here').attr('id','');
								$(this).find('img').attr('id','here');
								old_image=menu_current_img;
								
				})
$('.menu_subsublinks1').click(function(){ 
									   menu_current_img='palace';
								if(old_image+'_h'==menu_current_img)return;
								$('#here').attr('src','images/'+old_image+'.png');
								$('#middle1').find('img').attr('src','images/'+menu_current_img+'_h.png');
								current_img=menu_current_img;
								$('#curr_img').attr('src','images/'+curr_img+'.png');
								$('#here').attr('id','');
								$('#middle1').find('img').attr('id','here');
								old_image=menu_current_img;
				})
$('.menu_subsublinks2').click(function(){
									    menu_current_img='artfestival';
								if(old_image+'_h'==menu_current_img)return;
								$('#here').attr('src','images/'+old_image+'.png');
								$('#middle2').find('img').attr('src','images/'+menu_current_img+'_h.png');
								current_img=menu_current_img;
								$('#curr_img').attr('src','images/'+curr_img+'.png');
								$('#here').attr('id','');
								$('#middle2').find('img').attr('id','here');
								old_image=menu_current_img;
				})


var preload = ["contactus_h.png", "joinour_h.png","sponsors_h.png","festivalprog_h.png","artfestival_h.png","palace_h.png","prevfestival_h.png","booking_h.png","gallery_h.png"];
	$(preload).each(function(i, e) {
			(new Image()).src = "images/" + e;
							 });
	
var preload = ["history.png", "history_h.png", "getto_bet.png", "getto_bet_h.png", "story.png", "story_h.png", "perf.png", "perf_h.png", "committee.png", "committee_h.png", "prev_bk.jpg", "close_h.png", "sponsor_sublink_h.png", "add_spons_h.png"];
	$(preload).each(function(i, e) {
			(new Image()).src = "images/" + e;
							 });

})


function prev_fest_anim(){
	 $('.close, .close_fest, .close_new').hover(function(){ $(this).attr('src','images/close_h.png');
								}, function(){
								$(this).attr('src','images/close.png');
							   }
					  )
	//put the light cover in prev fest	, prev fest area
	$(".festi").hover( function(){$(this).find('.layer').show(); $(this).find('.year').css({'color':'#fff', 'text-decoration':'underline'}); }, function(){
								 $(this).find('.layer').hide(); $(this).find('.year').css({'color':'#1d1d1d', 'text-decoration':'none'});})
	
	var counter=1;
	var prev_id=-1;
	var curr_id=-2;
	$('.festi').click( function(){ 		
								curr_id=$(this).attr('id'); curr_id=curr_id.split('_'); curr_id=curr_id[1];
								//alert(prev_id); alert(curr_id);
								if(prev_id==curr_id)return;
								
								count_of_fest=$('.festi').attr('lang');
									count_of_fest=parseInt(count_of_fest)
									new_widtho=	145*( (count_of_fest+1.2) );
									$('#sub_prev_fest').width(new_widtho+'px');//we should change the box with according to the number of elements
									
									
									
									$('.festo').animate({width:'0px'},300);
									$('.close_fest').hide();
									$('.year').animate({left:'86px'},300).css('color','#1d1d1d');
									
									box_width=156;
									width_after_open=new_widtho+450;
									if(curr_id>=1){
											for(i=3;i<count_of_fest;i++){
												if(curr_id==i){	value=267+(box_width*(i-2));}
											}
											if(curr_id==1){value=100;}
											if(curr_id==2){value=267;}
											
										$('#sub_prev_fest').animate({'left':'-'+value+'px'},400);
										$('#sub_prev_fest').width(width_after_open+'px');
										//stoper_p=1260;
										stoper_p=145*(count_of_fest-4+0.25)+450;
										step_p=-value
									}
									
									$('#year_'+curr_id).animate({left:'537px'},300).css('color','#fff');
									
									$('#close_fest_'+curr_id).fadeIn();
									$('#festo_'+curr_id).animate({width:'446px'},300);
									
									prev_id=curr_id;
							   })
	$('.close_fest').click( function(){ 		
									//alert(scroll_width);
									$('.festo').animate({width:'0px'},300);
									$('.year').animate({left:'86px'},300).css('color','#1d1d1d');
									
									stoper_p=145*(count_of_fest-4+0.25); //step_p=step_p;
									if(curr_id==(count_of_fest-1) || curr_id==(count_of_fest-2) || curr_id==(count_of_fest-3) ){
										step_p=parseInt(step_p);
										step_p=step_p+(120*4);
										$('#sub_prev_fest').animate({'left':step_p+'px'},400);
									}
									 $('#sub_prev_fest').animate({width:new_widtho+'px'},300);
									
									$('.close_fest').hide();
									prev_id=-1;
	
							   })
}
function adjust_menu(id){
	close_prog();}
function committee_jquery(){
	var curr_img='exec';
	var src=1;
	var img=2;
	$('#com_title img').hover(function(){ 
									   src=$(this).attr('src');
									   imgx=src.split('/');
									   imgx=imgx[1];
									   img=imgx.split('.');
									   img=img[0];
									   
									   //alert(curr_img);alert(img);
										if((curr_img+'_h')!=img ){
									   $(this).attr('src','images/'+img+'_h.png');
									   //alert(img);
											 }
									   },
						  function(){ if(curr_img!=img ) $(this).attr('src','images/'+img+'.png'); })
	$('#com_title img').click(function(){ 
										 //alert(curr_img);
										 $('#curr_img').attr('src','images/'+curr_img+'.png');
										 $('#curr_img').attr('id','');
										 $(this).attr('id','curr_img');
										 curr_img=img;
									   })
}
function anim_ro_art_fest(){
	$('.part_1').hover( function(){ $(this).attr('src','images/story_sublink_h.png') },   function(){ $(this).attr('src','images/story_sublink.png') }  )
	$('.part_2').hover( function(){ $(this).attr('src','images/perf_sublink_h.png') },   function(){ $(this).attr('src','images/perf_sublink.png') }  )
	$('.part_3').hover(function(){  $(this).attr('src','images/committee_sublink_h.png') },   function(){ $(this).attr('src','images/committee_sublink.png') }  )
	//$('#s_1, #s_3,#p_1, #p_2').hide();
}
function start_fancy(){
	$("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over"> ' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});	
}
function gallery_jquery(){
	$("div#gal_year_scroll").smoothDivScroll({ 
		autoScroll: "" ,
		scrollingHotSpotLeft: "div.left_scr",
		scrollingHotSpotRight: "div.right_scr",
		autoScrollDirection: "backandforth", 
		autoScrollStep: 0, 
		autoScrollInterval: 300,	
		startAtElementId: "startAtMe"
		
	});
}

function sponsor_jquery_scroll(){
	$("div#sponsor_scroll").smoothDivScroll({ 
			autoScroll: "" ,
			autoScrollDirection: "backandforth", 
			autoScrollStep: 1, 
			autoScrollInterval: 30,	
			startAtElementId: "startAtMe",
			visibleHotSpots: ""
		});
}
function sponsor_jquery(){
	initialize_slider();
	start_scrolling();
$('.wraptocenter').hover( function(){ 
									spons_id=$(this).find('.sponser_img').attr('id');
									saturate(spons_id);
										} , function(){
									desaturate(spons_id);
										}  );
/*$('.mini_wraptocenter').hover( function(){ 			//rollover saturate desaturate the new sponsors added
									mini_spons_id=$(this).find('.mini_sponser_img').attr('id');
									saturate(mini_spons_id);
										} , function(){
									desaturate(mini_spons_id);
										}  );*/

$('.sponsor_bigbox').hover(function(){ 
							   	 $(this).find('.text_box').slideDown();
							   } ,function(){  
								$(this).find('.text_box').slideUp();
									})


}

function close_prog(){
	$('#prog_cont_new').animate({height:'1px'},400); $('#arrow').attr('src','images/u_arrow.png'); hide=1;
	$('#top2_img').attr('src','images/festivalprog.png');
}

//previous_img='aa';
//previous_id='bb';
current_img='cc';

/*function start_pirobox(){
	$().piroBox_ext({		//this is to initialize the popup  plugin
		piro_speed : 900,
		bg_alpha : 0.4,
		piro_scroll : true // pirobox always positioned at the center of the page
	});	
}*/
function start_scrolling(){
	$('.scroll_prev').jScrollPane({showArrows: true, arrowScrollOnHover:true});	
	$('.scroll_booking').jScrollPane({showArrows: true, arrowScrollOnHover:true});
	$('.scroll_gallery').jScrollPane({showArrows: true, arrowScrollOnHover:true});
	$('.scroll_history').jScrollPane({showArrows: true, arrowScrollOnHover:true});
	$('.scroll_location').jScrollPane({showArrows: true, arrowScrollOnHover:true});
	$('.scroll_story').jScrollPane({showArrows: true, arrowScrollOnHover:true});
	$('.scroll_sponsor').jScrollPane({showArrows: true, arrowScrollOnHover:true});
	$('.jspArrowUp').hover(function(){ $(this).css({'background-image':'url(images/scroll_up.png)'}) }, function(){ $(this).css({'background-image':'url(images/scroll_up_off.png)'}) });
	$('.jspArrowDown').hover(function(){ $(this).css({'background-image':'url(images/scroll_down.png)'}) }, function(){ $(this).css({'background-image':'url(images/scroll_down_off.png)'}) });
}
function intro_desat(numbr){
	//alert(numbr);
	for(i=0;i<numbr;i++){
		//alert(i);
		desaturate('spons_'+i);
	}
}
function intro_desat_mini(numbr){
	//alert(numbr);
	for(i=0;i<numbr;i++){
		//alert(i);
		desaturate('mini_spons_'+i);
	}
}

function initialize_slider(){
		 $("#parent").wslide({
			width:725,
			height: 340,
			pos: 1,
			duration :1000,
			horiz: true,
			autolink: false
		});

		/*$('#layer_br0').css('display','none');
		var im_name=$('#img_name'+1).val();
		$('#img_name_ref').html(im_name);
		var im_link=$('#img_link'+1).val();
		$('#img_link_r').attr('name',im_link);*/
}
var enterer=-1;
var showing=0;
function sat(img){		
    $('.layer_brown').css('display','block');
	$('#'+img).css('display','none');
	showing=img;
	}
function saturate(img){		
    	Pixastic.revert(document.getElementById(img));
	}

function desaturate(img){	
 	Pixastic.process(document.getElementById(img), "desaturate", {
	average : $("#value-average").attr("checked")
	})
}


function create_slideshow(){
	$.supersized({
		//Functionality
		slideshow               :   1,		//Slideshow on/off
		autoplay				:	0,		//Slideshow starts playing automatically
		start_slide             :   1,		//Start slide (0 is random)
		random					: 	0,		//Randomize slide order (Ignores start slide)
		slide_interval          :   3000,	//Length between transitions
		transition              :   6, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
		transition_speed		:	1700,	//Speed of transition
		new_window				:	1,		//Image links open in new window/tab
		pause_hover             :   0,		//Pause slideshow on hover
		keyboard_nav            :   0,		//Keyboard navigation on/off
		performance				:	1,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
		image_protect			:	1,		//Disables image dragging and right click with Javascript
		image_path				:	'img/', //Default image path

		//Size & Position
		min_width		        :   0,		//Min width allowed (in pixels)
		min_height		        :   0,		//Min height allowed (in pixels)
		vertical_center         :   1,		//Vertically center background
		horizontal_center       :   1,		//Horizontally center background
		fit_portrait         	:   1,		//Portrait images will not exceed browser height
		fit_landscape			:   0,		//Landscape images will not exceed browser width
		
		//Components
		navigation              :   1,		//Slideshow controls on/off
		thumbnail_navigation    :   0,		//Thumbnail navigation
		slide_counter           :   1,		//Display slide numbers
		slide_captions          :   1,		//Slide caption (Pull from "title" in slides array)
		slides 					:  	images_info
		 	//	[								
//				{image : 'images/Water.jpg', title : 'Water', url : 'fade.html'},
//				{image : 'images/Winter.jpg', title : 'Winter', url : 'fade.html'},  
//				{image : 'images/Sunset.jpg', title : 'Sunset', url : 'fade.html'}  
//				]
									
	}); 
}




var timerDown="";
var timerUp="";
var step = 0;
var stoper=1146;
function scrollRig(){
	step=step-5;
	if(step<-stoper){ step=-stoper; return;}
	$('#sub_prog_cont').animate({left:step+'px'},1);
	timerDown=setTimeout("scrollRig()",1);
} 
function scrollLef(){
	step=step+5;
	if(step>0){ step=0; return;}
	$('#sub_prog_cont').animate({left:step+'px'},1);
	timerUp=setTimeout("scrollLef()",1);
} 
function quitScroll(){
	clearTimeout(timerDown);
	clearTimeout(timerUp);
}

var timerR="";
var timerL="";
var step_p = 0;
var stoper_p=1340;
num_count=0;
function scrollRig_p(){
	num_count++;
	step_p=step_p-5;
	if ( $.browser.msie )step_p=step_p-10; 
	if(num_count==1){
		count_of_fest=$('.festi').attr('lang');
		count_of_fest=parseInt(count_of_fest)
		stoper_p=145*(count_of_fest-4+0.25);
		new_widtho=	145*( (count_of_fest+1.2) );
		$('#sub_prev_fest').width(new_widtho+'px');//we should change the box with according to the number of elements
	}
	if(step_p<-stoper_p){ step_p=-stoper_p; return;}
	$('#sub_prev_fest').animate({left:step_p+'px'},1);
	timerR=setTimeout("scrollRig_p()",1);
} 
function scrollLef_p(){
	step_p=step_p+5;
	if ( $.browser.msie )step_p=step_p+10;
	if(step_p>0){ step_p=0; return;}
	$('#sub_prev_fest').animate({left:step_p+'px'},1);
	timerL=setTimeout("scrollLef_p()",0.5);
} 
function quitScroll_p(){
	clearTimeout(timerR);
	clearTimeout(timerL);
}




function validate_mailing(obj){
	 with(obj){
		   if(first_name.value==""){
			alert("Please fill in your first name");
			return ;
			}
			if(last_name.value==""){
			alert("Please fill in your last name");
			return ;
			}
			if(email.value==""){
			alert("Please fill in your email address");
			return ;
			}
			if(!isEmail(email.value)){
			alert("Please fill in a valid email address");
			return ;
			}
			

				
	
				
	}
	// alert("email="+obj.email.value+"&first_name="+obj.first_name.value+"&last_name="+obj.last_name.value+"&field[]=&nlbox[]=37&funcml=add&p=1006&_charset=utf-8");
	 $('#thankyou').show();
	  $('#thankyou').html("<img src='images/loader.gif'/> ");
	  //return;
	 $.ajax({
	type: "POST",
	url: "sendmailing.php",
	data: "email="+obj.email.value+"&first_name="+obj.first_name.value+"&last_name="+obj.last_name.value+"&occupation="+obj.occupation.value,
	success: function(returned){
		 $('#thankyou').html(returned);
		 //$('#thankyou').show();
	   }
	 });
	 
	obj.submit();
	obj.reset();
	$('#thankyou').show();
	 
}


function isEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 }
