function MM_validateForm() { //v4.0
  if (document.getElementById){
    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=document.getElementById(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 check_checkbox(check_box,qty,items_num) {
	if (check_box.checked) { qty.value = 1; items_num.value++; }
	else { qty.value = ''; items_num.value--; }
}

function check_qty(qty,check_box,items_num) {
	if (qty.value > 0) { check_box.checked = true; items_num.value++; }
	else { check_box.checked = false; items_num.value--; }
}

function fill_address(check_box,this_form,first_name,last_name,title,company,address_1,address_2,city_name,state_name,postal_code,phone_number,fax_number,email) {
	if (check_box.checked) { 
		this_form.first_name.value = first_name; this_form.first_name.disabled = true;
		this_form.last_name.value = last_name; this_form.last_name.disabled = true;
		this_form.title.value = title; this_form.title.disabled = true;
		this_form.company.value = company; this_form.company.disabled = true;
		this_form.address_1.value = address_1; this_form.address_1.disabled = true;
		this_form.address_2.value = address_2; this_form.address_2.disabled = true;
		this_form.city_name.value = city_name; this_form.city_name.disabled = true;
		this_form.state_name.value = state_name; this_form.state_name.disabled = true;
		this_form.postal_code.value = postal_code; this_form.postal_code.disabled = true;
		this_form.phone_number.value = phone_number; this_form.phone_number.disabled = true;
		this_form.fax_number.value = fax_number; this_form.fax_number.disabled = true;
		this_form.email.value = email; this_form.email.disabled = true;
	} else {
		this_form.first_name.value = ''; this_form.first_name.disabled = false;
		this_form.last_name.value = ''; this_form.last_name.disabled = false;
		this_form.title.value = ''; this_form.title.disabled = false;
		this_form.company.value = ''; this_form.company.disabled = false;
		this_form.address_1.value = ''; this_form.address_1.disabled = false;
		this_form.address_2.value = ''; this_form.address_2.disabled = false;
		this_form.city_name.value = ''; this_form.city_name.disabled = false;
		this_form.state_name.value = ''; this_form.state_name.disabled = false;
		this_form.postal_code.value = ''; this_form.postal_code.disabled = false;
		this_form.phone_number.value = ''; this_form.phone_number.disabled = false;
		this_form.fax_number.value = ''; this_form.fax_number.disabled = false;
		this_form.email.value = ''; this_form.email.disabled = false;
	}
}

function check_cart(this_form) {
	if (this_form.items_num.value > 0) {
		var ans = confirm("Would you like to add the selected items to your cart?");
		if (ans) {
			this_form.redirect_flag.value = 1;
			this_form.submit();
		} else {
			window.location = "http://ipspeppm.org/summary.php";
		}
	} else {
		window.location = "http://ipspeppm.org/summary.php";
	}
}
