var total = '';

function Init_Cookie() {
	FSizeCookie = Get_Cookie("FSize");
	if (FSizeCookie){
		if (FSizeCookie >> 0){
			for (i=1;i<=FSizeCookie;i++){
				changeFontAtNode(document,0);
			}
		}
		if (FSizeCookie << 0){
			for (i=-1;i >= FSizeCookie;i--){
				changeFontAtNode(document,1);
			}
		}
	}
}

function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function changeFont(no,op){
	if (!Get_Cookie("FSize")){
		sizesteps=0;
		document.cookie = "FSize=" + sizesteps;
	}
		sizesteps = Get_Cookie("FSize");
		if ((op!=1) && (sizesteps <= 2)){
			sizesteps++;
			changeFontAtNode(no,0);
		} else if ((op==1) && (sizesteps >= -2)){
			sizesteps--;
			changeFontAtNode(no,1);
		}
		document.cookie = "FSize=" + sizesteps;
}


function changeFontAtNode(node,operation)
{
   var fontSizeString;
   for (var i = 0; i < node.childNodes.length; i ++)
   {
      if ( node.childNodes[i].id != "nav1" && node.childNodes[i].id != "nav0back" && node.childNodes[i].id != "toolbar" && node.childNodes[i].id != "fixfont" && node.childNodes[i].id != "loc-menu" && node.childNodes[i].id != "searchbar") {
      	changeFontAtNode(node.childNodes[i],operation);
      }
   }
   if (node.style != null)
   {
      if ( node.currentStyle ) {
      	fontSizeString = node.currentStyle.getAttribute("fontSize", "false");
      } else {
      	fontSizeString = window.getComputedStyle(node,null).fontSize;
      }
      currentSize = parseInt(fontSizeString);
      if ( currentSize >= 1) {
				if (operation!=1){
	      	currentSize++;
  	    } else {
      		currentSize--;
      	}
			}
    node.style.fontSize = (currentSize.toString() + "px");
		}

}
