function trim(strText)
 {

    // this will get rid of leading spaces
    while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;

}

function emailcheck(str) 
{
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid Email Address");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email Address");
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Email Address");
		    return false;
		}
		if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Email Address");
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Email Address");
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Email Address");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid Email Address");
		    return false;
		 }
 		 return true;				
}

function integercheck(str)
 {
  var pattern="0123456789";
   var i=0;
   do
   {
     var pos=0;
     for(var j=0; j<pattern.length; j++)
     if(str.charAt(i)==pattern.charAt(j))
     {
      pos=1;
      break;
     }
     i++;
   }
   while(pos==1 && i<str.length)
   if(pos==0){
   	alert("Enter Integer Only");		
   	return false;
	}
	return true;
 }
