﻿// JScript File
// Added By Satish Chandra
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
	function fnGetKeyCode(e)
	{
		return (navigator.appName=="Netscape") ? e.which : event.keyCode;
	}
	
	function isPBSpecialChars(strValue, e)
	{
		var n = fnGetKeyCode(e);
		if(fnValidateCommonKeys(n))
			return true;		
		if ((strValue.length == 0) && (n == 32))
			return false;
		if(strValue.length >=1)
		{
			if(n == 45 && strValue.substring(strValue.length -1, strValue.length) == "-")
				return false;
		}
		if (n == 37 || n == 34 || n == 42 || n == 59 || n == 60 || n == 62 || n == 35 || n == 124 || n == 43 || n == 38 || n == 39)
			return false;
		return true;
	}
	function fnValidateCommonKeys(keyCode)	
    {
	    if ((keyCode == 8) || (keyCode == 9) || (keyCode == 0))
		    return true;
	    else
	        return false;

	    return true;
    }
function fnAlphabetRestict(e)
{
	var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122)|| code==32)
	{ 
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphabates Allowed !");		
		return (checknos);        }
}
function fnNotAlphabet(e)
{
    
    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;        
    
    //Code Explanation{ 0-9, 45=Insert, 13=Enter, 08=Backspace, 09=Tab}
    if ((code >= 48 && code <= 57)||(code == 13 || code == 08 || code == 09)) 
    { 
        checknos = true;
	    return (checknos);
    }
    else
    {
	    checknos= false;
	    alert("Only Number Allowed !");	
	    return (checknos);
    }
}

function fnNumeric(e)
{
    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;        
    
    //Code Explanation{ 0-9, 45=Insert, 13=Enter, 08=Backspace, 09=Tab}
    if (code >= 48 && code <= 57) 
    { 
        checknos = true;
	    return (checknos);
    }
    else
    {
	    checknos= false;
	    alert("Only Number Allowed !");	
	    return (checknos);
    }
}

// Added By Satish

// allow 0-9,A-Z,a-z,'/\,-.'  and space. 

function fnAlphabatesValid(e)
{
	var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;
	if ((code >= 48 && code <= 57) || (code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code>= 44 && code<=47)|| code==92 || code==8 || code==17 || code==127 || code==9 || code==16 || code==32 || code==41 || code==38 || code==39 || code==40)
	{ 
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphabates Allowed !");		
		return (checknos);        
    }
}

// Allow Alphabates
function fnAlphabet(e)
{
	var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;
	//alert(code);
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122)|| code==8 || code==17 || code==127 || code==9 || code==16 || code==32 )
	{ 
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphabates Allowed !");		
		return (checknos);        }
}

function fnAlphabetAndNumericWithSpace(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	//alert(code);
	
	
	if(e.shiftKey)
	{
	    //alert("Shift + "+code);
	    if ((code >= 65 && code <= 90) )
	    { 
		    checknos = true;
		    return (checknos);
	    }
	    else
	    {
		    checknos= false;
		    alert("Special characters are not allowed!");
		    return (checknos);
	    }    
	}
	else
	{
	
    //if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || code==32 || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==37 || code==38 || code==39 || code==40)		
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) ||(code == 32)||(code == 8)||(code == 37)||(code ==39)||(code == 36)||(code == 40)||(code == 35))
	{ 
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphabates Allowed !");		
		return (checknos);    
		}
}
}

function fnCarAlphabetwithSpace(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || code==32 || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==40 || code==41)		
	{ 
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphabates Allowed !");		
		return (checknos);        }
}
function fnMemberidValidation(e)
	{
		var n = (navigator.appName=="Netscape") ? e.which : event.keyCode;
		if(fnValidateCommonKeys(n))
			return true;		
		if(!((n>=65 && n<=90)||(n>=97 && n<=122)||(n>=48 && n<=57)||(n==32)|| (n == 45)))
		{
		    alert("Only Alphanumeric with space Allowed!");
			return false;
		}
		return true;
	}

