/*

	Shop JavaScript functions
	
*/

var chosenCurrency = 'GBP';

function setcurrency() {
	chosenCurrency = document.getElementById('currency').value;
	updatePrice();
	return false;
}

function convertPrice(price, currency) {
	var new_price;
	var display_price;
	if (currency=='GBP') display_price = "&pound;"+ price.toFixed(2);;
	if (currency=='EUR') {
		new_price = price*1.45;
		display_price = "&euro; "+ new_price.toFixed(2);
	}
	if (currency=='USD') {
		new_price = price*1.72;
		display_price = "$"+ new_price.toFixed(2);
	}
	if (currency=='AUD') {
		new_price = price*2.45;
		display_price = "$"+ new_price.toFixed(2);
	}
	return display_price;
}

function updatePrice() {
	var quantity = document.getElementById('quantity').value;
	var price;
	if (quantity==1) price = 50;
	if (quantity==2) price = 40;
	if (quantity==3) price = 40;
	if (quantity==4) price = 38;
	if (quantity==5) price = 38;
	if (quantity==6) price = 37;
	if (quantity==7) price = 37;
	if (quantity==8) price = 37;
	if (quantity==12) price = 36;
	if (quantity==18) price = 36;
	if (quantity==24) price = 35;
	if (quantity==30) price = 35;
	if (quantity==36) price = 34;
	if (quantity==42) price = 34;
	if (quantity==48) price = 33;
	if (quantity==54) price = 31;
	if (quantity==60) price = 31;
	if (quantity==66) price = 31;
	if (quantity==72) price = 29;
	document.getElementById('priceguide').innerHTML = quantity + " @ " + convertPrice(price,chosenCurrency) + " each = <strong>" + convertPrice((quantity * price), chosenCurrency) + "</strong>";
}
