$(function() {
	$('#link-flipbook').click(function() {
		var link = window.open(this.href, '', 'width=700,height=500');
		if ( link ) link.focus()
		return false;
	});

	//Sifr
	
	$('body.spa-home div#content h1').sifr({ strSWF: '/flash/adobe-jensen-pro.swf', strColor: '#2a1701', strWmode: 'transparent' },{ expressInstall: true });
	$('body.spa div#content h2').sifr({ strSWF: '/flash/adobe-jensen-pro.swf', strColor: '#2a1701', strWmode: 'transparent', intPadding: [0, 10, 0, 10] },{ expressInstall: true });
	$('body.landing div#content h2').sifr({ strSWF: '/flash/adobe-jensen-pro.swf', strColor: '#2a1701', strWmode: 'transparent', strFlashVars: 'textalign=center&'},{ expressInstall: true });
	$('div#header-wrapper h1').sifr({ strSWF: '/flash/adobe-jensen-pro.swf', strColor: '#e8dab9', strWmode: 'transparent' },{ expressInstall: true });
	$('div#content h2').sifr({ strSWF: '/flash/adobe-jensen-pro.swf', strColor: '#2a1701', strWmode: 'transparent' },{ expressInstall: true });
	$('div#breadcrumb-sidebar h2').sifr({ strSWF: '/flash/adobe-jensen-pro.swf', strColor: '#cb9f60', strWmode: 'transparent' },{ expressInstall: true });
	$('#sidebar h3').sifr({ strSWF: '/flash/aquiline.swf', strColor: '#2a1701', strWmode: 'transparent', strFlashVars: 'textalign=center&' },{ expressInstall: true });
	//$('div.push-item h3 a').sifr({ strSWF: 'flash/aquiline.swf', strColor: '#2a1701', strLinkColor: '#2a1701', strHoverColor: '#2a1701', strWmode: 'transparent', strFlashVars: 'textalign=center&' },{ expressInstall: true });
	

$('#mycarousel').jcarousel({
		auto: 4,
		//size: 6,
		visible: 4,
		scroll: 2,
		itemFirstInCallback: 1,
		wrap: 'circular'
	}); 
	



	// Flash
	$("div#dhr-logo").flash( {src:"http://www.destinationhotels.com/flash/branding/flash_logoDhr.swf?link=miramonteresort", width:250, height:25, wmode:"transparent", quality:"high", allowscriptaccess:"always"}, {version:"7"});
	
	// Homepage Push hover
	$('div.push-item').hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	$('table#weather-table tr td + td').addClass('avg');
	$('table#weather-table tbody tr:first td').addClass('firstrow');
	
	$('table#press-release-table tr:even').addClass('even');
	
    if (typeof jQuery.prototype.msnMap != 'undefined') {
    $('#map').msnMap({categories: false, sortable: true, acceptQuery: true, clickMap: true}); 
    }
	
	$('a#clear-link').click(function(){
		$('div#custom-locations form').trigger('reset');
		return false;
	});
		
	$("body.grove-artisan-kitchen div#masthead").flash(
		{src:"flash/dining-masthead.swf",
		 width:950,
		 height:244,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.flvPath = '/flash/dining-masthead-video.flv';
				$(this).html($.fn.flash.transform(htmlOptions));
		});	
	$("body.home div#home-masthead").flash(
		{src:"flash/masthead-slideshow.swf",
		 width:950,
		 height:304,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlFile = "/flash/images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});	
	$("body.spa-home div#spa-masthead").flash(
		{src:"/flash/masthead-spa-slideshow.swf",
		 width:950,
		 height:304,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlFile = "/flash/spa-images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});			

	$("body.primary-weddings div#masthead").flash(
		{src:"/flash/masthead-weddings-slideshow.swf",
		 width:950,
		 height:244,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlFile = "/flash/weddings-images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});			

	$("div#photo-gallery").each(function() {
		var gal = $(this).attr('rel');
		
		$(this).flash(
		{src:"/flash/photoGallery-slideshow.swf",
		 width:590,
		 height:405,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.initialAlbum = gal;
				$(this).html($.fn.flash.transform(htmlOptions));
		});	
	});


	$("div#video-flash").flash(
		{src:"flash/miramonte-golf-video.swf",
		 width:320,
		 height:280,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});	

	$("div#meeting-rooms-flash").flash(
		{src:"flash/meeting-space.swf",
		 width:601,
		 height:513,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});	
		 
	 $("div#palm-springs-summer-specials").flash(
		{src:"flash/palm-springs-summer-specials.swf",
		 width:586,
		 height:380,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});	

	 $("div#palm-springs-seasonal-specials").flash(
		{src:"/flash/fall-specials.swf",
		 width:586,
		 height:380,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.flvPath = "flvs/fall-specials.flv";
				htmlOptions.flashvars.skinPath = "flash/flvs/SkinUnderPlaySeekMute.swf";
				$(this).html($.fn.flash.transform(htmlOptions));
		});		

	$(".hide-popup").hide();
	
	//$("div#resort-video2").flash( {src:"/flash/resort-video2.swf", width:590, height:376, wmode:"transparent", quality:"high", allowscriptaccess:"always", autoplay:"true"}, {version:"8"});

	//alert(testy);

// 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 }
	);
	*/


// 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");
    }
	*/
	$('a.modalgallery').click( function() {
		var modalLink= $(this).attr('href').slice(1);
		$('div.modalinline').attr('id',modalLink);
		$('h1.header').attr('id',modalLink);
		$("div.golf-video-wrapper").flash(
			{src:"/golf-video-slideshow.swf",
			 width:400,
			 height:325,
			 wmode:"transparent",
			 quality:"high"},
			 {version:"8"},
				function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	
					htmlOptions.flashvars.xmlPath="/flash/xml/"+modalLink+"-course-video-slideshow.xml";
					$(this).html($.fn.flash.transform(htmlOptions));
			});
		$("div.modalinline").jqm({overlay:70}).jqmShow().jqmAddClose($('.jqmClose'));
		return false;
	});


	// Blog
	$(".blog-post").each(function(){
		var blogPost = $(this);
		$(".post-read-more-btn",blogPost).toggle(function(){
			$.get('/direct/blog-details.php', { event_id: this.id.substr(3), channel: this.rel },function(data) { 
				$(".post-more-content",blogPost).hide().html(data).slideDown();
			});
			$(this).html("READ LESS...");
		}, function(){
			$(".post-more-content",blogPost).slideUp().html('');
			$(this).html("READ MORE...");
		});
		$(".share-link",blogPost).click(function(){
			$(".share-panel",blogPost).slideDown();
			return false;
		});
		$(".share-close",blogPost).click(function(){
			$(".share-panel",blogPost).slideUp();
			return false;
		});
		$(".blog-icon a",blogPost).click(function(){
			$(".post-read-more-btn",blogPost).click();
			return false;
		});
	});

	// Press Releases
	$("#press-releases").each(function(){
		var pressRelease = $(this);
		$(".share-link",pressRelease).click(function(){
			$(".share-panel",pressRelease).slideDown();
			return false;
		});
		$(".share-close",pressRelease).click(function(){
			$(".share-panel",pressRelease).slideUp();
			return false;
		});
	});

	// Packages
	$(".package-share").each(function(){
		var offer = $(this);
		$(".share-link",offer).click(function(){
			$(".share-panel",offer).slideDown();
			return false;
		});
		$(".share-close",offer).click(function(){
			$(".share-panel",offer).slideUp();
			return false;
		});
	});

	// Events
	$(".event-share").each(function(){
		var shareEvent = $(this);
		$(".share-link",shareEvent).click(function(){
			$(".share-panel",shareEvent).slideDown();
			return false;
		});
		$(".share-close",shareEvent).click(function(){
			$(".share-panel",shareEvent).slideUp();
			return false;
		});
	});
	
	//Blog post help link
	$(".help-link").each(function(){
		$(this).toggle(function(){
			$(".form-help").show();
		},function() {
			$(".form-help").hide();
		});
	});
	
	$('.toggle-promo').click(function(e){
		e.preventDefault();
		$('#promo-console').toggle(0,function(){
			if($(this).is(':visible')) {
				$('#group-code').focus();
			}
			else {
				$('.submit').focus();
			}
		});
		if (BROWSER=='msie6') $('select#child').toggle();
		if (BROWSER=='msie6') $('select#adults').toggle();
		if ($('#group-code').val() || $('#promo-code').val() || $('#iata-number').val()) {
			$('#complete-promo').show();
		}
		else {
			$('#complete-promo').hide();
		}
	});

	//Connect Push
	$(document).ready(function(){
		if ($.cookie('connect-rp') != 'clicked-connect') {
			$.cookie('connect-rp', 'not-clicked');
			$("div#bottom-connect-with-outer-wrapper").show().animate({ bottom: 0 }, 500 );
			//alert($.cookie('connect-with'));
		}
	});
	
	$('div#bottom-connect-with-outer-wrapper a').click(function() {
		$("div#bottom-connect-with-outer-wrapper").animate({ bottom: -60 }, 200 ).hide();
		$.cookie('connect-rp', 'clicked-connect');
		//alert($.cookie('connect-with'));		
	});
	
	// Connect push fix for iOS devices - will need to modify if we change for android/palm
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod' || (navigator.userAgent.indexOf('Android') != -1) ) {
		$("div#bottom-connect-with-outer-wrapper").css("position", "static");
	};
	
	$('.connect-inner-wrapper a#close-button').click(function(e){
		e.preventDefault();									   
	});

});


// 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); }
		);
	});

};  

function flashPutHref(href) { }


