/***********************************************************************
	CURRENCY FUNCTIONS
************************************************************************/

// YEN EXCHANGE RATES (LAST UPDATED 02/06/09)

var ukRate = 0.00633355;
var australiaRate = 0.01285036;
var canadaRate = 0.01137618;
var mexicoRate = 0.13794663;
var thailandRate = 0.35484381;
var chinaRate = 0.07097018;
var usRate = 0.00992864;
var europeRate = 0.00734615;

function currencyDetails() {
	
	// TIMEZONE CHECK (GMT)
	var rightNow = new Date();
	var userTime = new Date(rightNow.getFullYear(),0, 1, 0, 0, 0, 0);
	var convertTime = userTime.toGMTString();
	var gmtTime = new Date(convertTime.substring(0,convertTime.lastIndexOf(" ")-1));
	var timeOffset = (userTime - gmtTime) / (1000 * 60 * 60);	
	if (timeOffset == 0) {
		document.getElementById("currency-us").style.display = "none";
		document.getElementById("currency-uk").style.display = "block";
	};
	
	// YEN PRICE
	var yenPrice = document.getElementById("yenPrice");
	
	// NEW YEN PRICE (REMOVAL OF COMMAS)
	var yenNewPrice = yenPrice.firstChild.nodeValue;
	yenNewPrice = yenNewPrice.replace(/,/g, '');
	yenNewPrice = yenNewPrice.split(',').join();

	// MAIN PRICES
	var ukMainPrice = document.getElementById("ukMainPrice");
	var usMainPrice = document.getElementById("usMainPrice");
	var europeMainPrice = document.getElementById("europeMainPrice");
	
	var ukMainConvert = Math.round(yenNewPrice * ukRate);
	var usMainConvert = Math.round(yenNewPrice * usRate);
	var europeMainConvert = Math.round(yenNewPrice * europeRate);
	
	ukMainPrice.firstChild.nodeValue=ukMainConvert;
	usMainPrice.firstChild.nodeValue=usMainConvert;
	europeMainPrice.firstChild.nodeValue=europeMainConvert;

	// OTHER PRICES
	var ukPrice = document.getElementById("ukPrice");
	var australiaPrice = document.getElementById("australiaPrice");
	var canadaPrice = document.getElementById("canadaPrice");
	var mexicoPrice = document.getElementById("mexicoPrice");
	var thailandPrice = document.getElementById("thailandPrice");
	var chinaPrice = document.getElementById("chinaPrice");
	var usPrice = document.getElementById("usPrice");
	var europePrice = document.getElementById("europePrice");

	var ukConvert = Math.round(yenNewPrice * ukRate);
	var australiaConvert = Math.round(yenNewPrice * australiaRate);
	var canadaConvert = Math.round(yenNewPrice * canadaRate);
	var mexicoConvert = Math.round(yenNewPrice * mexicoRate);
	var thailandConvert = Math.round(yenNewPrice * thailandRate);
	var chinaConvert = Math.round(yenNewPrice * chinaRate);
	var usConvert = Math.round(yenNewPrice * usRate);
	var europeConvert = Math.round(yenNewPrice * europeRate);
	
	ukPrice.firstChild.nodeValue=ukConvert;
	australiaPrice.firstChild.nodeValue=australiaConvert;
	canadaPrice.firstChild.nodeValue=canadaConvert;
	mexicoPrice.firstChild.nodeValue=mexicoConvert;
	thailandPrice.firstChild.nodeValue=thailandConvert;
	chinaPrice.firstChild.nodeValue=chinaConvert;
	usPrice.firstChild.nodeValue=usConvert;
	europePrice.firstChild.nodeValue=europeConvert;
	
	return true;
}

function currencyItems() {
	
	// YEN TOTAL PRICE
	var yenTotalPrice = document.getElementById("yenTotalPrice");

	// NEW YEN TOTAL PRICE (REMOVAL OF COMMAS)
	var yenNewTotalPrice = yenTotalPrice.firstChild.nodeValue;
	yenNewTotalPrice = yenNewTotalPrice.replace(/,/g, '');
	yenNewTotalPrice = yenNewTotalPrice.split(',').join();

	// OTHER TOTAL PRICES
	var ukTotalPrice = document.getElementById("ukTotalPrice");
	var australiaTotalPrice = document.getElementById("australiaTotalPrice");
	var canadaTotalPrice = document.getElementById("canadaTotalPrice");
	var mexicoTotalPrice = document.getElementById("mexicoTotalPrice");
	var thailandTotalPrice = document.getElementById("thailandTotalPrice");
	var chinaTotalPrice = document.getElementById("chinaTotalPrice");
	var usTotalPrice = document.getElementById("usTotalPrice");
	var europeTotalPrice = document.getElementById("europeTotalPrice");

	var ukTotalConvert = Math.round(yenNewTotalPrice * ukRate);
	var australiaTotalConvert = Math.round(yenNewTotalPrice * australiaRate);
	var canadaTotalConvert = Math.round(yenNewTotalPrice * canadaRate);
	var mexicoTotalConvert = Math.round(yenNewTotalPrice * mexicoRate);
	var thailandTotalConvert = Math.round(yenNewTotalPrice * thailandRate);
	var chinaTotalConvert = Math.round(yenNewTotalPrice * chinaRate);
	var usTotalConvert = Math.round(yenNewTotalPrice * usRate);
	var europeTotalConvert = Math.round(yenNewTotalPrice * europeRate);
	
	ukTotalPrice.firstChild.nodeValue=ukTotalConvert;
	australiaTotalPrice.firstChild.nodeValue=australiaTotalConvert;
	canadaTotalPrice.firstChild.nodeValue=canadaTotalConvert;
	mexicoTotalPrice.firstChild.nodeValue=mexicoTotalConvert;
	thailandTotalPrice.firstChild.nodeValue=thailandTotalConvert;
	chinaTotalPrice.firstChild.nodeValue=chinaTotalConvert;
	usTotalPrice.firstChild.nodeValue=usTotalConvert;
	europeTotalPrice.firstChild.nodeValue=europeTotalConvert;
	
	return true;
}

