var isOpen=false;
$(document).ready(function () {
	$("#EMAIL").focus(function(){$(this).val("");})
	$("#EMAIL").blur(function(){if($(this).val()=="")$(this).val("Your email Address");})
	
	if($("a.lightbox").length>0)$("a.lightbox").lightbox({fileBottomNavCloseImage:closeImg,fileLoadingImage:loadingImg});
	
	$("select[name=ContentObjectAttribute_country_1834[]]").val("GB");	
	$("#monthYear").change(function(){
		var $monthYearVal = $("#monthYear option:selected").val().split("-");
		
		if ($monthYearVal[0]=="4"||$monthYearVal[0]=="6"||$monthYearVal[0]=="9"||$monthYearVal[0]=="11")
		{
			if($("#day option").length==31)
			{
				$("#day").removeOption(30);				  
			}
		}else{
			if($("#day option").length==30)
			{
				$("#day").addOption("31","31");  
			}
		}
	});
	
	$("ul.footer li a:not(.accessibility)").each(function(i){
		$(this).click(popMeBaby);
	})	
	
	$("#res_widget_best_rate_popup").click(popMeBaby);
	
	$("#datepicker").datepicker({
		dateFormat:'m-yy_d',
		onSelect: function(dateText){
			var date = dateText.split("_");
			$("#monthYear").val(date[0]);
			$("#day").val(date[1]);
			$("#datepicker").hide();
		}
	});
	$("#datepickerOpen").click(function(){
		$("#datepicker").toggle();
	});
	
	$(".datepicker").datepicker({
		dateFormat:'mm/dd/yy',
		onSelect: function(dateText){
			var date = dateText.split("/");
			var myID = this.id.split("_");
			
			//set the hidden values for submission
			$("#ContentObjectAttribute_month_"+myID[0]).val(date[0]);
			$("#ContentObjectAttribute_day_"+myID[0]).val(date[1]);
			$("#ContentObjectAttribute_year_"+myID[0]).val(date[2]);
			

		}
	});
	
	
	if($.browser.msie){
		if($.browser.version<7){
			$("#left ul li ul").each(function(i){
				$parent = $(this).parent();
				$parent.mouseover(function(){$(this).addClass("hover");});
				$parent.mouseout(function(){$(this).removeClass("hover");});
				$parent.children("a").addClass("ie-li-child");
			});
			DD_belatedPNG.fix('#left a img,#reservation');
		}
	}
	
	/*Omniture Tracking*/	
	$("form[name='omni_reservation_form']").submit(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Widget'; s.eVar1='Reservation Widget'; s.tl(this,'o','Reservation Widget');});
	$("a[name='omni_reservations_content']").submit(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Link'; s.eVar1='Reservation Link'; s.tl(this,'o','Reservation Link');});
	$("a[name='omni_reservation_content']").submit(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Link'; s.eVar1='Reservation Link'; s.tl(this,'o','Reservation Link');});
	$("form[name='omni_email_form']").submit(function(){	  var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar2,events'; s.events='event3'; s.prop1='Email Sign Up'; s.eVar2='Email Sign Up'; s.tl(this,'o','Email Sign Up');});
	$("a[name='omni_reservation_nav']").click(function(){	  var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Nav'; s.eVar1='Reservation Nav'; s.tl(this,'o','Reservation Nav');});
	$("a[name='omni_reservations_nav']").click(function(){	  var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Nav'; s.eVar1='Reservation Nav'; s.tl(this,'o','Reservation Nav');});
	$("a[name='omni_reservation_footer']").click(function(){  var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Footer'; s.eVar1='Reservation Footer'; s.tl(this,'o','Reservation Footer');});	
	$("a[name='omni_reservations_footer']").click(function(){  var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event1'; s.prop1='Reservation Footer'; s.eVar1='Reservation Footer'; s.tl(this,'o','Reservation Footer');});	
	$("a[name='omni_specials_nav'],a[name='omni_specials_footer']").click(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar1,events'; s.events='event2'; s.prop1='Specials and Packages'; s.eVar1='Specials and Packages'; s.tl(this,'o','Specials and Packages');});
	$("a[name='omni_gallery_nav'],a[name='omni_gallery_footer']").click(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar2,events'; s.events='event6'; s.prop1='Photo Tour'; s.eVar2='Photo Tour'; s.tl(this,'o','Photo Tour');});
	$("a[name='omni_location_nav'],a[name='omni_location_footer']").click(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar2,events'; s.events='event8'; s.prop1='Location and Map'; s.eVar2='Location and Map'; s.tl(this,'o','Location and Map');});
	$("a[name='omni_contact_nav'],a[name='omni_contact_footer']").click(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar2,events'; s.events='event9'; s.prop1='Contact Us'; s.eVar2='Contact Us'; s.tl(this,'o','Contact Us');});
	$("a[name='omni_rfp_nav']").click(function(){var s=s_gi('thaystrandpalace'); s.linkTrackVars='prop1,eVar2,events'; s.events='event4'; s.prop1='Group RFP'; s.eVar2='Group RFP'; s.tl(this,'o','Group RFP');});		
});

function getGets( name )
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

function popMeBaby() {
	var r;
	popup=window.open($(this).attr("rel"),"popup_win","width=700,height=480,top=0,left=0,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes",false);
				
	if(!popup){r=true;}
	else{popup.focus();r=false;}		
	
	return r;		
}