/* Text changer - light version.
Let your text's font size customizable.
by Marco Rosella - http://www.centralscrutinizer.it/en/design/js-php/text-changer
                v0.2 - May 18, 2006
*/
window.onload = function()
{
	if(typeof(init2) == 'function'){ init2();}
	textChanger.init();
}
var textChanger = {
	cpanel : 'textchanger',  //set here the id of the element (div, p) within you want to insert the control panel
	element : 'textchange',  //set here the id of the element (div, p) within you want to change the text, prev. pagewidth
	defaultFS : 1, //set here the default font size in 'em'
	init: function() 
	{
		var cpel = document.getElementById(textChanger.cpanel);
		var el = document.getElementById(textChanger.element);
		if (cpel != null && el != null) 
		{
		    var txt = cpel.innerHTML;
		    var u = document.createElement('ul');
		    cpel.innerHTML = "";
		    cpel.appendChild(u);
		    u.innerHTML = 
		    '<li id="increase"><a href="#" title="' + txt + '">AAA</a><a href="#" title="' + txt + '" id="incrtxt" style="padding-left:6px; color:#000000;">' + txt + '</a></li>'
		    var sz = textChanger.getCookie();
		    el.style.fontSize = sz ? sz + 'em' : textChanger.defaultFS + 'em';		
		    var incr = document.getElementById('increase');
		    incr.onclick = function(){textChanger.changeSize(1); return false;};
		}
	} ,
	changeSize: function(val) 
	{
		var el = document.getElementById(textChanger.element);
		var size = el.style.fontSize.substring(0,3);
		var fSize = parseFloat(size,10);
		if (val == 1) {
			fSize += 0.2;
			if (fSize > 1.5) fSize = 1;
		} 
		el.style.fontSize = fSize + 'em';
		textChanger.updateCookie(fSize);
		} ,
		
	updateCookie: function(vl) 
	{
		var today = new Date();
		var exp = new Date(today.getTime() + (365*24*60*60*1000)); //the cookie will expire in one year  
		document.cookie = 'textChangerL=size=' + vl + ';' +'expires=' + exp.toGMTString() + ';' +'path=/';
	} ,

	getCookie: function() 
	{ 
		var cname = 'textChangerL=size=';
		var start = document.cookie.indexOf(cname);
		var len = start + cname.length;
		if ((!start) && (cname != document.cookie.substring(0,cname.length))) {return null;}
		if (start == -1) return null;
		var end = document.cookie.indexOf(";",len);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(len, end));
	}
}
function clearDefault(txt) 
{
 if (txt.defaultValue==txt.value) txt.value = ""
}

function SetRedirectCookie(cookieValue) {
	var today = new Date();
	var expire = new Date();

	expire.setTime(today.getTime() + 3600000 * 24 * 365);
	document.cookie = "REDIRECTSITE=" + cookieValue
                 + ";expires=" + expire.toGMTString();

	window.location = "http://" + cookieValue;
}

