(function($){
	$(document).ready(function(){

	//attach the away link code to call
	$('a').live('click', function()
	{
		var linkHref = String(this.href);
		if(linkHref.indexOf('gc.synxis.com') != -1)
		{
			try
			{
				pageTracker._link(linkHref);
			}
			catch(err){}
		}
	return true;
	});


	if ($('#indexSS').length )
	{
		$("#indexSS").cycle({
				timeout: 5000,
				autostop: 1
		});
	}
	$("#signupEmail").focus(function(){
		if ($(this).val() == "" || $(this).val() == "ENTER EMAIL HERE")
		{
			$(this).val("");
		}
		$("#emailSignupDropdown").fadeIn();
	});
	$("#signupEmail").blur(function(){
		if ($(this).val() == "" || $(this).val() == "ENTER EMAIL HERE")
		{
			$(this).val("ENTER EMAIL HERE");
		}
	});

	$("#emailSignupForm").submit(function() {
		$("#emailSignupDropdown").hide();
		$("#emailSignupDropdownThankYou").fadeIn();
		setTimeout('$("#emailSignupDropdownThankYou").fadeOut();', 5000);
		$.ajax(
		{
			type: "POST",
			url: "/subscribe.php?SendUpdate=1",
			data: $(this).serialize(),
			success: function(response)
			{
			   $("#emailSignupForm")[0].reset();

			}
		})

		return false;
	});
	var rulesShown = false;
	$("a.promoRules").click(function(){
		if (rulesShown)
		{
			$("#promoRulesPopup").fadeOut();
			rulesShown = false;
		}
		else
		{
			$("#promoRulesPopup").fadeIn();
			rulesShown = true;
		}
	});
	$("#promoRulesPopup p.xButton a").click(function(){
		$("#promoRulesPopup").fadeOut();
		rulesShown = false;
	});

	$("#borderContainer #shadow #mainContainer #mainOffer a.grandGuestroom").click(function(){
		if (rulesShown)
		{
			$("#grandGuestroomPopup").fadeOut();
			rulesShown = false;
		}
		else
		{
			$("#grandGuestroomPopup").fadeIn();
			rulesShown = true;
		}
	});
	$("#borderContainer #shadow #mainContainer #mainOffer #grandGuestroomPopup p.xButton").click(function(){
		$("#grandGuestroomPopup").fadeOut();
		rulesShown = false;
	});
	$("#borderContainer #shadow #mainContainer #mainOffer a.resortAmenities").click(function(){
		if (rulesShown)
		{
			$("#resortAmenitiesPopup").fadeOut();
			rulesShown = false;
		}
		else
		{
			$("#resortAmenitiesPopup").fadeIn();
			rulesShown = true;
		}
	});
	$("#borderContainer #shadow #mainContainer #mainOffer #resortAmenitiesPopup p.xButton").click(function(){
		$("#resortAmenitiesPopup").fadeOut();
		rulesShown = false;
	});

	 // dropdown nav
	 $('ul.sf-menu').superfish({speed: 0});

	 $('#testdiv1').css("z-index", "999999");

	// packages more options and family activites page
	$("a.packagesExpand").unbind("click");
	$("a.packagesExpand").click(function(e){
		e.preventDefault();
		$(this).hide();
		$(this).parent(".morePackageBullets").css("height", "100%");
	});
	$("a.packagesContract").click(function(e){
		e.preventDefault();
		$(this).parent(".morePackageBullets").find("a.packagesExpand").show();
		$(this).parent(".morePackageBullets").css("height", "18px");
	});

	// packages page SS
	$(".singleSS").cycle({
		timeout: 5000
	});
	// top slideshows
	$(".leftSS").cycle({
		timeout: 7000,
		delay: -3500
	});
	$(".rightSS").cycle({
		timeout: 7000
	});
	$(".emailCloseBtn").click(function(e){
		$(this).parent().fadeOut();
	});

	$("a.disabledLink").click(function(e){
		e.preventDefault();
	});

	$("a.galClose").click(function(){
		$(this).parent("div").hide();
		var area = "#" + ($(this).parent("div").parent("div").attr("id")) + "Menu";
		$(area).children("a").removeClass("text-link-on");
	});

	$(".tabLink").click(function(){
		$(".tabLink").removeClass("tabSelected");
		$(this).addClass("tabSelected");
		$(".tabContent").hide();
		$("#" + $(this).attr("id") + "_content").show();
	});

   $('.hoverMarker').hover(function(){$("#" + $(this).attr("id") + "_Data").fadeIn(100)}, function(){$("#" + $(this).attr("id") + "_Data").hide()});
   $('.hoverData').hover(function(){$(this).show()}, function(){$(this).fadeOut(500)});
   $('#reserveCalendar').datepicker();

});})(jQuery)

