/*------------------------------------------------------------
	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','span','p', 'table','tbody');

// Font sizes xx-small and x-small are not used here because they would reduce the
// size of the text to below the standard size of the site.
var szs = new Array('x-small','small','medium','large','x-large' );

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz,i,j,cTags;

	sz = Number(getCurSize())
	// alert('sz=' + sz + '; inc=' + inc)
	if ( sz == 0 && inc == -1) 
		alert('De tekst kan niet kleiner worden gemaakt dan het huidige formaat.')
	else if (sz == szs.length - 1 && inc == 1) 
		alert('De tekst kan niet groter worden gemaakt dan het huidige formaat.')
	else
  {
		sz = Number(sz) + Number(inc);
		// alert('new fontsize = ' + szs[sz])
		if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	
		// alert('setting main ' + szs[sz])
		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.substr(cTags[j].id.length - 10) == 'lblContent'
				    ||
				    cTags[j].id.substr(cTags[j].id.length - 13) == 'ModuleContent'
				    ||
				    cTags[j].id.substr(cTags[j].id.length - 11) == 'ContentPane')
				{
					// alert('setting ' + cTags[j].id + ' to ' + szs[sz])
					cTags[ j ].style.fontSize = szs[ sz ];
				}
			}
		}
		if (inc != 0) 
		{
			setCurSize(sz);
			location.reload();
		}
	}
}

// DESIGNWISE

var textSizeCookieName = "THC_TEXTSIZE"
function getCurSize() 
{
	var theCookies = document.cookie.split(";")
	var curSize = ''

	for(index = 0; index < theCookies.length; ++index)
	{
		var cookieName = theCookies[index].split("=")[0]
    var cookieValue = theCookies[index].split("=")[1]

	  // Mozilla returns the cookie name with space in front.
	  // No idea why; we just incorporate it in the comparison.
		if (cookieName == textSizeCookieName ||
		    cookieName == ' ' + textSizeCookieName)
		{
			curSize = cookieValue
			break;
		}
	}
	
	if (typeof(curSize) == "undefined") curSize = '0'
	if (curSize.length == 0) curSize = '0'
	
	return curSize
}

function setCurSize(curSize) 
{
	document.cookie = textSizeCookieName + "=" + curSize +
                  "; path=/;domain=" + location.host
}

