// JScript File
var obj;
function ShiftExchange1(Shiftnotallocated)
{
   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 E1date=document.getElementById('ctl00_BodyContentPH_txt_E1Date').value
		var EmpId=document.getElementById('ctl00_BodyContentPH_txt_Ecode1').value
		if(E1date != "")
		{
		   if(window.ActiveXObject)
           {
		        obj.onreadystatechange = ProcessTheResponseShiftExChange1;		
		        obj.open("GET","AjaxShiftExchange.aspx?Edate=" + E1date + "&EmpId=" + EmpId + "&RanId=" + Math.random(),true)
		        obj.send(null);
		    }
		    else if(window.XMLHttpRequest)
            {
		        obj.open("GET","AjaxShiftExchange.aspx?Edate=" + E1date + "&EmpId=" + EmpId + "&RanId=" + Math.random(),false)
		        obj.send(null);
		        obj.onreadystatechange = ProcessTheResponseShiftExChange1();		
            }
		} 
	}
	return false;
}
function ProcessTheResponseShiftExChange1()
{ 
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
            var response=obj.responseText;
                if(response=="NotAllocated")
                {
                    //alert("Shift not allocated");
                    alert(Shiftnotallocated);
                }   
                else
                {    
                   document.getElementById('ctl00_BodyContentPH_txt_E1ActualShift').value=response;
                }
         }
	}
}
function ShiftExchange2(Shiftnotallocated)
{
	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 E2date=document.getElementById('ctl00_BodyContentPH_txt_E1Date').value
		var EmpId=document.getElementById('ctl00_BodyContentPH_txt_Ecode2').value
		if(E2date != "")
		{
			if(window.ActiveXObject)
            {
		        obj.onreadystatechange = ProcessTheResponseShiftExChange2;		
		        obj.open("POST","AjaxShiftExchange.aspx?EDate=" + E2date + "&EmpId=" + EmpId + "&RanId=" + Math.random(),true)
		        obj.send(null);
		    }
		    else if(window.XMLHttpRequest)
            {
		        obj.open("POST","AjaxShiftExchange.aspx?EDate=" + E2date + "&EmpId=" + EmpId + "&RanId=" + Math.random(),false)
		        obj.send(null);
		        obj.onreadystatechange = ProcessTheResponseShiftExChange2();		
            }
		} 
	}
	return false;
}
function ProcessTheResponseShiftExChange2()
{ 
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
            var response=obj.responseText;
            if(response=="NotAllocated")
                {
                    //alert("Shift not allocated");
                    alert(Shiftnotallocated);
                }   
                else
                {  
                    document.getElementById('ctl00_BodyContentPH_txt_E2ActualShift').value=response;
                }
         }
	}
}
function InsertEmployeeDetailsShiftExchange(e)
{
    var rdbId = e.id;
    var elm=document.aspnetForm.elements;
    for(i=0;i<elm.length;i++)
    {
        if(elm[i].type=="radio")
        { 
            if(elm[i].checked==true && elm[i] != e)
            {
                elm[i].checked = false;
            }
        }
    }
    document.getElementById('hdnEmployeeCodeId').value = e.value;
}
  function ProcessTheResponse_ShiftExchange()
  {
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
		  //alert("Record Inserted");
		}
	}
}
	function ProcessTheResponse_ShiftExchange1()
    {
	    if (obj.readyState == 4)
	    {
		    if(obj.status == 200)
		    {
		        //alert("Record Deleted");
		    }
	    }
}
function CloseShiftExchangeWindow()
{
var selVal = document.getElementById('hdnEmployeeCodeId').value;
var txtFld = document.getElementById('hdnTxtField').value;

parent.$('#myModal').modal('hide');
assignValueShiftExchange(selVal,txtFld);
//document.getElementById('ctl00_BodyContentPH_txt_EmployeeId').value=selVal;

}
function assignValueShiftExchange(selValue,txtFld)
{
var txtFlds='ctl00_BodyContentPH_' + txtFld;
if(selValue != "")
{
parent.$("#" + txtFlds).val(selValue);
parent.$('#' + txtFlds).focus();
}
}
//For Pop up windows
function OpenWindowShiftExchange(Txt,isFrom)
{
    var url = 'PopUp_ShiftExchange.aspx?Txt=' + Txt + '&ID=' + Math.random() + '&isFrom=' + isFrom;
//        window.open(url,'','top=100px, width=1000px, height=500px, scrollbars=yes, status=yes, resizable=no');
        document.getElementById('ctl00_BodyContentPH_iframePopup').src = url;
        return false;
}
//For Pop up windows
function OpenWindowShiftExchangeGrid(Txt) {
    var url = 'PopUp_ShiftAddGrid.aspx?Txt=' + Txt + '&ID=' + Math.random() + '&isFrom=' + isFrom;
    //        window.open(url,'','top=100px, width=1000px, height=500px, scrollbars=yes, status=yes, resizable=no');
    document.getElementById('ctl00_BodyContentPH_iframePopup').src = url;
    return false;
}
//For Compensation Pop up
function OpenWindowCompensationEntry(Txt)
{
    var url='PopUp_CompensationEntry.aspx?Txt=' + Txt + '&ID=' + Math.random();    
        window.open(url,'','left=250px, top=245px, width=1000px, height=450px, scrollbars=yes, status=yes, resizable=no');
        return false;
}