function Validate( theForm ){
	if ( theForm.Prefix.value == "" ){
		alert( 'Please provide your prefix.' );
		return false;
		}
	if ( theForm.FirstName.value == "" || theForm.LastName.value == "" ){
		alert( 'Please enter your full name.' );
		return false;
		}
	if ( theForm.BrideGroomWeddingParty.value == "" ){
		alert( 'Please provide the Bride/Groom Wedding Party.' );
		return false;
		}
	if ( theForm.Address1.value == "" ){
		alert( 'Please enter your address.' );
		return false;
		}
	if ( theForm.City.value == "" ){
		alert( 'Please enter your city.' );
		return false;
		}
	if ( theForm.Country.selectedIndex == 0 ){
		alert( 'Please select your country.' );
		return false;
		}
	if ( theForm.Country.selectedIndex == 1 && theForm.State.selectedIndex == 0 ){
		alert( 'Please select your state.' );
		return false;
		}
	if ( theForm.Zip.value == "" ){
		alert( 'Please enter your zip code.' );
		return false;
		}
	if ( theForm.Phone.value == "" ){
		alert( 'Please enter your phone number.' );
		return false;
		}
	if ( theForm.Email.value == "" ){
		alert( 'Please enter your email address.' );
		return false;
		}
	if ( theForm.Email.value != theForm.ConfirmEmail.value ){
		alert( 'Please make sure the email and confirm email fields match.' );
		return false;
		}
	if ( theForm.NumCeremonyGuests.value == "" ){
		alert( 'Please enter the number of Ceremony guests.' );
		return false;
		}
	if ( theForm.NumReceptionGuests.value == "" ){
		alert( 'Please enter the number of Reception guests.' );
		return false;
		}
	return true;
}


function Validate2( theForm ){
/*	if ( theForm.Prefix.value == "" ){
		alert( 'Please provide your prefix.' );
		return false;
		}
	if ( theForm.FirstName.value == "" || theForm.LastName.value == "" ){
		alert( 'Please enter your full name.' );
		return false;
		}
	if ( theForm.City.value == "" ){
		alert( 'Please enter your city.' );
		return false;
		}
	if ( theForm.Country.selectedIndex == 0 ){
		alert( 'Please select your country.' );
		return false;
		}
	if ( theForm.Country.selectedIndex == 1 && theForm.State.selectedIndex == 0 ){
		alert( 'Please select your state.' );
		return false;
		}
	if ( theForm.Zip.value == "" ){
		alert( 'Please enter your zip code.' );
		return false;
		}
	if ( theForm.Email.value == "" ){
		alert( 'Please enter your email address.' );
		return false;
		}
	return true;
*/
	if ( theForm.Address1.value != "" ){
		if ( theForm.City.value == "" ){
			alert( 'Please enter your city.' );
			return false;
			}
		 if ( theForm.Country.selectedIndex == 0 ){
			alert( 'Please select your country.' );
			return false;
			}
		if ( theForm.Country.selectedIndex == 1 && theForm.State.selectedIndex == 0 ){
			alert( 'Please select your state.' );
			return false;
			}
		if ( theForm.Zip.value == "" ){
			alert( 'Please enter your zip code.' );
			return false;
			}
		}
	if ( theForm.Email.value == "" ){
		alert( 'Please enter your email address.' );
		return false;
		}
	if ( theForm.Email.value != theForm.ConfirmEmail.value ){
		alert( 'Please make sure the email and confirm email fields match.' );
		return false;
		}
}


var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable=no,toolbar=no,location=no,scroll=yes,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}


// remove/replace input text
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
}
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

function spaPackageToggle(which, linkId)
{
	$(".spaPackage").hide();
	$("#package" + which).show();
	$(".packageToggleLink").removeClass("text-link-on");
	$("#packageToggle" + which).addClass("text-link-on");
}
