function addLoadEvent ( func ) {
	var oldonload = window.onload;
	if ( typeof window.onload != 'function' ) {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		};
	}
}

pageLoaders = {
	init : function ( ) {
		var orderForm = document.getElementById("orderForm");
		if ( orderForm ) {
			orderForm.onsubmit = new Function( "return orderForms.checkForm(this);" );
		}
	}
}

orderForms = {
	fieldNames : {	"entry_0":"Billing Company",
					"entry_3":"Billing Contact",
					"entry_1":"Billing Address",
					"entry_2":"Billing City, State, Post Code",
					"entry_4":"Billing Phone",
					"entry_5":"Billing Email",
					"entry_16":"Shipping Info is same as billing",
					"entry_6":"Ship to Company",
					"entry_14":"Shipping Contact",
					"entry_7":"Shipping Address",
					"entry_8":"Shipping City, State, Post Code",
					"entry_9":"Shipping Phone",
					"entry_10":"Shipping Email",
					"entry_17":"ProScreen Cup",
					"entry_18":"ProScreen Dip",
					"entry_19":"ProScreen Cassette",
					"entry_11":"ProScreen Saliva",
					"entry_15":"First Sign Saliva",
					"entry_20":"Alco-Screen",
					"entry_12":"Call for credit card info",
					"entry_21":"Order Number",
					"entry_22":"iScreen Oral Fluids",
					"entry_23":"",
					"entry_24":"Order Number"
	},
	checkForm : function ( orderForm ) {
		var action = orderForm.action;
		var msg = "";
		if ( orderForm.entry_0.value == "" ) {
			msg += "Please enter your " + orderForms.fieldNames["entry_0"] + "\n";
		}
		if ( orderForm.entry_3.value == "" ) {
			msg += "Please enter your " + orderForms.fieldNames["entry_3"] + "\n";
		}
		if ( orderForm.entry_1.value == "" ) {
			msg += "Please enter your " + orderForms.fieldNames["entry_1"] + "\n";
		}
		if ( orderForm.entry_2.value == "" ) {
			msg += "Please enter your " + orderForms.fieldNames["entry_2"] + "\n";
		}
		if ( orderForm.entry_4.value == "" ) {
			msg += "Please enter your " + orderForms.fieldNames["entry_4"] + "\n";
		}
		if ( orderForm.entry_5.value == "" ) {
			msg += "Please enter your " + orderForms.fieldNames["entry_5"] + "\n";
		}
		var qty = false;
		if ( orderForm.entry_11 && orderForm.entry_11.value == "" ) {
			qty = true;
		}
		if ( orderForm.entry_15 && orderForm.entry_15.value == "" ) {
			qty = true;
		}
		if ( orderForm.entry_17 && orderForm.entry_17.value == "" ) {
			qty = true;
		}
		if ( orderForm.entry_18 && orderForm.entry_18.value == "" ) {
			qty = true;
		}
		if ( orderForm.entry_19 && orderForm.entry_19.value == "" ) {
			qty = true;
		}
		if ( orderForm.entry_20 && orderForm.entry_20.value == "" ) {
			qty = true;
		}
		if ( orderForm.entry_22 && orderForm.entry_22.value == "" ) {
			qty = true;
		}
		if ( qty ) {
			msg += "Please enter the quantity of kits you are ordering.\n";
		}
		if ( msg ) {
			alert( msg );
			return false;
		}

		var tk = document.createElement("input");
		tk.name = "transactionKey";
		tk.value = "1";
		tk.type = "hidden";
		orderForm.appendChild(tk);
		var tk2 = document.createElement("input");
		tk2.name = "origForm";
		tk2.value = orderForm.action;
		tk2.type = "hidden";
		orderForm.appendChild(tk2);
		orderForm.action = "process-forms.php";
		return true;
	}
}


if ( document.getElementById && document.getElementsByTagName ) {
	addLoadEvent(pageLoaders.init);
}