//example function from http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/cookie.asp
function getCookie(sName) {
  var aCookie = document.cookie.split("; ");
  
  for (var i=0; i < aCookie.length; i++){
    var aCrumb = aCookie[i].split("=");
    
    if (sName == aCrumb[0]) 
		return unescape(aCrumb[1]);
  }

  return null;
}

function writeCookie(name, value, expiresIn) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + expiresIn);
	
	document.cookie = name + "=" + escape(value) + "; expires=" + exdate.toGMTString();
}

function checkSavedTextSize() {
	value = getCookie("textSize");
	
	if(value != null)
		switchTextSize(value);
}

window.onload = checkSavedTextSize;

function switchTextSize(newSize) {
	element = document.getElementById("mainBox");
	element.style.fontSize = newSize + "%";
	element.style.lineHeight = "1.5em";
	
	writeCookie("textSize", newSize, 30);
}


