var SAlertMess = new Array(20);
var SErrmes ;

SAlertMess[0] = "Invalid Date."
SAlertMess[1] = "Invalid Time."
SAlertMess[2] = "Cannot Be Greater Then Current Date."
SAlertMess[3] = "Invalid Number."
SAlertMess[4] = "Cannot Be Zero."
SAlertMess[5] = "Invalid String."
SAlertMess[6] = "Select From The Dropdown."
SAlertMess[7] = "Selection Is mandatory."
SAlertMess[8] = "Age Cannot Be Less Then 18 years."
SAlertMess[9] = "Click On search To Select."
SAlertMess[10] = "Invalid Email Address."
SAlertMess[11] = "Cannot Be Blank."
SAlertMess[12] = "Invalid Zipcode."
SAlertMess[13] = "Invalid Phone Number."
SAlertMess[14] = "Invalid Fax Number."
SAlertMess[15] = "Invalid SSN Number."
SAlertMess[16] = "Invalid  Number."
SAlertMess[17] = "Please Select CheckBox."
SAlertMess[18] = "Invalid Fax Number."

function GotoUrl(surl)
{
	document.location = surl
}

function openwin(surl,sheight,swidth,stop,sleft)
 {
	
	 //stop = 300;
	 //sleft = 300;
	 window.open(surl,'test','height='+sheight+',width='+swidth+',top='+stop+',left='+sleft+',alwaysRaised=1');
 }

function changeDate(obj)
{
	var sval,sexp;
	sval = obj.value;
	if (sval.length == 8)
	{	
		obj.value = sval.substr(0,2) + "/" + sval.substr(2,2) + "/" + sval.substr(4,4) 
	}
}

function ReturnErr(IErr)
{
 SErrmes =   SAlertMess[IErr] ; 
 return SErrmes ; 
}


var SAbort ; // used as flag for excuting the functions
SAbort = "TRUE" ;


//*********************************************************
function CheckZip(objName,sErrorCol)
{

if(SAbort == "FALSE")
{
return (false);
}


var alertsay = ""; // define for long lines
// check to see if the field is blank

if (objName.value == "")
{
alert(sErrorCol);
objName.focus();
objName.select();
SAbort = "FALSE" ;
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
//var checkOK = "0123456789-";
var checkStr = objName.value;
var allValid = true;
var iPoszero ; 
iPoszero= 0 ;  

var iPos ;
iPos = 0 ;
  if (checkStr.length < 5) 
       {
          alert(sErrorCol) ;
          objName.focus() ;
          objName.select();
          SAbort = "FALSE" ;
		   return(false)    ;
       }      
     else
      {
		if (checkStr.length == 5) //to find the positoins of -'s 
		 {
	         for (i = 0;  i < checkStr.length;  i++)
		            {
			          ch = checkStr.charAt(i);
				        if(ch=="-")
					       {
						     iPos = iPos + i   ;
	                       }   
		                   
			            if(ch=="0")
				           {
	                         iPoszero = iPoszero + 1;
		                     //alert(iPoszero);
			               }      
					} // for

			if(iPos!=0 || iPoszero==5) // 
			{
 				alert(sErrorCol) ;
				objName.focus() ;
	             objName.select();
		         SAbort = "FALSE" ;
			      return(false)    ;
			}  
			 
		 }
		 else
		 {
			if (checkStr.length != 10) //to find the positoins of -'s 
			{
	          alert(sErrorCol) ;
			  objName.focus() ;
	          objName.select();
		      SAbort = "FALSE" ;
			  return(false);
	        }
		    else
	        {
			for (i = 0;  i < checkStr.length;  i++)
					{
	                  ch = checkStr.charAt(i);
		                if(ch=="-")
	                       {
							iPos = iPos + i   ;
	                       }   
	                       
		                if(ch=="0")
	                       {
	                         iPoszero = iPoszero + 1;
		                     //alert(iPoszero);
			               }      
				     } // for

				if(iPos!=5 || iPoszero==9) // 
		          {
			 		    alert(sErrorCol) ;
						objName.focus() ;
						objName.select();
						SAbort = "FALSE" ;
						return(false)    ;
				  }  
	        }
		 }
      } 

//}
return(true);
}

//*********************************************************


//***************************************************

function CheckText(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false) ;
}

// this can be altered for any "checkOK" string you desire

var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var checkStr = objName.value;

var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);
objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);

}





//****************************************************

function CheckPassword(objName,sAlertmess)
{
if(SAbort == "FALSE")
{
return (false) ;
}

// this can be altered for any "checkOK" string you desire

var checkOK = " ";
var checkStr = objName.value;
var allValid = true;

for (j = 0;  j < checkStr.length ;  j++)
{
if (checkStr.charAt(j) == " ")
  {
	allValid = false ;	
  } 	
}
	if (!allValid)
	{
		alert(sAlertmess);
		objName.focus();
		SAbort = "FALSE" ;
		return (false);
	}
	
return(true);

}

//**************************************
function CheckSentence(objName,sAlertmess)
{
if(SAbort == "FALSE")
{
return (false) ;
}

// this can be altered for any "checkOK" string you desire

var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz &";
var checkStr = objName.value;

var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);

objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);

}



//****************************************************



function CheckAlphaNumeric(objName,sAlertmess)
{
if(SAbort == "FALSE")
{
return (false) ;
}

// this can be altered for any "checkOK" string you desire

var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -";
var checkStr = objName.value;

var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);

objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);

}


