$(function() {	
	// home push carousel
	$('#home-push-wrapper').each(function() {		
		$("#home-push-list").carouFredSel({
			items               : 3,
			width				: 598,
			prev				: "#go-prev",
			next				: "#go-next",
			scroll				: {
				items: 1
			},
			auto				: {
				pauseDuration: 3000,
				pauseOnHover: true,
				delay: 3000
			}
		}); 
	});

	$("#holiday-lightbox").each(function() {
		var holidayModalWidth = ($(window).width()-$(this).width())/2;
		$(this).css('left',holidayModalWidth);
		$(this).css('top','120px');
		$(this).jqm({closeClass:'jqmClose,'}).jqmShow();
	});   
		   
  $('.view-details-entertainment').bind('click',function(e) {
				e.preventDefault();
				$('.share-panel').hide();
				if ($(this).parent().hasClass('active')) {
					$(this).html(' ').parent().removeClass('active').parent().children('.event-description').slideUp('slow', function() { 
						$(this).html(''); 
					});
				}
				else {
					var el = $(this);
					var temp = this.rel.split(':');
					$.get('events-calendar-entertainment-ajax.php', { permalink: temp[0], rssfeed: temp[1], op: 'details' },function(data) { 
						el.html(' ').parent().addClass('active').parent().children('.event-description').hide().html(data).slideDown('slow');
						 
					
						});
				}
			});	   
		   
    
		   
		 $(" div.package-wrapper").find(" div.package-long").animate({
			height: 'hide'
		} );
	
// temp function for "fake" MCC
 	$('div.package-details a').toggle(function() {
		$(this).parents("div.package-wrapper").find("div.package-long").animate({
			height: 'show'
		}, 'slow');
		$(this).addClass('active');
	}, function() {
		$(this).parents("div.package-wrapper").find("div.package-long").animate({
			height: 'hide'
		}, 'slow');
		$(this).removeClass('active');
	});
 
		   
	// Booking console - Check availability promo code click button
	$("form#booking-form").each(function(){
		var x = $(this);
		$("a#promo-click", x).click(function(){
			$("#dropdown-fields",x).slideDown();
			//$(this).removeClass("promo-closed").addClass("promo-open");
			if(BROWSER=='msie6'){
				$("select",x).hide();
			}
			return false;
		});
		$("#extra-fields-close").click(function() {
			$("#dropdown-fields",x).slideUp();
			//$(this).removeClass("promo-open").addClass("promo-closed");
			if(BROWSER=='msie6'){
				$("select",x).show();
			}
			return false;
		});
	});
	$("#promo-done-btn").click(function(){
		$("#dropdown-fields").hide();
		if ($('#group-code').val() || $('#promo-code').val() || $('#iata-number').val()) {
			$("#promo-click").addClass("selected-promo-click");
		} else {
			$("#promo-click").removeClass("selected-promo-click");
		}
		return false;
	});  
		   
		   
		   
	//social media sharing
	$('.share-link').bind('click',function() {
		$('.share-panel').hide();
		$(this).parents('.rss-item').find('.share-panel').css('display','inline');
		return false;
	});
	$('.share-close').click(function(){
		$(this).parents('.rss-item').find('.share-panel').slideUp('fast');
		return false;
	});
	
	
 
	
	

	
	
	
	
	
	

 	$('.entertainment-h').sifr({ strSWF: '/flash/gotham.swf', strColor: '#563511', strWmode: 'transparent', strFlashVars: 'textalign=left&'}, { expressInstall: true });
	$('div#content h2').sifr({ strSWF: '/flash/piranesi-it-bt.swf', strColor: '#563511', strWmode: 'transparent'}, { expressInstall: true });
	$('div#sidebar h4').sifr({ strSWF: '/flash/piranesi-it-bt.swf', strColor: '#815c19', strWmode: 'transparent', strFlashVars: 'textalign=center&'}, { expressInstall: true });
	$('div#nav-push-header h3').sifr({ strSWF: '/flash/piranesi-it-bt.swf', strColor: '#b74c00', strWmode: 'transparent', strFlashVars: 'textalign=center&'}, { expressInstall: true });

		$("div#historic-timeline").flash( {src:"flash/timeline.swf", width:625, height:405, wmode:"transparent", quality:"high"}, {version:"7"});		
		$("body.home div#masthead").flash( {src:"flash/home.swf", width:960, height:380, wmode:"transparent", quality:"high"}, {version:"7"});

	$("button.submit").hover( function() { $(this).css("background-position", "0 -44px"); }, function () { $(this).css("background-position", "0 0px"); });

	$("div#jewel-news-video").flash( {src:"http://www.youtube.com/v/KsyMldf3648&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#haunted-video").flash( {src:"http://www.youtube.com/v/KyWH_9MFZ8U&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#ghost-stories-video").flash( {src:"http://www.youtube.com/v/j8v0mWOWEQ4&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#jason-lytle-video").flash( {src:"http://www.youtube.com/v/11jH-M6ih78&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#moriarty-video").flash( {src:"http://www.youtube.com/v/M3UjyVTF6PY&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#mirah-video").flash( {src:"http://www.youtube.com/v/Us45yiJGms0&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#concerte-video").flash( {src:"http://www.youtube.com/v/69BozyMnVSg&hl=en&fs=1&", width:425, height:344, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});
	$("div#driskill-video").flash( {src:"/flash/about-historic-driskill-hotel.swf", width:280, height:245, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});	
	$("div#driskill-hotel-video").flash( {src:"driskill-video.swf", width:480, height:308, wmode:"transparent", allowScriptAccess:"always", quality:"high"}, {version:"7"});		
	
	$("div#flash-photo-gallery").each(function() {
		$(this).flash(
			{src:"flash/photo_gallery.swf",
			 width:466,
			 height:416,
			 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));						
			}
		);
	});
	
	$('a.pop-up').click( function () {
	    var pLink = this.href;
		window.open(pLink,'PopUp','width=620,height=410, scrollbars=no')
		return false;
		});
	
    //form buttons hover states

	$('#mycarousel').jcarousel();
	var id = $("div.jcarousel-copy").attr('id');	
	
	$("div.jcarousel-copy").hide();
	$('a.jtoggle').click(function(){
		var href = $(this).attr("href");
		$(".jcarousel-copy").hide();
		$(href).show();
		return false;
		
	});
	
	//Scrapbook js

	$(".blog-post").each(function(){
		var x = $(this);
		$(".share-link",x).click(function(){
			$(".share-panel").hide();
			$(".share-panel",x).slideDown();
			return false;
		});
		$(".share-close",x).click(function(){
			$(".share-panel",x).slideUp();
			return false;
		});
		$(".post-details a", x).toggle(function(){
			var postid = $(this).attr("id");
			postid = postid.substr(3);	
			var postchan = $(this).attr("rel");
			$.get('/scrapbook-details.php', { event_id: postid, channel: postchan, lang: 'en' },function(data) { 
				$('.post-description', x).hide().html(data).slideDown();
			});
			$(this).html("Hide Details");
		} , function(){
			$('.post-description', x).slideUp().html('');
			$(this).html("Read Full Post");
		});

	});
	
	$("#featured-blog-post").each(function(){
		$("#featured-blog-post-more-content").hide();
		$("#featured-blog-post-read-more a").toggle(function(){
			$("#featured-blog-post-more-content").slideDown();
			$(this).html("Hide Details");
		}, function() {
			$("#featured-blog-post-more-content").slideUp();
			$(this).html("Read Full Post");
		});
	});
	
	$("a.help-link").each(function(){
		$(".form-help").hide();
		$(this).toggle(function(){
			$(".form-help").show();
			$(this).html("Hide Help");
		}, function(){
			$(".form-help").hide();
			$(this).html("Help?");
		});
	});
	
	$(document).ready(function(){
		if ($.cookie('connect-with') != 'they-clicked-me') {
			$.cookie('connect-with', 'no-clicked-me');
			$("div#bottom-connect-with-outer-wrapper").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 );
		$.cookie('connect-with', 'they-clicked-me');
		//alert($.cookie('connect-with'));		
	});
    
    // Bios page adding last class
    
    $('div.bios:last').addClass('last-bio');
	
	//initialize calendar
	$('.vcalendar').eventPreview();
 
	

	// IE6 fix for social media footer banner
	for(var i in $.browser) {
		if ($.browser[i])
			BROWSER = i + (($.browser.msie)?$.browser.version.charAt(0):'');
	}
	if(BROWSER=='msie6') {
		$(window).scroll(function() {
			ieposfix();
		});
		ieposfix();
		$(".connect-inner-wrapper #close-button").click(function(e){
			$("#bottom-connect-with-outer-wrapper").hide();
		});
	}
	function ieposfix() {
		var pos = ($(window).scrollTop() + $(window).height()) - $('#bottom-connect-with-outer-wrapper').height();
		$("#bottom-connect-with-outer-wrapper").css("top", pos + "px").css("position","absolute").css("bottom","auto");
	}
	
	$('div.live-long').hide();
	$('div.view-live-details a').click(function (e){
		e.preventDefault();
		$(this).parents().next().next('.live-long').slideToggle("fast",function(){
			if(!$(this).is(":hidden"))
			{
				$(this).prev().prev().addClass('close');
			} else {
				$(this).prev().prev().removeClass('close');
			}
		});
	});

});