function fnCarAddressValid(e)
{
    var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	
	if(e.shiftKey)
	{
	    //alert("Shift + "+code);
	    if ((code >= 65 && code <= 90) || code==35 || code==38 || code==58 ||code==37  )
	    { 
		    checknos = true;
		    return (checknos);
	    }
	    else
	    {
		    checknos= false;
		    alert("Special characters are not allowed!");
		    return (checknos);
	    }    
	}
	else
	{
	    //alert(code);
	    if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code >= 48 && code <= 57) || (code==13) || code==32 || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==37 || code==38 || code==39 ||  code==47 || code==92 || code==35 || code==44|| code==45 || code==40 || code==41 || code==36)
	    { 
		checknos = true;
		return (checknos);
	    }
	    else
	    {
		checknos= false;
		alert("Special characters are not allowed!");
		return (checknos);
	    }    
	}
}
function fnCarAlphanumeric(e)
{
    var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;

    if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) ||(code >= 48 && code <= 57))
    {
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphanumeric without space Allowed !");		
		return (checknos);      
    }
}
function fnAddressValid(e)
{
    var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
//	alert(code);
//	return true;
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122)||(code >= 37 && code <= 40)|| (code >= 48 && code <= 57)|| (code >= 44 && code <= 47) ||(code == 32) ||(code == 35) ||(code == 38) ||(code == 58)||(code == 64) || (code == 13) || (code == 08) || (code == 09))
	{ 
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Invalid character in address !");		
		return (checknos);      
    }
}
function fnAlphabetwithSpace(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	
	
    
    if(e.shiftKey)
	{
	
	    if ((code >= 65 && code <= 90) )
	    { 
		    checknos = true;
		    return (checknos);
	    }
	    else
	    {
		    checknos= false;
		    alert("Special characters are not allowed!");
		    return (checknos);
	    }    
	}
    else if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || code==32 || code==8 ||code==127 || code==9 || code==16 || code==37 ||code==39 || code==35 || code==36 || code==58 || code==46)		
	{ 
	
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;			
		alert("Only Alphabates Allowed !");		
		return (checknos);        }
}

function fnAlplhaNumericOnly(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	//alert(code);
	if(e.shiftKey)
	{
	    //alert("Shift + "+code);
	    if ((code >= 65 && code <= 90) || code==35 || code==38 || code==58 ||code==37  )
	    { 
		    checknos = true;
		    return (checknos);
	    }
	    else
	    {
		    checknos= false;
		    alert("Special characters are not allowed!");
		    return (checknos);
	    }    
	}
	else
	{
	    //alert(code);
	    if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code >= 48 && code <= 57) || (code==13) || code==32 || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==37 || code==38 || code==39 ||  code==47 || code==92 || code==35 || code==44|| code==45 || code==40 || code==41 || code==36)
	    { 
		checknos = true;
		return (checknos);
	    }
	    else
	    {
		checknos= false;
		alert("Special characters are not allowed!");
		return (checknos);
	    }    
	}
}


function fnAlplhaNumericOnlyWithoutSpeChar(e)
{

	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	
	if(e.shiftKey)
	{
	    //alert("Shift + "+code);
	    if ((code >= 65 && code <= 90) )
	    { 
		    checknos = true;
		    return (checknos);
	    }
	    else
	    {
		    checknos= false;
		    alert("Special characters are not allowed!");
		    return (checknos);
	    }    
	}
	else
	{
	
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code >= 48 && code <= 57) || code==8 || code==35 || code==36 || code==37 || code==39 )
	
	{ 
		checknos = true;
		return (checknos);
	}
	
	else
	{
		checknos= false;
		alert("Only Alphanumeric Allowed !");
		return (checknos);
	}
	}
}


function validatePanCard(id1)
{
//    if (document.getElementById(id1).value=="") 
//      {      
//        return false;
//      }     
//     //var emailPat =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
//     var PanPat = /^\[A-Z]{5}\d{4}[A-Z]{1}$/;
//     var PanNumber=document.getElementById(id1).value;
//     var matchArray = PanNumber.match(PanPat);     
//     if (matchArray == null)
//        {        
//          //alert("Please check your e-mail address. It is incorrect");
//          document.getElementById(id1).focus();
//          return false;
//        }     
//    return true;
}