//***********************************************

function CheckNumeric(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789";
var checkStr = objName.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);
objName.focus();
SAbort = "FALSE" ;
return (false);
}

return(true);
}

//***********************************************

function CheckDecimal(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789.";
var checkStr = objName.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;

if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
isnumeric = "false";
alert(sAlertmess);
objName.focus();
SAbort = "FALSE" ;
return (false);
}else {
isnumeric = "true";
}


var checkStr ;
var validnum ;
validnum = "F"
checkStr = objName.value;
 for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch=="." && i!=0)
                       {
                        validnum = "T"                                 
                       }   
                 }   
				          
         if((validnum=="F") && (isnumeric == "false"))
         {
               alert(sAlertmess) ;
			   objName.focus();
			   SAbort = "FALSE" ;
			   return (false);             
         } 
         else
         {
         validnum = "F"
         }       
                 
return(true);
}


//************************************************
//***********************************************

function CheckDecimalPos(objName,sAlertmess)
{
	rateStr = objName.value;
	if (rateStr.indexOf(".") > -1) 
	{
		if (rateStr.indexOf(".") > 4)
			{
				alert(sAlertmess);
				SAbort = "FALSE" ;
				return(false);
			}
		else
			{
			 arrStr = rateStr.split(".");
			 alert(arrStr[1].length);
			 if (arrStr[1].length > 2) 
				{
					alert(sAlertmess);
					SAbort = "FALSE" ;
					return(false);
				}
			 if (arrStr[1].length == 0) 
				{
					alert(sAlertmess);
					SAbort = "FALSE" ;
					return(false);
				}
			}	
	}
                 
return(true);
}
//************************************************




function CheckConfirmPassword(objName1,objName2,passnum,sAlertmess)
{
// require at least passnum characters in the password field
//alert(SAbort) ;
if(SAbort == "FALSE")
{
return (false);
}


if (objName1.value.length < parseInt(passnum) || objName1.value.length == 0)
{
objName1.focus();
SAbort = "FALSE" ;
alert("Password Cannot Be less then " + passnum + "characters.");
return (false);
}

// check if both password fields are the same
if (objName1.value != objName2.value)
{
	alert(sAlertmess);
	objName2.focus();
        SAbort = "FALSE" ;
	return (false);
}
return(true);
}


//**********************************************************


function CheckDropdownbox(objName,sAlertmess) // use alert str so that it can b use forcompany //selectio,gender selection ,etc
{

if(SAbort == "FALSE")
{
return (false);
}

// check if no drop down has been selected
if (objName.selectedIndex == 0)
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false) ;
}
return (true) ;
}


//check for valid Email******************************************************

function CheckEmail(objName,sAlertmess){
	if(SAbort == "FALSE" || SAbort == "false"){
		return (false);
	}
	var FieldValue;
	FieldValue = objName.value;
	var RegExpres = /^['a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9._-]{2,8}$/;
	if(RegExpres.test(FieldValue)){
		//now check for two consecutive dots
		var bValid = true;
		for(i = 0; i < FieldValue.length; i++){
			//alert("FieldValue.length = " + FieldValue.length);
			if(FieldValue.charAt(i) == "."){
				if(FieldValue.charAt(i+1) == "."){
					bValid = false;
					break;
				}
			}
			if(FieldValue.charAt(i) == "@"){
				if(FieldValue.charAt(i+1) == "."){
					bValid = false;
					break;
				}
			}
		}
		if(bValid){
			if(FieldValue.charAt(0) == "." || FieldValue.charAt(0) == "@" || FieldValue.charAt(0) == "_" || FieldValue.charAt(0) == "-")
				bValid = false;
			else if(FieldValue.charAt(FieldValue.length - 1) == "."  || FieldValue.charAt(FieldValue.length - 1) == "@" || FieldValue.charAt(FieldValue.length - 1) == "_" || FieldValue.charAt(FieldValue.length - 1) == "-")
				bValid = false;
			else
				bValid = true;
		}
	}
	else{
			bValid = false;
	}
	if(! bValid)
	{
		alert("Email field is not entered correctly. \n" +"\nCorrect email Format:ValidName@ValidDomain.com");
		objName.focus();
		objName.select();
		SAbort = "FALSE" ;
		return false;
	}
	else
		return true;
}
//***************************Email Validation Over*********************
//************************************************************************

function CheckBirthdate(datefield,yeardiff,agelimit,sAlertmess) 
{
// to check whether date is entered or not in the field

if(SAbort == "FALSE")
{
return (false);
}
  

if (datefield.value == "")
{
alert("Enter Value In Date Field");
datefield.focus();
SAbort = "FALSE" ;
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789/";
var checkStr = datefield.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess) ;
datefield.focus();
SAbort = "FALSE" ;
return(false)    ;
}
     

//to check whether its of length 11(mm/dd/yyyy) and /'s are on 2nd  and 5th postion or not
var iPos ;
iPos = 0 ;
  if (checkStr.length != 10) 
       {
alert(sAlertmess) ;
          datefield.focus() ;
          SAbort = "FALSE" ;
		   return(false)    ;
       }      
     else//to find the positoins of /'s 
       {
         for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch=="/")
                       {
                         iPos = iPos + i   ;                        
                       }   
                 }            
       }
  //to check valid month day and year
	if(iPos==7) // Sinc 2 and 5 addition
           { 
              strDateArray = checkStr.split("/"); // to extract month,day,year

              
	      strMonth = strDateArray[0] ;
          strDay   = strDateArray[1] ; 
	      strYear  = strDateArray[2] ; 

                    if(strMonth<01 || strMonth>12)              
			{
			 alert(sAlertmess) ;
             datefield.focus() ;
			 SAbort = "FALSE" ;
	         return(false)    ;  
	        }
	        
		    if(strDay<01 || strDay>31)              
			{
			 alert(sAlertmess) ;
			 datefield.focus() ;
			 SAbort = "FALSE" ;
	  		 return(false)    ;
			}
                //to caluclate todays date so that we can validate for 100 yrs back for 		//valication and also it shd not b greater then 2days date..

                   var itoday = new Date(); 
                   var itodayfin = new Date();  
                   var stodayyear ;
                       // itoday = itoday.getYear() - yeardiff ;
                     //to calculate the present year
              
                     stodayyear = itoday.toString() ;
                     itodayyearlen = stodayyear.length - 4 ;
                     itoday1 =   stodayyear.substr(itodayyearlen, 4) ;  //present year        
                     yeardifffin =  parseInt(itoday1) - parseInt(strYear) ;  
		   
			               
                    if(yeardifffin>yeardiff || strYear>itoday1)//to check date is <year passed //diff and not greater then present year
			{
						 alert(sAlertmess) ;
                         datefield.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			}
                       else
                        {                      
            
                      //check the age whether its greater then 18 or not -----
                        var iAge ;                        
                        iAge =   itoday1  - parseInt(strYear )
                        alertsay = "Age is less Then " + agelimit + " Years";
                        if(iAge<agelimit)              
			{
			  alert(alertsay);
			  datefield.focus() ;
              SAbort = "FALSE" ;
	  		  return(false)    ;
			}

                        } 
           }
         else
           {
	   		 alert(sAlertmess) ;
             datefield.focus();
             SAbort = "FALSE" ;
	  		 return(false)    ;
           } 
