 function fnValidateSearchParams()
 {
	var lstrRefString="AD0123456789";
	var lstrInString = astrFieldValue;
	if (lstrInString.length != 0)	
	{
		for (Count=0; Count < lstrInString.length; Count++)
		{
			if (lstrRefString.indexOf(lstrInString.substring (Count, Count+1)) == -1)
			{
				alert("Please enter a valid "+astrFieldName+".");
				return(false);
			}
		}
		return(true);
	}
    return(true);
 }




function fnDownload()
 {
	
	window.open('TCS Employment Appliaction Form.zip');

 }


 function fnReset(myform)
 {
	var answer = confirm("Clicking OK will clear all the values!Do you want to proceed?")
	if (answer)
	{
		myform.reset();
	}
	return false;
 }

	
function checkEmail(myForm){
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm)){
		return (true) ;
	}
	return (false) ;
}//checkEmail()




function isPositiveInteger(inpString){
	//check for negative sign
	if( inpString.indexOf("-") != -1){
		return false; 
	}
	var inpStrLen = inpString.length;
	for(var i = 0 ; i < inpStrLen; i++){
		if( isNaN(parseInt(inpString.charAt(i)))){
			//the input string contains alphabet or special charcters 
			return false;
		}
	}//for
	return true;//valid integer hence return true
}//end of isPositiveInteger

function fnCheckSelected(astrFieldValue,astrFieldName)
{
	
	if (fnStripSpaces(astrFieldValue) == "-1") 
	{
		alert("Please enter "+astrFieldName+".");
		return false;
	}
	else 
	{
		return true;
	}	
}

function validateForNo(aStr) {
	len = aStr.length;
	for(ch=0; ch < len; ch++) {
		if(aStr.charAt(ch) == '.') {
			continue; 
		}//if

		if( isNaN(parseInt(aStr.charAt(ch))) ) {
			return true;
		}//if
	}//for
	return false;
}//validateForNo()


function fnStripSpaces (astrString)  {		      
	var astrOutString;
	var astrTempChar;
	astrOutString="";
	for ( Count=0 ; Count < astrString.length ; Count++ ) {
		astrTempChar=astrString.substring (Count, Count+1);
		if ( astrTempChar != " " )
			astrOutString=astrOutString+astrTempChar;
	}//for

	return (astrOutString);
}//fnStripSpaces ()




function fnCheckNull(astrFieldValue,astrFieldName)
{
	
	if (fnStripSpaces(astrFieldValue) == "") 
	{
		alert("Please enter "+astrFieldName+".");
		return false;
	}
	else 
	{
		return true;
	}	
}
function fnCheckDropDown(astrFieldValue,astrFieldName)
{
	if (astrFieldValue == -1) 
	{
		alert( "Please select a " + astrFieldName+"." );
		return false;
	}
	else 
	{
		return true;
	}	
}

function fnCheckName(astrFieldValue,astrFieldName)
{		      
	return fnCheckAlphabeticHypAposSpace(astrFieldValue,astrFieldName);
}
function fnCheckAlphabeticHypAposSpace(astrFieldValue,astrFieldName)
{
	var lstrRefString="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-.";
	var lstrInString = astrFieldValue;
	if (lstrInString.length != 0)	
	{
		for (Count=0; Count < lstrInString.length; Count++)
		{
			if (lstrRefString.indexOf(lstrInString.substring (Count, Count+1)) == -1)
			{
				alert("Please enter a valid "+astrFieldName+".");
				return(false);
			}
		}
		return(true);
	}
return(true);
}
function fnCheckAgentCode(astrFieldValue,astrFieldName)
{
	var lstrRefString="0123456789";
	var lstrInString = astrFieldValue;
	if (lstrInString.length != 0)	
	{
		for (Count=0; Count < lstrInString.length; Count++)
		{
			if (lstrRefString.indexOf(lstrInString.substring (Count, Count+1)) == -1)
			{
				alert("Please enter a valid "+astrFieldName+".");
				return(false);
			}
		}
		return(true);
	}
return(true);
}
function fnCheckYear(lYear,lFieldName)
{
	if(isNaN(lYear.value))
	{
		alert("Please enter a valid "+lFieldName+".");
		lYear.select();
		lYear.focus();
		return false;
	}
	var curYear = new Date().getYear();
	 if(navigator.appName == "Netscape")
        	{
        	curYear = curYear + 1900;
        	}
	if(lYear.value < 1950 || lYear.value > curYear)
	{
		alert("Please enter a valid "+lFieldName+".");
		lYear.select();
		lYear.focus();
	    return false;
	}
 return true;
}

