// JScript File
//On Center Screen
function popupwindow(url, title, w, h) {
  var left = (screen.width/2)-(w/2);
  var top = (screen.height/2)-(h/2);
  return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
function OpenWindow()
{
        
        //popupwindow('PopUp_ShiftAllocation.aspx','',850,650);
        var url='PopUp_ShiftAllocation.aspx';
        document.getElementById('ctl00_BodyContentPH_iframePopup').src = url;
        //window.open('PopUp_ShiftAllocation.aspx','','left=250px, top=200px, width=700px, height=600px, scrollbars=yes, status=no, resizable=no');
        return false;    
}
//Added by Manjula.P on 04-Aug-2014 for manual group entry
function OpenWindowGroupPolicy()
{
//    popupwindow('TA_UI_Transactions_GroupLeavePolicy_Popup.aspx','',800,600);
    document.getElementById('ctl00_BodyContentPH_iframePopup').src = 'TA_UI_Transactions_GroupLeavePolicy_Popup.aspx';
    //window.open('TA_UI_Transactions_GroupLeavePolicy_Popup.aspx','','left=180px, top=150px, width=700px, height=580px, scrollbars=no, status=no, resizable=no');
    return false;   
}
//Added by Manjula.P pn 04-Aug-2014
function OpenWindowGroupEntry()
{
        popupwindow('PopUp_ManualGroupEntry.aspx','',800,450);
        return false;    
}
/*function closewindow()
{
}*/
function OpenPopupWindow()
{
        window.open('Resetpassword_Popup.aspx','','left=250px, top=245px, width=700px, height=470px, scrollbars=yes, status=no, resizable=no');
        return false;
}
function OpenShiftAllocationViewWindow()
{    
    var Shift="Permanent";
    //popupwindow(,'',1000,620);
    var url='ShiftAllocationView_Popup.aspx?Shift=' + Shift + '';
    document.getElementById('ctl00_BodyContentPH_iframePopup2').src = url;
    //window.open('ShiftAllocationView_Popup.aspx?Shift=' + Shift + '','','left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=no');
    return false;    
}
function OpenTemporaryShiftAllocationViewWindow()
{
    var Shift="Temporary";
    popupwindow('ShiftAllocationView_Popup.aspx?Shift=' + Shift + '','',1000,620);    
    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 te = row.innerText;        
//        var arr = new Array();
//        arr = te.split(chk.value);
//        var x = "";
//        for(var i = 1;i<arr.length;i++)
//        {
//            x = x + arr[i];           
//            
//        }
        //var EmpId=x.substring(0,chk.value.length);
        var EmpId=chk.value;
        //alert("1 = " +EmpId)
       // var EmpName=x.substring(chk.value.length);
  //      alert("2 = " + EmpName)
        if(chk.checked==true)
        {
            var mode="Insert";
            var url="AjaxShiftAllocation.aspx?";
            //url=url + "EmpId=" + EmpId + "&" + "EmpName=" + EmpName + "&" + "Mode="+ mode ;
            url=url + "EmpId=" + EmpId + "&" + "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 ;
            url=url + "EmpId=" + EmpId + "&" + "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");
		    }
	    }
}