function currencyItemsConfirm() {
	
	// YEN SHIPPING PRICE
	var yenShippingPrice = document.getElementById("yenShippingPrice");

	// NEW YEN TOTAL PRICE (REMOVAL OF COMMAS)
	var yenNewShippingPrice = yenShippingPrice.firstChild.nodeValue;
	yenNewShippingPrice = yenNewShippingPrice.replace(/,/g, '');
	yenNewShippingPrice = yenNewShippingPrice.split(',').join();

	// YEN TOTAL PRICE
	var yenTotalPrice = document.getElementById("yenTotalPrice");
	
	// NEW YEN TOTAL PRICE (REMOVAL OF COMMAS)
	var yenNewTotalPrice = yenTotalPrice.firstChild.nodeValue;
	yenNewTotalPrice = yenNewTotalPrice.replace(/,/g, '');
	yenNewTotalPrice = yenNewTotalPrice.split(',').join();
	
	// OTHER SHIPPING PRICES
	var ukShippingPrice = document.getElementById("ukShippingPrice");
	var australiaShippingPrice = document.getElementById("australiaShippingPrice");
	var canadaShippingPrice = document.getElementById("canadaShippingPrice");
	var mexicoShippingPrice = document.getElementById("mexicoShippingPrice");
	var thailandShippingPrice = document.getElementById("thailandShippingPrice");
	var chinaShippingPrice = document.getElementById("chinaShippingPrice");
	var usShippingPrice = document.getElementById("usShippingPrice");
	var europeShippingPrice = document.getElementById("europeShippingPrice");

	var ukShippingConvert = Math.round(yenNewShippingPrice * ukRate);
	var australiaShippingConvert = Math.round(yenNewShippingPrice * australiaRate);
	var canadaShippingConvert = Math.round(yenNewShippingPrice * canadaRate);
	var mexicoShippingConvert = Math.round(yenNewShippingPrice * mexicoRate);
	var thailandShippingConvert = Math.round(yenNewShippingPrice * thailandRate);
	var chinaShippingConvert = Math.round(yenNewShippingPrice * chinaRate);
	var usShippingConvert = Math.round(yenNewShippingPrice * usRate);
	var europeShippingConvert = Math.round(yenNewShippingPrice * europeRate);
	
	ukShippingPrice.firstChild.nodeValue=ukShippingConvert;
	australiaShippingPrice.firstChild.nodeValue=australiaShippingConvert;
	canadaShippingPrice.firstChild.nodeValue=canadaShippingConvert;
	mexicoShippingPrice.firstChild.nodeValue=mexicoShippingConvert;
	thailandShippingPrice.firstChild.nodeValue=thailandShippingConvert;
	chinaShippingPrice.firstChild.nodeValue=chinaShippingConvert;
	usShippingPrice.firstChild.nodeValue=usShippingConvert;
	europeShippingPrice.firstChild.nodeValue=europeShippingConvert;
	
	// OTHER TOTAL PRICES
	var ukTotalPrice = document.getElementById("ukTotalPrice");
	var australiaTotalPrice = document.getElementById("australiaTotalPrice");
	var canadaTotalPrice = document.getElementById("canadaTotalPrice");
	var mexicoTotalPrice = document.getElementById("mexicoTotalPrice");
	var thailandTotalPrice = document.getElementById("thailandTotalPrice");
	var chinaTotalPrice = document.getElementById("chinaTotalPrice");
	var usTotalPrice = document.getElementById("usTotalPrice");
	var europeTotalPrice = document.getElementById("europeTotalPrice");

	var ukTotalConvert = Math.round(yenNewTotalPrice * ukRate);
	var australiaTotalConvert = Math.round(yenNewTotalPrice * australiaRate);
	var canadaTotalConvert = Math.round(yenNewTotalPrice * canadaRate);
	var mexicoTotalConvert = Math.round(yenNewTotalPrice * mexicoRate);
	var thailandTotalConvert = Math.round(yenNewTotalPrice * thailandRate);
	var chinaTotalConvert = Math.round(yenNewTotalPrice * chinaRate);
	var usTotalConvert = Math.round(yenNewTotalPrice * usRate);
	var europeTotalConvert = Math.round(yenNewTotalPrice * europeRate);
	
	ukTotalPrice.firstChild.nodeValue=ukTotalConvert;
	australiaTotalPrice.firstChild.nodeValue=australiaTotalConvert;
	canadaTotalPrice.firstChild.nodeValue=canadaTotalConvert;
	mexicoTotalPrice.firstChild.nodeValue=mexicoTotalConvert;
	thailandTotalPrice.firstChild.nodeValue=thailandTotalConvert;
	chinaTotalPrice.firstChild.nodeValue=chinaTotalConvert;
	usTotalPrice.firstChild.nodeValue=usTotalConvert;
	europeTotalPrice.firstChild.nodeValue=europeTotalConvert;
	
	return true;
}