// JavaScript Document



function trim(str)
{
   return( (""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );
}









function vld_ord(frmOrd) {

	if (document.frmOrd.txtFN.value == '') {
	alert ("Please enter First Name.");
	document.frmOrd.txtFN.focus();
	return false;
	}
	if (document.frmOrd.txtLN.value == '') {
	alert ("Please enter Last Name.");
	document.frmOrd.txtLN.focus();
	return false;
	}
	if (document.frmOrd.txtAdd.value == '') {
	alert ("Please enter Address.");
	document.frmOrd.txtAdd.focus();
	return false;
	}
	if (document.frmOrd.txtCity.value == '') {
	alert ("Please enter City.");
	document.frmOrd.txtCity.focus();
	return false;
	}
	if (document.frmOrd.txtCountry.value == '') {
	alert ("Please enter Country.");
	document.frmOrd.txtCountry.focus();
	return false;
	}

// Count the number of radio boxes there
var radioSelected; 
for (var i=0; i<document.frmOrd.rdoTest.length; i++){ 
	if (document.frmOrd.rdoTest[i].checked) { 
	radioSelected = document.frmOrd.rdoTest[i].value 
	} 
} 

// Fire an error message if no radio boxes are selected
if (!radioSelected){ 
alert("Please choose a Test Type."); 
document.frmOrd.rdoTest[0].focus(); 
return false; 
} 

	if (!document.frmOrd.rdoShip[0].checked && !document.frmOrd.rdoShip[1].checked) {
	alert ("Please select a shipping method.");
	document.frmOrd.rdoShip[0].focus();
	return false;
	}


	if (!document.frmOrd.rdoCC[0].checked && !document.frmOrd.rdoCC[1].checked) {
	alert ("Please select a credit card type.");
	document.frmOrd.rdoCC[1].focus();
	return false;
	}



	var txtCC1=document.frmOrd.txtCC1.value;	
	txtCC1 = trim(txtCC1);

	if (txtCC1.length != 4) {
	alert ("Please enter your credit card number.");
	document.frmOrd.txtCC1.focus();
	return false;
	}

	var txtCC2=document.frmOrd.txtCC2.value;
	txtCC2 = trim(txtCC2);
	
	if (txtCC2.length != 4) {
	alert ("Please enter your credit card number.");
	document.frmOrd.txtCC2.focus();
	return false;
	}
	
	var txtCC3=document.frmOrd.txtCC3.value;
	txtCC3 = trim(txtCC3);
	
	if (txtCC3.length != 4) {
	alert ("Please enter your credit card number.");
	document.frmOrd.txtCC3.focus();
	return false;
	}
	
	var txtCC4=document.frmOrd.txtCC4.value;
	txtCC4 = trim(txtCC4);
	
	if (txtCC4.length != 4) {
	alert ("Please enter your credit card number.");
	document.frmOrd.txtCC4.focus();
	return false;
	}

	var txtExpM=document.frmOrd.txtExpM.value;
	txtExpM = trim(txtExpM);
	
	if (txtExpM.length != 2) {
	alert ("Please enter the month of expiry date.");
	document.frmOrd.txtExpM.focus();
	return false;
	}
	
	
	var txtExpY=document.frmOrd.txtExpY.value;
	txtExpY = trim(txtExpY);
	
	if (txtExpY.length != 2) {
	alert ("Please enter the year of expiry date.");
	document.frmOrd.txtExpY.focus();
	return false;
	}


	if (document.frmOrd.txtCCHolder.value == '') {
	alert ("Please enter the full name of the cardholder.");
	document.frmOrd.txtCCHolder.focus();
	return false;
	}

	if (document.frmOrd.txtPW.value.length < 4) {
	alert ("Please create a password with 4 or more characters.");
	document.frmOrd.txtPW.focus();
	return false;
	}
	if (document.frmOrd.txtPW.value == '') {
	alert ("Please create a password with 4 or more characters.");
	document.frmOrd.txtPW.focus();
	return false;
	}

return true;
}