var contentHidden = false;
var i;
var colors = new Array("00c7a4", "4fbdce", "ff2a2a", "ff4fe8", "f1cc00", "29d102");
var specialColor;
var detailsOn = false;

$(document).ready(function(){
	setSpecialColor();
	pasteBackground();
	details();
	blockquote();
	$(window).resize(function(){
		fit();
	})
	fit();
	//alert("This Site uses Adobe Flash for displaying audio and images. Continue anyways?");
})
function fit(){
	$("#moveplane").css({
		"width": $(window).width() - 70
	})
}
function blockquote(){
	$("blockquote").each(function(){
		$(this).find("p:last").addClass("blockquote-out");
	})
}
function pasteBackground(){
	var galleryXML;
	var soundLink = "noSound";
	if($('#audio-link').length > 0){
		soundLink = $('#audio-link').attr('href');
		$('#audio-link').remove();
	}
	
	isHome = isHome == 1 ? true : false;
	
	if($('.gallery').length > 0){
		galleryXML = "<data>\n" + $('.gallery:first').html() + "\n</data>";
		//alert(galleryXML);
		$('.gallery').remove();

		var flashVars = {};
			flashVars.specialColor = specialColor;
			flashVars.isHome = isHome;
			flashVars.galleryXML = galleryXML;
			flashVars.soundLink = soundLink;
			flashVars.postID = postID;

		var params = {};
			params.menu = "false";
			params.allowFullScreen = "true";
			params.wmode = "transparent";

		var attributes = {};
			attributes.id = "flashmovie";
			attributes.name = "flashmovie";
		
		$('body').prepend('<div id="flashcontent"></div>');
		swfobject.embedSWF(stylesheetDirectory + "/media.swf", "flashcontent", "100%", "100%", "9.0.45", rootURL + "/js/expressinstall.swf", flashVars, params, attributes);
	}
}
function startMouseHandler(){
	if(isHome != true){
		$("body").mousemove(function(e){
			moveHandler(e);
		});
	}
}
function showContainer(){
	if(contentHidden == true){
		$("#container").css('z-index', '1000');
		$("#container").css('visibility', 'visible');
		contentHidden = false;
	}
}
function hideContainer(){
	if(contentHidden == false){
		$("#container").css('z-index', '0');
		$("#container").css('visibility', 'hidden');
		contentHidden = true;
	}
}
function moveHandler(event){
	if(event.pageX > $('#flashmovie').width() - 80 && event.pageX < $('#flashmovie').width() && event.pageY < 300){
		hideContainer();
		
	} else {
		showContainer();
	}
}
function details(){
	$('#morelink a').click(function(e){
		e.preventDefault();
		toggleDetails();
	})
	$('#details-entry').hide();
}
function toggleDetails(){
	if(detailsOn == false){
		detailsOn = true;
		$('#morelink a .show-details-text').hide();
		$('#morelink a .hide-details-text').show();
		$('#details-entry').show();
	} else {
		detailsOn = false;
		$('#morelink a .show-details-text').show();
		$('#morelink a .hide-details-text').hide();
		$('#details-entry').hide();
	}
}
function setSpecialColor(){
	specialColor = colors[Math.floor(Math.random() * colors.length)];
	$('head').append("<style type='text/css'>a:hover, h2 span, .current-cat a, .current_page_item a { background-color: #"+specialColor+" !important; }</style>");
	
}






