function selectNewCurrency(selectboxname)
{
	var chosenCode = selectboxname.value;
	if(chosenCode == "") chosenCode = "ZAR";
	var expiryDate = new Date();
	expiryDate.setTime(expiryDate.getTime()+(365*24*60*60*1000));
	var expires = "; expires=" + expiryDate.toGMTString();
	var newValue = "cedarcurrency=" + chosenCode + expires + "; path=/;";

	document.cookie = newValue;
	window.location.reload(true);
}

function readCookie(cookiename)
{
	var nameEQ = cookiename+"=";
	var cookieArray = document.cookie.split(";");
	for(i=0; i<cookieArray.length; i++)
	{
		var thisCookie = cookieArray[i];
		while(thisCookie.charAt(0) == " ") thisCookie = thisCookie.substring(1,thisCookie.length);
		if(thisCookie.indexOf(nameEQ) == 0)
		{
			return thisCookie.substring(nameEQ.length,thisCookie.length);
		}
		else
		{
			continue;
		}
	}
	return null;
}

function preselectCurrency(chosenCurrency)
{
	var cBox = document.getElementById("dispcurrency");
	var foundIndex = -1;
	for(i=0; i<cBox.length; i++)
	{
		if(cBox.options[i].value == chosenCurrency) foundIndex = i;
	}
	if(foundIndex != -1) cBox.selectedIndex = foundIndex;
}