// JScript File

function OpenWindow()
{
    
        window.open('PopUp_ShiftAllocation.aspx','','left=250px, top=245px, width=700px, height=450px, scrollbars=no, status=no, resizable=no');
        return false;
    
}

/*function closewindow()
{



}*/
function OpenPopupWindow()
{
    
        window.open('Resetpassword_Popup.aspx','','left=250px, top=245px, width=700px, height=450px, scrollbars=no, status=no, resizable=no');
        return false;
    
}

function OpenShiftAllocationViewWindow()
{
    var Shift="Permanent";
        window.open('ShiftAllocationView_Popup.aspx?Shift=' + Shift + '','','left=10px, top=60px, width=1000px, height=600px, scrollbars=no, status=no, resizable=no');
        return false;
    
}


function OpenTemporaryShiftAllocationViewWindow()
{
    var Shift="Temporary";
        window.open('ShiftAllocationView_Popup.aspx?Shift=' + Shift + '','','left=10px, top=60px, width=1000px, height=600px, scrollbars=no, status=no, resizable=no');
        return false;
    
}

function InsertEmployeeDetails(chk)
{
    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);
            
            obj.onreadystatechange = ProcessTheResponse_ShiftAlloc;		
		    obj.open("POST", url, true);
		    obj.send(null);
       
        }
        
        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);
            
            obj.onreadystatechange = ProcessTheResponse_ShiftAlloc1;		
		    obj.open("POST", url, true);
		    obj.send(null);
       
        }
        
        
    }
    
    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");
         
         
		    }
	    }
}