/**
* Source.........: $Source: M:/Concurrent\040Versions\040System/src/master/dogit/WWWroot/templates/template_standard.php,v $
* Created........: 2004-05-12
* Project........: StartCMS
* Last Modified..: $Date: 2006/12/21 16:22:04 $
* CVS Revision...: $Revision: 1.46 $
* Copyright......: 2004, 2005 Fred Liauw
*/

// initialize window
window.onload = init;

// global variables
var sTemplateClass = '';
var aFontSizes= [ 'smaller', '', 'bigger', 'biggest'];

function init(){
	// initialize sTemplateClass
	// sTemplateClass = window.document.body.className;
	var aClassNames = window.document.body.className.split(" ");
	sTemplateClass = aClassNames[0];
	
	// alert('function init()!');
	if($('fontSmaller')){ Event.observe('fontSmaller', 'click', smallerFont, false) };
	if($('fontBigger')) { Event.observe('fontBigger',  'click', biggerFont,  false) };

	// set cookie (expire in a week)
	var expDate = new Date();
	expDate.setDate(expDate.getDate()+7);
	setCookie('personalfontsize', sCurrentFontSize, expDate.toGMTString(), '/');

	// set templateclass
//	window.document.body.className = sTemplateClass + ' ' + sCurrentFontSize;
//	deleteCookie('personalfontsize','/');
//	window.document.body.className = sTemplateClass;
	
	if(typeof(window.initializeSuggestFramework)!='undefined'){
		initializeSuggestFramework();
	}
}

// biggerfont
function biggerFont(){
	var nOffset = aFontSizes.indexOf(sCurrentFontSize);
	var expDate = new Date();

	if(nOffset==-1){
		sCurrentFontSize = aFontSizes[aFontSizes.length-1];
	} else if(nOffset < aFontSizes.length-1) {
		sCurrentFontSize = aFontSizes[nOffset+1];
	}
	// set cookie (expire in a week)
	expDate.setDate(expDate.getDate()+7);
	setCookie('personalfontsize', sCurrentFontSize, expDate.toGMTString(), '/');
	
	// set body.className	
	window.document.body.className = sTemplateClass + ' ' + sCurrentFontSize;
	// alert('PLUSJE!\nwindow.document.body.className = \'' + window.document.body.className + '\'');
}

// smallerfont
function smallerFont(){
	var nOffset = aFontSizes.indexOf(sCurrentFontSize);
	var expDate = new Date();

	if(nOffset==-1){
		sCurrentFontSize = aFontSizes[0];
	} else if(nOffset > 0) {
		sCurrentFontSize = aFontSizes[nOffset-1];
	}
	// set cookie (expire in a week
	expDate.setDate(expDate.getDate()+7);
	setCookie('personalfontsize', sCurrentFontSize, expDate.toGMTString(), '/');

	// set body.className	
	window.document.body.className = sTemplateClass + ' ' + sCurrentFontSize;
	// alert('minnetje!\nwindow.document.body.className = \'' + window.document.body.className + '\'');
}

