// JScript File
var object = null;
    function ajaxspouse(EntertheSpouseintherangeof1to4,NoDetailsfoundinspouse,Errorinretrivingdetailsfromspouse,InvalidSpouseDOB,EntertheSpouseintherangeof1to10)
    {
    //alert("hi");
       if(window.ActiveXObject)
        {    
	        try
	        {
		        object = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        object = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        object = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        object = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        object = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        object = null;
		        }
	        }
        }
//        try
//        {
//             object = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                object=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    object=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    object=null;
//                }
//            }
//        }
        if(object!=null)
        {
        if(document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value > 4)
        {
            document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value='';
            //alert('Enter the Spouse in the range of 1-4');
            alert(EntertheSpouseintherangeof1to4);
            return;
        }
         if(document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value > 0)
         {
           if(window.ActiveXObject)
            {
                object.onreadystatechange=Process_Response_spouse;
                object.open("GET","Employee_Spouse.aspx?No="+document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value,true);
                object.send(null);
            }
            else if(window.XMLHttpRequest)
            {
                object.open("GET","Employee_Spouse.aspx?No="+document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value,false);
                object.send(null);
                object.onreadystatechange=Process_Response_spouse();
            }
         }
         else
         {
            document.getElementById("div_Spouse").innerHTML="";
         }
        }
        return false;
    }
    function Process_Response_spouse()
	{
		if(object.readyState == 4)
		{
			if(object.status == 200)
			{
				var retval=object.responseText;
				if (retval.length > 0)
				{
				   document.getElementById("div_Spouse").innerHTML=retval;
				}
				else
				{
				    //alert("No Details found in spouse!");
				    alert(NoDetailsfoundinspouse);
				}
			}
			else
			{
				//alert("Error in retriving details from spouse ");
				alert(Errorinretrivingdetailsfromspouse);
			}
		}
	}
	//assign the spouse details to hidden field
	function assign_hidden_spouse(spouse)
    {
    if(spouse != 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(spouse.id) != null)
               {
                  dob=document.getElementById(spouse.id).value;
               }
               else
               {    
                 dob = document.getElementById(spouse).value;               
               }
               //dob = document.getElementById(spouse.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 Spouse DOB");
                        alert(InvalidSpouseDOB);
                        return false;
                    }
                    if (dobYear == CurYear)
                    {
                        if (dobMonth >= CurMonth)
                        {
                            if (dobMonth > CurMonth)
                            {
                                //alert("Invalid Spouse DOB");
                                alert(InvalidSpouseDOB);
                                return false;
                            }
                            if (dobMonth == CurMonth)
                            {
                                if (dobDate >= cdate)
                                {
                                    //alert("Invalid Spouse DOB");
                                    alert(InvalidSpouseDOB);
                                    return false;
                                }
                                else
                                {
                                }
                            }
                        }
                        else
                        {
                        }
                    }        
                }
                else
                {
                }
        }
        var no_of_rows=document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value;
        var data="";
        for(var i=1; i<= no_of_rows; i++)
            {
            var txt = "txt_SpName" + i;
            var dat = "txt_SpouseDOB" + 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_Spouse").value=data;
    return true;
    } 
//Employee spouse Details Modify
function ajaxfunctionModify_spouse(EmpID)
{
      if(window.ActiveXObject)
        {    
	        try
	        {
		        object = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        object = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        object = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        object = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        object = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        object = null;
		        }
	        }
        }
