
//WHEN RELOADING PAGE, SET SELECTED ELEMENT TO TRANSLATION INDICATED BY COOKIE
function setTransIndex(transSelectBox)
{
prefTrans = getCookie("preferredTranslation")
for(i=0;i< transSelectBox.length;i++)
	{
	if (prefTrans == transSelectBox.options[i].value)
		{transSelectBox.selectedIndex = i}
	}
}
//SET COOKIE VALUE TO SELECTED TRANSLATION AND UNCONDITIONALLY RELOAD PAGE
function processTranslationChange(transSelectBox)
{
newTrans = transSelectBox.options[transSelectBox.selectedIndex].value
cookieName = 'preferredTranslation'
x= makeCookie (cookieName, newTrans)
this.location.reload(true) //TRUE MEANS DON'T USE THE CACHED COPY
}
function getCookieValue(pos)
	{
    // Function to return the decoded value of a cookie. You will
	// not call this in your script; it is used internally.
	var temp = document.cookie.indexOf(";", pos)
	if (temp == -1)
		temp = document.cookie.length
	return unescape(document.cookie.substring(pos, temp))
	}

function getCookie(name)
	{
    //  Returns the value of the cookie specified by "name".
	//  Returns null if the cookie is not found.
	var cName = name + "="
	var len = cName.length
	var cookieLen = document.cookie.length
	var i = 0, j
	while (i < cookieLen)
		{
		j = i + len
		if (document.cookie.substring(i, j) == cName)
			return getCookieValue(j)
		i = document.cookie.indexOf(" ", i) + 1
		if (i == 0)
			break
		}
	return null
}

// Function to create or update a cookie.
// The function requires two arguments:
//
//		name -  the cookie name.
//	    value - the cookie value.
//
// The following arguments are optional:
//    expDate - cookie expiration date in a Date object. If this argument
//    	is left out or null, the cookie expires at the end of the current session.
//
//    path - the path for which the cookie is valid. If this argument
//    	is left out or null, the calling document's path is used.
//
//    domain - the domain for which the cookie is valid.  If this argument
//		is left out or null, the calling document's domain is used.
//    secure - true or false indicating whether cookie is secure.
//
// The optional arguments must be passed in the indicated order. Use null
// for a placeholder as needed.

function makeCookie(thename, thevalue)
	{
	var x1 = makeCookie.arguments
	var x2 = makeCookie.arguments.length
	var expDate = (x2 > 2) ? x1[2] : null
	var path = (x2 > 3) ? x1[3] : null
	var domain = (x2 > 4) ? x1[4] : null
	var secure = (x2 > 5) ? x1[5] : false
	var buf = thename + "=" + escape (thevalue)
	buf += ((expDate == null) ? "" : ("; expires=" + expDate.toGMTString()))
    buf += ((path == null) ? "" : ("; path=" + path))
	buf += ((domain == null) ? "" : ("; domain=" + domain))
	buf += ((secure == true) ? "; secure" : "")
	document.cookie = buf
    }


