function chkForm($frmObj) {
	var $isValid = false;
	$errorCount = 0;
	
	$name = document.getElementById("cu_name");
	$emailAddress = document.getElementById("cu_emailAddress");
	$subject = document.getElementById("cu_subject");
	$content = document.getElementById("cu_content");
	$select = document.getElementById("cu_select");
	$orderid = document.getElementById("cu_orderid");
	
	$isValid = chkNull($name, 'lblName');
	if ($isValid == false) {
		++$errorCount;
	}
	$isValid = chkNull($emailAddress, 'lblEmailAddress');
	if ($isValid == false) {
		++$errorCount;
	}
	$isValid = checkSelectInq($select.value, 'lblSelect');
	if ($isValid == false) {
		++$errorCount;
	}
	$isValid = chkNull($subject, 'lblSubject');
	if ($isValid == false) {
		++$errorCount;
	}
	$isValid = chkNull($content, 'lblContent');
	if ($isValid == false) {
		++$errorCount;
	}
	$isValid = chkNull($orderid, 'lblOrderID');
	if ($isValid == false) {
		++$errorCount;
	}
	
	if ($errorCount == 0 ) {
		$frmObj.submit();
	}
	
}

function chkNull($frmObj, $label) {
	var $name = $frmObj.name;
	var $length = $frmObj.value.length;
	var $isValid = false;
	var $trimmed = $frmObj.value.replace(/^\s+|\s+$/g, '') ;
	
	if (($trimmed==null)||($trimmed=="")) {
		if ($name == "cu_name") {
			document.getElementById($label).innerHTML = "Please Enter Your Name.";
		}
		if ($name == "cu_emailAddress") {
			document.getElementById($label).innerHTML = "Please Enter Your Email Address.";
		}
		if ($name == "cu_subject") {
			document.getElementById($label).innerHTML = "Please Enter Subject.";
		}
		if ($name == "cu_content") {
			document.getElementById($label).innerHTML = "Please Enter Content.";
		}
		if ($name == "cu_orderid") {
			if (document.getElementById("cu_select").value == "tracking" || document.getElementById("cu_select").value == "return") {
				document.getElementById($label).innerHTML = "Please Enter Order ID.";
			} else {
				document.getElementById($label).innerHTML = "";
				$isValid = true;
			}
		}
	} else {
		if ($name == "cu_name") {
			document.getElementById($label).innerHTML = "";
			$isValid = true;
		}
		if ($name == "cu_emailAddress") {
			if (!echeck($frmObj.value)) {
				document.getElementById($label).innerHTML = "Invalid Email Address.";
			} else {
				document.getElementById($label).innerHTML = "";
				$isValid = true;
			}
		}
		if ($name == "cu_subject") {
			document.getElementById($label).innerHTML = "";
			$isValid = true;
		}
		if ($name == "cu_content") {
			document.getElementById($label).innerHTML = "";
			$isValid = true;
		}
		if ($name == "cu_orderid") {
			document.getElementById($label).innerHTML = "";
			$isValid = true;
		}
	}
	return $isValid;
}

function checkSelectInq($obj, $label) {
	if (($obj == "")||($obj == null)){
		document.getElementById($label).innerHTML = "Please Select the Type of Enquiries.";
		return false;
	} else {
		if (document.getElementById("cu_select").value == "tracking" || document.getElementById("cu_select").value == "return") {
			document.getElementById("lblCOrderID").innerHTML = "*";
			document.getElementById("lblOrderID").innerHTML = "";
		} else {
			document.getElementById("lblCOrderID").innerHTML = "";
			document.getElementById("lblOrderID").innerHTML = "";
		}
		document.getElementById($label).innerHTML = "";
		return true;
	}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }