// JavaScript Document

// function to write selected language to cookie
function changeLanguage(l)
{
	// set expiry date for 1 year from now
	var d = new Date();
	FixCookieDate (d);

	d.setDate( d.getDate() + 365 ); 
	
	// write cookie
	SetCookie( "lang", l, d, "/" );
	
	// take user to appropriate language page
	document.location.href = document.location.protocol + "//" + document.location.hostname + (document.location.port == 80 ? "" : ":" + document.location.port ) + "/" + l ;
	
	// THIS LINE SHOULD BE UNCOMMENT AS SOON AS THE CHINESE TRANSLATION IS DONE
	//document.location.href = document.location.protocol + "//" + document.location.hostname + (document.location.port == 80 ? "" : ":" + document.location.port ) + "/" + l + "/" + document.location.pathname.substr(4);
}

// function to write selected language to cookie
function checkupLanguage(l)
{
	// check to see if cookie exists
	// if yes, redirect to language page
	if (GetCookie("lang") == "en")
	{
		document.location.href="/en/index.html";
	}
	else if (GetCookie("lang") == "ch")
	{
		document.location.href="/ch/index.html";
	}
}


