initNav = function() {
	var navRoot = document.getElementById("control-panel");
	if (navRoot) {
		var lis = navRoot.getElementsByTagName("li");
		for (var i=0; i<lis.length; i++)
		{
			lis[i].onmouseover = function()
			{
				this.className += " hover";
			}
			lis[i].onmouseout = function()
			{
				this.className = this.className.replace("hover", "");
			}
		}
	}
}
if (document.all && window.attachEvent)
	attachEvent("onload", initNav);
	
function initInputs()
{
	var inputs_form = document.getElementById("form_search");
	if (inputs_form) var inputs = inputs_form.getElementsByTagName("input");
	if (inputs) {
		for (var i=0; i<inputs.length; i++)
		{
			if (inputs[i].type == "text" && (inputs[i].name == "email" || inputs[i].name == "search" || inputs[i].name == "keyword"))
			{
				var form = getAncestor(inputs[i], "form");
				if (form) form.onsubmit = handleSubmit;
				inputs[i].onfocus = function ()
				{
						if ((this.value == "e-mail address") || (this.value == "Search") || (this.value == "Search Term"))
							this.value = "";
				}
				inputs[i].onblur = function ()
				{
						if (this.value == "" && this.name == "email") this.value = "e-mail address";
						if (this.value == "" && this.name == "search") this.value = "Search";
						if (this.value == "" && this.name == "keyword") this.value = "Search Term";
				}
			}
		}
	}
}
function getAncestor(element, tagName)
{
	var node = element;
	while (node.parentNode && (!node.tagName ||
			(node.tagName.toUpperCase() != tagName.toUpperCase())))
		node = node.parentNode;
	return node;
}
function handleSubmit()
{
	var re = new RegExp('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$');
	var element = this.elements["email"];
	if (element)
	{
		if (element.value == "")
		{
			alert("Email address is empty!");
			return false;
		}
		else
			return element.value.match(re)
				|| (alert("You have entered incorrect email address!"), false);
	}
	return true;
}

if (window.addEventListener)
{
	window.addEventListener("load", initInputs, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", initInputs);
}

window.onload = function(){
	textChanger.init(); 	
}

var textChanger = {
	cpanel : 'textchanger',  //set here the id of the element (div, p) within you want to insert the control panel
	element : 'page-box',   	 //set here the id of the element (div, p) within you want to change the text
	defaultFS : 1.18,         //set here the default font size in 'em'
	init: function() {
		var cpel = document.getElementById(textChanger.cpanel);
		var el = document.getElementsByTagName("body")[0];
		if (cpel == null || el == null) {} else {
		var u = document.createElement('ul');
		cpel.appendChild(u);
		u.innerHTML = 
		'<li id="decrease"><a href="#" title="Decrease font size">A</a></li>'+
		'<li id="reset"><a href="#" title="Default font size">A</a></li>'+
		'<li id="increase"><a href="#" title="Increase font size">A</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;};
		var decr = document.getElementById('decrease');
		decr.onclick = function(){textChanger.changeSize(-1); return false;};
		var reset= document.getElementById('reset');
		reset.onclick = function(){textChanger.changeSize(0); return false;};
		}
	} ,

	changeSize: function(val) {
		var el = document.getElementsByTagName("body")[0];
		var size = el.style.fontSize.substring(0,3);
		var fSize = parseFloat(size,10);
		if (val == 1) {
			fSize += 0.11;
			if (fSize > 1.33) fSize = 1.33;
		} 
		if (val == -1) {
			fSize -= 0.11;
			if (fSize < 0.88) fSize = 0.88;
		}		
		if (val == 0) {
			fSize = 1.18;
		}
		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));
	}
}