//Pan Card Validation. Added by Satish Chandra
function PANValidation(pno)
 {
    var regex1=/^[A-Z]{5}\d{4}[A-Z]{1}$/;  
    //this is the pattern of regular expersion
    
    if(regex1.test(pno)== false)
    {  
        return false;
     }
     else
     {
        return true;
     }
 }
 
function fnPancard(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	
//	alert(code);

    if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code >= 48 && code <= 57))
	{ 	
//	alert(code);
		checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;
		alert("Only Alphanumeric Allowed !");
		return (checknos);
	}
}

function fnAlplhaNumericOnlyWithoutSpace(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	//alert(code);
	if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code >= 48 && code <= 57) || (code==13) || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==37 || code==38 || code==39 || code==40 || code==47 || code==92)
	
	{ 
		checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;
		alert("Only Alphanumeric Allowed !");
		return (checknos);
	}
}

function emailValid(id1) //function to validate Email format
{
    if (document.getElementById(id1).value=="") 
      {      
        return false;
      }     
     var emailPat =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
     var emailid=document.getElementById(id1).value;
     var matchArray = emailid.match(emailPat);     
     if (matchArray == null)
        {        
          //alert("Please check your e-mail address. It is incorrect");
          document.getElementById(id1).focus();
          return false;
        }     
        
    var source=document.getElementById(id1).value;
    var ext=source.substring(source.lastIndexOf("@")+1);
        
    var digits="(~`!#$%^&*_+|-=}{'?/)";
    var temp;
    for (var i=0;i<ext.length;i++)
    {
       temp=ext.substring(i,i+1);
       if (digits.indexOf(temp)>=0)
       {
        //alert("Please check your e-mail address. It is incorrect");
        document.getElementById(id1).focus();
        return false;       
        }
    }
    return true;
}


function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting 
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	cDate=dateString.substring(0,curPos);
	
	//extract month portion				
	endPos=dateString.indexOf(sepChar,curPos+1);			cMonth=dateString.substring(curPos+1,endPos);

	//extract year portion				
	curPos=endPos;
	endPos=curPos+5;			
	cYear=curValue.substring(curPos+1,endPos);
	
	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);	
	return dtObject;
}


function chkfeb(id)
{
     
 try{
    var year=document.getElementById(id+"_drpYear").value;
    if(document.getElementById(id+"_drpDay").options.length==30)
    {
        document.getElementById(id+"_drpDay").options[30]= new Option('30','30');
        document.getElementById(id+"_drpDay").options[31]= new Option('31','31');
    }
    else if(document.getElementById(id+"_drpDay").options.length==29)
    {
        document.getElementById(id+"_drpDay").options[29]= new Option('29','29');
        document.getElementById(id+"_drpDay").options[30]= new Option('30','30');
        document.getElementById(id+"_drpDay").options[31]= new Option('31','31');
    }
     
    if (document.getElementById(id+"_drpMonth").value=="2")
    {
        
        if(document.getElementById(id+"_drpDay").options.length==32)
        {
            if ((year%4)==0)
            {
                document.getElementById(id+"_drpDay").options[31]= null;
                document.getElementById(id+"_drpDay").options[30]= null;
            }
            else
            {
                document.getElementById(id+"_drpDay").options[31]= null;
                document.getElementById(id+"_drpDay").options[30]= null;
                document.getElementById(id+"_drpDay").options[29]= null;
            }
        }
        else
        {
        if ((year%4)==0)
            {
                
                document.getElementById(id+"_drpDay").options[30]= null;
            }
            else
            {
                document.getElementById(id+"_drpDay").options[30]= null;
                document.getElementById(id+"_drpDay").options[29]= null;
            }
            
        }
    }
    
    else if ((document.getElementById(id+"_drpMonth").value=="4")||(document.getElementById(id+"_drpMonth").value=="6")||(document.getElementById(id+"_drpMonth").value=="9")||(document.getElementById(id+"_drpMonth").value=="11"))
    {
       document.getElementById(id+"_drpDay").options[31]= null;
    }
    else
    {
        if(document.getElementById(id+"_drpDay").options.length!="32")
       document.getElementById(id+"_drpDay").options[31]= new Option('31','31');
    }
    if((id=="ctl00_ctl00_MainContent_QueryForm_ucChild_ucChildPlnParentDateOfBirth" || id=="ctl00_ctl00_MainContent_QueryFormInvestMent_ucChildPlnParentDateOfBirth") && (document.getElementById(id+"_drpDay").selectedIndex>0) && (document.getElementById(id+"_drpMonth").selectedIndex>0) && (document.getElementById(id+"_drpYear").selectedIndex>0))
        {
        //alert("Agrawal");
          CallChildAge();
        }
    }catch(ex){}  
   
}


