/*function centerWindow(url,w,h,scr) {
  if ((document.all) || (document.getElementById))
        var xMax = screen.width, yMax = screen.height;
  else
  if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
  else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
  if (top.objWindow){
    	if (!top.objWindow.closed){
    		top.objWindow.focus();
    		top.objWindow.location=url;
    	}else{
top.objWindow=window.open(url,'Mercator'+w,'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars='+scr);
    	}
    }else{
top.objWindow=window.open(url,'Mercator'+w,'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars='+scr);
    }
top.objWindow.focus();
  }*/

function highlight(element,mode)
{
	if ( mode == 1 )
	{
	element.className="ButtonOff";
	}
	else if ( mode == 2 )
	{
	element.className="ButtonOn";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
*/
//common functions
//to open popup window
function popupSearch(ctrlText,path,len)
{

var Len=len
 var Query;
 var URL;
  var flag = 1
 Query=ctrlText.value;
 if(ctrlText.value.length<Len)
 {
 alert("please enter atleast " +Len+ " characters")
 ctrlText.focus();
 }
 else if(ctrlText.value.length >=Len)
 {
   
	val = ctrlText.value
	var val_length=ctrlText.value.length;
	for(i=0;i<len;i++)
	{ 
	   str=val.charCodeAt(i);
	   if((str==38)||(str == 32))
	   {	  
		  alert("'&' and blanks not allowed in first"+ Len +"places");
		  flag = 0;
		  break;
	   }
	}
	for(i=0;i<val_length;i++)
	{
	  str=val.charCodeAt(i);
	  if(str == 37)
	  {
	    alert("'%' not allowed here");
	    flag = 0 ;
	    break;
	  }
	}
 }
 
 if(flag == 1)
 {
 var count=0
 for(i=0;i<=Query.length;i++)
  {	
   if(Query.charAt(i)==" ")
	{
	 count=count+1;
	}
  }
 for(i=0;i<=count;i++)
 Query=Query.replace(" ","%20")
 URL=path+"?SString="+Query;
 newwin = window.open(URL,"newwin","height=350,width=550,status=yes,toolbar=no,menubar=no,location=no,resize=no,fullscreen=no,scrollbars")
 }
}


//to copy the data of firm combo's to personal
function cDataTransfer(c1,c2)
{
 var pCounLen=c1.length;
 var counVal=c2.options[c2.selectedIndex].value;
 for(var couni=0;couni<=pCounLen;couni++)
	{
		if (counVal==c1.options[couni].value)
			{
			c1.options[couni].selected=true;
			break
			}
		}
}

//function to select a combo for a given value
function selCombo(combo,selVal)
{
selVal=selVal

  	 var pComLen=combo.length
	 for(var i=0;i<pComLen;i++)
	 {
		//alert(selVal)
		//alert(combo.options[i].value)
		  if (selVal==combo.options[i].value)
		  {
			  //alert("hi")
			   combo.options[i].selected=true;
			   break;
		  }
	 }

}

//function to load a combo according to the other combo
function loadSCity(ctrname,arrayname,country)
{
	var len=ctrname.length;
	ctrname.options.length=0
	     var oOption = new Option();
	      oOption.text = "Select One From The List";
	      oOption.value = '0';
	      ctrname.options[0] = oOption;

	  var j=1;
	 
	 
	  for (i=0;i<arrayname.length;i++)
	  {
	    
	    if (arrayname[i][0] == country)
	    {
	      var oOption = new Option();
	      oOption.text = arrayname[i][2];
	      oOption.value = arrayname[i][1];
	      ctrname.options[j] = oOption;
	      j = j + 1;
	         
	    }
	  }
if (country>0)
{
  var oOption = new Option();
	      oOption.text = "Others";
	      oOption.value = 'ABCD';
	      ctrname.options[j] = oOption;
}
ctrname.options[0].selected=true
}
//end of function

//function to copy the data of combo's from child window to parent window combo
function CWDataTransfer(ctrname,array,n)
{
var counLen=ctrname.length;
for(var couni=0;couni<counLen;couni++)
 {
  var counVal=ctrname.options[couni].value;
  if (counVal==array[i][n])
	{
     ctrname.options[couni].selected=true;
	 break
	}
 }
}


//function to validate password's
function validatePassword(a,b)
 {
  
  if(a.value!=b.value)
  {
   alert("Password Mismatch");
   b.value="";
   b.focus();
   return false;
  }
  else
  {
    return true;
  }
 }
// function to validate combo's

function validateCombo(a,cboname)
 {
 
  //alert(a.selectedIndex)
   if(a.selectedIndex <=0)
   {
     alert("Please select the " + cboname + " field" );
     a.focus();
     return false;
   }
  else
   {
     return true;
   } 

}

function ismin(ctrlName)
{
   var ctrlText;
   ctrlText=ctrlName;
   var val=ctrlText.value;
   if(val < 0 || val > 59 || val =="" || isNaN(val)== true)
      {//check for hours
	   alert("MM-Enter the Correct Time(hh:mm)")
	   ctrlText.focus();
        return false;
      }
   else
    {
     return true;
    }
    
}

function ismin(ctrlName)
{
   var ctrlText;
   ctrlText=ctrlName;
   var val=ctrlText.value;
   if(val < 0 || val > 59 || val =="" || isNaN(val)== true)
      {//check for hours
	   alert("SS-Enter the Correct Time(hh:mm)")
	   ctrlText.focus();
        return false;
      }
   else
    {
     return true;
    }
    
}
// to check whether only numbers are entered in a text field
function gfb_IsNumber1(ctrlName,minChar,maxChar)
{	
	var i;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	minChar=minChar;
	maxChar=maxChar;
	errMessage="";
	var val=ctrlText.value;
    var val_Length=ctrlText.value.length;
       
		for(i=0;i<val_Length;i++)
		{
		  str=val.charCodeAt(i);
            if((str<48 || str>57)) 		  
		   
		  {	  
			errMessage="Only Numbers Are Allowed.No Special Characters,Blank Spaces are Allowed\n";
			
		  }
		  
		}
	if((val_Length < minChar) ||(val_Length > maxChar))
	{
		
		errMessage=errMessage + "There should be Minimum of" + minChar + " and Maximum of" + maxChar +" Numbers";
	}
	if (errMessage !="")
	{
		alert(errMessage);
		ctrlText.focus();
		return false;
	}
    else
    {
		return true;
    }
}



//function to validate textbox
function Validate(ctrlText,splchr,Numb,alph,maxChar,minChar)
{
  
  var val=ctrlText.value;
  var val_Length=ctrlText.value.length;
  var errMessage;
  var minChar
  var maxChar

   if((val_Length < minChar) || (val_Length > maxChar))
   {
     alert("You have to enter a minimum of "+minChar+" and maximum is not allowed more than "+maxChar+" ");
     ctrlText.focus();
     return false
   }

  //Allows Only Alphabets
  if(alph == 1)
   {
    for(i=0;i<val_Length;i++)
	 { 
	 	str=val.charCodeAt(i);
	 	if((isNaN(val.charAt(i)) == false) || (str>=9 && str<=38) ||(str>=40 && str<=47)|| (str>=58 && str<=64) ||(str>=91 && str<=96) || (str>122 && str<=255))
		 {	  	
		    alert("Only Text(a-z or A to Z) and Single Quotes are Allowed in this field");
			ctrlText.focus();
			return false;
		  }
		  
	 }
    if((val_Length < minChar) || (val_Length > maxChar))
      {
       alert("Only maximum "+maxChar+"and"+"minimun"+minChar+"Allowed");
       ctrlText.focus();
       return false;
      }
    
    }
 
  // Does Not Allow Special Characters
  // allows Numbers Alphabets and '
    if(splchr == 1)
     {
	   for(i=0;i<val_Length;i++)
		{ 
		  str=val.charCodeAt(i);
		  if((str>=9 && str<=38) ||(str>=40 && str<=47)|| (str>=58 && str<=64) ||(str>=91 && str<=96) || (str>122 && str<=255))
		  {	  
			alert("Only Numbers and Text Are Allowed");
			ctrlText.focus();
			return false;
		  }
		  
		}
		
   
      }
     
   //Doesnot allow Alphabets And Special Characters
   // allows only numbers
     if(Numb == 1)
      {
      
       if(val_Length > 0)
       { 
			if(isNaN(val) || (val < 1))
     			{
				  alert("Enter Numbers")
				  ctrlText.focus();
				  return false;
				}
				 for(i=0;i<val_Length;i++)
				{ 
				   str=val.charCodeAt(i);
				   if((str == 46)||(str == 101)||(str == 32)||(str == 45)||(str == 43))
					 {	  
						   	alert("Only Integers Allowed");
							ctrlText.focus();
							return false;
					  }
				 }
	   
	   }
	   else
	   {
	     return true;
	   
	   }  
	return true;
       }
  
  
   
 return true
}

function val_Date(ctrlText)
{ 
   val = ctrlText.value;
   val_Length = val.length;
      if(val != "")
       {
         t1 = val.split("/");
         if (t1.length == 3) 
         {
          //To Check For Dot,Space,+,e In Date		
				for(i=0;i<val.length;i++)
				{ 
		      		  str=val.charCodeAt(i);
					   if((str == 46)||(str == 32)||(str == 45)||(str == 43))
						{	  
						 alert("Enter A Valid Date")
						 ctrlText.focus();
						 return false; 
					    }
				}
        
        
          //check if the date is valid
          if(t1[0] > 31 || t1[0] < 1 || t1[0]=="" ||isNaN(t1[0])==true)
		   { 
		     alert("Enter the Correct Date(dd/mm/yyyy)");
		     ctrlText.focus();
		     return false;
	       } 
	      //check if the Month is valid  
		  else if(t1[1] > 12 || t1[1] < 1 || t1[1]=="" || isNaN(t1[1])==true)
	       {
		     alert("Enter the Correct Month(dd/mm/yyyy)");
		     ctrlText.focus();
		     return false;
		   } 
	     //check if the year is valid 
		 else if( t1[2]<1900 || t1[2] >2078 ||t1[2]=="" || isNaN(t1[2])==true || t1[2].length < 2 || t1[2].length > 4 || t1[2] == 3)
		   {
		     alert("Enter the Correct Year(dd/mm/yyyy)");
		     ctrlText.focus();
		     return false;
		   }
		 else if ((t1[1] == 1)||(t1[1] == 3)||(t1[1] == 5)||(t1[1] == 7)||(t1[1] == 8)||(t1[1] == 10)||(t1[1] == 12))
          {
    	//Check for 31 days in the month
			if (t1[0] > 31)
			{ 
			  alert("Enter the Correct Date(dd/mm/yyyy)");
		      ctrlText.focus();
		      return false;
			}
          }
        else if ((t1[1] == 4)||(t1[1] == 6)||(t1[1] == 9)||(t1[1] == 11))
		{
	   //Check for 30 days in the month
		  if (t1[0] >30)
		  {
		     alert("Enter the Correct Date(dd/mm/yyyy)");
		     ctrlText.focus();
		     return false;
		  }
		}
		else if(t1[1] == 2)
		{
	   //check for leap year
		  if (( (t1[2] % 4 == 0) && (t1[2] % 100 !=0)) || (t1[2] % 400 == 0))
		  {
		     if (t1[0] > 29)
		     {
		       alert("Enter the Correct Date(dd/mm/yyyy)");
		      ctrlText.focus();
		      return false;
		     }
		  }
		  else
		  {
		    if (t1[0] > 28)
		     {
		       alert("Enter the Correct Date(dd/mm/yyyy)");
		       ctrlText.focus();
		       return false;
		     }
		  }
	    }
	    
	       d=new Date();
		   d1=new Date(t1[1]+"/"+t1[0]+"/"+t1[2])
		   if(d1 < d)
            {
              alert(" Date Lesser than current Date "); 
      	      ctrlText.focus();
      	      return false;
		    }
               
	    
        }
        else
        {
		   alert("Enter the Correct Date(dd/mm/yyyy)");
		   ctrlText.focus();
		   return false;
		   
		}
		 
	 }
	 else
	 {
	   return true;
	 }
	 return true;       
    }

  
  
 function date_check(dtm_con_date,con_allow)
{
  startDate =  new Date();
  t1 = dtm_con_date.value.split("/");
 
  dtm_con_dat = new Date(t1[1]+"/"+t1[0]+"/"+t1[2]);
 
  con_allow = con_allow * 30;
 
  startDate.setDate( startDate.getDate() - con_allow);
 
  if(dtm_con_dat > startDate)
  {
    Month=startDate.getMonth()+1
    alert("BirthDate should be less than " + startDate.getDate()+"/"+Month+"/"+startDate.getFullYear())
    dtm_con_date.focus();
    return false;
  } 
  return true;
}    


function validate_Postal(ctrlText)
{
  // Does Not Allow Special Characters
  // allows Numbers Alphabets and space
    val=ctrlText.value;
    val_Length = val.length;
    if(val_Length>0)
		{
		str2=val.charAt(0); 
				if((str2<'0'|| str2 >'9')&&(str2<'a' || str2 >'z') && (str2<'A' || str2 >'Z'))
		           {
					alert("First Character should be either a number or an alphabet in the Postal code Field!");
					ctrlText.focus();
					return false;
					}
         }       
    if(val != "")
	 {
	    for(i=0;i<val_Length;i++)
		{ 
		  str=val.charCodeAt(i);
		   if((str>=9 && str<=31)||(str>=33 && str<=44)||(str==46)||(str==47)|| (str>=58 && str<=64) ||(str>=91 && str<=96) || (str>122 && str<=255))
		  {	  
			alert("Only Numbers and Text Are Allowed in the Postal Code Field");
			ctrlText.focus();
			return false;
		  }
		  		  
		}
	  }
	  else
	  {
	     alert("Postal Code cannot be blank");
	     ctrlText.focus();
	     return false;
	  }	
		return true;
}

function validate_spaces(ctrlText)
{
     val=ctrlText.value;
     val_Length = val.length;
     var c = 0
     for(i=0;i<val_Length;i++)
	  { 
		  str=val.charCodeAt(i);
		  if((str==32))
		  {	  
			c = c+1;
		  }
		  else
		  { 
		    if(c > 3)
		     {
		      alert("You Can't Enter More Spaces");
		      return false;
		     }
		    else
		     {
		       c = 0 
		     }  
		       
		  }
	  }
	 if(c > 3)
	  {
	    alert("You Can't Enter More Spaces");
	    return false;
	  }
	 else
	  {
	    return true;
	  }   
} 

//general validation to validate a first name of a person 
function validate_FName(ctrlText)
{
    val=ctrlText.value;
    val_Length = val.length;
    if((val != "" ) && (val_Length >=3))
	 {
	    for(i=0;i<val_Length;i++)
		{ 
		  str=val.charCodeAt(i);
		  if((str==62) || (str == 60))
		  {	  
			alert("< and > is not allowed");
			ctrlText.focus();
			return false;
		  }
		  
		}
	  }
	  else
	  {
	     alert("Company Name should be minimum of 3 characters");
	     ctrlText.focus();
	     return false;
	  }	
		return true;

}
 
 //to validate username 
function validate_UName(ctrlText)
{
  // Does Not Allow Special Characters
  // allows Numbers Alphabets and _ and . and -
    val=ctrlText.value;
    val_Length = val.length;
    if(val_Length<0)
    {
    
	     alert("Company Name cannot be blank");
	     ctrlText.focus();
	     return false;
	  }	
	
    if(val != "")
	 {
	    for(i=0;i<val_Length;i++)
		{ 
		  str=val.charCodeAt(i);
		  if((str>=9 && str<=44)||(str==47)|| (str>=58 && str<=64) ||(str>=91 && str<=94)||(str == 96) || (str>122 && str<=255))
		  {	  
			alert("Only Text,Numbers,UnderScore,Dot and hiphen are allowed in the Company Name");
			ctrlText.focus();
			return false;
		  }
		  
		}
	  }
	  else
	  {
	     alert("Company Name cannot be blank");
	     ctrlText.focus();
	     return false;
	  }	
		return true;
}
 
//function for firm name

function gfb_formValidate(ctrlName)
{
	var val;
	var val_len;
	var icount;
	var str;
	val=ctrlName.value;
	val_len=val.length;
	for(icount=0;icount<=val_len;icount++)
	{
		str=val.charCodeAt(icount)
		if((str==60)||(str==62)||(str==47)||(str==92))
		{
			alert("Please Avoid using Characters <,>,\,/ ")
			ctrlName.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	return true;
}

//function to change quotes

function gfb_changeQuotes(prstr_ctrl)
{
	var lenctrl,valctrl,strRet="";
	var icount
	var arrsMessage=new Array();
	lenctrl=prstr_ctrl.value.length;
    valctrl=prstr_ctrl.value;
	for(icount=0;icount<=lenctrl;icount++)
		{
			if(valctrl.charAt(icount)=='\'')
				arrsMessage[icount]="''";
			else
				arrsMessage[icount]=valctrl.charAt(icount) 
		}
	for(icount=0;icount<=lenctrl;icount++)
		{
			strRet=strRet + arrsMessage[icount];
		}
	prstr_ctrl.value=strRet
	return true;
}


/*
return type:Boolean
Takes Input as Control Name,Minimum number of Characters Allowed and 
Maximum Number of Character Allowed...
*/

function gfb_IsAlphaNumeric(ctrlName,minChar,maxChar)
{
	var i;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	minChar=minChar;
	maxChar=maxChar;
	errMessage="";
	var val=ctrlText.value;
    var val_Length=ctrlText.value.length;
    var val_Length=val.length;
	for(i=0;i<val_Length;i++)
	{
		  str=val.charCodeAt(i);
		  if((str<65 || str >90) &&(str<97 || str>122)&&(str<48 || str>57)&&(str<38 || str>39))
				{	  
					errMessage="Only Numbers and Text Are Allowed.No Special Characters,Blank Spaces are Allowed\n";
				}
	}   
	if ((ctrlText.value.length<minChar)||(ctrlText.value.length > maxChar))
	{
		errMessage= errMessage + "The Length of the Field should be minimum of" + minChar +"and Maximum of " + maxChar;		
	}
	if (errMessage !="")
	{alert("t");
		alert(errMessage);
		ctrlText.focus();
		return false;
	}
	else
	{
	return true;
	}
}



//Password Fuction Allows User to Enter any Characters in this Field 
//except Blank Spaces...
//Return type:Boolean

function gfb_IsPassword(ctrlName,minChar,maxChar)
{	
	var i;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	minChar=minChar;
	maxChar=maxChar;
	errMessage="";
	var val=ctrlText.value;
	 
	var val_Length=val.length;
    for(i=0;i<val_Length;i++)
	{
		str=val.charCodeAt(i);
		//alert(str);
		if((str==32))
		{	  
			alert("blank space");		
			errMessage="No Blank Spaces are Allowed\n";
		}
	}
	if ((ctrlText.value.length<=minChar)||(ctrlText.value.length > maxChar))
	{
		errMessage= errMessage + "The Length of the Field should be minimum of" + minChar +"and Maximum of " + maxChar;		
	}
	if (errMessage !="")
	{	alert(errMessage);
		ctrlText.focus();
		return false;
    }		
    else
	{
		return true;
	}
}

 
//return type=Boolean
//Takes Input as Control Name,Minimum number of Characters Allowed 
//and Maximum Number of Character Allowed...

function gfb_IsNumber(ctrlName,minChar,maxChar)
{	
	var i;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	minChar=minChar;
	maxChar=maxChar;
	errMessage="";
	var val=ctrlText.value;
    var val_Length=ctrlText.value.length;
       
		for(i=0;i<val_Length;i++)
		{
		  str=val.charCodeAt(i);
            if((str<48 || str>57)) 		  
		   
		  {	  
			errMessage="Only Numbers  Are Allowed.No Special Characters,Blank Spaces are Allowed\n";
			
		  }
		  
		}
	if((val_Length < minChar) ||(val_Length > maxChar))
	{
		
		errMessage=errMessage + "There should be Minimum of" + minChar + " and Maximum of" + maxChar +" Numbers";
	}
	if (errMessage !="")
	{
		alert(errMessage);
		ctrlText.focus();
		return false;
	}
    else
    {
		return true;
    }
}



  /*
input	:ControlName is Passed..eg. document.formName.textboxName
function:This Function Changes the single Quotes into two Single Quotes...
Return	: Boolean

*/

function gfb_changeQuotes(prstr_ctrl)
{
	var lenctrl,valctrl,strRet="";
	var icount
	var arrsMessage=new Array();
	lenctrl=prstr_ctrl.value.length;
    valctrl=prstr_ctrl.value;
	for(icount=0;icount<=lenctrl;icount++)
		{
			if(valctrl.charAt(icount)=='\'')
				arrsMessage[icount]="''";
			else
				arrsMessage[icount]=valctrl.charAt(icount) 
		}
	for(icount=0;icount<=lenctrl;icount++)
		{
			strRet=strRet + arrsMessage[icount];
		}
	prstr_ctrl.value=strRet
	return true;
}


/*
return type:Boolean
	Input:Takes Input as Control Name,Minimum number of Characters Allowed and 
		  Maximum Number of Character Allowed...
function: Checks Whether the Control is AlphaNumeric or Not	  
*/


function gfb_IsAlphaNumeric(ctrlName,minChar,maxChar,message)
{
	var icount;
	var ctrlText,minChar,maxChar;
	ctrlText=ctrlName;
	intMinChar=minChar;
	intMaxChar=maxChar;
	strErrMessage="";
	var val=ctrlText.value;
    var val_Length=ctrlText.value.length;
    var val_Length=val.length;
	for(icount=0;icount<val_Length;icount++)
	{
		  str=val.charCodeAt(icount);
		  if((str<65 || str >90) &&(str<97 || str>122)&&(str<48 || str>57)&&(str<45 ||str>45) && (str<95 ||str>95)&&(str<46 ||str>46))
				{	  
					strErrMessage=message;
				}
		  else if(val.charCodeAt(0)==46)
		  {
			strErrMessage=message;
		  }
		  else if(val.charCodeAt(0)==95)
		  {
			strErrMessage=message;
		  }
		  else if(val.charCodeAt(0)==45)
		  {
			strErrMessage=message;
		  }
	}   
	if ((ctrlText.value.length<intMinChar)||(ctrlText.value.length >intMaxChar))
	{
		strErrMessage= message;	
	}
	if(val=="_")
	{
		strErrMessage=message;
	}

	if (strErrMessage!="")
	{
		alert(strErrMessage);
		ctrlText.focus();
		return false;
	}
	else
	{
	return true;
	}
}






/*Input   :Allows User to Enter any Characters in this Field 
           except Blank Spaces...
 Function :Checks all the Characters and allows everything except BlankSpaces..
   Return :Boolean
*/
function gfb_IsPassword(ctrlName,minChar,maxChar,message)
{
	var icount;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	intMinChar=minChar;
	intMaxChar=maxChar;
	strErrMessage="";
	var val=ctrlText.value;
	
	var val_Length=val.length;
 /*   for( icount=0; icount<val_Length; icount++)
	{
		str=val.charCodeAt( icount);
		if((str==32))
		{	  
			strErrMessage=message;
		}
	}*/
	if ((ctrlText.value.length<intMinChar)||(ctrlText.value.length >intMaxChar))
	{
		strErrMessage= message;		
	}
	if (strErrMessage!="")
	{	
		alert(strErrMessage);
		ctrlText.focus();
		return false;
    }		
    else
	{
	return true;
	}
}
/*
return  :type=Boolean
Function:Checks whether it is A Number or Not
Input   :Takes Input as Control Name,Minimum number of Characters 
		Allowed 
		and Maximum Number of Character Allowed...
*/
function gfb_IsNumber(ctrlName,minChar,maxChar,message)
{
	var icount;
	var ctrlText,minChar,maxChar;
	var strErrMessage;
	ctrlText=ctrlName;
	intMinChar=minChar;
	intMaxChar=maxChar;
	strErrMessage="";
	var val;
	val=ctrlName.value;
    var val_Length=ctrlText.value.length;
       
		for(icount=0;icount<val_Length;icount++)
		{
		  str=val.charCodeAt(icount);
            if((str<48 || str>57)) 		  
		   
		  {	  
			strErrMessage=message;
			
		  }
		  
		}
	if((val_Length < intMinChar) ||(val_Length > intMaxChar))
	{
		
		strErrMessage=message;
	}
	if(val==0)
	{
	strErrMessage=message;
	
	}
	if (strErrMessage !="")
	{
		alert(strErrMessage);
		ctrlText.focus();
		return false;
	}
    else
    {
    return true;
    }
}
/*
Return :Boolean
function:Returns true only if it is a Valid Email Id..
Input  :Control Name

*/
 function gfb_EmailCheck (ctrlText)
 {
	 var xCtrl=ctrlText.value
	/* The following pattern is used to check if the entered e-mail address
	   fits the user@domain format.  It also is used to separate the username
	   from the domain. */
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special
	   characters.  We don't want to allow special characters in the address. 
	   These characters include ( ) < > @ , ; : \ " . [ ]    */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]%#$^+&'*~"
	/* The following string represents the range of characters allowed in a 
	   username or domainname.  It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern applies if the "user" is a quoted string (in
	   which case, there are no rules about which characters are allowed
	   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	   is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,
	   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	   e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents an atom (basically a series of
	   non-special characters.) */
	var atom=validChars + '+'
	/* The following string represents one word in the typical username.
	   For example, in john.doe@somewhere.com, john and doe are words.
	   Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic
	   domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	/* Finally, let's start trying to figure out if the supplied address is
	   valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	   different pieces that are easy to analyze. */

	   emailStr=xCtrl;
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Enter a Valid Email Address")
	ctrlText.focus();
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The Email-Username doesn't seem to be valid.")
    ctrlText.focus();
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var icount=1;icount<=4;icount++) {
	    if (IPArray[icount]>255) {
	        alert("Destination IP address is invalid!")
	        ctrlText.focus();
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
	ctrlText.focus();
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   ctrlText.focus();
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   ctrlText.focus();
   return false
}

// If we've gotten this far, everything's valid!
return true;
}

 // to check whether only text is entered in a textbox field
function isText(ctrlName,minChar,maxChar)
{	
	
	var i;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	minChar=minChar;
	maxChar=maxChar;
	errMessage="";
	var val=ctrlText.value;
	val=changeQuotes(ctrlText)
	var val_Length=val.length;
    
	for(i=0;i<val_Length;i++)
	{
	  str=val.charCodeAt(i);
	  if((str>=48 && str<=57) || (str>=9 && str<=47) || (str>=58 && str<=64) ||(str>=91 && str<=96) || (str>122 && str<=255))
	  {	  
		  errMessage="Only Text Are Allowed.No Special Characters,Blank Spaces and Numbers are Allowed\n";
	  }
		  
	}
			
	if ((ctrlText.value.length<=minChar)||(ctrlText.value.length > maxChar))
	{
		errMessage= errMessage + "The Length of the Field should be minimum of" + minChar +"and Maximum of " + maxChar;		
	}
	
	if (errMessage !="")alert(errMessage);
	return false;

}

//to validate password
function gfb_IsPassword_msg(ctrlName,minChar,maxChar,message)
{
	var icount;
	var ctrlText,minChar,maxChar;
	var errMessage;
	ctrlText=ctrlName;
	intMinChar=minChar;
	intMaxChar=maxChar;
	strErrMessage="";
	var val=ctrlText.value;
	
	var val_Length=val.length;
    for( icount=0; icount<val_Length; icount++)
	{
		str=val.charCodeAt( icount);
		if((str==32))
		{	  
			strErrMessage=message;
		}
	}
	if ((ctrlText.value.length<intMinChar)||(ctrlText.value.length >intMaxChar))
	{
		strErrMessage= message;		
	}
	if (strErrMessage!="")
	{	
		alert(strErrMessage);
		ctrlText.focus();
		return false;
    }		
    else
	{
	return true;
	}
}

//to validate alpha numeric

function gfb_IsAlphaNumeric_msg(ctrlName,minChar,maxChar,message)
{
	var icount;
	var ctrlText,minChar,maxChar;
	ctrlText=ctrlName;
	intMinChar=minChar;
	intMaxChar=maxChar;
	strErrMessage="";
	var val=ctrlText.value;
    var val_Length=ctrlText.value.length;
    var val_Length=val.length;
	for(icount=0;icount<val_Length;icount++)
	{
		  str=val.charCodeAt(icount);
		  if((str<65 || str >90) &&(str<97 || str>122)&&(str<48 || str>57)&&(str<45 ||str>45) && (str<95 ||str>95))
				{	  
					strErrMessage=message;
				}
	}   
	if ((ctrlText.value.length<intMinChar)||(ctrlText.value.length >intMaxChar))
	{
		strErrMessage= message;	
	}
	if(val=="_")
	{
		strErrMessage=message;
	}

	if (strErrMessage!="")
	{
		alert(strErrMessage);
		ctrlText.focus();
		return false;
	}
	else
	{
	return true;
	}
}

/********
To Check whether the first character of the field is an Alphabet.
Input : Control Name
Output : Boolean
*******/
function gfb_FirstAlpha(ctrlName)
{
var strText=ctrlName.value;
	//str=strText.charCodeAt(0);
	str=strText.charAt(0);
	//alert(str)
	if((str<'a' || str >'z') && (str<'A' || str >'Z'))
		{
		alert("First Character should only be an Alphabet in this field");
		ctrlName.focus();
		return false;
		}
	else
	{
		return true;
	}	
}

/*******
To check whether the Password Answer is Blank or contains space in first character
Input : Control Name
Output : Boolean
*****/
function gfb_IsPwdAnswer(ctrlName,minChar,maxChar)
{
var val=ctrlName.value;
var errMessage="";
if(val.length<minChar || val.length>maxChar)
	errMessage="Password Answer should have atleast "+minChar+" Character and cannot exceed "+maxChar+" Characters";
if(val.charAt(0)==" ")
	errMessage=errMessage+"\nFirst Character Cannot be Blank in Password Answer"
if(errMessage!="")
	{
	alert(errMessage);
	ctrlName.focus();
	return false;
	}
else
	{
	return true;
	}	
}


/*******
To check whether the Password Question is Blank or contains space in first character
Input : Control Name
Output : Boolean
*****/
function gfb_IsPwdQuestion(ctrlName,minChar,maxChar)
{
var val=ctrlName.value;
var errMessage="";
if(val.length<minChar || val.length>maxChar)
	errMessage="Password Question should have atleast "+minChar+" Character and cannot exceed "+maxChar+" Characters";
if(val.charAt(0)==" ")
	errMessage=errMessage+"\nFirst Character Cannot be Blank in Password Question"
if(errMessage!="")
	{
	alert(errMessage);
	ctrlName.focus();
	return false;
	}
else
	{
	return true;
	}	
}


/*******
To check whether the Field is Null
Input : Control Name, Error message
Output : Boolean
*****/
function gfb_IsNull(ctrlName,errMessage)
{
var val=ctrlName.value;
if(val.length==0 || val=="")
	{
	alert(errMessage);
	ctrlName.focus();
	return false;
	}
else
	{
	return true;
	}	
}



function gfb_IsTime(datTime)
{
	dat_Time=datTime.value;
	d  = dat_Time.split(":"); 
	if (dat_Time !="")
	{
		if (d.length==3)
		{
			 for(i=0;i<dat_Time.length;i++)
			{ 
				 str=dat_Time.charCodeAt(i);
				 if((str == 46)||(str == 32)||(str ==45) ||(str == 43))
				{	  
					 alert("Enter A Valid Time in Hh:Mm:Ss  Format");
					 datTime.focus();
					 datTime.value="";
					 return false; 
				 }
							
			}		
			if( d[0]<0 || d[0]>23 || isNaN(d[0])==true)
			{
				alert("Enter A Valid Hour in the Time Field");
				datTime.focus();
				datTime.value="";
				return false;
			}
			else if(d[1]<0 || d[1] > 59|| isNaN(d[1])==true)
			{
				alert("Enter A Valid Mininute in the Time Field");
				datTime.focus();
				datTime.value="";
				return false;
			}
			else if(d[2]<0 || d[2] >59 || isNaN(d[2])==true)
			{
				alert("Enter A Valid Seconds in the Time Field");
				datTime.focus();
				datTime.value="";
				return false;
			}
			return true;
		}
		else
		{
			alert("Enter Valid Time In the Format Hh:Mm:Ss");
			datTime.focus();
			datTime.value="";
			return false;
		}

	}
	else
	{
		alert("Enter Valid Time In the Format Hh:Mm:Ss");
		datTime.focus();
		datTime.value="";
		return false;
	}
}


function validate_Tittle(ctrlText)
{
  // Does Not Allow Special Characters
  // allows Numbers Alphabets and space
    val=ctrlText.value;
    val_Length = val.length;
    if(val != "")
	 {
	    for(i=0;i<val_Length;i++)
		{ 
		  str=val.charCodeAt(i);
		 if((str>=9 && str<=31)||(str>=33 && str<=44)||(str==46)||(str==47)|| (str>=58 && str<=64) ||(str>=91 && str<=96) || (str>122 && str<=255))
		  {	  
			alert("Only Numbers and Text Are Allowed");
			ctrlText.focus();
			return false;
		  }
		  
		}
	  }
	  else
	  {
	     alert("Enter Tittle");
	     ctrlText.focus();
	     return false;
	  }	
		return true;
}


//function to validate a phone number

function Validate_phNumber(ctrlText)
		{
		// Does Not Allow Special Characters
		  // allows Numbers and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    str1=val.charCodeAt(0)
            if(val != "")
			 {
			    for(i=0;i<val_Length;i++)
				{ 
			     str=val.charCodeAt(i);
				 //alert(str);
				 str0=val.charCodeAt(0)
				 //alert(str0)
				 str1=val.charCodeAt(1)
				 //alert(str1)
				 str2=val.charCodeAt(2)
				 //alert(str2)
				 
				    if(val_Length<7)
				    {
				    	alert("Minimum 7 numbers have to be entered")
						ctrlText.focus();
						return false;
					
				    }
						if((str0==45||str0==43)&&(str1==32||str2<47||str2>58)&&(str2<47||str2>58))
						{	
						alert("Enter a Valid Phone number")
						ctrlText.focus();
						return false;
						}
						else if ((str!=45)&&(str!=43)&&(str!=32)&& (str<48 || str>57) )
						 {	  
							alert("Only Numbers,plus,minus symbol and spaces are allowed in Phone Number");
							ctrlText.focus();
							return false;
						}
				  
				}
			  }
			  else
			  { 
			     alert("Phone field cannot be blank");
			     ctrlText.focus();
			     return false;
			  }	
			
			     return true;
			  
}



/**********
purpose: to check whether the first character of the control is Blank
return: boolean
input : control name
********/
function gfb_FirstBlank(CtrlName)
{
	var CtrlValue=CtrlName.value;
	if(CtrlValue.charAt(0)==" ")
		{
		alert("First Character cannot be Blank!");
		CtrlName.focus();
		return false;
		}
	else
		return true;
}

//to validate Fax number

function Validate_FaxNumber(ctrlText)
		{
		// Does Not Allow Special Characters
		  // allows Numbers and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    strlen=val.charCodeAt(0)
		    if (strlen==32)
		    {
		     alert("First character cant be blank")
					ctrlText.focus();
					return false;
		     }
		    
            if(val_Length>0)
			 {
			    for(i=0;i<val_Length;i++)
				{ 
			     str=val.charCodeAt(i);
				 //alert(str);
				 str0=val.charCodeAt(0)
				 //alert(str0)
				 str1=val.charCodeAt(1)
				 //alert(str1)
				 str2=val.charCodeAt(2)
				 //alert(str2)
				 		if(val_Length<7)
							{
								alert("Minimum 7 numbers have to be entered")
								ctrlText.focus();
								return false;
							}
						if((str0==45||str0==43)&&(str1==32||str2<47||str2>58)&&(str2<47||str2>58))
						{	
						alert("Enter a Valid Fax number")
						ctrlText.focus();
						return false;
						}
						else if ((str!=45)&&(str!=43)&&(str!=32)&& (str<48 || str>57) )
						 {	  
							alert("Only Numbers,plus,minus and spaces are allowed in the Fax field ");
							ctrlText.focus();
							return false;
						}
				  
				}
			  }
			  else
			  { 
			     alert("Fax field cannot be blank.");
			     ctrlText.focus();
			     return false;
			  }	
			  return true;
			  
			  
}

//to validate password questions
		
	function Validate_pwdquestion(ctrlText)
		{
		// Does Not Allow Special Characters
		  // allows Alphabets and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    if(val != "")
			 {
			    for(i=0;i<val_Length;i++)
				{ 
				  str=val.charCodeAt(i);
				// alert(str);
                                //question,singlequotes,space
				 if ((str!=63)&& (str!=39)&&(str!=32)&&(str!=35)&&(str!=45)&&(str<=47 || str>=58)&&((str<=64 || str>=91)&&(str<=95 || str>122)) )
				    {	  
					alert("Only Text,Numbers,spaces,singlequotes and ? are allowed in the Password question field");
					ctrlText.focus();
					return false;
				  }
				  
				}
			  }
			  else
			  {
			     alert("Password Question field cannot be blank");
			     ctrlText.focus();
			     return false;
			  }	
				return true;
}

//to validate password answers 

function Validate_pwdanswer(ctrlText)
		{
		// Does Not Allow Special Characters
		// allows Alphabets and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    str2=val.charCodeAt(0)
		    //alert(str2)
		    if(str2==39)
		    {
		    alert("First character should be a number or an alphabet in the Password Answer Field ");
					ctrlText.focus();
					return false;
			}
		    if(val != "")
			 {
			    for(i=0;i<val_Length;i++)
				{ 
				  str=val.charCodeAt(i);
				// alert(str);
                                //question,singlequotes,space
				 if ((str!=39)&&(str!=32)&&(str<46 || str>=58)&&((str<=63 || str>=91)&&(str<=95 || str>122)) )
				    {	  
					alert("Only Text(a-z)or(A-Z),Numbers(0-9) are allowed in the Password Answer Field ");
					ctrlText.focus();
					return false;
				  }
				  
				}
			  }
			  else
			  {
			     alert("Password Answer Field cannot be blank");
			     ctrlText.focus();
			     return false;
			  }	
				return true;
}

//to validate the address 

function Validate_Address1(ctrlText)
		{
		// Does Not Allow Special Characters
		  // allows Alphabets and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    str2=val.charAt(0);
		    if((str2!='#')&&(str2<'a' || str2 >'z') && (str2<'A' || str2 >'Z')&&(str2<'0'||str2>'9'))
		           {
					alert("First Character should be a Number,Alphabet or a Hash symbol in the Address fiedd !");
					ctrlText.focus();
					return false;
					}
		    if(val != "")
			 {
			    for(i=0;i<val_Length;i++)
				{ 
				  str=val.charCodeAt(i);
				// alert(str);
                                //singlequotes,space,alphabets,numbers,#,.,-,/,comma
				 if ((str!=13)&&(str!=10)&&(str!=39)&&(str!=32)&&(str!=35)&&(str!=44)&&(str!=45)&&(str!=46)&&(str!=47)&&(str<48 ||str>57)&&((str<=64 || str>=91)&&(str<=95 || str>122)) )
				    {	  
					alert("Only Text,Numbers,spaces,hiphen,singlequotes,hash,dot,forward slash Are Allowed ");
					ctrlText.focus();
					return false;
				  }
				  
				}
			  }
			  else
			  {
			  //alert("im in")
			     alert("Address Field cannot be blank");
			     ctrlText.focus();
			     return false;
			  }	
			return true;
}

function Validate_Address2(ctrlText)
  {
	    val=ctrlText.value;
	    val_Length = val.length;
        str1=val.charCodeAt(0)
        if (str1==32)
		{
		alert("First character cannot be blank in the Town field")
		ctrlText.focus();
		return false;
		}
		if(val_Length>0)
		{
		str2=val.charAt(0); 
				if((str2<'a' || str2 >'z') && (str2<'A' || str2 >'Z'))
		           {
					alert("First Character should only be an Alphabet in the Town field!");
					ctrlText.focus();
					return false;
					}
         }       
        if(val_Length>0)
			 {
			    for(i=0;i<val_Length;i++)
				{
				 
				  str=val.charCodeAt(i);
				// alert(str);
                                //singlequotes,space,alphabets,numbers,#,.,-,/,comma
				 if ((str!=39)&&(str!=32)&&(str!=46)&&(str<48 ||str>57)&&((str<=64 || str>=91)&&(str<=95 || str>122)) )
				    {	  
					alert("Only Text,Numbers,spaces,singlequotes and dot Are Allowed in Town field");
					ctrlText.focus();
					return false;
			            }
				  
				}
			  }
				return true;
}

//to validate firstname
function Validate_firstname(ctrlText)
		{
		// Does Not Allow Special Characters
		  // allows Alphabets and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    if(val != "")
			 {
			    for(i=0;i<val_Length;i++)
				{ 
				  str=val.charCodeAt(i);
				 //alert(str);
				 //singlequotes,space,alphabets,numbers,#,.,-,/,comma
				 if ((str!=39)&&(str!=32)&&((str<=64 || str>=91)&&(str<=95 || str>=123)) )
				    {	  
					alert("Only Text and Single quotes are Allowed in the FirstName");
					ctrlText.focus();
					return false;
				  }
				  
				}
			  }
			  else
			  {
			     alert("First Name cannot be blank");
			     ctrlText.focus();
			     return false;
			  }	
				return true;
}

//to validate lastname

function Validate_lastname(ctrlText)
		{
		// Does Not Allow Special Characters
		  // allows Alphabets and space
		    val=ctrlText.value;
		    val_Length = val.length;
		    if(val != "")
			 {
			    for(i=0;i<val_Length;i++)
				{ 
				  str=val.charCodeAt(i);
				 //alert(str);
				 //singlequotes,space,alphabets,numbers,#,.,-,/,comma
				 if ((str!=39)&&(str!=32)&&((str<=64 || str>=91)&&(str<=95 || str>=123)) )
				    {	  
					alert("Only Text and Singlequotes are Allowed in the LastName");
					ctrlText.focus();
					return false;
				  }
				  
				}
			  }
			
		else
			  {
			     alert("Last Name cannot be blank");
			     ctrlText.focus();
			     return false;
			  }	
				return true;
			
}

//to validate state

function Validate_State(ctrlText)
  {
	    val=ctrlText.value;
	    val_Length = val.length;
            str1=val.charCodeAt(0)
               if (str1==32)
		{
		alert("first character cant be balnk")
					ctrlText.focus();
					return false;
		}
		if(val_Length>0)
		{
		str2=val.charAt(0); 
				if((str2<'a' || str2 >'z') && (str2<'A' || str2 >'Z'))
		           {
					alert("First Character should only be an Alphabet in the State Field!");
					ctrlText.focus();
					return false;
					}
         }       
        
                if(val_Length>0)
			 {
			    for(i=0;i<val_Length;i++)
				{ 
				  str=val.charCodeAt(i);
				// alert(str);
                                //singlequotes,space,alphabets,numbers,#,.,-,/,comma
				 if ((str!=39)&&(str!=32)&&((str<=64 || str>=91)&&(str<=95 || str>122)) )
				    {	  
					alert("Only Text,spaces,single quotes Are Allowed in the State Field");
					ctrlText.focus();
					return false;
			            }
				  
				}
			  }
				return true;
}


function validatemyPassword(ctrlName)
 {	
	var i;
	var ctrlText,minChar,maxChar;
	ctrlText=ctrlName;
	var val=ctrlText.value;
	var val_Length=val.length;
   //alert(val)
   // to validate for </form>
   //ascii character for < =60
  // alert(val_Length)
   if(val_Length >0)
    {
     for(i=0;i<val_Length;i++)
	  {
		str=val.charCodeAt(i);
		//alert(str);
		if((str<48 ||str>57)&&((str<=64 || str>=91)&&(str<=95 || str>122)))
		//if((str==32)||(str==60))
		{	  
			alert("Only Numbers and Alphabets are allowed in this field");		
                  ctrlText.focus();
		       return false;
	    }
		
	  }
    }
    else 
    {
    return true;
    }
    return true
}

function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Maximum allowed length exceeded. Your input has been truncated!');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}