//        try
//        {
//             object = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                object=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    object=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    object=null;
//                }
//            }
//        }
        if(object!=null)
        {  
            if(document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value > 10)
            {
                document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value='';
                //alert('Enter the Spouse in the range of 1-10');
                alert(EntertheSpouseintherangeof1to10);
                return;
            }
            if (document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value !="")
            { 
                if(window.ActiveXObject)
                {         
                    object.open("POST","Emp_SpouseModify.aspx?No=" + document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value + "&EmpID="+EmpID+"",true);
                    object.onreadystatechange=ProcessResponseModify_spouse;
                    object.send(null);
                }
                else if(window.XMLHttpRequest)
                {
                     object.open("POST","Emp_SpouseModify.aspx?No=" + document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value + "&EmpID="+EmpID+"",false);
                     object.send(null);
                     object.onreadystatechange=ProcessResponseModify_spouse();
                }
            }
            else
            {
              document.getElementById('div_Spouse').innerHTML='';
              document.getElementById("ctl00_BodyContentPH_hid_Spouse").value='';  
            }
                return false
        }               
        return false;
    }
    function ProcessResponseModify_spouse()
	{
		if(object.readyState == 4)
		{
			if(object.status == 200)
			{
			    document.getElementById('div_Spouse').innerHTML = object.responseText;
			}
		}
	}
	//assign the spouse details to hidden field
	function assign_hiddenModify_spouse(spouse)
    {
            if(spouse != 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(spouse.id) != null)
               {
                  dob=document.getElementById(spouse.id).value;
               }
               else
               {    
                 dob = document.getElementById(spouse).value;   
               }
               //dob = document.getElementById(spouse.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 spouse DOB");
                        alert(InvalidSpouseDOB);
                        return false;
                    }
                    if (dobYear == CurYear)
                    {
                        if (dobMonth >= CurMonth)
                        {
                            if (dobMonth > CurMonth)
                            {
                                //alert("Invalid spouse DOB");
                                alert(InvalidSpouseDOB);
                                return false;
                            }
                            if (dobMonth == CurMonth)
                            {
                                if (dobDate >= cdate)
                                {
                                    //alert("Invalid spouse DOB");
                                    alert(InvalidSpouseDOB);
                                    return false;
                                }
                                else
                                {
                                }
                            }
                        }
                        else
                        {
                        }
                    }        
                }
                else
                {
                }
            }
        var no_of_rows=document.getElementById("ctl00_BodyContentPH_txt_SpouseNo").value;
        var data="";
        for(var i=0; i< no_of_rows; i++)
            {
            var txt = "txt_SpName" + i;
            var dat = "txt_SpouseDOB" + 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_Spouse").value=data;
            return true;
    } 
	//Employee Children Details View
function ajaxfunctionView_spouse(EmpID)
{
      if(window.ActiveXObject)
        {    
	        try
	        {
		        object = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        object = new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        object = null;
		        }
	        }
        }  
         else if(window.XMLHttpRequest)
         {
	        try
	        {
		        object = new XMLHttpRequest("Msxml2.XMLHTTP");
	        }
	        catch(e)
	        {
		        try
		        {
			        object = new XMLHttpRequest("Microsoft.XMLHTTP");
		        }
		        catch(e1)
		        {
			        object = null;
		        }
	        }
        }
//        try
//        {
//             object = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//            try
//            {
//                object=new ActiveXObject("Msxml2.XMLHTTP");
//            }
//            catch(e)
//            {
//                try
//                {
//                    object=new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                catch(e1)
//                {
//                    object=null;
//                }
//            }
//        }
        if(object!=null)
        {
           if(window.ActiveXObject)
            {            
                object.open("POST","Emp_SpouseView.aspx?EmpID="+EmpID+"",true);
                object.onreadystatechange=ProcessResponseView_spouse;
                object.send(null);
            }
            else if(window.XMLHttpRequest)
            {
              object.open("POST","Emp_SpouseView.aspx?EmpID="+EmpID+"",false);
              object.send(null);
              object.onreadystatechange=ProcessResponseView_spouse();
            }
         }               
        return false;
    }
    function ProcessResponseView_spouse()
	{
		if(object.readyState == 4)
		{
			if(object.status == 200)
			{
			    document.getElementById('div_Spouse').innerHTML = object.responseText;
			}
		}
	}