// JavaScript Document
var flashvars = false;
var params = {
	menu: "false",
	swliveconnect: "true",
	wmode: "transparent"
};
var attributes = {};

$(document).ready(function () {
	$("#menu li").bind("mouseenter",function(){
				this.className += " over";
	}).bind("mouseleave",function(){
				this.className = this.className.replace("over", "");
	});
	
	$("button").bind("mouseenter",function(){
				this.className += " on";
	}).bind("mouseleave",function(){
				this.className = this.className.replace("on", "");
	});
	
	
	
	if ($(".calloutPage").length > 0) {
			loadGuide();
			$(".callout:not(#guide)").show();
	}
	
	if( $("#homeBody").length > 0 ){
		loadHome();
	}
	
	if( $("#storyFlash").length > 0 ){
		loadStory();
	}
	
	if( $("#accContainer").length > 0 ){
		BuildAccordian();
	}
	

	
	
	//$.localScroll({offset:-50});
});

function toggleFlash(flashOpen){
	if(flashOpen){
		$(".callout:not(#guide)").fadeOut(350);
		$("#guide").animate({ height: "500px"}, 250);
	} else{
		$("#guide").animate({height: "210px"}, 250);
		$(".callout:not(#guide)").fadeIn(250);	
	}
}

function BuildAccordian(){
	$("div.accContent").not(".start").hide();
	
	$("div.accTitle").bind("click",function(){
		
		if($(this).hasClass("open")){
			$(this).next("div.accContent").slideUp(500, function(){
				$.scrollTo('#accContainer',500, {offset:-50});
			 });
			$(this).removeClass("open");
			
		} else{
			$('#accContainer div.open').next("div.accContent").slideUp(500, function(){
				$('#accContainer div.open').removeClass("open");
			});
			
			
			$(this).next("div.accContent").slideToggle(500, function(){
				$(this).prev("div.accTitle").addClass("open");
				$.scrollTo('#accContainer .open',500, {offset:-50});
			});
		}
		
	});	
	
	if( $("#toolsPage").length > 0 ){
		checkAccHash();
	}
}

function checkAccHash(){
	var myHash = window.location.hash;
	var myTitle = myHash + "Title";
	var myContent = myHash + "Content";
	
	if( $(myTitle).length > 0 && $(myTitle).hasClass('accTitle')){
		$(myTitle).trigger('click');
		
	}
}

function sizeIFrame(){
	$("iframe").bind("load", function(){
		var innerDoc = ($(this).get(0).contentDocument) ? $(this).get(0).contentDocument : $(this).get(0).contentWindow.document;
		$(this).css("height", (innerDoc.body.scrollHeight + 35));
	});	
}
