function keyCheck(e, str, typ, spc){
var keyCode
var str=str.value
if (document.all){keyCode=e.keyCode}
else{keyCode=e.which}
if(typ=="b"){alert(keyCode); return false;}
if(spc!="ns" && keyCode==32){return true;}
if(keyCode==8) return true;
//if(keyCode==46)	if (str.indexOf(".")>0){return false;}
if(typ=="n") if((keyCode>46 && keyCode <58)){return true;}
if(typ=="nf") if((keyCode>46 && keyCode <58)){return true;}
if((typ=="nf") && (str.indexOf(".")==-1)) 
{
if (keyCode==46) {return true;}
}

if(typ=="a") if((keyCode >64) ||(keyCode == 46)){return true;}
if(typ=="an") if(keyCode >45){return true;}
return false;
}

function IsEmailAddress() {
	/*var s = this.replace(/^\s*|\s*$/g, "");
	var re = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{2,3}$/i
	if (!re.test(s)) {return false;}
	re = /\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov)$/i
	if (!re.test(s)) {return false;}
	re = /\@\@/
	return(!re.test(s));*/
	var exp = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"
	var rx = new RegExp(exp);
    var matches = rx.exec(this);
    return (matches != null && this == matches[0]);

}
String.prototype.IsEmail = IsEmailAddress;

//added
function Validate_email(Str){
	var a=Str;
    var reEmail=/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[\w-\.]*[a-zA-Z0-9]\.[a-zA-Z]{2,7}$/;
	if (a.search(reEmail) == -1){
		alert("Check ur email id");
		return false; 
	}  
	else { return true; }
}

//17-11-2003 added in chennai
function checkMandatory()	{
         var total=checkMandatory.arguments.length;
	     var fields= new Array(total-1);	
	     var label= arguments[total-1];
		 for(i=1 ; i<total-1 ; i++)
		 {
    		if(document.forms[arguments[0]].elements[arguments[i]].value == "")    		{
	        alert(" Please Enter "+label[i-1]);
		    document.forms[arguments[0]].elements[arguments[i]].focus();
		    return false;
		     }
         }		
		return true;
  }
  
 function checkMandatoryForCombo()
	{
     var total=checkMandatoryForCombo.arguments.length;
	 var fields=new Array(total-1);	
	 var label=arguments[total-1];
		for(i=1 ; i<total-1 ; i++)
		 {
		  if(document.forms[arguments[0]].elements[arguments[i]].options[document.forms[arguments[0]].elements[arguments[i]].selectedIndex].value=="")
		     {
		    alert("Please Select "+label[i-1]);
		    document.forms[arguments[0]].elements[arguments[i]].focus();
		    return false;
			}
		 }		
		return true;
  } 
  
//18-11-2003 added in chennai
//function for validating alphanumeric data
function Validate_Alphanum(Str,Caption)
 {
        var a
        a=eval(Str+ ".value");
        var strcaption=Caption;
        var reAlpha=/^[a-zA-Z0-9_]*$/;
		if (a=="") 
    	{
    	        eval(Str).focus();
                alert("please enter "+ strcaption);
                eval(Str+ ".value=''");
                return false;
        }       
        
        if ( a.search(reAlpha) == -1)
       	{
    	        eval(Str).focus();
                alert("please enter Valid "+ strcaption);
                eval(Str+ ".value=''");
                return false;
         }       
 
        
            return true;   
}
 
