$(function() {
	//Documentation located in special.docs.js
	$(document).pngFix({
	    blankgif:'/images/blank.gif'
	});

	// H1 - Heading Sifr - Cellar 49 template pages
		$('body.cellar-49 div#content h1').sifr(
		{ strSWF: '/flash/goudy-old-style.swf', strColor: '#e7e6dd', strLinkColor: '#e7e6dd', strHoverColor: '#e7e6dd', strWmode: 'transparent', intPadding: [0, 0, 0, 0] },
		{ expressInstall: true }
	);

	// H1 - Heading Sifr
		$('div#content h1').sifr(
		{ strSWF: '/flash/goudy-old-style.swf', strColor: '#362c1e', strLinkColor: '#362c1e', strHoverColor: '#362c1e', strWmode: 'transparent', intPadding: [0, 0, 0, 0] },
		{ expressInstall: true }
	);
		
	// H3 - Sub-nav heading
		$('div#sec-nav-heading h3').sifr(
		{ strSWF: '/flash/goudy-old-style.swf', strColor: '#f2f1eb', strLinkColor: '#f2f1eb', strHoverColor: '#f2f1eb', strWmode: 'transparent', intPadding: [0, 0, 0, 0] },
		{ expressInstall: true }
	);
		
	//Home Push h2
		$('div.home-push-offer h2').sifr(
		{ strSWF: '/flash/goudy-old-style.swf', strColor: '#8a181b', strLinkColor: '#8a181b', strHoverColor: '#8a181b', strWmode: 'transparent', intPadding: [0, 0, 0, 0] },
		{ expressInstall: true }
	);

	// Estate History page years
		$('.history-year h5').sifr(
		{ strSWF: '/flash/goudy-old-style.swf', strColor: '#362c1e', strLinkColor: '#362c1e', strHoverColor: '#362c1e', strWmode: 'transparent', intPadding: [0, 0, 0, 0] },
		{ expressInstall: true }
	);
	
	
	$("div#holiday-flash-2009").flash(
		{src:"http://www.tarrytownhouseestate.com/flash/HolidayEcard2009.swf",
		 width:700,
		 height:552,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});


	//DHR logo flash
				$("div#dhr-logo").flash(
			{src:"http://www.destinationhotels.com/flash/branding/flash_logoDhr-white.swf?link=tarrytownhouseestate",
			 width:250,
			 height:25,
			 wmode:"transparent",
			 allowScriptAccess:"always",
			 quality:"high"},
			 {version:"8"});

	//Homepage Flash Masthead
	$("body.home div#masthead").flash(
		{src:"flash/homepage.swf",
		 width:687,
		 height:324,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlFile = "/flash/xml/homepage-mast.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	
	
	// Photo gallery flashes
	$("div#photo-gallery").flash(
		{src:"flash/photo_gallery.swf",
		 width:640,
		 height:466,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlFile = "/flash/xml/images_resort.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	
	$("div#wedding-photo-gallery").flash(
		{src:"flash/photo_gallery.swf",
		 width:640,
		 height:466,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlFile = "/flash/xml/images_weddings.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});


	// Meeting Facilities Flash
	$("div#meetings-flash").flash(
		{src:"/flash/meeting-map.swf",
		 width:670,
		 height:490,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				//htmlOptions.flashvars.configPath = "gallery_config_weddings";
				htmlOptions.flashvars.sitePath = "/flash/xml/meeting-map.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});

	//Homepage push marketing rotation with jcycle
	var randomPush = Math.floor(Math.random()*10);
	$('div#left-push div.home-push-offers').cycle({ 
		fx:     'scrollHorz', 
		speed:  1000, 
		timeout: 0, 
		startingSlide: randomPush,
		next:   '.home-push-next'
		//prev:   '#prev-push' 
	});

	var randomPush = Math.floor(Math.random()*10);
	$('div#right-push div.home-push-offers').cycle({ 
		fx:     'scrollHorz', 
		speed:  1000, 
		timeout: 0, 
		startingSlide: randomPush,
		next:   '.home-push-next2'
		//prev:   '#prev-push' 
	});
	
	// Booking console - Check availability promo code click button
	$("form#booking").each(function(){
		var x = $(this);
		$("a#promo-click", x).toggle(function(){
			$("#drodpdown-feilds",x).slideDown();
			$(this).removeClass("promo-closed").addClass("promo-open");
			if(BROWSER=='msie6') {
				$("div#content h1").hide();
				$("div#sec-nav-heading h3").hide();
				//$("div#content").css("padding-top","53px");
			}
		}, function() {
			$("#drodpdown-feilds",x).slideUp();
			$(this).removeClass("promo-open").addClass("promo-closed");
			if(BROWSER=='msie6') {
				$("div#content h1").show();
				$("div#sec-nav-heading h3").show();
				//$("div#content").css("padding-top","5px");
			}
		});
	});
	
	
	// Events calender js - Wrote my own since main.js wasn't working (Amir)
	
	$("li.event").each(function(){
		var x = $(this);
		$(".event-details a",x).toggle(function(){
			var temp = this.rel.split(':');
			$.get('/direct/events-calendar-ajax.php', { permalink: temp[0], rssfeed: temp[1], lang: LANG, op: 'details' },function(data) { 
				$(".event-description",x).hide().html(data).slideDown('slow');
			});
			$(this).removeClass("view-details").addClass("hide-details");
		}, function() {
			$(".event-description",x).slideUp('slow').html('');
			$(this).removeClass("hide-details").addClass("view-details");
		});
	});
	
	
	
	$(".story-wrapper").each(function(){
		var x = $(this);
		$(".story-long").hide();
		$(".full-story",x).toggle(function(){
			$(".story-long",x).slideDown();
			$(this).removeClass("hide-details").addClass("view-details");
		}, function() {
			$(".story-long",x).slideUp();
			$(this).removeClass("view-details").addClass("hide-details");
		});
	});
	
	//Blog post icons
	$(".post").each(function(){
		var x = $(this);
		$(".post-icon a",x).click(function(){
			$(".post-details a",x).trigger("click");
			return false;
		});
	});
	
	// Post an entry help link
	$("#scrapbook-entry").each(function(){
		$(".form-help").hide();
		$(".help-link").toggle(function(){
			$(".form-help").slideDown();
		}, function() {
			$(".form-help").slideUp();			
		});
	});

	/* adds "odd" class to odd rows in tables */	
	$("table tr:nth-child(odd)").addClass("odd");


	// jqModal popup
		var openFn=function(hash){
			$("div#video-flash").flash(
				{src:"/flash/video-chef-interview.swf",
				 width:500,
				 height:415,
				 wmode:"transparent",
				 quality:"high"},
				 {version:"8"});
			$("div#video-flash-chef").flash(
				{src:"flash/tarrytown-chef-on-news.swf",
				 width:500,
				 height:417,
				 wmode:"transparent",
				 quality:"high"},
				 {version:"8"});
            $("div#video-flash-ny").flash(
                {src:"flash/ny-golden-apple.swf",
                 width:500,
                 height:315,
                 wmode:"transparent",
                 quality:"high"},
                 {version:"8"},
                    function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                        htmlOptions.flashvars.flvPath = "flash/ny-golden-apple.flv";
                        htmlOptions.flashvars.skinPath = "flash/SkinUnderAllNoFullNoCaption.swf";
                        $(this).html($.fn.flash.transform(htmlOptions));
                });
            $("div#video-flash-lady").flash(
                {src:"flash/Tarrytown_house.swf",
                 width:500,
                 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 = "/flash/Tarrytown_house.flv";
                        htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
                        $(this).html($.fn.flash.transform(htmlOptions));
                });
			$("div#video-flash-lady").css("padding-bottom","37px");
			hash.w.show();
			var difference = $(window).width() - $('#video-wrapper').width();
			difference = difference / 2;
			$('#video-wrapper').css({left:difference+275,top:$(window).scrollTop()+10});			
		};
		var hideFn=function(hash){
			hash.w.hide()
			hash.o.remove();
			$("div.video-flash-remove").html('');
		};
	
	$("#video-wrapper").each(function(){
		$(this).jqm({onShow: openFn, onHide: hideFn});
	});
		
});