$(function() {	
	//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;
	});
	
	$('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'));		
	});
	
	

});

