/*------------------------------------------------------------
	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:
var tgs = new Array('div','td','tr','p','li','a');

//Specify spectrum of different font sizes:
var szs = new Array( '9px','10px','11px','12px','13px','14px','16px' );
var startSz = 3;
var inccookie = 0;
var totalinc = 0;


function incrementFont(delta){
	//alert("fontsize set to:");
	delta = delta * 1;
	currentCookieSize = getCookieFontSize();
	
	if(currentCookieSize == "doNotResize"){
		currentCookieSize = 3;
	}else{
		currentCookieSize = getCookieFontSize() * 1;
	}

	fontsize = currentCookieSize + delta;

	if ( fontsize < 0 ) fontsize = 0;
	if ( fontsize > 6 ) fontsize = 6;

	setCookieFontSize(fontsize);

	setFontSize('body',fontsize);
	
	//alert("fontsize set to:" + fontsize);
}

function setFontSize(trgt, fontsize){
	

	/*if starsz=3 size is 12px; it is the limit. If the text size is more than 12 px,
	we need more than one line for the text in the top menu of the Bond page. We must switch to 
	navigation1 css class: */

	if( fontsize < 4){
		document.getElementById("navigation").className = "navigation";
	}else
	{
		document.getElementById("navigation").className = "navigation1";
	}

	changeSize(trgt, fontsize);		
}	


function changeSize(trgt, sz){
	var d = document,cEl = null,cTags,i,j;

	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++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

function getCookieFontSize()
{
	if (document.cookie.length > 0)
	{
		val_start=document.cookie.indexOf("fontSize=");
		
		if (val_start!=-1)
		{

		    	val_start=val_start + 9;
			val_end=document.cookie.indexOf(";",val_start);	
		
			if (val_end == -1) val_end=document.cookie.length;
	
			//alert("belj:" + unescape(document.cookie.substring(val_start,val_end)));
			return unescape(document.cookie.substring(val_start,val_end));
		}
	}
	
	return "doNotResize";
}

function setCookieFontSize(fontSize)
{
	document.cookie = "fontSize=" + fontSize + ";path=/;";
	//alert('Cookie font size set to: ' + fontSize);
}