//***********************************************************
//Validating the year of birth,passportissueyear,passportexpiryyear.businessstartdate
//*************************************************************
function Validate_year()
{         var total=Validate_year.arguments.length;         var label= arguments[total-1];
         ppiss=document.forms[arguments[0]].elements[arguments[2]].options[document.forms[arguments[0]].elements[arguments[2]].selectedIndex].value
         ppexp=document.forms[arguments[0]].elements[arguments[3]].options[document.forms[arguments[0]].elements[arguments[3]].selectedIndex].value         birth=document.forms[arguments[0]].elements[arguments[1]].options[document.forms[arguments[0]].elements[arguments[1]].selectedIndex].value         busis=document.forms[arguments[0]].elements[arguments[4]].options[document.forms[arguments[0]].elements[arguments[4]].selectedIndex].value               
         count=0;	     for(i=1;i<total-1;i++)
		 {		    if(document.forms[arguments[0]].elements[arguments[1]].options[document.forms[arguments[0]].elements[arguments[1]].selectedIndex].value==document.forms[arguments[0]].elements[arguments[i]].options[document.forms[arguments[0]].elements[arguments[i]].selectedIndex].value)		      {
				count=count+1;
    	       }		
   	     }		
    	  
    	if (count==4)
    	{		
    	        alert("Please Check the Year of Birth,Passport Expiry,Passport Issue,Business Start");
    	        return false;    			
    	}		
    	                 
          if (!(ppexp-ppiss >= 0))
        {
               alert("Check the  Passport Expiry and Passport Issue date");
               return false;
        }
                   if (!(busis-birth >= 0))
        {
			  alert("Check the Birth Year and Business Start Year");	
			  return false;
        }
         
                 //if ANY OF THE YEAR FIELD IS NULL         for(k=1; k<total-1 ;k++)
         {                if (document.forms[arguments[0]].elements[arguments[k]].options[document.forms[arguments[0]].elements[arguments[k]].selectedIndex].value=="")
				{				 alert("Please select the "+label[k-1]+" Year");				 document.forms[arguments[0]].elements[arguments[k]].focus();
				 return false;				}				         }
          //ANY YEAR THAT IS SAMLLER THAN THE BIRTH YEAR
    	  for(j=1;j<total-1;j++)
		 {		    
		    if(document.forms[arguments[0]].elements[arguments[1]].options[document.forms[arguments[0]].elements[arguments[1]].selectedIndex].value > document.forms[arguments[0]].elements[arguments[j]].options[document.forms[arguments[0]].elements[arguments[j]].selectedIndex].value)		      {
				alert("Please Check the Year of Birth and "+ label[j-1]);    			return false;
   	          }		
    	  }		        return true;          
}

// 08-May-2004 Added For Value Add From One SelectBox to Another SelectBox
	function AddToList(frmName,objName1,objName2,msg){
			if ( eval("document."+frmName+"."+objName1).selectedIndex == -1 ){alert(msg);return false;}
			var its = "T";
			for (i=0; i< eval("document."+frmName+"."+objName2).options.length; i++){
				if (eval("document."+frmName+"."+objName2).options(i).value == eval("document."+frmName+"."+objName1).value){ its = "F";}
					if (eval("document."+frmName+"."+objName2).options(i).value.toUpperCase() == 'ALL')its = "F";
		    }
			if ( eval("document."+frmName+"."+objName1).value.toUpperCase() == 'ALL' ){
				eval("document."+frmName+"."+objName2).innerText='';
				its = "T";
			}
			if (its == "T"){
				newOpt = new Option(eval("document."+frmName+"."+objName1).options[eval("document."+frmName+"."+objName1).selectedIndex].text);
				newOpt.value = eval("document."+frmName+"."+objName1).value;
				eval("document."+frmName+"."+objName2).add(newOpt);
			}

	}	
// 08-May-2004 Added For Value Remove From One SelectBox
	function RemoveFromList(frmName,objName,msg){
		var selection=eval("document."+frmName+"."+objName+".selectedIndex");
		if (selection== -1){
			alert(msg);
			eval("document."+frmName+"."+objName+".focus()");
			return false;
		}	
		eval("document."+frmName+"."+objName).remove(eval("document."+frmName+"."+objName).selectedIndex);
	}

//12-May-2004 added For Chking the length of Object
	function ChkLength(frmName,ObjName,Msg){
		if ((((eval("document."+frmName+"."+ObjName).value).length) < 6) || ((((eval("document."+frmName+"."+ObjName).value).length) > 15))){
			alert(Msg);
			eval("document."+frmName+"."+ObjName).focus();
			eval("document."+frmName+"."+ObjName).select();
			return false;
		}
		return true;
	}
