// JScript File
var objec = null;
    function ajaxfunction(EntertheChildrenintherangeof1to10,NoDetailsfoundinChild,Errorinretrivingdetails,InvalidChildDOB)
    {
        if(window.ActiveXObject)
        {    
	        try
	        {
		        objec = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objec = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objec = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        objec = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objec = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objec = null;
		        }
	        }
        }
//        try
//        {
//             objec = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                objec=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    objec=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    objec=null;
//                }
//            }
//        }
        if(objec!=null)
        {
        if(document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value > 10)
        {
            document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value='';
            //alert('Enter the Children in the range of 1-10');
            alert(EntertheChildrenintherangeof1to10);
            return;
        }
         if(document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value > 0)
         {
            if(window.ActiveXObject)
            {
                objec.onreadystatechange=Process_Response;
                objec.open("GET","Employee_Children.aspx?No="+document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value,true);
                objec.send(null);
            }
            else if(window.XMLHttpRequest)
            {
                objec.open("GET","Employee_Children.aspx?No="+document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value,false);
                objec.send(null);
                objec.onreadystatechange=Process_Response();
            }
         }
         else
         {
            document.getElementById('div_children').innerHTML='';
         }
        }
        return false;
    }
    function Process_Response()
	{
		if(objec.readyState == 4)
		{
			if(objec.status == 200)
			{
				var retval=objec.responseText;
				if (retval.length > 0)
				{
				   document.getElementById("div_children").innerHTML=retval;
				}
				else
				{
				    //alert("No Details found in Child!");
				    alert(NoDetailsfoundinChild);
				}
			}
			else
			{
				//alert("Error in retriving details");
				alert(Errorinretrivingdetails);
			}
		}
	}
	//assign the children details to hidden field
	function assign_hidden(child)
    {
        if(child != 1)
        {  
                   //current date
               var Curdate=new Date();
               var CurYear=Curdate.getFullYear();
               var CurMonth=Curdate.getMonth();
               CurMonth=CurMonth+1;
               var cdate=Curdate.getDate();
               //DOB child validation
                        var dob;
               if(document.getElementById(child.id) != null)
               {
                  dob=document.getElementById(child.id).value;
               }
               else
               {    
                 dob = document.getElementById(child).value;               
               }
               //dob = document.getElementById(child.id).value;  
               //validation for MM/dd/YYYY format
              if(document.getElementById('ctl00_BodyContentPH_Hidden1').value=='MM/DD/YYYY')
              {             
               var dobMonth=dob.substring(0,2);
               var dobDate=dob.substring(3,5);
               var dobYear=dob.substring(6,dob.length);
              }
               //validation for dd/MM/YYYY format
              if(document.getElementById('ctl00_BodyContentPH_Hidden1').value=='DD/MM/YYYY')
                {
                var dobMonth=dob.substring(3,5);
                var dobDate=dob.substring(0,2);
                var dobYear=dob.substring(6,dob.length);
                }
                //validation for dd-MMM-YYYY format
                if(document.getElementById('ctl00_BodyContentPH_Hidden1').value=='DD-MMM-YYYY')
                {
                   var mon = dob.substring(3,6);
                   var dobMonth = Month(mon);
                   var dobDate=dob.substring(0,2);
                   var dobYear=dob.substring(7,dob.length);
                }
                if (dobYear >= CurYear)
                {
                    if (dobYear > CurYear)
                    {
                        //alert("Invalid Child DOB");
                         alert(InvalidChildDOB);
                        return false;
                    }
                    if (dobYear == CurYear)
                    {
                        if (dobMonth >= CurMonth)
                        {
                            if (dobMonth > CurMonth)
                            {
                                //alert("Invalid Child DOB");
                                alert(InvalidChildDOB);
                                return false;
                            }
                            if (dobMonth == CurMonth)
                            {
                                if (dobDate >= cdate)
                                {
                                    //alert("Invalid Child DOB");
                                    alert(InvalidChildDOB);
                                    return false;
                                }
                                else
                                {
                                }
                            }
                        }
                        else
                        {
                        }
                    }        
                }
                else
                {
                }
        }                      
        var no_of_rows=document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value;
        var data="";
        for(var i=1; i<= no_of_rows; i++)
            {
            var txt = "txt_ChName" + i;
            var dat = "txt_ChildDOB" + i;
                if(data == "")
                {
                    data = document.getElementById(txt).value + "," + document.getElementById(dat).value;
                }
                else
                {
                   data = data + "*" + document.getElementById(txt).value + "," + document.getElementById(dat).value;
                }
            }
            document.getElementById("ctl00_BodyContentPH_hid_Children").value=data;
     return true;
    } 
//Employee Children Details Modify
function ajaxfunctionModify(EmpID)
{
       if(window.ActiveXObject)
        {    
	        try
	        {
		        objec = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objec = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objec = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        objec = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objec = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objec = null;
		        }
	        }
        }