function fnValidDate(lDay,lMonth,lYear)
{
	var day = lDay.value;
	var mon = lMonth.value;
	var year = lYear.value;
  	if( isNaN(day) || isNaN(mon) || isNaN(year))
	{
		alert("Enter only numeric value for date");
		if (isNaN(day)) 	{	lDay.select();lDay.focus(); }
		if (isNaN(mon)) {	lMonth.select();lMonth.focus(); }
		if (isNaN(year)) 	{	lYear.select();lYear.focus(); }		
		return false;
	} 
		if (day < 1 || day > 31)
		{
		    alert("Please enter a valid Day.");
			lDay.select();lDay.focus();
			return false;
	
		}
		if (mon < 1 || mon > 12)
		{
		    alert("Please enter a valid Month.");
			lMonth.select();lMonth.focus();
			return false;
		}
		 
		if (year < 1900)
		{
	        alert("Please enter a valid Year.");
			lYear.select();lYear.focus();
			return false;
		}
						
		if ((mon == 4) || (mon == 6) || (mon == 9) || (mon == 11))
		{
				if (day == 31) 
				{
		            alert("Please enter a valid Month.");
			        lMonth.select();lMonth.focus();
					return false;
				}
		}

    if (mon == 2)
		{
		
			var lpYear = parseInt(year/4);
				
			if (isNaN(lpYear))
			{
		       alert("Please enter a valid Year.");
			   lYear.select();lYear.focus();
			   return false;
				
			}
			if (day >29)
			{
		      	alert("Please enter a valid Day.");
			    lDay.select();lDay.focus();
				return false;
				
			}
				
			if ((day == 29) && ( (year/4) != parseInt(year/4) )) 
			{
	      	    alert("Please enter a valid Day.");
			    lDay.select();lDay.focus();
				return false;
			}
				
			if ((day == 29) && ( (year%100) == 0) && ( (year%400) != 0 )) 
			{
	      	    alert("Please enter a valid Day.");
			    lDay.select();lDay.focus();
				return false;
			}
				
		}
		
	return true; 
}


function fnCheckPassport(inVal){
   var  valPassport=fnStripSpaces(inVal);
   
   if(valPassport.length ==0) return true;

      if( valPassport.length >0 && valPassport.length<8){
	    alert("Please enter your 'Passport Number' in the format 'A9999999'");
		return false;
   }else if(!fnValidatePassport(inVal)){
        return false;
   }
   if(!fnCheckPaasportInvalid(inVal)) return false;

return true;
}
 
function fnValidatePassport(lstrInString)
{
	var lstrRefString="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var istRefNum='0123456789';
 	var space=' ';
	var numFlag=0;
	if (lstrInString.length >0)	
	{
		

		if (lstrRefString.indexOf(lstrInString.substring (0,1)) == -1)	{
				alert("Please enter your 'Passport Number' in the format 'A9999999'");
				return(false);
			}

		  		
		for (Count=1; Count < lstrInString.length; Count++)
		{
			if(space.indexOf(lstrInString.substring (Count, Count+1)) != -1){
				alert("Please enter your 'Passport Number' in the format 'A9999999'");
				return false;
			}
 			if (istRefNum.indexOf(lstrInString.substring (Count, Count+1)) == -1)	{
				alert("Please enter your 'Passport Number' in the format 'A9999999'");
				return(false);
			}
			if(istRefNum.indexOf(lstrInString.substring (Count, Count+1))!=-1){
				numFlag=1;
			}
		}
 	}
	if(numFlag==0){
		alert("Please enter your 'Passport Number' in the format 'A9999999'");
        return false;
	}
return(true);
} 
/************/
function fnCheckPaasportInvalid(lstrInString){
 	var removePassVal  =new Array("NOT AVAILABLE", "AVAILABLE","AWAITED","APPLIED FOR","APPLIED","NONE","APPLY","EXPECT","APPLICABLE","WAITING","FORGOT","READY","RECEIVE","KNOW","RETURN","REME","PRESENT","EXPIRED","HAVE","VALID","INDIAN","ISSUE","EXIST","LATER","HOLD");
	var len = removePassVal.length;
 	var passFlag = false;
 	if(null != lstrInString && !lstrInString==""){
		lstrInString= lstrInString.toUpperCase();
		for(var i=0; i<len; i++){
  				if(lstrInString.indexOf(removePassVal[i]) != -1){
 					passFlag = true;
					break;
				}
			}
			if(passFlag){
				alert("Please enter your 'Passport Number' in the format 'A9999999'");
				return false;
			}
		}

		return true;
	 
} 

 //***********************************************************************
//Function Name : fnCheckInteger
//Author			: TCS
//Date				: 10th May, 2000
//Input			: Field value, Field name
//Output			: Returns true if valid integer else false
//Purpose		: Checks if the field is valid integer or not
//***********************************************************************

function fnCheckInteger(astrFieldValue,astrFieldName)
{
	var RefString="1234567890";
	var InString = astrFieldValue;	

	//check only the characters present in RefString are entered

	for (Count=0; Count < InString.length; Count++)  
	{			
        if (RefString.indexOf (InString.substring (Count, Count+1))==-1)  
		{
				//alert(astrFieldName + " should be numeric");
				alert('Please enter valid '+astrFieldName+'.');
				return (false);
		}
     }
     return true;
}


	
