$(function() {

	//Sifr
	$('div#banner-rates div.push-content h4').sifr({ strSWF: '/flash/akzidenz-grotesk-be-regular.swf', strColor: '#eaead8', strWmode: 'transparent', strFlashVars: 'textalign=center&', strCase: 'upper' },{ expressInstall: true });
	$('div.push-content h4').sifr({ strSWF: '/flash/akzidenz-grotesk-be-regular.swf', strColor: '#eaead8', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#push-weather h4').sifr({ strSWF: '/flash/akzidenz-grotesk-be-regular.swf', strColor: '#9a613e', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#check-avail h4').sifr({ strSWF: '/flash/akzidenz-grotesk-be-regular.swf', strColor: '#eeeedf', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#push-content h4').sifr({ strSWF: '/flash/akzidenz-grotesk-be-regular.swf', strColor: '#eeeedf', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#content h1').sifr({ strSWF: '/flash/akzidenz-grotesk-be-condensed.swf', strColor: '#83320d', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#spa-content h1').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#6e6839', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	
	
	$('div.push-content').hide();
	
	$(".push-container").each( function() {
		var con = $(this)
		$('a.btn-push', con).mouseover( function() {
			$('div.push-content', con).animate({
				height: 'show'
			}, 'slow');;
		});
		$('div#masthead').mouseover( function() {
			$('div.push-content', con).animate({
				height: 'hide'
			}, 'slow');;
		});
	});
	
	$(".push-cmt-container").each( function() {
		var con = $(this)
		$('a.btn-push', con).mouseover( function() {
			$('div.push-content', con).animate({
				height: 'show'
			}, 'slow');;
		});
		$('div#masthead').mouseover( function() {
			$('div.push-content', con).animate({
				height: 'hide'
			}, 'slow');;
		});
	});
	
	/*$("ul#nav-primary li").hover(
        function(){ $("ul", this).show(); $('ul#nav-primary li ul ul').hide(); }, 
        function(){ $("ul", this).hide(); $('ul#nav-primary li.current ul').show(); $('ul#nav-primary li.current ul ul').hide(); } 
    );
    if (document.all) {
        $("ul#nav-primary li").hoverClass("over");
		$('ul#nav-primary li ul ul').hide();
		$('ul#nav-primary li.current ul').show();
    }*/

	$("body.home div#masthead").flash(
		{src:"flash/homepage.swf",
		 width:949,
		 height:579,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});
	$("div#postcard-gallery").flash(
		{src:"flash/photo_gallery.swf",
		 width:500,
		 height:400,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
		function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.epostConfigXML = "flash/xml/epostConfig.xml";
				htmlOptions.flashvars.imagesXML = "flash/xml/images.xml";
				htmlOptions.flashvars.langXML = "flash/xml/formLabels_english.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});

	$("div#teton-video").flash(
		{src:"http://www.circumerrovideo.com/v/c/projectid=7956&programid=72375",
		 width:510,
		 height:333,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});

	var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
	var url = location.href.substring(dir.length,dir.length+19);
	if (url == '/jackson-hole-events') {
		$(".event-description").hide();
	}

	$("li.event").each( function() {
		var obj = $(this);
		$(".details-link a", obj).toggle( function() {
			$.get('/includes/events-calendar-details.php', { event_id:$(this, obj).attr('id') },function(data) { 
				$(".event-description", obj).html(data).animate({height: 'show'}, 'slow');
				$(".details-link a", obj).html("Hide Details");
			});
			return false;
		}, function(){
			$(".event-description", obj).animate({height: 'hide'}, 'slow');
			$(".details-link a", obj).html("View Details");
		});
	});

	$('div.form-help').hide();
	$('a.help-link').toggle( function() {
		$(this).parents('div.help-text').children('div.form-help').show();
		return false;
	},function(){ 
	  $(this).parents('div.help-text').children('div.form-help').hide();
	  return false;
	});
	
	// If Ter Nav exists then some css changes
	
	$("#ter-nav-wrapper").each( function() {
		$("div#nav").css("height","79px");
		$("#push-weather-wrapper").css("top","293px");
	});
	
	
	
	var pagepath = window.location.pathname;
	var getpage = pagepath.substring(pagepath.lastIndexOf('/') + 1);
	if (getpage == 'subscribe.php')
		$('li#pri-offers').addClass('current');
		
		
	 $('#resort-credit').jqm();

// Sample usage of jquery.flash plugin - remove if not needed
	/*	If given the following markup:

	<div id="masthead">
		<img src="/images/mastheads/flash-alt.jpg" alt="" /><br />
	</div>
	
	you would use the following to replace the alternate content:

	$("div#masthead").flash(
		{src:"flash/home.swf",
		 width:600,
		 height:300,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.configFile = "flash/xml/gallery_config.xml";
				htmlOptions.flashvars.xmlFile = "flash/xml/images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	*/


// Sample sifr usage - remove if not needed
	/*
	// intPadding array order is: left, top, right, bottom - must match css for corresponding element
	$('div#content h2').sifr(
		{ strSWF: 'flash/font-name.swf', strColor: '#cc0000', strLinkColor: '#cccc00', strHoverColor: '#cc00cc', strWmode: 'transparent', intPadding: [35, 0, 0, 0], strFlashVars: 'textalign=center&', strCase: 'upper' },
		{ expressInstall: true }
	);
	*/
	
	$('#survey').each(function() {
	// since we cant edit the markup directly.. 
	var first = $('div:first', this),
	    firstLabel = $('<div class="label-first survey-headings"><strong>Prior to your stay:</strong><div class="labels"><label class="not-expectations">Did Not Meet Expectations</label><label class="expectations">Exceeded Expectations</label></div></div>'),
	    secondSet = $('input:text:eq(0)').parents('.field').next(),
	    secondLabel = $('<div class="label-second survey-headings"><strong>During your stay:</strong><div class="labels"><label class="not-expectations">Did Not Meet Expectations</label><label class="expectations">Exceeded Expectations</label></div></div>'),
		/*
		<div class="labels">
		<label class="label-location">Location</label>\
		<label class="label-eco">Eco</label>\
		<label class="label-prince">Prince</label>\
		<label class="label-osteria">Osteria</label>\
		<label class="label-terra">Hotel Terra</label>
		</div>) */
	    thirdSet = $('#div_3328bdf9a4b9504b9398284244fe97c2'),
	    thirdLabel = $('<div class="label-third survey-headings"><strong>Reflecting on your stay:</strong><div class="labels"><label class="not-expectations">Did Not Meet Expectations</label><label class="expectations">Exceeded Expectations</label></div></div>');

	    $(first).before(firstLabel);
	    $(secondSet).after(secondLabel);
	    $(thirdSet).before(thirdLabel)

	    $('input.button', this).wrap('<div class="button"></div>');
    });
    
    $('.follow-link').initializeFollowing();
	
	
	//MSN Map
	var openFn=function(hash){
		hash.w.show();
		var difference = $(window).width() - $('#msnmap-wrapper').width();
		difference = difference / 2;
		$('#msnmap-wrapper').css({left:difference+275,top:$(window).scrollTop()+10}).css("z-index","5000");
		$('#map').msnMap({listView:true,hotelOnly:true});
		setTimeout(function() {
			$('.place:eq(0) .name').click();
		}, 500);
	};
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
		$('.places').remove();
	};
	$("#view-map-btn").each(function() {
		$('#msnmap-wrapper').jqm({trigger:'#view-map-btn', onShow: openFn, onHide: hideFn});
	});
	
	
});

$.fn.initializeFollowing = function() {
	return this.each(function() {
		$('.follow-link').live('click',function(event) {
			event.preventDefault();
			$('.follow-panel').hide();
			$(this).siblings('.follow-panel').css('display','inline');
		});
		$('.follow-close').live('click',function(event){
			event.preventDefault();
			$(this).parent().slideUp('fast');
		});
	});
};


// Function to add/remove "over" class for drop down nav - remove if not needed
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});

};   

// JS for photo gallery / postcard
	function openPreview(urlrequest) {
		window.open(urlrequest, 'myWindow', 'width=750,height=520,left=100,top=100,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');
		document.getElementById('flashCallBox').value = urlrequest;
	}