function checkaddtocart ( form )
{
  if ( ( form.qty.value == "") || ( form.qty.value == "0") ) { alert( "Please enter a quantity." ); form.qty.focus(); return false ; }
  if ( form.szid.selectedIndex == 0 ) { alert( "Please select a size." ); return false ; }
  if ( form.coid.selectedIndex == 0 ) { alert( "Please select a color." ); return false ; }
  return true ;
}
function verifyState (form)
{
  if ( form.state.selectedIndex == 0) { alert( "Please select a state." ); return false; }
  return true;
}
function GoTo(thisPage) {
  if((thisPage.substring(0,4) == "http") || (thisPage.substring(0,4) == "HTTP")){
     self.location = thisPage;
  } else {
    self.location = "http://www.thefunkybanana.com/shop/" + thisPage;
  }
}
function validateOrder(form) {
  if ( form.fname.value.length < 1) { alert("Please enter your First Name."); form.fname.focus(); return false ; }
  if ( form.lname.value.length < 2) { alert("Please enter your Last Name."); form.lname.focus(); return false ; }
  if ( form.hphone.value.length < 10) { alert("Please enter a complete 10 digit telephone number with no spaces, dashes or parens. (5555555555)"); form.hphone.focus(); return false ; }
  if ( form.hphone.value.length > 10) { alert("Please enter a complete 10 digit telephone number with no spaces, dashes or parens. (5555555555)"); form.hphone.focus(); return false ; }
  if ( !isInteger(form.hphone.value ) ) { alert("Please enter a complete 10 digit telephone number with no spaces, dashes or parens. (5555555555)"); form.hphone.focus(); return false ; }
  if ( form.email.value.length < 4) { alert("Please enter a valid email address."); form.email.focus(); return false ; }
  if ( form.maddy.value.length < 6) { alert("Please enter your mailing address."); form.maddy.focus(); return false ; }
  if ( form.mcity.value.length < 2) { alert("Please enter your mailing city."); form.mcity.focus(); return false ; }
  if ( form.mzip.value.length < 5) { alert("Please enter your mailing zip code 5-9 digits with no spaces or hyphens. (55555 or 555551111)"); form.mzip.focus(); return false ; }
  if ( form.mzip.value.length > 9) { alert("Please enter your mailing zip code 5-9 digits with no spaces or hyphens. (55555 or 555551111)"); form.mzip.focus(); return false ; }
  if ( !isInteger(form.mzip.value) ) { alert("Please enter your mailing zip code 5-9 digits with no spaces or hyphens. (55555 or 555551111)"); form.mzip.focus(); return false ; }
  if ( form.baddy.value.length < 6) { alert("Please enter your billing address."); form.baddy.focus(); return false ; }
  if ( form.bcity.value.length < 2) { alert("Please enter your billing city."); form.bcity.focus(); return false ; }
  if ( form.bzip.value.length < 5) { alert("Please enter your billing zip code."); form.bzip.focus(); return false ; }
  if ( form.bzip.value.length > 9) { alert("Please enter your billing zip code 5-9 digits with no spaces or hyphens. (55555 or 555551111)"); form.bzip.focus(); return false ; }
  if ( !isInteger(form.bzip.value) ) { alert("Please enter your billing zip code 5-9 digits with no spaces or hyphens. (55555 or 555551111)"); form.bzip.focus(); return false ; }
  if ( form.bname.value.length < 4) { alert("Please enter your name as it appears on the credit card."); form.bname.focus(); return false ; }
  if ( form.ccexp.value.length < 4) { alert("Please enter the credit card expiration date as 4 digits (mmyy)."); form.ccexp.focus(); return false ; }
  if ( form.ccexp.value.length > 4) { alert("Please enter the credit card expiration date as 4 digits (mmyy)."); form.ccexp.focus(); return false ; }
  if ( !isInteger(form.ccexp.value) ) { alert("Please enter the credit card expiration date as 4 digits (mmyy)."); form.ccexp.focus(); return false ; }
  if ( form.ccn.value.length < 15) { alert("Please enter your complete credit card number."); form.ccn.focus(); return false ; }
  if ( form.ccn.value.length > 16) { alert("Please enter your complete credit card number without any dashes or spaces."); form.ccn.focus(); return false ; }
  if ( (form.ccn.value.length == 15) && (form.cctype.selectedIndex != 2)) { alert("Please enter your complete credit card number."); form.ccn.focus(); return false ; }
  if ( form.cvv.value.length < 3) {alert("Please enter the 3-4 digit CVV code found on the back side of your credit card near the signature."); form.cvv.focus(); return false ; }
  if ( form.cvv.value.length > 4) {alert("Please enter the 3-4 digit CVV code found on the back side of your credit card near the signature."); form.cvv.focus(); return false ; }
  if ( (form.cvv.value.length > 3) && (form.cctype.selectedIndex != 2)) {alert("CVV Code does not match card type."); form.cvv.focus(); return false ; }
  if ( (form.cvv.value.length < 4) && (form.cctype.selectedIndex == 2)) {alert("CVV Code does not match card type."); form.cvv.focus(); return false ; }
  if ( !isInteger(form.cvv.value) ) {alert("CVV Code must be digits only."); form.cvv.focus(); return false ; }
  return true;
}
function isInteger (s) {
  var i;
  if (isEmpty(s)) {
    if (isInteger.arguments.length == 1) return 0;
    else return (isInteger.arguments[1] == true);
  }
  for (i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if (!isDigit(c)) return false;
  }
  return true;
}
function isEmpty(s) {
  return ((s == null) || (s.length == 0))
}
function isDigit (c) {
  return ((c >= "0") && (c <= "9"))
}