//        try
//        {
//             objec = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                objec=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    objec=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    objec=null;
//                }
//            }
//        }
        if(objec!=null)
        {  
        if(document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value > 10)
        {
            document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value='';
            //alert('Enter the Children in the range of 1-10');
            alert(EntertheChildrenintherangeof1to10);
            return;
        }
            if (document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value !="")
            { 
                if(window.ActiveXObject)
                {         
                    objec.open("POST","Emp_ChildrenModify.aspx?No=" + document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value + "&EmpID="+EmpID+"",true);
                    objec.onreadystatechange=ProcessResponseModify;
                    objec.send(null);
                }
                else if(window.XMLHttpRequest)
                {
                    objec.open("POST","Emp_ChildrenModify.aspx?No=" + document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value + "&EmpID="+EmpID+"",false);
                    objec.send(null);
                    objec.onreadystatechange=ProcessResponseModify();
                }
            }
            else
            {
                document.getElementById('div_children').innerHTML='';
                document.getElementById("ctl00_BodyContentPH_hid_Children").value='';
            }
                return false
        }               
        return false;
    }
    function ProcessResponseModify()
	{
		if(objec.readyState == 4)
		{
			if(objec.status == 200)
			{
			    document.getElementById('div_children').innerHTML = objec.responseText;
			}
		}
	}
	//assign the children details to hidden field
	function assign_hiddenModify(child)
    {
            if(child != 1)
            {  
                   //current date
               var Curdate=new Date();
               var CurYear=Curdate.getFullYear();
               var CurMonth=Curdate.getMonth();
               CurMonth=CurMonth+1;
               var cdate=Curdate.getDate();
               //DOB child validation
                var dob;
               if(document.getElementById(child.id) != null)
               {
                  dob=document.getElementById(child.id).value;
               }
               else
               {    
                 dob = document.getElementById(child).value;   
               }
               //dob = document.getElementById(child.id).value;   
               //validation for MM/dd/YYYY format
              if(document.getElementById('ctl00_BodyContentPH_Hidden1').value=='MM/DD/YYYY')
              {             
               var dobMonth=dob.substring(0,2);
               var dobDate=dob.substring(3,5);
               var dobYear=dob.substring(6,dob.length);
              }
               //validation for dd/MM/YYYY format
              if(document.getElementById('ctl00_BodyContentPH_Hidden1').value=='DD/MM/YYYY')
                {
                var dobMonth=dob.substring(3,5);
                var dobDate=dob.substring(0,2);
                var dobYear=dob.substring(6,dob.length);
                }
                //validation for dd-MMM-YYYY format
                if(document.getElementById('ctl00_BodyContentPH_Hidden1').value=='DD-MMM-YYYY')
                {
                   var mon = dob.substring(3,6);
                   var dobMonth = Month(mon);
                   var dobDate=dob.substring(0,2);
                   var dobYear=dob.substring(7,dob.length);
                }
                if (dobYear >= CurYear)
                {
                    if (dobYear > CurYear)
                    {
                        //alert("Invalid Child DOB");
                        alert(InvalidChildDOB);
                        return false;
                    }
                    if (dobYear == CurYear)
                    {
                        if (dobMonth >= CurMonth)
                        {
                            if (dobMonth > CurMonth)
                            {
                                //alert("Invalid Child DOB");
                                alert(InvalidChildDOB);
                                return false;
                            }
                            if (dobMonth == CurMonth)
                            {
                                if (dobDate >= cdate)
                                {
                                    //alert("Invalid Child DOB");
                                    alert(InvalidChildDOB);
                                    return false;
                                }
                                else
                                {
                                }
                            }
                        }
                        else
                        {
                        }
                    }        
                }
                else
                {
                }
            }  
        var no_of_rows=document.getElementById("ctl00_BodyContentPH_txt_ChildrenNo").value;
        var data="";
        for(var i=0; i< no_of_rows; i++)
            {
            var txt = "txt_ChName" + i;
            var dat = "txt_ChildDOB" + i;
                if(data == "")
                {
                    data = document.getElementById(txt).value + "," + document.getElementById(dat).value;
                }
                else
                {
                   data = data + "*" + document.getElementById(txt).value + "," + document.getElementById(dat).value;
                }
            }
            document.getElementById("ctl00_BodyContentPH_hid_Children").value=data;
            return true;
    } 
	//Employee Children Details View
function ajaxfunctionView(EmpID)
{
       if(window.ActiveXObject)
        {    
	        try
	        {
		        objec = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objec = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objec = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        objec = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        objec = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        objec = null;
		        }
	        }
        }
//        try
//        {
//             objec = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                objec=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    objec=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    objec=null;
//                }
//            }
//        }
        if(objec!=null)
        { 
           if(window.ActiveXObject)
           {           
                objec.open("POST","Emp_ChildrenView.aspx?EmpID="+EmpID+"",true);
                objec.onreadystatechange=ProcessResponseView;
                objec.send(null);
            }
            else if(window.XMLHttpRequest)
            {
                objec.open("POST","Emp_ChildrenView.aspx?EmpID="+EmpID+"",false);
                objec.send(null);
                objec.onreadystatechange=ProcessResponseView();
            }
         }               
        return false;
    }
    function ProcessResponseView()
	{
		if(objec.readyState == 4)
		{
			if(objec.status == 200)
			{
			    document.getElementById('div_children').innerHTML = objec.responseText;
			}
		}
	}