/*
* Plugins JS scripts
/*/

//Verify if this session has a valid zipcode
//If not - ask for a zip code, verify it and update sZipCode input value.
//This value will be saved by PHP later

//Input parameter - sZipCode the current zip code 

function getZipCode(sZipCode, sZipCodeInput, sZipCodeForm) {
 var nZip = sZipCode;
 while (!nZip.match(/\d{5}/) && !nZip.match(/\w\d\w\d\w\d/)){
	 nZip = prompt("Please enter your Zip Code or Postal Code to calculate shipping price" ,nZip);
	 if(nZip != null) 
	   nZip = nZip.toUpperCase().replace(/\s+/g, ""); 
         else 
           nZip = "-1";
 }
 //OK minimal test for zip is passed - continue
  document.getElementById(sZipCodeInput).value = nZip;
  var form = document.getElementById(sZipCodeForm);
  form.submit();

 
}


//Verify that shipping is set in PayPal form and submit if OK
function verifyPayPal(PayPalForm, PayPalSign){
	
	
	
	var shipping = document.getElementById("shipping").innerHTML;
	if(!shipping.match(/\d/)){
		alert("Please calculate shipping price");
		return;
	}
	
	//Send a notice that PayPal button was pressed
	document.getElementById(PayPalSign).value = "sPayPal"; 
	var form = document.getElementById(PayPalForm);
	form.submit();
	
}

