//var site = "http://localhost/myprojectorlampsuk/";

function update_quantity(operation){
	//alert(document.buy_form.quantity.value);
	if( operation == '+'){
		buy_form.quantity.value = parseFloat(buy_form.quantity.value) + 1;
		}
	else{//minus
		if( parseFloat(buy_form.quantity.value) > 1 ){
			buy_form.quantity.value = parseFloat(buy_form.quantity.value) - 1;
			}
		}
	}


function addToCart(target_screen)
{
	
	//document.buy_form.action = action;
	if(document.buy_form.Secure)
		document.buy_form.Secure.value = "";
	document.buy_form.SCREEN.value = target_screen;
	document.buy_form.ACTION.value = "ADD_TO_CART";
	document.buy_form.submit(); // Submit the page
	//return true;
}


/*function update_shipping(shipping, price, currency,discount)
{
	var new_shipping = parseFloat(shipping.value).toFixed(2);
	var new_total = (parseFloat(shipping.value) + parseFloat(price) -  ( parseFloat(price)*parseFloat(discount)/100) ).toFixed(2);
	var new_currency = ((parseFloat(shipping.value) + parseFloat(price*(1-parseFloat(discount)/100)))*parseFloat(currency)).toFixed(2);
	document.getElementById("shipping_td").innerHTML = "USD $" + new_shipping;
	document.getElementById("total_td").innerHTML = "USD $" + new_total;
	document.getElementById("currency_td").innerHTML = "<strong> GBP $" + new_currency +"</Strong>";
	
}*/

function update_shipping(shipping, price,countrySelector){
	var new_shipping = parseFloat(shipping.value).toFixed(2);
	var new_total = parseFloat(shipping.value) + parseFloat(price) ;
	
	if(countrySelector.value == "CA")
	{
		//var beforeTax = document.getElementById('totalPriceForGST').value;
		//var beforeTax = parseFloat(shipping.value) + parseFloat(total_without_shipping.value);
		var GST = Math.round((new_total * .05)*100)/100;
		document.getElementById('GST_TD').innerHTML = "<strong>USD $" + GST.toFixed(2)+ "</strong>";
		document.getElementById('GST_ROW').style.display = "block";
		new_total = Math.round((parseFloat(new_total) + parseFloat(GST))*100)/100;
		//total_td.innerHTML = "<strong>USD $"+ (Math.round((parseFloat(new_total) + parseFloat(GST))*100)/100).toFixed(2) + "</strong>";
		//document.getElementById('cur_exchange_div').innerHTML = "<strong>GBP $"+ (Math.round((parseFloat(beforeTaxCAD) + parseFloat(GSTCAD))*100)/100).toFixed(2) + "</strong>";
	}
	new_total = new_total.toFixed(2);
	//var new_currency = ((parseFloat(shipping.value) + parseFloat(price*(1-parseFloat(discount)/100)))*parseFloat(currency)).toFixed(2);
	document.getElementById("shipping_td").innerHTML = "USD $" + new_shipping;
	document.getElementById("total_td").innerHTML = "<strong>USD $" + new_total + "</strong>";
	//document.getElementById("currency_td").innerHTML = "<strong> GBP $" + new_currency +"</Strong>";
	}

function checkbillinginfo(f) {
	if (f.inputFirstName.value < " ") {
		alert("Please enter the first name on your credit card.");
		f.inputFirstName.focus();
		return false;
	}

	if (f.inputLastName.value < " ") {
		alert("Please enter the last name on your credit card.");
		f.inputLastName.focus();
		return false;
	}

	if (f.inputAddress.value < " ") {
		alert("Please enter your address.");
		f.inputAddress.focus();
		return false;
	}

	if (f.inputCity.value < " ") {
		alert("Please enter the city.");
		f.inputCity.focus();
		return false;
	}

	if (f.inputState.value < " ") {
		alert("Please enter the state.");
		f.inputState.focus();
		return false;
	}

	if (f.inputCountry.value < " ") {
		alert("Please enter the country.");
		f.inputCountry.focus();
		return false;
	}


	if (f.inputZIP.value < " ") {
		alert("Please enter the zip code.");
		f.inputZIP.focus();
		return false;
	}

	if (f.inputEmail.value < " ") {
		alert("Please enter your e-mail address.");
		f.inputEmail.focus();
		return false;
	}

	if(f.inputAltShip[0].checked == true)
	{
		if(f.inputShipFirstName.value == "")
		{
			alert("Please enter your Shipping First Name");
			return false;
		}

		if(f.inputShipLastName.value == "")
		{
			alert("Please enter your Shipping Last Name");
			return false;
		}

		if(f.inputShipAddress.value == "")
		{
			alert("Please enter your Shipping Address");
			return false;
		}

		if(f.inputShipCity.value == "")
		{
			alert("Please enter your Shipping City");
			return false;
		}

		if(f.inputShipState.value < " ")
		{
			alert("Please enter your Shipping State / Province");
			return false;
		}

		if(f.inputShipCountry.value < " ")
		{
			alert("Please enter your Shipping State / Province");
			return false;
		}

		if(f.inputShipZIP.value == "")
		{
			alert("Please enter your Shipping Zip / Postal Code");
			return false;
		}
		
	}
	
return true;
	
}