// function to validate the date selection by user
function checkFutureDate(idYear, idMonth, idDay, idColumnLabelToHighlight)
{
    var varYear = document.getElementById(idYear).value;
    var varMonth = document.getElementById(idMonth).value;
    var varDate = document.getElementById(idDay).value;

    var toDay = new Date();
    var AgeToCompare = new Date();
    
    AgeToCompare.setDate(varDate);
    AgeToCompare.setMonth((parseInt(varMonth)-1));
    AgeToCompare.setFullYear(varYear);
    //alert("Diff : ");
    var currentDays = (toDay.getFullYear() * 365) + (toDay.getMonth() * 30) + (toDay.getDay())
    var toCompareDays = (AgeToCompare.getFullYear() * 365) + (AgeToCompare.getMonth() * 30) + (AgeToCompare.getDay())
    
        
    //alert("Diff : " + (currentDays - toCompareDays)) ;
    if( (currentDays - toCompareDays)  < 1)    
    {
        alert("Date Error : Cannot be future date.");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    else 
    {
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
    return true;
} 


function checkIfAdult(idYear, idMonth, idDay, idColumnLabelToHighlight)
{
    var varYear = document.getElementById(idYear).value;
    var varMonth = document.getElementById(idMonth).value;
    var varDate = document.getElementById(idDay).value;

    var toDay = new Date();
    var AgeToCompare = new Date();
    
    AgeToCompare.setDate(varDate);
    AgeToCompare.setMonth((parseInt(varMonth)-1));
    AgeToCompare.setFullYear(varYear);
    //alert("Diff : ");
    var currentYear = toDay.getFullYear();
    var toCompareYear = AgeToCompare.getFullYear();
    //alert("Inside");
    var currentMonth = toDay.getMonth(); 
    var toCompareMonth = AgeToCompare.getMonth(); 
    //alert("Inside");

    var currentDay = toDay.getDate(); 
    var toCompareDay = AgeToCompare.getDate();
    //alert("Inside");
    
    var toReturn = true;
        
    //alert("Diff : " + (currentYear - toCompareYear)) ;
    document.getElementById(idColumnLabelToHighlight).style.color="#000000";    
    if( (currentYear - toCompareYear)  > 17 )    
    {
        //alert("> 17");
        toReturn = true;
    }
    else if( (currentYear - toCompareYear)  == 17 )    
    {
        //alert("= 17");
       //alert("Diff : " + (currentMonth - toCompareMonth)) ;
        if( (currentMonth - toCompareMonth)  > 0 )    
        {
            toReturn = true;
        }
        else if( (currentMonth - toCompareMonth)  == 0 )    
        {
            //alert("Diff : " + (currentDay - toCompareDay)) ;
            if( (currentDay - toCompareDay)  > 0 )  
            {  
                toReturn = true;
            }    
            else
            {
                toReturn = false;
            }    
        }
        else
        {
             toReturn = false;
        }   
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
    else
    {
        toReturn = false;
    }
    if(toReturn == false)
    {
        alert("-because user is not 18 years old today.");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    return toReturn;
} 

function checkIfChild(idYear, idMonth, idDay, idColumnLabelToHighlight)
{
    var varYear = document.getElementById(idYear).value;
    var varMonth = document.getElementById(idMonth).value;
    var varDate = document.getElementById(idDay).value;

    var toDay = new Date();
    var AgeToCompare = new Date();
    
    AgeToCompare.setDate(varDate);
    AgeToCompare.setMonth((parseInt(varMonth)-1));
    AgeToCompare.setFullYear(varYear);
    //alert("Diff : ");
    var currentYear = toDay.getFullYear();
    var toCompareYear = AgeToCompare.getFullYear();
    var currentDays = (toDay.getFullYear() * 365) + (toDay.getMonth() * 30) + (toDay.getDay())
    var toCompareDays = (AgeToCompare.getFullYear() * 365) + (AgeToCompare.getMonth() * 30) + (AgeToCompare.getDay())
    

    if( (currentDays - toCompareDays)  < 1) 
    {
        alert("Date Error : Cannot be future date");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    else 
    {
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
        
    //alert("Diff : " + (currentDays - toCompareDays)) ;
    if( (currentYear - toCompareYear)  > 18)    
    {
        alert("Date Error : Date of birth of a child is wrongly entered.");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    else 
    {
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
    return true;
} 

function checkHealthChild(idYear, idMonth, idDay, idColumnLabelToHighlight)
{
    var varYear = document.getElementById(idYear).value;
    var varMonth = document.getElementById(idMonth).value;
    var varDate = document.getElementById(idDay).value;

    var toDay = new Date();
    var AgeToCompare = new Date();
    
    AgeToCompare.setDate(varDate);
    AgeToCompare.setMonth((parseInt(varMonth)-1));
    AgeToCompare.setFullYear(varYear);
    //alert("Diff : ");
    var currentYear = toDay.getFullYear();
    var toCompareYear = AgeToCompare.getFullYear();
    var currentDays = (toDay.getFullYear() * 365) + (toDay.getMonth() * 30) + (toDay.getDay())
    var toCompareDays = (AgeToCompare.getFullYear() * 365) + (AgeToCompare.getMonth() * 30) + (AgeToCompare.getDay())
    

    if( (currentDays - toCompareDays)  < 1) 
    {
        alert("Date Error : Cannot be future date");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    else 
    {
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
        
    //alert("Diff : " + (currentDays - toCompareDays)) ;
    if( (currentYear - toCompareYear)  > 21)    
    {
        alert("Children over the age of 21 cannot be covered with parents under the Reliance HealthWise policy.\n  You will have to buy a separate policy for the child.");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    else 
    {
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
    return true;
} 

function validateMobileNumber(idMobileNumber, idColumnLabelToHighlight)
{
    var varMobileNumber = document.getElementById(idMobileNumber).value;
    if(isNaN(varMobileNumber) || varMobileNumber.indexOf(" ")!=-1)
    {
        alert("Mobile Number : Enter numeric value");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";        
        return false;  
    }
    if (varMobileNumber.length != 10 )
    {
        alert("Mobile Number : Enter 10 characters valid mobile number without 0"); 
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";        
        return false;
    }
    
    if (varMobileNumber.charAt(0)!=8 && varMobileNumber.charAt(0)!=9 && varMobileNumber.charAt(0)!=7)
    {
      
        alert("Mobile Number : The number can only start with 7, 8 or 9.");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";        
        return false
    }
    
    document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    return true;
}
function checkIfAdultLIC(idYear, idMonth, idDay, idColumnLabelToHighlight)
{
    var varYear = document.getElementById(idYear).value;
    var varMonth = document.getElementById(idMonth).value;
    var varDate = document.getElementById(idDay).value;

    var toDay = new Date();
    var AgeToCompare = new Date();
    
    AgeToCompare.setDate(varDate);
    AgeToCompare.setMonth((parseInt(varMonth)-1));
    AgeToCompare.setFullYear(varYear);
    //alert("Diff : ");
    var currentYear = toDay.getFullYear();
    var toCompareYear = AgeToCompare.getFullYear();
    //alert("Inside");
    var currentMonth = toDay.getMonth(); 
    var toCompareMonth = AgeToCompare.getMonth(); 
    //alert("Inside");

    var currentDay = toDay.getDate(); 
    var toCompareDay = AgeToCompare.getDate();
    //alert("Inside");
    //alert("curent year "+currentYear);
    //alert("compare year "+toCompareYear);
    var toReturn = true;
        
    //alert("Diff : " + (currentYear - toCompareYear)) ;
    document.getElementById(idColumnLabelToHighlight).style.color="#000000";    
    if( (currentYear - toCompareYear)  > 13 )    
    {
        //alert("> 17");
        toReturn = true;
    }
    else if( (currentYear - toCompareYear)  == 13 )    
    {
        //alert("= 17");
       //alert("Diff : " + (currentMonth - toCompareMonth)) ;
        if( (currentMonth - toCompareMonth)  > 0 )    
        {
            toReturn = true;
        }
        else if( (currentMonth - toCompareMonth)  == 0 )    
        {
            //alert("Current Day : " + currentDay) ;
            //alert("Compare Day : " + toCompareDay) ;
            ///alert("Diff : " + (currentDay - toCompareDay)) ;
            if( (currentDay - toCompareDay)  >= 0 )  
            {  
                toReturn = true;
            }    
            else
            {
                toReturn = false;
            }    
        }
        else
        {
             toReturn = false;
        }   
        document.getElementById(idColumnLabelToHighlight).style.color="#000000";
    }
    else
    {
        toReturn = false;
    }
    if(toReturn == false)
    {
        alert("Date Error : Age should be more than 13 years.");
        document.getElementById(idColumnLabelToHighlight).style.color="#ff0000";
        return false;
    }
    return toReturn;
} 
  function trimAll (str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}

function chkfebMoneyBk(id)
{
    //alert("ID is : " + id);
    var year=document.getElementById(id+"_drpChildYear").value;
    if(document.getElementById(id+"_drpChildDay").options.length==30)
    {
        document.getElementById(id+"_drpChildDay").options[30]= new Option('30','30');
        document.getElementById(id+"_drpChildDay").options[31]= new Option('31','31');
    }
    else if(document.getElementById(id+"_drpChildDay").options.length==29)
    {
        document.getElementById(id+"_drpChildDay").options[29]= new Option('29','29');
        document.getElementById(id+"_drpChildDay").options[30]= new Option('30','30');
        document.getElementById(id+"_drpChildDay").options[31]= new Option('31','31');
    }
    if (document.getElementById(id+"_drpChildMonth").value=="2")
    {
        if(document.getElementById(id+"_drpChildDay").options.length==32)
        {
            if ((year%4)==0)
            {
                document.getElementById(id+"_drpChildDay").options[31]= null;
                document.getElementById(id+"_drpChildDay").options[30]= null;
            }
            else
            {
                document.getElementById(id+"_drpChildDay").options[31]= null;
                document.getElementById(id+"_drpChildDay").options[30]= null;
                document.getElementById(id+"_drpChildDay").options[29]= null;
            }
        }
        else
        {
        if ((year%4)==0)
            {
                
                document.getElementById(id+"_drpChildDay").options[30]= null;
            }
            else
            {
                document.getElementById(id+"_drpChildDay").options[30]= null;
                document.getElementById(id+"_drpChildDay").options[29]= null;
            }
            
        }
    }
    
    else if ((document.getElementById(id+"_drpChildMonth").value=="4")||(document.getElementById(id+"_drpChildMonth").value=="6")||(document.getElementById(id+"_drpChildMonth").value=="9")||(document.getElementById(id+"_drpChildMonth").value=="11"))
    {
       document.getElementById(id+"_drpChildDay").options[31]= null;
    }
    else
    {
        if(document.getElementById(id+"_drpChildDay").options.length!="32")
       document.getElementById(id+"_drpChildDay").options[31]= new Option('31','31');
    }
}
function fnAddressValidation(e)
{
  	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	//alert(code);
	if(e.shiftKey)
	{
	    //alert("Shift + "+code);
	    if ((code >= 65 && code <= 90) || code==35 || code==38 || code==58 ||code==37  )
	    { 
		    checknos = true;
		    return (checknos);
	    }
	    else
	    {
		    checknos= false;
		    alert("Special characters are not allowed!");
		    return (checknos);
	    }    
	}
	else
	{
	    //alert(code);
	    if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || (code >= 48 && code <= 57) || (code==13) || code==32 || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==37 || code==38 || code==39 ||  code==47 || code==92 || code==35 || code==44|| code==45 || code==40 || code==41 || code==36)
	    { 
		checknos = true;
		return (checknos);
	    }
	    else
	    {
		checknos= false;
		alert("Special characters are not allowed!");
		return (checknos);
	    }    
	}
}



function fnNotAlphabetandZero(e,obj)
{
    var controlId=obj.id;
    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;        
 
    
    //Code Explanation{ 0-9, 45=Insert, 13=Enter, 08=Backspace, 09=Tab}
    if ((code >= 48 && code <= 57)||(code == 13 || code == 08 || code == 09)) 
    { 
        if(document.getElementById(controlId).value.length==0 && code==48)
	    {
	        checknos= false;
	        alert("-Contact number can not start with 0!");	
	        return (checknos);
	    }
	    else
	    
	    {
            checknos = true;
	        return (checknos);
	   }
    }
    else
    {
	    checknos= false;
	    
	    alert("Only Number Allowed !");	
	    return (checknos);
    }

}
function fnNotAlphabetandZeroPincode(e,obj)
{
    var controlId=obj.id;
    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;        
    
    //Code Explanation{ 0-9, 45=Insert, 13=Enter, 08=Backspace, 09=Tab}
    if ((code >= 48 && code <= 57)||(code == 13 || code == 08 || code == 09)) 
    { 
        if(document.getElementById(controlId).value.length==0 && code==48)
	    {
	        checknos= false;
	        alert("- Pin Code can not start with 0!");	
	        return (checknos);
	    }
	 
	    else
	    
	    {
            checknos = true;
	        return (checknos);
	   }
    }
    else
    {
	    checknos= false;
	    
	    alert("Only Number Allowed !");	
	    return (checknos);
    }

}
function fnNotAlphabetAndNoneZeroAtFirst(e,obj)
{
    var controlId=obj.id;
//    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;  
   
    
    if (isNaN(obj.value) == false) 
    { 
        if(obj.value.charAt(0) == "0")
	    {
	        checknos= false;
	        alert("- Pin Code can not start with 0!");	
	        obj.value = "";
	       
	        return (checknos);
	    }
	    else
	    {
            checknos = true;
	        return (checknos);
	    }
    }
    else
    {
	    checknos= false;
	    alert("Only Number Allowed !");	
	    obj.value = "";
	    return (checknos);
    }
}

function fnNotAlphabetAndNoneZeroAtFirstpassport(e,obj)
{

    //var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;        
    
    
        if(obj.value.charAt(0) == "0")
	    {
	        checknos= false;
	        alert("- Passport can not start with 0!");	
	        obj.value = "";
	       
	        return (checknos);
	    }
	    
	    else
	    {
            checknos = true;
	        return (checknos);
	    }
  
  
}

function fnNotAlphabetAndNoneZeroAtFirstContact(e,obj)
{

    var controlId=obj.id;
//    alert(controlId);
//    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;        
//    alert(code);
    if (isNaN(obj.value) == false) 
    { 
        if(obj.value.charAt(0) == "0")
	    {
	        checknos= false;
	        alert("- Contact No. can not start with 0!");	
	         obj.value = "";
//	         document.getElementById('ctl00_ctl00_MainContent_QueryForm_lblContactNumber').style.color="#ff0000";   
	        return (checknos);
	    }
	    else
	    {
            checknos = true;
	        return (checknos);
	    }
    }
    else
    {
	    checknos= false;
	    alert("Only Number Allowed !");	
	    obj.value = "";
	    return (checknos);
    }
}
//
function fnSTDCode(obj)
{
    if(obj.value.length >0)
    {
        if (isNaN(obj.value) == false) 
        { 
            if( obj.value.length >=2 && obj.value.length <= 5)
	        {
    	        if(obj.value == "00" || obj.value == "000" || obj.value == "0000" || obj.value == "00000")
	            {
	                alert("- Only Zero Not Allow!");
	                obj.value = "";
	                obj.focus();
	                return false;	
	            }
	        }
	        else
	        {
	            alert("- Enter Valid STD Number!");	
	            obj.value = "";
	            obj.focus();
	            return false;
	        }
        }
        else
        {
	        alert("Only Number Allowed !");	
	        obj.value = "";
	        obj.focus();
	        return false;
        }
        return true;
    }
    return true;
}

function fnContactNumber(obj)
{
    
    if(obj.value.length >0)
    {
        if (isNaN(obj.value) == false) 
        { 
            if( obj.value.length >=4 && obj.value.length <= 10)
	        {
    	        if(obj.value == "00" || obj.value == "000" || obj.value == "0000" || obj.value == "00000")
	            {
	                alert("- Only Zero Not Allow!");
	                obj.value = "";
	                obj.focus();
                    return false;	
	            }
	        }
	        else
	        {
	            alert("- Enter Valid Contact Number!");	
	            obj.value = "";
	            obj.focus();
	            return false;
	        }
        }
        else
        {
	        alert("Only Number Allowed !");	
	        obj.value = "";
	        obj.focus();
	        return false;
        }
        return true;
    }
    return true;
}
/*=========================================================================================
        <<<<< Code for Indian Currency formate Provoid by Shailendra Sir
===========================================================================================*/
function fnFormatCurrencyIndianStyle(objTextBox)
	{
		var number = "";
		var temp = objTextBox.value.split(',');
		//alert(temp.length);
		for(var i=0; i < temp.length;i++)
		{
			number = number + "" + temp[i];
			//alert(number);
		}
		//alert(number);
		if(number != "")
		{
			objTextBox.value = fntemp(parseInt(number));
		}
		
	}
	function fntemp(number)
	{
		var formattedNumber = "";
		if(number > 999)
		{
			var no = parseInt(number/1000);
			formattedNumber = (number - no*1000)
			if (formattedNumber == 0)
			{
				formattedNumber = "000";
			}
			else if (formattedNumber<10)
			{
				formattedNumber = "00" + formattedNumber;
			}
			else if (formattedNumber < 100)
			{
				formattedNumber = "0" + formattedNumber;
			}						
			number=no;
			while(no > 99)
			{
				//alert(no)
				no = parseInt(no/100);
				var temp = (number - no*100);
				if (temp == 0)
				{
					formattedNumber = "00" + "," + formattedNumber;
				}
				else if (temp < 10)
				{
					formattedNumber = "0" + (number - no*100) + "," + formattedNumber;
				}
				else
				{
					formattedNumber = (number - no*100) + "," + formattedNumber;
				}
				number=no;
			}
			formattedNumber = no + "," + formattedNumber;
			//alert(formattedNumber);
		}
		else
		{
			formattedNumber = number;
		}
		return formattedNumber;
	}
/*=========================================================================================
             Code for Indian Currency formate   >>>>>
===========================================================================================*/

//=========================================================================================//
// Format Currency IN Indian Style Added by Satish Chandra
//=========================================================================================//

function FormatCurrencyIndianStyle(objTextBoxValue)
{
    objTextBoxValue = objTextBoxValue+"";
    var str = "";
    var tempstr = objTextBoxValue.split(',');

    for(var i=0; i < tempstr.length;i++)
    {
	    str = str + "" + tempstr[i];
    }
     
    var temp = "", numbers = "";
    var n = 0;        
    for (var i = (str.length - 1); i >= 0; i--)
    {
        n++;
        temp += str.charAt(i);
        if (i > 0 && n > 2)
        {
            temp += ",";
            n = 1;
        }
    }
    for (var i = (temp.length - 1); i >= 0; i--)
    {
        numbers += temp.charAt(i);
    }               
    return numbers;
}

//=========================================================================================//
//                                      END
//=========================================================================================//