return(true);
}


//**********************************************************************

function CheckDate(datefield,sAlertmess) 
{
// to check whether date is entered or not in the field

if(SAbort == "FALSE")
{
return (false);
}
  

if (datefield.value == "")
{
alert("Enter Value In Date Field");
datefield.focus();
SAbort = "FALSE" ;
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789/";
var checkStr = datefield.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess) ;
datefield.focus();
SAbort = "FALSE" ;
return(false)    ;
}
     

//to check whether its of length 11(mm/dd/yyyy) and /'s are on 2nd  and 5th postion or not
var iPos ;
iPos = 0 ;
  if (checkStr.length != 10) 
       {
          alert(sAlertmess) ;
          datefield.focus() ;
          SAbort = "FALSE" ;
		   return(false)    ;
       }      
     else//to find the positoins of /'s 
       {
         for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch=="/")
                       {
                         iPos = iPos + i   ;                        
                       }   
                 }            
       }
  //to check valid month day and year
	if(iPos==7) // Sinc 2 and 5 addition
           { 
              strDateArray = checkStr.split("/"); // to extract month,day,year

              
	      strMonth = strDateArray[0] ;
          strDay   = strDateArray[1] ; 
	      strYear  = strDateArray[2] ; 

          if(strMonth<01 || strMonth>12)              
			{
			 alert(sAlertmess) ;
             datefield.focus() ;
			 SAbort = "FALSE" ;
	         return(false)    ;  
	        }
		    if(strDay<01 || strDay>31)              
			{
			 alert(sAlertmess) ;
			 datefield.focus() ;
			 SAbort = "FALSE" ;
	  		 return(false)    ;
			}
                //to caluclate todays date so that we can validate for 100 yrs back for 		//valication and also it shd not b greater then 2days date..
                   var yeardiff ;
                   yeardiff = 100
                   var itoday = new Date(); 
                   var itodayfin = new Date();  
                   var stodayyear ;
                      // itoday = itoday.getYear() - yeardiff ;
                     //to calculate the present year
              
                     stodayyear = itoday.toString() ;
                     itodayyearlen = stodayyear.length - 4 ;
                     itoday1 =   stodayyear.substr(itodayyearlen, 4) ;  //present year        
                     yeardifffin =  itoday1 - strYear ;  
		             
			               
                    if(yeardifffin>yeardiff)//to check date is <year passed
			{
						 alert(sAlertmess) ;
                         datefield.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			}
                      
           }
         else
           {
	   	   alert(sAlertmess) ;
           datefield.focus();
           SAbort = "FALSE" ;
	  	   return(false)    ;
           } 
           
var iPoszero ; 
iPoszero= 0  ;          
           for (i = 0;  i < checkStr.length;  i++)
                {                 
                  ch = checkStr.charAt(i);
                    if(ch=="0")
                       {
                         iPoszero = iPoszero + 1   ;                        
                         //alert(iPoszero);
                       }                             
                 }            
                  
	   if(iPoszero==8) // Since 3 and 6 addition           
           {
 		     alert(sAlertmess) ;
             objName.focus() ;
             SAbort = "FALSE" ;
	         return(false)    ;
			}
                 
CheckDateNew(datefield,sAlertmess);
}




//*************************************************************************************

