var arrDisplay        = new Array();
arrDisplay['pound']   = '&pound;';
arrDisplay['euro']    = '&euro;';
arrDisplay['dollar']  = '$';

function format2dp(value)
{
	if(value == 0)
	{
		return '0.00';
	}
	var tmpValue  = String(parseInt((value + .005) * 100));
	var intLength = tmpValue.length;
	return tmpValue.substring(0, intLength-2) + '.' + tmpValue.substr(intLength-2, 2);
}




function cookieGet(strName)
{
	//alert(document.cookie);
	var arrCookie       = document.cookie.split('; ');
	//var arrEachCookie = new Array();
	var strValue        = '';
	
	for( var intLoop = 0; intLoop < arrCookie.length; intLoop++)
	{
		var arrEachCookie = arrCookie[intLoop].split('=');
		
		if(arrEachCookie[0] == strName)
		{
			var strValue = arrEachCookie[1];
		}
	}
	
	return strValue;
}




function cookieSet(strName, strValue, intHours)
{
	var dtmToday    = new Date();
	var dtmExpiry   = new Date(dtmToday.getTime() + (intHours * 60 * 60 * 1000));
	
	document.cookie = strName + "=" + escape(strValue) + "; expires=" + dtmExpiry.toGMTString() + "; path =/";
}



function cookieDelete(strName)
{
	cookieSet(strName, null, -24);
}



function SetCurrency(strDisplay)
{
	cookieSet('Currency', strDisplay, 24);

	location.reload();
}



function DisplayPrice(floAmount, bolVAT, bolStrong)
{
	strCookie = unescape(cookieGet('Currency'));
	
	if(strCookie == '')
	{
		strCookie = 'pound';
	}
	
	var strOutput = arrDisplay[strCookie] + format2dp(floAmount * arrConvert[strCookie]);
	
	
	if(bolStrong == 0)
	{
		document.write(strOutput);
	}
	else
	{
		document.write('<strong>' + strOutput + '</strong>');
	}
	
	if(bolVAT)
	{
		//document.write(' (' + arrDisplay[strCookie] + format2dp((floAmount * arrConvert[strCookie]) / 1.175) + ' ex. Tax)');
	}
}


function British()
{
	strCookie = unescape(cookieGet('Currency'));
	arrCookie = strCookie.split(',');
	
	if(strCookie == '' || strCookie == 'pound')
	{
		return true;
	}
	return false;
}

