function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   //if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
function TrimString(sInString)
{
  sInString = sInString.replace(/^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}




function ChkValidity()
{
	if(TrimString(document.feedbackform.Name.value) == "") 
	{
		alert ("Please Enter Your Name");
		document.feedbackform.Name.focus();
		return false;
	}
	
	if(TrimString(document.feedbackform.Tel_no.value) == "")
	{
		alert ("Please Enter your Contact Number");
		document.feedbackform.Tel_no.focus();
		return false;
	}


	if(!checkEmail(document.feedbackform.Email,'Email',false))return false;
	document.feedbackform.action = "feedback.asp"
	document.feedbackform.submit();

}


function checkEmail(txtElement,fieldName,allowEmpty)
{
	var exclude=/[^@\-\.\w\_]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;
	var strEmail = txtElement.value
	var email_array=strEmail.split(",");
	
	if(allowEmpty == false && txtElement.value.length == 0)
	{
		alert("Please enter Valid '" + fieldName + "' address");
		txtElement.focus()
		return false;
	}

	if(allowEmpty == true && txtElement.value.length == 0)
	{
		//empty value is allowed
		return true;
	}
	else 
	{
		var email_num=0;
		var checkEmail;
		while (email_num < email_array.length)
		{
				var trimemail = TrimString(email_array[email_num]);
				//alert("email=" + hello);
				//alert("email=" + email_array[email_num]);
				if(((trimemail.search(exclude) != -1) || 
					(trimemail.search(check)) == -1)   ||	
					(trimemail.search(checkend) == -1))
				{
					checkEmail = "false";
				}
				else
				{
					checkEmail = "true";
				}
				//alert(email_array[email_num]);
				email_num++;
				if(checkEmail == "false")
				{
					alert("Please enter a Valid Email address!");
					txtElement.focus()
					return false;
				}
				else 	
					return true;				
		}		
	}
}

