$(function(){
	$("#leftMenu a.hasSub").next().hide();
	$("#leftMenu a.hasSub").toggle(
		function(){
			$(this).next().slideDown("fast");
			$(this).addClass("open");
		},
		function(){
			$(this).next().slideUp("fast");
			$(this).removeClass("open");
		}
	);
	
	$(".content .toggleBox h1").next().hide();
	$(".content .toggleBox h1").toggle(
		function(){
			$(this).next().slideDown("fast");
			$(this).addClass("toggleOpen");
			//alert(location.hash);
		},
		function(){
			$(this).next().slideUp("fast");
			$(this).removeClass("toggleOpen");
		}
	);
	// preopen toggle box
	if (location.hash!=""){
		$(".content .toggleBox div"+location.hash).prev("h1").click();
	}
});





function disableLink(el){
	el.disabled=true;
}


// Text Resizer
var defaultFontSize = 75;
var currentFontSize = defaultFontSize;

function revertStyles(){
	setFontSize("c_fontSize", defaultFontSize);
}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(readCookie("c_fontSize")) + parseInt(sizeDifference * 5);
	if(currentFontSize > 110){
		currentFontSize = 110;
	}else if(currentFontSize < defaultFontSize){
		currentFontSize = defaultFontSize;
	}
	setFontSize("s_fontSize", currentFontSize);
}

function setFontSize(c_name, fontSize){
	document.body.style.fontSize = fontSize + '%';
	createCookie("c_fontSize", fontSize, 365);
}

function prevFontSize(c_name){
	fsCookie=getCookie(c_name);
	if(fsCookie==""){
		//alert("no cookie");
		setFontSize("s_fontSize", defaultFontSize);
	} else {
		document.body.style.fontSize = readCookie(c_name) + '%';
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

// COOKIE
function createCookie(name,value,days){
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	//return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}