/*REMOVED AND REPLACE BY CODE IN makeCountrySelector, as this doesn't work in FF
document.body.onload = load;
function load()
{
	//document.getElementById('inputCountry').addEventListener('onchange' = updateGST;
	
	//document.all["inputCountry"].onchange = updateGST;
}*/

function updateGST(countrySelector,shipping,total_without_shipping)
{
	if(countrySelector.value == "CA")
	{
		//var beforeTax = document.getElementById('totalPriceForGST').value;
		var beforeTax = parseFloat(shipping.value) + parseFloat(total_without_shipping.value);
		var GST = Math.round((beforeTax * .05)*100)/100;
		document.getElementById('GST_TD').innerHTML = "<font class=bold color=650000>USD $" + GST.toFixed(2)+ "</font>";
		document.getElementById('GST_ROW').style.display = "block";
		total_td.innerHTML = "<strong>USD $"+ (Math.round((parseFloat(beforeTax) + parseFloat(GST))*100)/100).toFixed(2) + "</strong>";
		//document.getElementById('cur_exchange_div').innerHTML = "<strong>GBP $"+ (Math.round((parseFloat(beforeTaxCAD) + parseFloat(GSTCAD))*100)/100).toFixed(2) + "</strong>";
	}

	else
	{
		//var grandTotalDiv = document.getElementById('grandTotalDiv');
		var beforeTax = parseFloat(shipping.value) + parseFloat(total_without_shipping.value);
		//var beforeTaxCAD = document.getElementById('totalCADForGST').value;
		document.getElementById('GST_ROW').style.display = "none";
		//document.getElementById('GST_TD').style.display = "none";
		total_td.innerHTML = "<strong>USD $"+ (parseFloat(beforeTax).toFixed(2)) + "</strong>";
		//document.getElementById('cur_exchange_div').innerHTML = "<strong>GBP $"+ (parseFloat(beforeTaxCAD)).toFixed(2) + "</strong>";
	}
	
	status = "update";
}

function checkresellerinfo(f) {
	
	if (f.inputEmail.value < " ") {
		alert("Please enter your e-mail address.");
		f.inputEmail.focus();
		return false;
	}
	
	if (f.inputpassword.value < " ") {
		alert("Please enter your password.");
		f.inputpassword.focus();
		return false;
	}
	
	if (f.inputpasswordver.value < " ") {
		alert("Please retype your password.");
		f.inputpasswordver.focus();
		return false;
	}
	
	if (f.inputpasswordver.value != f.inputpassword.value) {
		alert("Invalid password confirmation.");
		f.inputpassword.focus();
		return false;
	}
	
	if (f.inputFirstName.value < " ") {
		alert("Please enter the first name on your credit card.");
		f.inputFirstName.focus();
		return false;
	}

	if (f.inputLastName.value < " ") {
		alert("Please enter the last name on your credit card.");
		f.inputLastName.focus();
		return false;
	}

	if (f.inputAddress.value < " ") {
		alert("Please enter your address.");
		f.inputAddress.focus();
		return false;
	}

	if (f.inputCity.value < " ") {
		alert("Please enter the city.");
		f.inputCity.focus();
		return false;
	}

	if (f.inputState.value < " ") {
		alert("Please enter the state.");
		f.inputState.focus();
		return false;
	}

	if (f.inputCountry.value < " ") {
		alert("Please enter the country.");
		f.inputCountry.focus();
		return false;
	}


	if (f.inputZIP.value < " ") {
		alert("Please enter the zip code.");
		f.inputZIP.focus();
		return false;
	}
	
	if (f.inputPhone.value < " ") {
		alert("Please enter your phone number.");
		f.inputPhone.focus();
		return false;
	}
	
	if (f.cardNumber.value < " ") {
		alert("Please enter your complete card number.");
		f.cardNumber.focus();
		return false;
	}
	

	var cc_date_pattern = /^[0-9][0-9][0-9][0-9][\-][0-9][0-9]$/;

	var cc_date_result;

	cc_date_result = cc_date_pattern.exec(f.expirationDate.value);

		if (cc_date_result) {

			// good to go!

		}

		else {

			alert("That is not a valid expiration date.\nExample: 2008-05 -- YYYY-MM.");

			f.expirationDate.focus();

			return false;

		}
		
	if (f.cardCode.value < " " || f.cardCode.value.length != 3 ) {
		alert("Please enter your 3 digit card code.");
		f.cardCode.focus();
		return false;
	}
return true;	
}

function check_u_p(f){

   if(f.username.value.length < 1 ){
      alert("Please type your Email.");
      f.username.value = "";
      f.username.focus();
      return false;
      }

   if(f.password.value.length < 1){
      alert("Please type your Password.");
      f.password.value = "";
      f.password.focus();
      return false;
      }

   return true;

   }