var changedFontSize = 0;

function RollOver(obj) 
{
	if (obj.src) 
	{
		var length = obj.src.length;
		var status = obj.src.substring(length-5, length-4);	
		obj.src = obj.src.substring(0, length-5) + (status == 0 ? 1 : 0) + obj.src.substring(length-4, length);    
	}
}

function ToolbarButton(str) 
{
	switch (str) 
	{
		case "zoom_in":
   		ChangeFontsize(1);
			break;
		case "zoom_out":
   		ChangeFontsize(-1);
			break;
		case "zoom_std":
		  ChangeFontsize(0);
			break;	
	}
}

function ChangeFontsize(increment) 
{
	changedFontSize += increment;
	
	SetCookie("fontSize", changedFontSize);

	var getElement = document.getElementsByTagName("body");
  for (var i=0; i < getElement.length; i++) 
  {
   	var eachElement = getElement[i];
		if (document.defaultView) 
		{	// Firefox
      var currentFontSize = document.defaultView.getComputedStyle(eachElement, null).getPropertyValue("font-size");   
      var currFontSize = parseInt(currentFontSize, 10);
      var fontIncrease = parseInt(increment, 10);	
      newFontSize = currFontSize + fontIncrease;
      eachElement.style.fontSize = newFontSize + "px";  
    } else 
    { // IE
			if (eachElement.currentStyle) 
			{	
      	var currentFontSize = eachElement.currentStyle.fontSize;
      	var currFontSize = parseFloat(currentFontSize);
      	var fontIncrease = parseInt(increment)/15;
      	newFontSize = currFontSize + fontIncrease;
      	eachElement.style.fontSize = newFontSize + "em";  
			}
		}
  }	
  
	if (changedFontSize == 0) 
	{
		DeleteCookie("fontSize");
	}
}

function RenderPNG(src, height, width, alt) {
	if (navigator.appVersion.indexOf("MSIE") != -1) {
		document.write("<img alt='"+alt+"' border=0 src=images/dot.gif style=width:"+width+"px;height:"+height+"px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+src+",sizingMethod='scale')/>");
	} else {
		document.write("<img alt='"+alt+"' src="+src+" style=width:"+width+"px;height:"+height+"px; border=0>");
	}
}

function Trim(s) {
  	// Remove leading spaces and carriage returns
  	while ((s.substring(0,1) == ' ' ) || 
	 	   (s.substring(0,1) == 'n') || 
		   (s.substring(0,1) == 'r')) {
		s = s.substring(1,s.length);
  	}

  	// Remove trailing spaces and carriage returns
  	while ((s.substring(s.length-1,s.length) == ' ') || 
		   (s.substring(s.length-1,s.length) == 'n') || 
		   (s.substring(s.length-1,s.length) == 'r')) {
    	s = s.substring(0,s.length-1);
	}
  	return s;
}

function SetCookie(name, value, expires, path, domain, secure) 
{
	document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

function GetCookie(name) {
    	var dc = document.cookie;
   	var prefix = name + "=";
    	var begin = dc.indexOf("; " + prefix);
    
	if (begin == -1) {
        	begin = dc.indexOf(prefix);
        	if (begin != 0) return null;
    	} else {
        	begin += 2;
    	}
    
	var end = document.cookie.indexOf(";", begin);
    	if (end == -1) {
        	end = dc.length;
    	}
    	return unescape(dc.substring(begin + prefix.length, end));
}

function DeleteCookie(name, path, domain) {
	if (GetCookie(name)) {
        	document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") +  "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function Popup(url, width, height) 
{
	window.open(url, '_blank', 'width=' + width + ', height=' + height + ', left=' + Math.round((screen.width - width)/2) + ', top=' + Math.round((screen.height - height)/4) + ', location=0, statusbar=0, menubar=0, toolbar=0, scrollbars=0, resizable=no');
}

function init() 
{
	// Set the font size
	if (GetCookie("fontSize")) 
	{
	  //alert(parseInt(GetCookie("fontSize")));
		//ChangeFontsize(parseInt(GetCookie("fontSize")));
	}
}
