window.onload = function() {
	addTextResizingWidget();
}



var addTextResizingWidget = function() {
	
	var tools = null, ul = null, li = null, a = null, href = null, txt = null;	
	var gray = '#999', black = '#000';	
	
	ul = document.createElement("ul");
	
	for (i=0;i<3;i++){
		li = document.createElement("li");
		
		a = document.createElement("a");
		href = document.createAttribute("href");
		
			href.nodeValue = "javascript:void(0);";		
			a.setAttributeNode(href);
			txt = document.createTextNode("a");
						
			a.appendChild(txt)
			li.appendChild(a);				
			ul.appendChild(li);
	}
	
	tools = document.getElementById("tools");		
	tools.appendChild(ul);
	
	var a1 = tools.getElementsByTagName("a")[0];
	var a2 = tools.getElementsByTagName("a")[1];
	var a3 = tools.getElementsByTagName("a")[2];
	
	a1.className = 'black bold';
	a2.className = "larger";
	a3.className = "largest";
	
	a1.onclick = function() {
		document.body.style.fontSize = '70%';			
		cookie.Create('WSPfontSize','70%',7);
		
		this.style.color = black;
		a1.style.fontWeight = 'bold';
		a2.style.color = gray;
		a2.style.fontWeight = 'normal';		
		a3.style.color = gray;
		a3.style.fontWeight = 'normal';		
	}
	
	a2.onclick = function() {
		document.body.style.fontSize = '80%';			
		cookie.Create('WSPfontSize','80%',7);
		
		this.style.color = black;
		a1.className = '';
		a1.style.color = gray;
		a1.style.fontWeight = 'normal';
		a2.style.fontWeight = 'bold';
		a3.style.color = gray;
		a3.style.fontWeight = 'normal';		
	}	
	
	a3.onclick = function() {
		document.body.style.fontSize = '90%';		
		cookie.Create('WSPfontSize','90%',7);
		
		this.style.color = black;		
		a1.style.color = gray;
		a1.style.fontWeight = 'normal';		
		a1.className = '';
		a2.style.color = gray;
		a2.style.fontWeight = 'normal';		
		a3.style.fontWeight = 'bold';
	}
	
	var fz = cookie.Read('WSPfontSize');
	
	if (fz != null)
	{   
	    if (fz == '70%') {
			document.body.style.fontSize = '70%';
			//this.style.color = black;
			a1.style.color = black;
			a1.style.fontWeight = 'bold';
			a2.style.color = gray;
			a2.style.fontWeight = 'normal';		
			a3.style.color = gray;
			a3.style.fontWeight = 'normal';		
		}
		
		else if (fz == '80%') {
			document.body.style.fontSize = '80%';
			a2.style.color = black;
			a1.className = '';
			a1.style.color = gray;
			a1.style.fontWeight = 'normal';
			a2.style.fontWeight = 'bold';
			a3.style.color = gray;
			a3.style.fontWeight = 'normal';
		}
		
		else if (fz == '90%') {
			document.body.style.fontSize = '90%';
			a3.style.color = black;		
			a1.style.color = gray;
			a1.style.fontWeight = 'normal';		
			a1.className = '';
			a2.style.color = gray;
			a2.style.fontWeight = 'normal';
			a3.style.fontWeight = 'bold';
		}
		
	}
	
}


var cookie = {
	Create: function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	},
	Read: function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},
	Erase: function(name) {
		cookie.Create(name,"","Thu, 01-Jan-1970 00:00:01 GMT");
	}
};


function openUrlWin(loc) {
    //var sY = (screen.height - height) / 2 ; var sX = (screen.width - width) / 2;
    //popupWin = window.open(loc,name,'scrollbars='+scrollbars+',top='+sY+',left='+sX+',height='+height+',width='+width+'');
    popupWin = window.open(loc,"popup","height=500,width=900,status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}
        
        
// This function really does not work very well
function changeFontSize(inc) {

    var p = document.getElementsByTagName('body');
    for(n=0; n<p.length; n++)
    {
        if(p[n].style.fontSize)
        {
            var size = parseInt(p[n].style.fontSize.replace("em", ""));
        }
        else
        {
            var size = 0.7;
        } 
        p[n].style.fontSize = size+inc + 'em';
    }
}


function SetMBAProperties(strapLine, link1Text, link1Url, link2Text, link2Url, link3Text, link3Url)
{
    document.getElementById("main").removeAttribute("style", 0);
    document.getElementById("links").removeAttribute("style", 0);
    document.getElementById("main").innerHTML = strapLine;
    document.getElementById("Link1").innerHTML = link1Text;
    document.getElementById("Link1").href = link1Url;
    document.getElementById("Link2").innerHTML = link2Text;
    document.getElementById("Link2").href = link2Url;
    document.getElementById("Link3").innerHTML = link3Text;
    document.getElementById("Link3").href = link3Url;
}