<!--

var blnerror;
var strerror;

blnerror = false;
strerror = 'Please check the following input\n\n';

function checkemail(objcheck) {

		var at="@"
		var blnemailerror
		var dot="."
		var str;
		str = objcheck.value;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var blnemailerror;
		blnemailerror = false;


		if (objcheck.value.length < 1) {
			if (!blnerror) {
				objcheck.focus();
			}
			strerror = strerror + 'The field ' + objcheck.id +  ' must not be left blank.\n';
 		    blnemailerror = true;
			blnerror = true;
		}


		if(!blnemailerror){
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
				if (!blnerror) {
					objcheck.focus();
				}
			   strerror = strerror + 'The field ' + objcheck.id +  ' contains an invalid email address - no @.\n';
			   blnemailerror = true;
	 		   blnerror = true;
			}
		}

		if(!blnemailerror){
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				if (!blnerror) {
					objcheck.focus();
				}
			   strerror = strerror + 'The field ' + objcheck.id +  ' contains an invalid email address - no . eg .com\n';
			   blnemailerror = true;
	 		   blnerror = true;
			}
		}

		if(!blnemailerror){
			 if (str.indexOf(at,(lat+1))!=-1){
				if (!blnerror) {
					objcheck.focus();
				}
			   strerror = strerror + 'The field ' + objcheck.id +  ' contains an invalid email address - no @.\n';
			   blnemailerror = true;
	 		   blnerror = true;
			}
		}

		if(!blnemailerror){
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				if (!blnerror) {
					objcheck.focus();
				}
			   strerror = strerror + 'The field ' + objcheck.id +  ' contains an invalid email address - no @.\n';
			   blnemailerror = true;
	 		   blnerror = true;
			}
		}

		if(!blnemailerror){
		 if (str.indexOf(dot,(lat+2))==-1){
				if (!blnerror) {
					objcheck.focus();
				}
			   strerror = strerror + 'The field ' + objcheck.id +  ' contains an invalid email address - no @.\n';
			   blnemailerror = true;
	 		   blnerror = true;
			}
		}

		if(!blnemailerror){
		 if (str.indexOf(" ")!=-1){
				if (!blnerror) {
					objcheck.focus();
				}
			   strerror = strerror + 'The field ' + objcheck.id +  ' contains an invalid email address - no @.\n';
			   blnemailerror = true;
	 		   blnerror = true;
			}
		}

		
	}

	
function checkdel_method(objcheck) {
	myOption = -1;
	for (i=objcheck.length-1; i > -1; i--) {
		if (objcheck[i].checked) {
			myOption = i; i = -1;
		}
	}
	if (myOption == -1) {
		strerror = strerror + 'Select a Delivery Method.\n';
		blnerror = true;
	}
}
	

function checkpmnt_method(objcheck) {
	myOption = -1;
	for (i=objcheck.length-1; i > -1; i--) {
		if (objcheck[i].checked) {
			myOption = i; i = -1;
		}
	}
	if (myOption == -1) {
		strerror = strerror + 'Select a Payment Method.\n';
		blnerror = true;
	}
}


function checklength(objcheck){
	if (objcheck.value.length < 1) {
		if (!blnerror) {
			objcheck.focus();
		}
		strerror = strerror + 'The field ' + objcheck.id +  ' must not be left blank.\n';
		blnerror = true;
	}
}

function checkstate(objcheck){
	if (objcheck.selectedIndex == 0) {
		strerror = strerror + 'Please select a ' + objcheck.id +'\n';
		blnerror = true;

	}
}

function validateMe() {
	checklength(document.frmcheckout.order_name);
	checklength(document.frmcheckout.order_city);	
	checkstate(document.frmcheckout.order_state);		
	checklength(document.frmcheckout.order_postcode);			
	checklength(document.frmcheckout.order_tel);									
	checkemail(document.frmcheckout.order_email);
	checkdel_method(document.frmcheckout.del_method);
	checkpmnt_method(document.frmcheckout.pmnt_method);	

	if (blnerror) {
		alert(strerror);
		blnerror = false;
		strerror = '';
		return false;
	} else {
		//displayloading();	
		document.frmcheckout.submit();
		//alert("ok");
		return true;
	}
}

// -->