var ou_tsx=0;



function ou_tschange(n)
{
	// Grab the area we want to resize
	e = document.getElementById("tsxcontent");
	if (e == null) return;
	
	// Read the cookie
	document.cookie = "P14TS=" + n + "; expires=Sun, 01 Dec 2030 23:59:59 GMT; path=/; domain=open.ac.uk;";
	
	// Set the display to show the cookie info
	if (document.getElementById("ou-smalltext"))
	{
		if (n == 1) document.getElementById("ou-smalltext").style.borderColor='#547FBD'; else document.getElementById("ou-smalltext").style.borderColor='#ccc';
		if (n == 2) document.getElementById("ou-mediumtext").style.borderColor='#547FBD'; else document.getElementById("ou-mediumtext").style.borderColor='#ccc';
		if (n == 3) document.getElementById("ou-largetext").style.borderColor='#547FBD'; else document.getElementById("ou-largetext").style.borderColor='#ccc';
		if (n == 4) document.getElementById("ou-extralargetext").style.borderColor='#547FBD'; else document.getElementById("ou-extralargetext").style.borderColor='#ccc';
	}
	
	// Figure out the font size based on the option chosen
	if (n == 4)
		n = 140;
	else
		n = 90 + n * 10;
		
	// Set anything that can obviously be resized
	e.style.fontSize = n + "%";
		
	// See if we were told we need to resize id tags
	if (ou_tsx > 0)
	{
		// find each id and resize it
		for (i=1 ; i <= ou_tsx ; i++)
		{
			e = document.getElementById("tsx" + i);
			if (e) e.style.fontSize = n + "%";
		}
	}
	else
	{
		// Find all elements with tsx in the id or the classname
		// saves having to code an incrementor for the id, and
		// keeps compatibilty with older sites that already use the incrementor method
		var inc=0;
		var alltags= e.getElementsByTagName("span")
		// change font size of tags that need resizing
		for (i=0; i<alltags.length; i++)
		{
			if (alltags[i].id.indexOf("tsx") != -1 || alltags[i].className.indexOf("tsx") != -1)
				alltags[i].style.fontSize = n + "%";
		}
	
	}
	
	// Now resize the header
	
	e = document.getElementById("tsheader");
	if (e) 
		e.style.fontSize = n + "%";
		
	// Now resize the footer
	e = document.getElementById("tsfooter");
	if (e) 
		e.style.fontSize = n + "%";
}

