activelnk=1;
hmenu=0;
mmenu=1;
ls=0;
showreviewf=0;
resinfo=0;

jQuery.fn.fadeSliderToggle=function(settings){
	settings=jQuery.extend({speed:500,easing:"swing"},settings)
	caller=this;

	$("#lm_sp_"+activelnk).toggleClass("sel");
	
 	if($(caller).css("display")=="none"){
 		$(caller).animate({
 			height:'toggle'
 		},settings.speed, settings.easing);
	}else{
		$(caller).animate({
			height: 'toggle'
		},settings.speed,settings.easing);
	}
};
jQuery.fn.SliderToggle=function(settings){
	settings=jQuery.extend({speed:500},settings)
	caller=this;
	if(hmenu==1){
		$("#hl_nav_btn").find('span').html("&#9660;");
	}else{
		$("#hl_nav_btn").find('span').html("&#9650;");
	}
 	if(hmenu==0){
 		caller.animate({height:hl_h},300);
 		hmenu=1;
	}else{
		caller.animate({height:1},300);
		hmenu=0;
	}
};

$(document).ready(function(){
	$("#lm_sp_1").click(function(){
		activelnk=1;
		$(this).parent().next().fadeSliderToggle();
		return false;
	})
	$("#lm_sp_2").click(function(){
		activelnk=2;
		$(this).parent().next().fadeSliderToggle();
		return false;
	})
	$("#lm_sp_3").click(function(){
		activelnk=3;
		$(this).parent().next().fadeSliderToggle();
		return false;
	})
	$("#lm_sp_5").click(function(){
		activelnk=5;
		$(this).parent().next().fadeSliderToggle();
		return false;
	})
	$("#lm_sp_12").click(function(){
		activelnk=12;
		$(this).parent().next().fadeSliderToggle();
		return false;
	})
	
	hl_h=$("#hotels_list_b").height();
	if($('.body_center_a_hl').length > 0){
		$("#hotels_list_b").css("height","0px");
	}else{
		hmenu=1;
		$("#hotels_list_b").css("height","auto");
	}
	$("#hl_nav_btn").click(function(){
		$("#hotels_list_b").SliderToggle();
		return false;
	})
	
	$('#prtnrseditlnk').hide();
	$('#prtnreditblks').hide();
	
	$('#partnrseditfrm').mouseover(function(){
		$('#prtnrseditlnk').show();
	})
	$('#partnrseditfrm').mouseout(function(){
		$('#prtnrseditlnk').hide();
	})
	$('#prtnrseditlnk').click(function(){
		$("#prtnreditblks").toggle();
		return false;
	})
	
	$('#lsearch').hide();
	
	$('#lslnk').click(function(){
		$("#lsearch").toggle();
		sh=$("#lslnk").find('span');
		snhtml=sh.html();
		if(snhtml=="▼"){
			sh.html("&#9658;");
		}else{
			sh.html("&#9660;");
		}
		return false;
	})
	
	if($('.hlslider').length > 0)RunSlider();
	if($('#phcalendar').length > 0)phCalendar();
	if($('#review_add').length > 0)phCalendar2();
	if($('#phmnav').length > 0)phMainMenu();
	if($('#phmnav').length > 0)phCalendar();
	if($('#review_add_link').length > 0){
		if(showreviewf==0)$('#review_add').hide();
		$('#review_add_link').click(function(){
			$("#review_add").toggle('slow');
		})
	}
	if($('#res_hb').length > 0)reservationFormInfos();
	if($('.imgslistthumbs,.hlimgslistthumbs').length > 0)imageThumbs();
	
});
function checkStatus(){
	var resid=document.getElementById("stat_id").value;
	var resmail=document.getElementById("stat_mail").value;
	_info ='toolbars=no';
	_info += ',location=no';
	_info += ',directories=no';
	_info += ',status=no';
	_info += ',menubar=no';
	_info += ',scrollbars=yes';
	_info += ',resizable=yes';
	_info += ',left=40';
	_info += ',top=30';
	_info += ',width=780';
	_info += ',height=690';
	window.open('http://'+window.location.hostname+'/status.php?res_id='+resid+'&res_mail='+resmail,'Status',_info);
}
function isEmpty(form){
	if(document.getElementById("name").value == ""){
		document.getElementById("send").disabled=true;
		document.getElementById("name").style.background="red";
	}else{
		document.getElementById("name").style.background="none";
		document.getElementById("send").disabled=false;
	}
	if (document.getElementById("mail").value == ""){
		document.getElementById("send").disabled=true;
		document.getElementById("mail").style.background="red";
	}else{
		document.getElementById("mail").style.background="none";
		document.getElementById("send").disabled=false;
	}
}
function set_zero(id,name,innerID){
	if(document.getElementById(id).checked==false){
		document.getElementById(innerID).innerHTML="<input type=\"hidden\" name=\""+name+"\" value=\"0\"/>";
	}else{
		document.getElementById(innerID).innerHTML="";
	}
}
function newWin3(urlLoc3){
	_winName3 = 'MNewWindow3';
	_info  = 'toolbar=0';
	_info += ',location=0';
	_info += ',directories=0';
	_info += ',status=0';
	_info += ',menubar=0';
	_info += ',scrollbars=1';
	_info += ',resizable=1';
	_info += ',refresh the parent=1';
	_info += ',height=1281';
	_info += ',width=917';
	_info += ',left=40';
	_info += ',top=30';
   DispWin3=window.open(urlLoc3,_winName3,_info);
   return false;
}
function newWin4(urlLoc4){
	_winName4 = 'MNewWindow4';
	_info  = 'toolbar=0';
	_info += ',location=0';
	_info += ',directories=0';
	_info += ',status=0';
	_info += ',menubar=0';
	_info += ',scrollbars=1';
	_info += ',resizable=1';
	_info += ',refresh the parent=1';
	_info += ',height=750';
	_info += ',width=1000';
	_info += ',left=40';
	_info += ',top=30';
   DispWin4=window.open(urlLoc4,_winName4,_info);
   DispWin4.focus();
   return false;
}
function facebook(urlLoc5){
	_winName5 = 'MNewWindow5';
	_info  = 'toolbar=0';
	_info += ',location=0';
	_info += ',directories=0';
	_info += ',status=0';
	_info += ',menubar=0';
	_info += ',scrollbars=0';
	_info += ',resizable=0';
	_info += ',refresh the parent=0';
	_info += ',height=330';
	_info += ',width=650';
	_info += ',left=300';
	_info += ',top=30';
   DispWin5=window.open(urlLoc5,_winName5,_info);
   DispWin5.focus();
   return false;
}
function possblsls(urlLoc6){
	_winName6 = 'MNewWindow6';
	_info  = 'toolbar=0';
	_info += ',location=0';
	_info += ',directories=0';
	_info += ',status=0';
	_info += ',menubar=0';
	_info += ',scrollbars=1';
	_info += ',resizable=1';
	_info += ',refresh the parent=1';
	_info += ',height=450';
	_info += ',width=750';
	_info += ',left=40';
	_info += ',top=30';
   DispWin6=window.open(urlLoc6,_winName6,_info);
   DispWin6.focus();
   return false;
}
function prtrsfrmsave(id){
	var txt=$('#partnerstxtedit').val();
	var path=$('#prtrspathid').val();
	$.ajax({
		type:"POST",
		url:"/media/js/ajax/saveFldInfo.php",
		data:"txt="+txt+"&path="+path,
		success:function(back){
			txt=txt.replace('\n','<br/>');
			$('#fld_info').html(txt);
			$('#prtnreditblks').hide();
		}
	});
}

