 
  //remove leading whitespaces
  function LTrim( value ) {

	 var re = /\s*((\S+\s*)*)/;
	 return value.replace(re, "$1");

   }
  // Removes ending whitespaces
  function RTrim( value ) {
	
   var re = /((\s*\S+)*)\s*/;
   return value.replace(re, "$1");
	
  }
  // Removes leading and ending whitespaces
  function trim(value) {

   return LTrim(RTrim(value));
 }

 //check the paramter is int ot not
  function isInteger(s){  
	var i;
	for (i = 0; i < s.length; i++)
		{   
		   // Check that current character is number.
		   var c = s.charAt(i);
		   if (((c < "0") || (c > "9"))) return false;
		}
   // All characters are numbers.
  return true;
  }

  // email format validation
    function checkEmail(email) {
       	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
   		    return true;
        }
	 //  alert("Please enter valid email id.");
	  // return false;
    }
 
function validate(){
	var firstName = document.getElementById("txtfname");
	var lastName = document.getElementById("txtlname");
	var address = document.getElementById("txthomeaddress");
	var emailId = document.getElementById("txtemail");
	var telephone = document.getElementById("txtresiphone");
	var schoolLocation = document.getElementById("txtschoollocation");
	var collegeLocation = document.getElementById("txtcollegelocation");
	var highestDegree = document.getElementById("txthighestdegree");
	var specialisation = document.getElementById("txtareaspecialisation");
	var experience = document.getElementById("txtexperience");
	var yearsPresentJob = document.getElementById("txtyearspresentjob");
	var designation = document.getElementById("txtdesignation");
	var company = document.getElementById("txtcompany");
	var aaplyingfor = document.getElementById("txtapplyingfor");
	var functional = document.getElementById("txtfunctional");
	//var zipCode = document.getElementById("Zip");
	//var state = document.getElementById("State");
	
	
	//check null value
	if(firstName.value == ""){
		alert("Please enter your first name");
		firstName.focus();
		return false;
	}

	//check is there any no. in name field
	if(isInteger(firstName.value)){
		alert("Please enter only character value in first name field.");
		firstName.focus();
		return false;
	}

	//check null value
	if(lastName.value == ""){
		alert("Please enter your last name");
		lastName.focus();
		return false;
	}

	//check is there any no. in name field
	if(isInteger(lastName.value)){
		alert("Please enter only character value in last name field.");
		lastName.focus();
		return false;
	}

	//check null value
	if(address.value == ""){
		alert("Please enter your Home Address");
		address.focus();
		return false;
	}

	//check null value
	if(emailId.value == ""){
		alert("Please enter your email id. (example: abc@xyz.com)");
		emailId.focus();
		return false;
	}

	if(!checkEmail(emailId.value)){
		alert("Please enter valid email id");
		emailId.focus();
		return false;
	}

	//check null value
	if(telephone.value == ""){
		alert("Please enter your residence phone number");
		telephone.focus();
		return false;
	}
	
	//check is there any no. in name field
	if(!isInteger(telephone.value)){
		alert("Please enter valid telephone no. It should be only numeric.");
		telephone.focus();
		return false;
	}

	//check null value
	if(schoolLocation.value == ""){
		alert("Please enter your School Location");
		schoolLocation.focus();
		return false;
	}

	//check null value
	if(collegeLocation.value == ""){
		alert("Please enter your College Location");
		collegeLocation.focus();
		return false;
	}

	//check null value
	if(highestDegree.value == ""){
		alert("Please enter your Highest Degree");
		highestDegree.focus();
		return false;
	}

	//check null value
	if(specialisation.value == ""){
		alert("Please enter your Area of Specialisation");
		specialisation.focus();
		return false;
	}

	//check null value
	if(experience.value == ""){
		alert("Please select your total years of work experience");
		experience.focus();
		return false;
	}

	//check null value
	if(yearsPresentJob.value == ""){
		alert("Please enter your years in present job");
		yearsPresentJob.focus();
		return false;
	}

	//check null value
	if(designation.value == ""){
		alert("Please enter your designation");
		designation.focus();
		return false;
	}

	//check null value
	if(company.value == ""){
		alert("Please enter your company name");
		company.focus();
		return false;
	}

	//check null value
	if(aaplyingfor.value == ""){
		alert("Please select your job type");
		aaplyingfor.focus();
		return false;
	}

	//check null value
	if(functional.value == ""){
		alert("Please select Functional Area");
		functional.focus();
		return false;
	}

	//check is there any no. in name field
/*	if(isInteger(lastName.value)){
		alert("Please enter only character value in company field.");
		companyName.focus();
		return false;
	}

	//check null value
	if(cityName.value == ""){
		alert("Please enter your city");
		cityName.focus();
		return false;
	}

	//check null value
	if(zipCode.value == ""){
		alert("Please enter your zip code");
		zipCode.focus();
		return false;
	}

	//check is there any no. in name field
	if(!isInteger(zipCode.value)){
		alert("Please enter proper zip code.");
		zipCode.focus();
		return false;
	}

	//check null value
	if(state.value == ""){
		alert("Please enter your state");
		state.focus();
		return false;
	}

	//check is there any no. in name field
	if(isInteger(state.value)){
		alert("Please enter proper state name.");
		state.focus();
		return false;
	}
*/

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