//to compare datefield1 shd greater then datefield2
function CompareDates(datefield1,datefield2,sAlertsay) 
{
// to check whether date is entered or not in the field

if(SAbort == "FALSE")
{
return (false);
}            

var sdatefield1 ;
var sdatefield2 ;
var idatefield1len ;
var idatefield2len ;
var idatefield1 ; 
var idatefield2 ; 
var valdatefield1 ; 
var valdatefield2 ; 
valdatefield2 = datefield2.value ;
valdatefield1 = datefield1.value ;

                     sdatefield1 = valdatefield1.toString() ;
                     sdatefield2 = valdatefield2.toString() ;
                     
                     //alert(sdatefield2);
                     
                     idatefield1len = sdatefield1.length - 4 ;
                     idatefield2len = sdatefield2.length - 4 ;
                      
                     // alert(idatefield2len);
                       
                     idatefield1 =   sdatefield1.substr(idatefield1len, 4) ;  //present year 
                     idatefield2 =   sdatefield2.substr(idatefield2len, 4) ;  //present year 
                             
                     //alert(idatefield2);
                     
		            // alert(parseInt(idatefield1)); 
		            // alert(parseInt(idatefield1)); 
			               
                    if(idatefield2<idatefield1)//to check date is <year passed
			{
						 alert(sAlertsay) ;
                         //datefield2.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			}
			
			else
			{
			if(idatefield2==idatefield1)//to check date is <month passed
			{
			var strDate1Array ;
			var strDate2Array ;
			
			var strMonth1 ; 
			var strMonth2 ;
			//alert(valdatefield1)  ;
			 
			strDate1Array = valdatefield1.split("/"); // to extract month,day,year
            strDate2Array = valdatefield2.split("/"); // to extract month,day,year  
              
            // alert(strDate1Array[0])  ;
             
            strMonth1 = strDate1Array[0] ;  
	        strMonth2 = strDate2Array[0] ;
	        
	         if(strMonth2<strMonth1)//to check date is < month passed
			{
						 alert(sAlertsay) ;
                         //datefield2.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			}
			else
			{	
			if(strMonth2==strMonth1)//to check date is < month passed
			{	
			strDay1   = strDate1Array[1] ;  
	        strDay2   = strDate2Array[1] ;	        
	         if(strDay2<strDay1)//to check date is < day passed
			{
						 alert(sAlertsay) ;
                         //datefield2.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			}
			}
			}	
			}//end of outer end if for month
			
            }//end of outer end if for year          
          
return(true);
}
//*******************************************************************

function CheckListbox(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}

// check if less than 1 options are selected
var numSelected = 0;
var i;
for (i = 0;  i < objName.length;  i++)
{
if (objName.options[i].selected)
numSelected++;
}

if (numSelected < 1)
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);
}

//**************************************************************
function CheckBlank(objName,sAlertmess)
{
//alert(SAbort);
if(SAbort == "FALSE")
{
return (false);
}

// require a value be entered in the field
if (objName.value == "")
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}

// require a value be entered in the field
if (objName.value == "")
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
var checkStr ;
checkStr = objName.value;
 for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch==" " && i==0)
                       {
                         alert("First Character Cannot Be Blank.") ;
						 objName.focus();
		    		     SAbort = "FALSE" ;
						 return (false);                      
                       }   
                 }            
       

return(true);
}

//*********************************************************
function CheckPhone(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}


var alertsay = ""; // define for long lines
// check to see if the field is blank

if (objName.value == "")
{
alert("Please Enter Value In Field");
objName.focus();
SAbort = "FALSE" ;
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789-";
var checkStr = objName.value;
var allValid = true;
var iPoszero ; 
iPoszero= 0 ;  

for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
else//check for valid phone number ..
{
//alert(checkStr.length);

var iPos ;
iPos = 0 ;
  if (checkStr.length != 12) 
       {
          alert(sAlertmess) ;
          objName.focus() ;
          SAbort = "FALSE" ;
		   return(false)    ;
       }      
     else//to find the positoins of -'s 
       {
         for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch=="-")
                       {
                         iPos = iPos + i   ;                        
                       }   
                       
                    if(ch=="0")
                       {
                         iPoszero = iPoszero + 1   ;                        
                         //alert(iPoszero);
                       }      
                 }      
                 
                   
                   
       }
		if(iPos!=10 || iPoszero==10) // Since 3 and 7 addition           
          {
 		     alert(sAlertmess) ;
             objName.focus() ;
             SAbort = "FALSE" ;
	          return(false)    ;
			}  
	
           
}
return(true);
}


//*********************************************************

//*********************************************************
function CheckCellPhone(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}


var alertsay = ""; // define for long lines
// check to see if the field is blank

if (objName.value == "")
{
alert("Please Enter Value In Field");
objName.focus();
SAbort = "FALSE" ;
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789.";
var checkStr = objName.value;
var allValid = true;
var iPoszero ; 
iPoszero= 0 ;  

for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
else//check for valid phone number ..
{
//alert(checkStr.length);

var iPos ;
iPos = 0 ;
  if (checkStr.length != 12) 
       {
          alert(sAlertmess) ;
          objName.focus() ;
          SAbort = "FALSE" ;
		   return(false)    ;
       }      
     else//to find the positoins of -'s 
       {
         for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch==".")
                       {
                         iPos = iPos + i   ;                        
                       }   
                       
                    if(ch=="0")
                       {
                         iPoszero = iPoszero + 1   ;                        
                         //alert(iPoszero);
                       }      
                 }      
                 
                   
                   
       }
		if(iPos!=10 || iPoszero==10) // Since 3 and 7 addition           
          {
 		     alert(sAlertmess) ;
             objName.focus() ;
             SAbort = "FALSE" ;
	          return(false)    ;
			}  
	
           
}
return(true);
}

