$(function() {

	$('fieldset#promo-panel').hide();
	$('a#promo-link').toggle(function() {
		$('fieldset#promo-panel').show();
		$('a#promo-link').addClass('promo-open');
		 return false;
	 }, function() { 
		 $('fieldset#promo-panel').hide();
		 $('a#promo-link').removeClass('promo-open');
		 return false; 
	 });

	var body = $('body').is('.home') ? 1 : 0;
	if (body) {

	    var offers = $('#push-right div.offer'), currentOffer = offers[0], constFirstItem = offers[0], constLastItem = offers[offers.length-1];

	    $(offers).not(':eq(0)').addClass('offer-alt')

	    $('div#next-btns a').click(function() {
		$(currentOffer).addClass('offer-alt');
		var id = $(this).attr('id');
		currentOffer = 
		    (id == 'btn-next')
		    ? ((currentOffer == constLastItem) ? constFirstItem : $(currentOffer).next()[0])
		    : ((currentOffer == constFirstItem) ? constLastItem : $(currentOffer).prev()[0])

		$(currentOffer).removeClass('offer-alt');
		return false;
	    });
	}

	var directionsAnchors = $('a.directions-link'), directions = $(directionsAnchors).next();
	directions.hide();
	//directions.after('<a class="collapse-directions" href="#">collapse directions</a>');
	//$('a.collapse-directions').hide();

	$(directionsAnchors).each(function() {
		var hidden = true;

		$(this).click(function() {
		    if (hidden) {
			$(this).next().show();
			//$(this).parent().find('.collapse-directions').show();
			hidden = false;

		    $('.collapse-directions').click(function() { $(this).prev().hide(); hidden = true; $(this).hide(); return false; })

		    } else {
			$(this).next().hide();
			//$(this).parent().find('.collapse-directions').hide();
			hidden = true;
		    }
		    return false;
		});
	});

	
	//Flash
	$("div#dhr-logo").flash(
		{src:"http://www.destinationhotels.com/flash/branding/flash_logoDhr.swf?link=gantaspen",
		 width:250,
		 height:25,
		 wmode:"transparent",
		 allowScriptAccess:"always",
		 quality:"high"},
		 {version:"7"});	
	
	$("body.home div#masthead").flash( {src:"flash/home-masthead.swf", width:960, height:361, wmode:"transparent", quality:"high"}, {version:"7"});
	$("div#resort-map").flash({src:"/flash/flashMap02.swf", width:666, height:502, wmode:"transparent", quality:"high"}, {version:"7"},
			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/pointsOfInterest.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	  
		   
	//Sifr
	
	$('body:not(".units") div#content h1').sifr({ strSWF: '/flash/verdana.swf', strColor: '#ba8701', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#weather-side h4').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#breadcrumb h1').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent' },{ expressInstall: true });
	$('div#breadcrumb h2').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent' },{ expressInstall: true });
	$('div#breadcrumb h3').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent' },{ expressInstall: true });
	$('div#breadcrumb span#bread1').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent', strFlashVars: 'offsetTop=12&', strCase: 'upper' },{ expressInstall: true });
	$('div#breadcrumb span#bread2').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent', strFlashVars: 'offsetTop=4&' },{ expressInstall: true });
	$('div#breadcrumb span#bread3').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent', strFlashVars: 'offsetTop=2&' },{ expressInstall: true });
	$('body.home div#push-right h4').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#2468d6', strWmode: 'transparent' },{ expressInstall: true });
	$('body.units div#content h1 span').sifr({ strSWF: '/flash/myriad-pro.swf', strColor: '#aa5625', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strFlashVars: 'offsetTop=12&', strCase: 'upper' },{ expressInstall: true });
	
	
	$('div.form-help').hide();
	$('a.help-link').toggle( function() {
		$(this).parents('div.field').children('div.form-help').show();
		return false;
	},function(){ 
	  $(this).parents('div.field').children('div.form-help').hide();
	  return false;
	});
	
// 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#aspen-photo-gallery").flash(
		{src:"/flash/gant_slideshow.swf",
		 width:670,
		 height:530,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.epostConfigPath = "/flash/xml/epostConfig.xml";
				htmlOptions.flashvars.langXMLPath = "/flash/xml/i18n/en_formLabels.xml";
				htmlOptions.flashvars.previewURL = "/postcard-preview.php";
				htmlOptions.flashvars.gatewayURL = "/flashservices/gateway.php";
				htmlOptions.flashvars.websiteURL = "http://www.gantaspen.com/";
				htmlOptions.flashvars.browser = "null";
				htmlOptions.flashvars.imagesXML = "/flash/xml/images.xml";
				htmlOptions.flashvars.startAlbum = "null";
				$(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 }
	);
	*/


// Adds hover class for IE and animation for drop down nav - remove if not needed
	/*
	$("ul#nav-primary li").hover(
        function(){ $("ul", this).fadeIn("fast"); }, 
        function() { } 
    );
    if (document.all) {
        $("ul#nav-primary li").hoverClass("over");
		$("ul#nav-primary li ul li").hoverClass("over");
    }
	*/
});


// 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); }
		);
	});

};   

