<!--

function checkBeforeProceeding () {
  if (confirm("This link opens another window. Would you like to proceed?")) {
    // do something like the next statement
    // window.open('nowhere.htm', 'newWin');
  } else {
    // do something else
  }
}


function validate_quantity(quantity) {
  if (object_is_ok(quantity,0,4,'0123456789','Quantity')) {
    return quantity;
  }
  else {
    return '0';
  }
}

function error_message(error) {
  error_win = Window.open("","Error","height=200,width=300,resize=no");
  error_win.document.write(error);
  error_win.document.close;
}

// rounds number to X decimal places
function variable_round(number,x) {
  return Math.round(number*Math.pow(10,x))/Math.pow(10,x);
}

// convert a numeric value to dollars and cents
function format_to_dollars(dollar_amount) {
  // force code to treat this as a number
  dollar_amount = dollar_amount - 0;
  // now round it to specified precision
  dollar_amount = (dollar_amount == Math.floor(dollar_amount)) ? dollar_amount + '.00' : (  (dollar_amount*10 == Math.floor(dollar_amount*10)) ? dollar_amount + '0' : dollar_amount);
  return dollar_amount;
}

function object_is_ok(string_to_validate,min_length,max_length,validation_string,error_string) {

  for (var i = 0; i < string_to_validate.length; i++) {
    if (validation_string.indexOf(string_to_validate.charAt(i)) < 0) {
      alert(error_string + ' has invalid characters');
      return false;
    }
  }

  // zero for min and max means ignore length
  if (string_to_validate.length < min_length) {
    alert(error_string+' is too short');
    return false;
  }

  if (string_to_validate.length > max_length) {
    alert(error_string + ' has too many characters');
    return false;
  }

  return true;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function validate_form(thisForm) { //v4.0
  var i,temp_imprint,imprint_ok,errors='';
  if (thisForm.cart_item_quantity.value == 0) {
	  errors += "No product quantity selected.\n";
  } else if (thisForm.cart_item_total.value == '0.00') {
	  errors += "Please make sure your price is not $0.00\n If it is, try tabbing out of the quantity box.\n Also, javascript must be turned on for this cart to work.\n";
  }
  if (errors) {
    alert('The following error(s) occurred:\n'+errors);
        return false;
  } else {
    return true;
  }
}

function validate_cart (thisForm){
  var errors='';
  if (thisForm.customer_name.value == "") {
    errors += "You did not enter your name.\n";
  }
  if (thisForm.customer_address.value == "") {
    errors += "We need a street address.\n";
  }
  if (thisForm.customer_city.value == "") {
    errors += "You did not enter your city.\n";
  }
  if (thisForm.customer_telephone.value == "") {
    errors += "You did not enter your telephone.\n";
  }
  if (thisForm.customer_zipcode.value == "") {
    errors += "You did not enter your zipcode.\n";
  }
  if (errors) {
    alert('The following error(s) occurred:\n'+errors);
        return false;
  } else {
    return true;
  }
}

function validate_reorder (thisForm){
  var errors='';
  if (thisForm.order_number.value == "") {
    errors += "You did not enter your order number.\n";
  }
  if (errors) {
    alert('The following error(s) occurred:\n'+errors);
    return false;
  } else {
    return true;
  }
}
//-->