//*********************************************************




function CheckFax(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}


var alertsay = ""; // define for long lines
// check to see if the field is blank

if (objName.value == "")
{
alert("Please Enter Value In Field");
objName.focus();
SAbort = "FALSE" ;
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789-";
var checkStr = objName.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
else//check for valid phone number ..
{
//alert(checkStr.length);

var iPos ;
iPos = 0 ;
  if (checkStr.length != 12) 
       {
          alert(sAlertmess) ;
          objName.focus() ;
          SAbort = "FALSE" ;
		   return(false)    ;
       }      
     else//to find the positoins of -'s 
       {
         for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch=="-")
                       {
                         iPos = iPos + i   ;                        
                       }   
                 }            
       }
 
	if(iPos!=10) // Since 3 and 7 addition           
          {
 		      alert(sAlertmess) ;
             objName.focus() ;
             SAbort = "FALSE" ;
	          return(false)    ;

			}
}
return(true);
}

//*********************************************************

function CheckSsn(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789-";
var checkStr = objName.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
else//check for valid Ssn number ..
{
//alert(checkStr.length);

var iPos ;
iPos = 0 ;
var sCheckzero ;
var iPoszero ;
iPoszero = 0 ;

  if (checkStr.length != 11) 
       {
          alert(sAlertmess) ;
          objName.focus() ;
          SAbort = "FALSE" ;
		  return(false)    ;
       }      
     else//to find the positoins of -'s 
       {
         for (i = 0;  i < checkStr.length;  i++)
                {
                  ch = checkStr.charAt(i);
                    if(ch=="-")
                       {
                         iPos = iPos + i   ;                        
                        // alert(iPos);
                       }   
                  ch = checkStr.charAt(i);
                    if(ch=="0")
                       {
                         iPoszero = iPoszero + 1   ;                        
                         //alert(iPoszero);
                       }                             
                 }            
       }
     //alert(iPos);
    
    sCheckzero =   checkStr.substr(4,2) ;  //to check middle 2 digits cannot b zero
    //alert(sCheckzero);
    
	if(iPos!=9 || iPoszero==9 ) // Since 3 and 6 addition           
          {
 		     alert(sAlertmess) ;
             objName.focus() ;
             SAbort = "FALSE" ;
	         return(false)    ;

			}
}
return(true);
}

//***********************************************************
function CheckMaxlength(objName,maxvalue,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}


// require a value be entered in the field
ilen = objName.value.length ;
//alert(ilen);
alertsay = "Maximum Length of " + sAlertmess + " is " + maxvalue + " .";
if (ilen > maxvalue)
{
alert(alertsay) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);
}



//***********************************************************
function CheckMinlength(objName,minvalue,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}



// require a value be entered in the field
ilen = objName.value.length ;
//alert(ilen);
alertsay = "Minium Length of " + sAlertmess + " is " + minvalue + " .";

//alertsay = "Minium Length is " + minvalue ;
if (ilen < minvalue)
{
alert(alertsay) ;
objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);
}


//***********************************************************
function CheckCheckbox(objName,sAlertmess)
{

 if(SAbort == "FALSE")
	{
	  return (false);
	}

 if(objName.checked==false)
   {
    alert(sAlertmess) ;
	objName.focus();
	SAbort = "FALSE" ;
	return (false);
   } 
	return(true);
}

//************************************************************
function CheckHigherdate(datefield1,sAlertmess)
{

if(SAbort == "FALSE")
	{
	  return (false);
	}

    var itoday = new Date(); 
    var stodayyear ;
      
   stodayyear = itoday.toString() ;
   itodayyearlen = stodayyear.length - 4 ;
   itoday1 =   stodayyear.substr(itodayyearlen, 4) ;  //present year      
   
   sidatefield1 = datefield1.value ;
   idatefield1len = sidatefield1.length - 4 ;
   idatefield1 =   sidatefield1.substr(idatefield1len, 4) ;  //field year      
   
   yeardifffin =   parseInt(idatefield1) - parseInt(itoday1) ;  		   
  alert(yeardifffin);
  if(yeardifffin<=-1) //to check date is < year passed //diff and not greater then present year
		{
           alert(sAlertmess) ;
	       datefield1.focus();
	       SAbort = "FALSE" ;
	       return (false);
        } 
    else
     {    
      //for checking month and date  
		if(yeardifffin==0)	// chk month and day only for the current year
		  {
			var strDate1Array ;
			var strDate2Array ;			
			var strMonth1 ; 
			var strMonth2 ;	
			var monthdiff ;
						
            strDate2Array = sidatefield1.split("/"); // to extract month,day              
            
			var strMonth1 = itoday.getMonth() + 1;          
	        var strMonth2 = strDate2Array[0] ;
	        
	        //alert(strMonth1);
	       // alert(strMonth2);
	        
	        monthdiff = strMonth2-strMonth1;
	        //alert(monthdiff);
	       
	         if(strMonth2 > strMonth1)//to check date is <month passed
			{
						 alert(sAlertmess) ;
                         datefield1.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			}
			else
			{
			var strDay1   = itoday.getDate();  
	        strDay2   = strDate2Array[1] ;
	        
	        var daydiff ;
	        daydiff = strDay2-strDay1 ;
	        
	       // alert(strDay1) ;
	       // alert(strDay2) ;
	       // alert(daydiff);
	       
	         
	         if(parseInt(monthdiff)==0)
	         {
	          if(strDay2 > strDay1)//to check date is <year passed
			     {
						 alert(sAlertmess) ;
                         datefield1.focus() ;
                         SAbort = "FALSE" ;
	  		 			 return(false)    ;
			      } 
			 }     
			}          
			
		 }	// inner else if
    }  //outer else if       
        
        return true ;

}

