var textsizetype = "normal";
var maxFontSize=1000;
var minFontSize=20;
var defaultFontSize = 100;
var currentFontSize = defaultFontSize;



function textsize(type){
	
	if (type=='large'){
		/*
		unsetActiveStyleSheet('sizenormal')
		unsetActiveStyleSheet('sizelarge')
		setActiveStyleSheet('sizelarge')*/
		styleSheetOnOff('sizenormal',true,false);
		styleSheetOnOff('sizelarge',true,true);
		textsizetype = "large"
	}
	else {
		/*unsetActiveStyleSheet('sizelarge')
		setActiveStyleSheet('sizenormal')*/
		styleSheetOnOff('sizelarge',true,false);
		styleSheetOnOff('sizenormal',true,true);
		textsizetype = "normal"
	}
	savecookies();
}
function savecookies() {
	var datenow = new Date();
	var pagewidth=0;
	var contrasttype=0;
	datenow.setTime(datenow.getTime()+(30*24*60*60*1000));//first number is days to keep
	document.cookie = "CUPcontrols=#"+pagewidth+"#"+textsizetype+"#"+contrasttype+"#;expires="+datenow.toGMTString()+"; path=/";
}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);
	if(currentFontSize > maxFontSize){
		currentFontSize = maxFontSize;
	}else if(currentFontSize < minFontSize){
		currentFontSize = minFontSize;
	}
	setFontSize(currentFontSize);
};

function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('container') : document.all('container');
	document.body.style.fontSize = fontSize + '%';
	
	//alert (document.body.style.fontSize);
}

function styleSheetOnOff(title, setOff, setOn) {
	//sets give style sheet off and/or on
	//need off then on to make sure that new sheet works properly
	var i, a, main;
	for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			if (a.getAttribute("title") == title) {
				if (setOff){
					a.disabled = true;
				}
				if (setOn){
					a.disabled = false;
				}
			}
		}
	}
}


