// JScript File
function OpenWindow()
{
        window.open('PopUp_ShiftAllocation.aspx','','left=300px, top=280px, width=580px, height=400px, scrollbars=no, status=no, resizable=no');
        return false;
}
/*function closewindow()
{
}*/
function OpenPopupWindow()
{
        window.open('Resetpassword_Popup.aspx','','left=300px, top=280px, width=1000px, height=400px, scrollbars=no, status=no, resizable=no');
        return false;
}
function InsertEmployeeDetails(chk)
{
        if(window.ActiveXObject)
        {    
            try
            {
                obj = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e)
            {
                try
                {
	                obj = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e1)
                {
	                obj = null;
                }
            }
        }  
         else if(window.XMLHttpRequest)
         {
            try
            {
                obj = new XMLHttpRequest("Msxml2.XMLHTTP");
            }
            catch(e)
            {
                try
                {
	                obj = new XMLHttpRequest("Microsoft.XMLHTTP");
                }
                catch(e1)
                {
	                obj = null;
                }
            }
         }  
//    try
//	{
//		obj = new XmlHttpRequest();
//	}
//	catch(e)
//	{
//		try
//		{
//			obj = new ActiveXObject("Microsoft.XMLHTTP");
//		}
//		catch(e1)
//		{
//			obj = new ActiveXObject("Msxml2.XMLHTTP");
//		}
//	}
	if(obj != null)
	{
        //var cell = chk.parentElement;
        //var row = cell.parentElement;
        var cell = chk.parentNode;
        var row = cell.parentNode;
        var te = row.innerText;
        var arr = new Array();
        arr = te.split(' ');
        var x = "";
        for(var i = 1;i<arr.length;i++)
        {
            x = x + arr[i];
        }
        var EmpId=x.substring(0,8);
        //alert("1 = " +EmpId)
        var EmpName=x.substring(8);
        //alert("2 = " + EmpName)
        if(chk.checked==true)
        {
            var mode="Insert";
            var url="AjaxShiftAllocation.aspx?";
            url=url + "EmpId=" + EmpId + "&" + "EmpName=" + EmpName + "&" + "Mode="+ mode ;
            //alert(url);
            if(window.ActiveXObject)
            {
                obj.onreadystatechange = ProcessTheResponse_ShiftAlloc;		
		        obj.open("POST", url, true);
		        obj.send(null);
		    }
		    else if(window.XMLHttpRequest)
            {
                obj.open("POST", url, false);
                obj.send(null);
                obj.onreadystatechange = ProcessTheResponse_ShiftAlloc();		
            }
        }
        if(chk.checked==false)
        {
            var mode="Delete";
            var url="AjaxShiftAllocation.aspx?";
            url=url + "EmpId=" + EmpId + "&" + "EmpName=" + EmpName + "&" + "Mode="+ mode ;
            //alert(url);
            if(window.ActiveXObject)
            {
                obj.onreadystatechange = ProcessTheResponse_ShiftAlloc1;		
		        obj.open("POST", url, true);
		        obj.send(null);
		    }
		    else if(window.XMLHttpRequest)
            {
                obj.open("POST", url, false);
                obj.send(null);
                obj.onreadystatechange = ProcessTheResponse_ShiftAlloc1();		
            }
        }
    }
    return false;
  }
  function ProcessTheResponse_ShiftAlloc()
  {
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
		  //alert("Record Inserted");
		}
	}
}
	function ProcessTheResponse_ShiftAlloc1()
    {
	    if (obj.readyState == 4)
	    {
		    if(obj.status == 200)
		    {
		        //alert("Record Deleted");
		    }
	    }
    }