function intialise()
{

SAbort = "TRUE" ;
}

function CheckCarAllowance(objname)
{
//function to validate car allowance
var sCar,sCarPart1,sCarPart2
sCar=objname.value

if(sCar.indexOf(".") == -1)
{
	if(sCar.length > 3)
	{
		alert("Invalid format of Car allowance.")
		return false;
	}
}
else
{
	sCarPart1=sCar.substr(0,sCar.indexOf("."))
	if(sCarPart1.length > 3)
	{
		alert("Invalid format of Car allowance.")
		return false;
	}
	
	sCarPart2 = sCar.substr(sCar.indexOf(".") + 1,sCar.length)
	if(sCarPart2.length > 2)
	{
		alert("Invalid format of Car allowance.")
		return false;
	}	
}
return true;
}


//********************************************************************
//Check Email which is not in field but hidden

function CheckStrEmail(objName,sAlertmess)
 {

if(SAbort == "FALSE")
{
return (false);
}
   Ctrl = objName.value ;
   
  
   if (Ctrl == "" || Ctrl.indexOf ('@', 0) == -1 || Ctrl.indexOf ('.', 0) == -1 || Ctrl.indexOf (',', 0) >= 0 ||  Ctrl.indexOf ('?', 0) >= 0 || Ctrl.indexOf ('#', 0) >= 0 || Ctrl.indexOf ('$', 0) >= 0 || Ctrl.indexOf ('%', 0) >= 0 || Ctrl.indexOf ('^', 0) >= 0 || Ctrl.indexOf ('~', 0) >= 0 || Ctrl.indexOf ('!', 0) >= 0 || Ctrl.indexOf ('`', 0) >= 0 || Ctrl.indexOf ('&', 0) >= 0 || Ctrl.indexOf ('*', 0) >= 0 || Ctrl.indexOf ('(', 0) >= 0 || Ctrl.indexOf (')', 0) >= 0 || Ctrl.indexOf ('<', 0) >= 0 || Ctrl.indexOf ('>', 0) >= 0 || Ctrl.indexOf ('+', 0) >= 0)
    {
   // p = Ctrl.indexOf (',', 0) ;
   //alert(p);
      alert(sAlertmess) ;
      //objName.focus();
      SAbort = "FALSE" ;
      return (false);   
   } 
   
      var EmailOk  = true ;
	  var Temp     = objName ;
      var AtSym    = Temp.value.indexOf('@') ;
      var period1  = Temp.value.indexOf('.');
      var Period   = Temp.value.lastIndexOf('.') ;
      var Space    = Temp.value.indexOf(' ') ;
      var Length   = Temp.value.length - 1 ;  // Array is from 0 to length-1

if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (period1 < 1) ||
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
    //  EmailOk = false
     alert(sAlertmess) ;
     //objName.focus() ;
     SAbort = "FALSE" ;
     return (false);
     a=1;

   }
     
   
      return (true);
} 

//End of Checkin ***************************************************


function CheckTaskProject(objName,sAlertmess)
{
if(SAbort == "FALSE")
{
return (false) ;
}

// this can be altered for any "checkOK" string you desire

var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz &()*-,./\"";
var checkStr = objName.value;

var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);

objName.focus();
SAbort = "FALSE" ;
return (false);
}
return(true);

}

/*****************************************************************/
//For Hours In Number Only

function CheckNumericHours(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789";
var checkStr = objName.value;
var allValid = true;
//if(checkStr=="0"){
//	return false;	
//}

for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);
objName.focus();
SAbort = "FALSE" ;
return (false);
}

return(true);
}


//********************************************************************
function CheckDateNew(datefield,sAlertmess){
	var bValid;
	var sAllowed = "1234567890/"
	if(SAbort == "FALSE"){
		return (false);
	}
		
	for(var i=0;i<datefield.value.length;i++){
		if(sAllowed.indexOf(datefield.value.charAt(i)) == -1){
			alert(sAlertmess) ;
			datefield.select();
			datefield.focus();
			SAbort = "FALSE" ;
			return(false);
		}
	}

	var strDate = datefield.value.split("/");
	bValid = 1;
	
	//if date format is " / / " its ok then
	//split date on "/" to get dd,mm and yyyy sperated
	//this will create a array of three elements where:
	//strDate[0] = MM, strDate[1] = DD, strDate[2] = "YYYY"
	
	var sMM,sDD,sYYYY;
	if(datefield.value.indexOf(" ") == -1){
		//if array has three elements i.e " / / " format is correct. check further
		if(strDate.length == 3){
			sMM=strDate[0];
			sDD=strDate[1];
			sYYYY=strDate[2];
			
			//if all elements in array are numbers i.e. "#/#/#" format is correct. check further
			if(! (isNaN(sMM) || isNaN(sDD) || isNaN(sYYYY)) )	{
				while(sMM.substr(0,1) == "0")
					sMM = sMM.substr(1,sMM.length);
				while(sDD.substr(0,1) == "0")
					sDD = sDD.substr(1,sDD.length);
				while(sYYYY.substr(0,1) == "0")
					sYYYY = sYYYY.substr(1,sYYYY.length);
				
				//if MM is between 1 - 12 i.e. "MM/#/#" is correct. check further			
				if(parseInt(sMM) >=1 && parseInt(sMM) <=12){
					var sToday = new Date();
				
					//if YYYY is between curren year + - 100 i.e "MM/#/YYYY" format is correct. check further
					if(parseInt(sYYYY) >= eval(sToday.getFullYear()-100) 
					&& parseInt(sYYYY) <= eval(sToday.getFullYear()+100)){
	
						//if DD is between 1 - Last day of MM/YYYY i.e "MM/DD/YYYY" format is correct. return true
						if(parseInt(sDD) >= 1 && parseInt(sDD) <= getMaxDays(parseInt(sMM),parseInt(sYYYY))){
							return (true);
						}
						
					}
				}
			}
		}
	}
	if(datefield.value != ""){
		//if any of the above check fails return false
		alert(sAlertmess) ;
		datefield.select();
		datefield.focus();
		SAbort = "FALSE" ;
		return(false);
	}
}



