// JavaScript Document

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function checkAddress()
{
 var a = document.getElementById('mailing_address').value;
 a = a.replace(".","","gi");
 a = a.replace(" ","","gi");
 a = a.toLowerCase();
 a = TrimString(a);
// alert("|" + a + "|");
 if (a.match("pobox"))
 {
  alert('Please note that we can only ship orders to PO Boxes via US Mail. If you choose to specify a mailing address with a PO Box, please make sure to select the USPS shipping option.');
 }
}

function orderAR()
{
 orderok = 1;
 var orderalert = "";

if (document.getElementById('shipping_service').value!="USPS")
 {
  if (document.getElementById('shipping_account_number').value=="")
  {
   orderok = 0;
   orderalert  = orderalert + " You must specify a shipping account number if you wish to receive your order through a service other than the US Postal Service.";
  }
 } 
 
 if ( (document.getElementById('payment_type').value=="check") && (document.getElementById('country').value!="USA") )
 {
  orderok = 0;
  orderalert  = orderalert + " If you are ordering from outside of the USA, then please select the Credit Card payment method. ";
 }


 if ( (document.getElementById('country').value!="USA") && (document.getElementById('shipping_service').value=="USPS") )
 {
  orderok = 0;
  orderalert  = orderalert + " If the reports will be shipped out of the US, you must choose a carrier OTHER than the US Postal Service. ";
 }


if (orderok==1)
 {
  document.form1.submit();
 }
 else
 {
  alert(orderalert);
 }
}


