// JavaScript Document
function fn_refresh()
{
	sURL = unescape(window.location.pathname);
    window.location.href = sURL;
}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
// Set_Cookie( 'test', 'it works', '', '/', '', '' );

function Read_Cookie(cookieName) 
{
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function site_accessibility_click(type)
{
	//alert(type);
	if(type == "normal" || type == "large" || type == "largest" )
	{
		Set_Cookie( 'text_size', type, '', '/', '', '' );
		fn_refresh();
	}
	else
	{
		current = Read_Cookie('text_contrast');
		if(current == 'on')
		{
			Set_Cookie( 'text_contrast', 'off', '', '/', '', '' );
			fn_refresh();
		}
		else
		{
			Set_Cookie( 'text_contrast', 'on', '', '/', '', '' );
			fn_refresh();
		}
	}
	
}


//
// LOOK FOR ACCESSABILITY COOKIES ALREADY SET

// TEXT SIZING
ctxt = Read_Cookie('text_size');
if(ctxt != "" && ctxt != undefined)
{
	//alert("text size cookie: "+ ctxt);
	document.write('<link type="text/css" name="myCSS" rel="stylesheet" media="screen" title="myCSS" href="'+path_to_root+'scripts/css/text_'+ctxt+'.css">');
}

// TEXT COLOUR
ccol = Read_Cookie('text_contrast');
if(ccol == "on")
{
	//alert("text contrast cookie: "+ ccol);
	document.write('<link type="text/css" name="myCSS" rel="stylesheet" media="screen" title="myCSS" href="'+path_to_root+'scripts/css/text_contrast.css">');
}