function getMaxDays(iMonth,iYear){
	switch(iMonth){
		case 4:
		case 6:
		case 9:
		case 11:
			return(30);
		case 2:
			if(iYear % 100 == 0 || iYear % 4 == 0 || iYear % 400 == 0)
				return(29);
			else
				return(28);
	}
	return(31);	
}



function checkValidDate(iDay,iMonth,iYear) {


		var dd = parseInt(iDay,10);
		var mm = parseInt(iMonth,10);
		var yy = parseInt(iYear,10);
		var indexMon = mm;
		var indexDate = dd;
		//alert("dd=" + dd + "mm=" + mm +  "yy=" + yy)
		if (dd==0 || mm==0 || yy==0 || yy=="" || isNaN(yy)){
			return ("Invalid Date");
		}
		
		if (iYear.length < 4) {
			return ("Please Enter Year in long format i.e YYYY");
		}
		
		if (indexMon==1 && (indexDate<1 ||indexDate>31)) {
 
		     return ("january has 31 days"); 
		
		}else if (indexMon==2 && (indexDate<1 ||indexDate>28)) {
			  if (indexDate==29){
				 //alert("Check for Leap Year")
				 var iFirstTwo =  parseInt(iYear.substring(0,2),10)
				 var iLastTwo = parseInt(iYear.substring(2,4),10)
				 //alert("Remainder" + (iFirstTwo % 4))				 
				 if ((yy%4) == 0) {
					if ((iLastTwo == 0) && (iFirstTwo % 4 != 0)){
						return (iYear + " is Not a Leap Year")
					}	
				 }else{
					return (iYear + " is Not a Leap Year")
				 }

			  }else{
				 return ("february has maximum of 29 days")
			  }

		}else if (indexMon==3 && (indexDate<1 ||indexDate>31)){

		     return("march has 31 days"); 
		 
		}else if (indexMon==4 && (indexDate<1 ||indexDate>30)) {

		     return("april has 30 days"); 
 
		}else if (indexMon==5 && (indexDate<1 ||indexDate>31)) {
 
		    return ("may has 31 days"); 
		
		}else if (indexMon==6 && (indexDate<1 ||indexDate>30)) {

		   return ("june has 30 days"); 
		
		}else if (indexMon==7 && (indexDate<1 ||indexDate>31)) {
		
		   return ("july has 31 days"); 
		
		}else if (indexMon==8 && (indexDate<1 ||indexDate>31)) {
		  
		   return("august has 31 days"); 

		}else if (indexMon==9 && (indexDate<1 ||indexDate>30)) {
		
		   return ("September has 30 days"); 
		
		}else if (indexMon==10 && (indexDate<1 ||indexDate>31)){

		   return ("October has 31 days"); 
 
		}else if (indexMon==11 && (indexDate<1 ||indexDate>30)) {

		   return ("November has 30 days"); 
 
		}else if (indexMon==12 && (indexDate<1 ||indexDate>31)) {

		   return ("December has 31 days"); 
		}
 		
		return("");    	
		
			
}

function CheckEID_Web_Name(objName,objName1,sAlertmess,sAlertmess2)
{
	 var sAlertmess2;
	 var EID = objName.value;
	 var webName = objName1.value;
	 var indexedEID1 = EID.indexOf("@");
	 var indexedEID2 = EID.indexOf(".");
	 var forCheckingEID = EID.substring(indexedEID1+1,indexedEID2);
//	 var forCheckingEID = EID.substring(indexedEID+1,EID.length);
	
	var indexedWeb = webName.indexOf("www.");
	var wo_indexedWeb = webName.substring(indexedWeb+4,webName.length)
	var indexedWeb2 = wo_indexedWeb.indexOf(".");
	var forCheckingWEB = wo_indexedWeb.substring(0,indexedWeb2);

//	var dot = ".";
//	var wwwWeb = webName.search(/www/);
//	var dotWeb = webName.search(/./);
//	if(dotWeb != -1)
//	{
// 		alert(dotWeb);
//	}
 


	 var freewebName = new Array(10);
	 freewebName[0] = "yahoo";
	 freewebName[1] = "hotmail";
	 freewebName[2] = "msn";
	 freewebName[3] = "gmail";
	 freewebName[4] = "rediff";
	 freewebName[5] = "yahoo";
	 freewebName[6] = "yahoomail";
	 freewebName[7] = "yahoo";
	 freewebName[8] = "yahoo";
	 freewebName[9] = "yahoo";

	if(SAbort == "FALSE")
	{
		return (false);
	}	

	 if(webName == "")
	 {
		alert("Please Enter the Website Name...");
		objName1.focus();
		SAbort = "FALSE" ;
		return(false);		
	 }	
	 if(indexedWeb == -1 || indexedWeb != 0)
	 {
		alert("Please Enter the right Website Name...\n"+""+"\nLike:  www.yourwebname.com");
		objName1.focus();
		SAbort = "FALSE" ;
		return(false);		
	 }	
	 if(forCheckingEID != forCheckingWEB)
	 {
		alert(sAlertmess);
		objName.focus();
		SAbort = "FALSE" ;
		return(false);		
	 }
	 if(forCheckingEID == forCheckingWEB)
	 {
		for(i=0;i<=10;i++)
		{
			if(forCheckingEID == freewebName[i])
			{
				alert(sAlertmess2);
				objName.focus();
				SAbort = "FALSE" ;
				return(false);		
			}
		}
	 }
	return(true);
}

