//function top check valid phone or not.

function chkphone(phno){
	ph = phno.value;
	for(i=0;i<ph.length;i++)
		if(isNaN(ph.charAt(i)) && (ph.charAt(i) != '-') && (ph.charAt(i)!='(') && (ph.charAt(i)!=')') && (ph.charAt(i)!=' ')){
//			if(compul)
				alert("Enter a valid Phone number.\nOnly '()- ' is permitted other than Numbers.");
//          else
//				alert("Enter a valid Phone number.\nOnly '()- ' is permitted other than Numbers.");
			phno.focus();
			phno.select();
			return false;
		}
/*	if(ph.length<3 || ph.length>13){
		alert("Enter a valid Phone number.");
		phno.focus();
		phno.select();
		return false;
	}
	else*/ return true;
}


// function to check for whether the email id is valid or not

var junkchars = "#%$&*()+|!~`^=\/'><;:,";
function chkemail(compemail){
	if(compemail.value.indexOf('@')==-1 || compemail.value.indexOf('@')==0 || compemail.value.indexOf('.')==-1 || compemail.value.indexOf('.')==0){
		alert("Invalid Email Address. Enter valid Email Address");
		compemail.focus();
		compemail.select();				
		return false;
	}
	else{
		elen=compemail.value.length;
		len=elen-4;
		if(compemail.value.indexOf('.',compemail.value.indexOf('@')) == -1){
			alert("Invalid Email Address. Enter valid Email Address");
			compemail.focus();
			compemail.select();					
			return false;
		}
		for(i=0;i<junkchars.length;i++){
			if(compemail.value.indexOf(junkchars.charAt(i)) != -1){
				alert("Invalid Email Address. Enter valid Email Address");
				compemail.focus();
				compemail.select();					
				return false;
			}
		}
		if(compemail.value.charAt(len)!='.' && compemail.value.charAt(len+1)!='.'){
			alert("Invalid Email Addresss. Enter valid Email Address");
			compemail.focus();
			compemail.select();					
			return false;
		}
		else return true;
	}
}

function ltrim(s)
{
	return s.replace(/^\s*/,"")
}

function rtrim(s)
{
	return s.replace(/\s*$/,"");
}

//function for trimming the spaces 

function trim(s)
{
	return rtrim(ltrim(s));
}


//Function for allowing only integers

function splvalidate()
{
      if((event.keyCode>=48 && event.keyCode<=57) || (event.keyCode==47))
          return true;
      else
      {
		alert("Enter only Integers");
        return false;
       }
}  
