<!--
var invitesPriceCDN = new Array("0.00","2.93","2.83","2.73","2.63","2.53","2.43","2.43","2.43","2.43");
var invitesPriceUS = new Array("0.00","2.87","2.77","2.68","2.58","2.48","2.38","2.38","2.38","2.38");
var rsvpPriceCDN = new Array("0.00","1.53","1.51","1.48","1.45","1.42","1.39","1.36","1.36","1.36");
var rsvpPriceUS = new Array("0.00","1.50","1.48","1.45","1.42","1.39","1.36","1.33","1.33","1.33");
var thankPriceCDN = new Array("0.00","2.23","2.13","2.03","1.93","1.83","1.63","1.63","1.63","1.63");
var thankPriceUS = new Array("0.00","2.19","2.09","1.99","1.89","1.79","1.60","1.60","1.60","1.60");
var initiated = false;

function initPackage(){
	updatePackage('fullI','invites','fiE','fi');
	updatePackage('fullR','rsvp','frE','fr');
	initiated = true;
	updatePackage('fullT','thank','ftE','ft');
}

function adjustCurrency(sum){
	// Format currency value
	if(sum==0){
		return("$ 0.00");
	} else {
		sum = ""+Math.round(100*sum);
		var dec_point = sum.length-2;
		var first_part = sum.substring(0,dec_point);
		var second_part = sum.substring(dec_point,sum.length);
		var result = "$ "+first_part+"."+second_part;
		return result;
	}
}

function updatePackage(prodItem,pricing,displayDivE,displayDiv){
	if(document.all){
		var temp = document.all[prodItem].selectedIndex;
		var curCountry = document.all["country"].selectedIndex;
		var qty = document.all[prodItem].options[temp].value;
	} else { 
		var temp = document.getElementById(prodItem).selectedIndex;
		var curCountry = document.getElementById("country").selectedIndex;
		var qty = document.getElementById(prodItem).options[temp].value;
	}
	
	var price = "";
	if(pricing=="invites"){
		if(curCountry=="1"){
			price = invitesPriceCDN[temp];
		}else{
			price = invitesPriceUS[temp];
		}
	} else if(pricing=="rsvp"){
		if(curCountry=="1"){
			price = rsvpPriceCDN[temp];
		}else{
			price = rsvpPriceUS[temp];
		}
	} else if(pricing=="thank"){
		if(curCountry=="1"){
			price = thankPriceCDN[temp];
		}else{
			price = thankPriceUS[temp];
		}
	}
	
	var sum = price*qty;
	// Display per unit price and total cost
	if(document.all){
		document.all[displayDivE].innerHTML = "$ "+price;
		document.all[displayDiv].innerHTML = adjustCurrency(sum);
	} else {
		document.getElementById(displayDivE).innerHTML = "$ "+price;
		document.getElementById(displayDiv).innerHTML = adjustCurrency(sum);
	}
	// Update subtotal price
	if(initiated){ updateSubTotal(); }
}
function updateSubTotal(){
	if(document.all){ productTotal = adjustCurrency(stripCurrency(document.all["fi"].innerHTML)*1 + stripCurrency(document.all["fr"].innerHTML)*1 + stripCurrency(document.all["ft"].innerHTML)*1); }
	else { productTotal = adjustCurrency(stripCurrency(document.getElementById("fi").innerHTML)*1 + stripCurrency(document.getElementById("fr").innerHTML)*1 + stripCurrency(document.getElementById("ft").innerHTML)*1); }

	if(document.all){ document.all["subtotal"].innerHTML = productTotal; }
	else { document.getElementById("subtotal").innerHTML = productTotal; }
	
	updateShipping();
	updateTax();
}
function updateCountry(){
	updateShipping();
	initPackage();
}
function updateShipping(){
	var shippingPrice = new Array(0,25,35);
	var currencyTypes = new Array("US","CDN","US");
	var location = 0;
	var shipping = 0;
	var shippingInfo = "<strong><em>free</em></strong>";
	
	if(document.all){
		var subTotal = stripCurrency(document.all["subtotal"].innerHTML)*1;
		var location = document.all["country"].selectedIndex;
		if(subTotal<150 && subTotal>0){
			var shipping = shippingPrice[location];
			var shippingInfo = "";
		}
		document.all["shipping"].innerHTML = "$ "+shipping+".00";
		document.all["shippingInfo"].innerHTML = shippingInfo;
		document.all["currencyType"].innerHTML = "("+currencyTypes[location]+ " funds)";
	} else {
		var subTotal = stripCurrency(document.getElementById("fi").innerHTML)*1;
		var location = document.getElementById("country").selectedIndex;
		if(subTotal<150 && subTotal>0){
			var shipping = shippingPrice[location];
			var shippingInfo = "";
		}
		document.getElementById("shipping").innerHTML = "$ "+shipping+".00";
		document.getElementById("shippingInfo").innerHTML = shippingInfo;
		document.getElementById("currencyType").innerHTML = "("+currencyTypes[location]+ " funds)";
	}
}
function updateTax(){
	// Update tax
	var taxRateGST = 0.05;
	var taxRatePST = 0.08;
	if(document.all){
		var productTotal = stripCurrency(document.all["subtotal"].innerHTML)*1;
		var location = document.all["country"].selectedIndex;
		if(location=="1"){
			document.all["tax"].innerHTML = adjustCurrency(productTotal*taxRateGST + productTotal*taxRatePST);
		} else {
			document.all["tax"].innerHTML = "";
		}
	} else {
		var productTotal = stripCurrency(document.getElementById("subtotal").innerHTML)*1;
		var location = document.getElementById("country").selectedIndex;
		if(location=="1"){
			document.getElementById("tax").innerHTML = adjustCurrency(productTotal*taxRateGST + productTotal*taxRatePST);
		} else {
			document.getElementById("tax").innerHTML = "";
		}
	}
	updateTotal();
}
function updateTotal(){
	if(document.all){ document.all["total"].innerHTML = adjustCurrency(stripCurrency(document.all["subtotal"].innerHTML)*1 + stripCurrency(document.all["tax"].innerHTML)*1 + stripCurrency(document.all["shipping"].innerHTML)*1); }
	else { document.getElementById("total").innerHTML = adjustCurrency(stripCurrency(document.getElementById("subtotal").innerHTML)*1 + stripCurrency(document.getElementById("tax").innerHTML)*1 + stripCurrency(document.getElementById("shipping").innerHTML)*1); }
}
function stripCurrency(text){
	return text.replace("$ ","");
}
//-->