function checkSpecial(objName,sAlertmess)
{
if(SAbort == "FALSE")
{
	return (false);
}
var checker = objName.value;
//for(i=0;i<objName.length;i++)
//{
if(checker.indexOf("/") != -1) 
{
	alert(sAlertmess);
	objName.focus();
	SAbort = "FALSE" ;
	return(false);		
}
else
{
	return true;
}
}

function checkSpecial2(objName,sAlertmess)
{
if(SAbort == "FALSE")
{
	return (false);
}
var checker = objName.value;
//for(i=0;i<objName.length;i++)
//{
if(checker.indexOf("|") != -1) 
{
	alert(sAlertmess);
	objName.focus();
	SAbort = "FALSE" ;
	return(false);		
}
else
{
	return true;
}
}

function CheckMyPhone(objName,sAlertmess)
{

if(SAbort == "FALSE")
{
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
var checkOK = "0123456789+()";
var checkStr = objName.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(sAlertmess);
objName.focus();
SAbort = "FALSE" ;
return (false);
}

return(true);
}


function CheckWeb_Name(objName)
{
 var webName = objName.value;
 var indexedWeb = webName.indexOf("www.");
 var wo_indexedWeb = webName.substring(indexedWeb+4,webName.length)
 var indexedWeb2 = wo_indexedWeb.indexOf(".");
 var forCheckingWEB = wo_indexedWeb.substring(0,indexedWeb2);

if(SAbort == "FALSE")
{
	return (false);
}
if(indexedWeb == -1 || indexedWeb != 0)
{
	alert("Please Enter the right Website Name...\n"+""+"\nLike:  www.yourwebname.com");
	objName.focus();
	SAbort = "FALSE" ;
	return(false);		
 }	
return(true);
}

/*
function CheckHigherdate1(datefield1,sAlertmess)
{
	var startday,startdate,startmon,startyear,flag1,flag2,flag3;
	var curday,curdate,curmon,curyear;
	var curdate=Date();
	if (curdate.length==9)
	{
		curdate="0"+today;
	}
	alert(curdate)
	curmon=curdate.substring(0,2);
	curday=curdate.substring(3,5);
	curyear=curdate.substring(6,10);
	
	startdate=datefield1.value;
	startmon=startdate.substring(0,2);
	startday=startdate.substring(3,5);
	startyear=startdate.substring(6,10);
	
	alert('cur: '+curday+'/'+curmon+'/'+curyear+'   Start: '+startday+'/'+startmon+'/'+startyear)
	if (parseInt(startyear)>parseInt(curyear))
	{
		flag1=1;
	}
	else if (parseInt(startyear)==parseInt(curyear))
	{	
		if (parseInt(startmon)>parseInt(curmon))
		{
			flag2=1;
		}
		else if (parseInt(startmon)==parseInt(curmon))
		{
			if (parseInt(startday)>parseInt(curday))
			{
				flag3=1	;
			}
		}
	}
		
	if(flag1==1 || flag2==1 || flag3==1)
	{
		return true;	
	}
	alert(sAlertmess) 
	datefield1.focus()
	SAbort = "FALSE" ;
	return (false);
}

*/

function CheckHigherdate1(datefield1,sAlertmess)
{
	if(SAbort == "FALSE")
	{
		return (false);
	}
	var startday,startdate,startmon,startyear,flag1,flag2,flag3;
	var today=new Date();
	flag1=0;
	flag2=0;
	flag3=0;
	startdate=datefield1.value;
	startmon=startdate.substring(0,2);
	startday=startdate.substring(3,5);
	startyear=startdate.substring(6,10);
	
	//alert('Start: '+startday+'/'+startmon+'/'+startyear)
	//alert(startday)
	//alert(parseInt(startday,10))

	if (parseInt(startyear,10)>today.getFullYear())
	{
		flag1=1;
	}
	else if (parseInt(startyear,10)==today.getFullYear())
	{	
		if (parseInt(startmon,10)>today.getMonth()+1)
		{
			flag2=1;
		}
		else if (parseInt(startmon,10)==today.getMonth()+1)
		{
			if (parseInt(startday,10)>=today.getDate())
			{
				flag3=1	;
			}
		}
	}

	//alert(parseInt(startyear,10)+':'+today.getFullYear())
	//alert(flag1+':'+flag2+':'+flag3)		
	if(flag1!=1 && flag2!=1 && flag3!=1)
	{
		alert(sAlertmess) 
		datefield1.focus()
		SAbort = "FALSE" ;
		return (false);
	}
	return true;	
}
