// JavaScript Document
	/**************************************/
	//Program		: contact.js 
	//Package 		: Contact form and sending email
	//Purpose 		: Form validating using Javascript
	//Created By	: Ashwin
	//Created On	: 30-Jul-2007
	//Modified By	: 
	//Modified On	: 
	//Company		: Thummas 
	/**************************************/

function IsEmpty(aTextField) {
	if ((aTextField.value.length==0) || (aTextField.value==null)) {
		return true;
	} else { 
		return false;
	}
}

function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


function ValidateForm(form){
	if(IsEmpty(form.CName)) { 
      alert('You have not entered an name') 
      form.CName.focus(); 
      return false; 
	} 
	if(IsEmpty(form.CEmail)) { 
      alert('You have not entered an email') 
      form.CEmail.focus(); 
      return false; 
	} 
	if(isValidEmail(form.CEmail.value) == false) { 
      alert('Email is not a valid, please give valid email') 
      form.CEmail.focus(); 
      return false; 
	} 
	if(IsEmpty(form.CPhone)) { 
      alert('You have not entered an phone') 
      form.CPhone.focus(); 
      return false; 
	} 

 
/*	if (!IsNumeric(form.account_number.value)) { 
		alert('Please enter only numbers or decimal points in the account field') 
		form.account_number.focus(); 
		return false; 
	}*/
	return true;
}