// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/



//Specify affected tags. Add or remove from list:
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;
		 //alert(unescape(c_start));
		 //alert(unescape(c_end));
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
//return '1';
}
function setCookie (name,value,expiredays,path,domain,secure) {
  var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
  document.cookie = name + "=" + escape (value) +
    ((expiredays) ? "; expires=" + exdate.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
/*
function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
*/

var tgs = new Array( 'div','td','tr', 'A', 'H2' ,'h1','li' ,'h3' ,'p' , 'span');
var cWidth = new Array('550','550','550','550','550','550','600','680','716','750','812','933'); 
var cWidthfirefox = new Array('550','550','550','550','550','550','600','716','780','750','812','933'); 

//Specify spectrum of different font sizes:
//var szs = new Array( 'x-small','small','medium' );
var szs = new Array('12','16','18');
var offsetHeights = new Array('6','8','9');
var tsBusy = true;
function ts( trgt,inc ) {
	if (!tsBusy) {
		tsBusy = true;
		if (!document.getElementById) {tsBusy=false;return;}
		var d = document,cEl = null,i,j,cTags,sz,oldsz;
		sz = parseInt(getCookie('fontsizecooke'));
//		var ietextsize = parseInt(getCookie('ietextsize'));
			oldsz=sz;
		if (inc != 0)
			ietextsize =  checkFontSizeInIE(sz,inc);
		else
		   ietextsize = parseInt(offsetHeights[sz]);	
//		alert(ietextsize + "," + sz);
		sz = parseInt(sz) + parseInt(inc);
	//	alert(getCookie('fontsizecooke'));
		if ( sz < 0 || isNaN(sz)) sz = 0;
//		if ( sz > 2 ) sz = 2;
		if ( sz > 2 ) sz = 2;
		setCookie('fontsizecooke',sz,2,"/");			
//		setCookie('ietextsize',ietextsize,2);
	//	alert("sz=" + sz);
	//	alert("ietextsize=" + ietextsize + ",oldsz=" + oldsz + ",inc=" + inc );
		if (((oldsz !=2 || inc != 1) && (oldsz != 0 || inc != -1)) || (inc==0))
		{
//  			alert("ietextsize=" + ietextsize + ",width=" +cWidth[ietextsize-1] + ",fontsize=" + szs[ sz ]);
//			alert(whichBrs());
			if (whichBrs() != "Firefox")
				document.getElementById("changerwidth").style.width = cWidth[ietextsize-1] + "px";
			else
			{
//	  			alert("ietextsize=" + ietextsize + ",width=" +cWidthfirefox[ietextsize-1] + ",fontsize=" + szs[ sz ]);
				document.getElementById("changerwidth").style.width = cWidthfirefox[ietextsize-1] + "px";
			}
		}
		if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
		cEl.style.fontSize = szs[ sz ];
		for ( i = 0 ; i < tgs.length ; i++ ) {
			cTags = cEl.getElementsByTagName( tgs[ i ] );
			for ( j = 0 ; j < cTags.length ; j++ ) 		
			{
			//	if (cTags[ j ].id != 'abcde' )
			//	{
				cTags[ j ].style.fontSize = szs[ sz ];
		//		}
			}						
		}
		tsBusy = false;
	}
}
function checkCookie()
{
tsBusy = false;
username=parseInt(getCookie('fontsizecooke'));
if (username!=0 && !isNaN(username))
  {	
	ts('body',0);
  }
  else 
  {
  //username=1;
	//setCookie('fontsizecooke',username,365);
	 //ts('body',username)
  }
}
	function checkFontSizeInIE(sz,inc){
	if(document.getElementById && document.getElementById("font-size-test"))
	{
		// 4 - smallest, 5-smaller, 6 - medium, 7 - larger, 8 - largest
		var intOffsetHeight = document.getElementById("font-size-test").offsetHeight;		
//		alert("before intOffsetHeight=" + intOffsetHeight + ",sz=" + sz + ",inc=" + inc);
/*
		if ( inc == 1 && sz < 2 )
		{
			if (intOffsetHeight == 6)
				intOffsetHeight = 8;
		    else 
				intOffsetHeight = 9;
		}
		else if (sz > 0 && inc == -1)
		{
		 	if(intOffsetHeight == 9)
				intOffsetHeight = 8;	 
			else 
				intOffsetHeight = 6;	 
		}
*/		
		if ( inc == 1 && sz < 2  )
		{
			intOffsetHeight =  offsetHeights[sz+1];
		}
		else if (sz > 0 && inc == -1)
		{
			intOffsetHeight = offsetHeights[sz-1];	 
		}

//		alert("after intOffsetHeight=" + intOffsetHeight);
		if (intOffsetHeight > 9) intOffsetHeight = 9;
		return intOffsetHeight;
	}	
	/*
		var strTextSizeSetting;
		if (intOffsetHeight == 4)
		{
			strTextSizeSetting = 0; // smallest = medium
		}
		else if (intOffsetHeight == 5)
		{
			strTextSizeSetting = 0; // smaller = medium
		}
		else if (intOffsetHeight == 6)
		{
			strTextSizeSetting = 0; // medium
		}
		else if (intOffsetHeight == 7)
		{
			strTextSizeSetting = 1; // "larger"
		}
		else if (intOffsetHeight == 8){
			strTextSizeSetting = 2;  // largest
		}
		return strTextSizeSetting;
	}
	*/
	return 0;
}
