 
  //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);
}


function goto(form) {
	var index=form.select.selectedIndex
	if (form.select.options[index].value != "0") 
	{
		location=form.select.options[index].value;
	}
}

function blinkIt() {
	 if (!document.all) return;
	 else {
	   for(i=0;i<document.all.tags('blink').length;i++){
	      s=document.all.tags('blink')[i];
	      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
	   }
	 }
}


//Added by Girish on 5 June to show navigation messages for Registration related JSP's
function piNavigationCheck(){
	var queryString = window.location.search.substring(1).toLowerCase();
  	//if (queryString.length==0) {return "null";}
  	var parameters = new Array();
  	parameters = queryString.split('&');
  	for(var i = 0; i < parameters.length; i++) {
	    var parameterName = 'navigationstatus';
	    if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {
	   
			var parameterValue = new Array();
			
		    parameterValue = parameters[i].split('=');
		    if(parameterValue[1] == 'CONFIRMED' || parameterValue[1] == 'confirmed'){
		    	alert('PI form is already submitted');
	      	}
	      	else if(parameterValue[1] == 'piFormSaved' || parameterValue[1] == 'piformsaved'){
		    	alert('PI form is submitted to council');
	      	}
	      	else if(parameterValue[1] == 'ecRequestSent' || parameterValue[1] == 'ecrequestsent'){
		    	alert('Eligibility Certificate Request has been submitted to Council');
	      	}
	      	else if(parameterValue[1] == 'regReqSubmitted' || parameterValue[1] == 'regreqsubmitted'){
		    	alert('Registration Information Change has been submitted to Council');
	      	}
	      	else if(parameterValue[1] == 'feeDetailsSent' || parameterValue[1] == 'feedetailssent'){
		    	alert('Registration fee details have been submitted successfully.');
	      	}
	      	else if(parameterValue[1] == 'feeDetailsUpdated' || parameterValue[1] == 'feedetailsupdated'){
		    	alert('Registration fee details have been updated successfully.');
	      	}
		}
  	}
}



function openMsgICSE(msgNo){
var opt = 'dialogWidth:815px; dialogHeight:450px; center:yes; scroll:yes; status:no';
	window.showModalDialog('HelpMsgICSE.jsp?strMsgNo='+msgNo,'' , opt );
}


function openMsgISC(msgNo){
var opt = 'dialogWidth:815px; dialogHeight:450px; center:yes; scroll:yes; status:no';
	window.showModalDialog('HelpMsg.jsp?strMsgNo='+msgNo,'' , opt );
}