function mycarousel_initCallback(carousel){
	carousel.buttonNext.bind('click',function(){carousel.startAuto(0);});
	carousel.buttonPrev.bind('click',function(){carousel.startAuto(0);});
	carousel.clip.hover(function(){carousel.stopAuto();},function(){carousel.startAuto();});
};
function RunSlider(){
	jQuery('.hlslider').jcarousel({auto:5,wrap:'last',initCallback:mycarousel_initCallback});
}

function phCalendar(){
	$('.phnfoico').mouseover(function(){
		$(this).next('.phnfoblk').show();
	}).mouseout(function(){
		$(this).next('.phnfoblk').hide();
	}).click(function(){
		return false;
	})
	
	$('.pheditico').mouseover(function(){
		$(this).next('.pheditblk').show();
	}).mouseout(function(){
		$(this).next('.pheditblk').hide();
	}).click(function(){
		return false;
	})
	
	$('.pheditblk').mouseover(function(){
		$(this).show();
	}).mouseout(function(){
		$(this).hide();
	});
}
function phMainMenu(){
	$('.phmnavnorm').mouseover(function(){
		$(this).find('span').html('&#9660;');
	}).mouseout(function(){
		$(this).find('span').html('&#9658;');
	})
}
function phCalendar(){
	$(function(){
		$("#fromdate").datepicker({
			onSelect:function(){
				var ndtarr = $("#fromdate").val().split('-');
				dt=new Date(ndtarr[0],(ndtarr[1]-1),ndtarr[2],+24);
				$("#todate").datepicker("option","minDate",dt);
			}
		});
		$("#fromdate").datepicker("option","dateFormat",'yy-mm-dd');
		$("#fromdate").datepicker("option","firstDay",1);
		$("#fromdate").datepicker("option","minDate",'+0d');
		$("#fromdate").datepicker("option","maxDate",'+8m');
		
		dt=new Date($("#fromdate").val());
		$("#todate").datepicker();
		$("#todate").datepicker("option","dateFormat",'yy-mm-dd');
		$("#todate").datepicker("option","firstDay",1);
		$("#todate").datepicker("option","minDate",dt);
		$("#todate").datepicker("option","maxDate",'+8m');
	});
}
function phCalendar2(){
	$(function(){
		$("#visit_date").datepicker({

		});
		$("#visit_date").datepicker("option","dateFormat",'yy-mm-dd');
		$("#visit_date").datepicker("option","firstDay",1);
		$("#visit_date").datepicker("option","maxDate",'+1d');
		
		dt=new Date($("#visit_date").val());
	});
	
	$('#rt_th_up').click(function(){
		$('#rating').val(1);
		$('#rt_th_up').css('border-bottom','1px solid #036AC8');
		$('#rt_th_down').css('border-bottom','0px');
		return false;
	})
	$('#rt_th_down').click(function(){
		$('#rating').val(0);
		$('#rt_th_down').css('border-bottom','1px solid #036AC8');
		$('#rt_th_up').css('border-bottom','0px');
		return false;
	})
}
function reservationFormInfos(){
	if($('.resblkinfoopen').length > 0){
		$('#res_hb').show();
		$('#res_flights').show();
	}else{
		$('#res_hb').hide();
		$('#res_flights').hide();
		$('#swresinfo').click(function(){
			$('#res_hb').toggle('slow');
			$('#res_flights').toggle('slow');
			if(resinfo==0){
				$('#swresinfo').html('&#9660;');
				resinfo=1;
			}else{
				$('#swresinfo').html('&#9664;');
				resinfo=0;
			}
			
			return false;
		})
	}
}
function imageThumbs(){
	$('.imgslistthumbs img,.hlimgslistthumbs img').click(function(){
		var bigsrc=$(this).attr('longdesc');
		$('#big_photo').attr({'src':bigsrc});
		return false;	
	})
}
