// JScript File

var obj;
function ShiftExchange1()
{
	
	
	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_CP_Transaction_txt_E1Date').value
		var EmpId=document.getElementById('ctl00_CP_Transaction_txt_Ecode1').value
		
		if(E1date != "")
		{
		    obj.onreadystatechange = ProcessTheResponseShiftExChange1;		
		    obj.open("GET","AjaxShiftExchange.aspx?Edate=" + E1date + "&EmpId=" + EmpId + "&RanId=" + Math.random(),true)
		    obj.send(null);
		    
		} 
	}
	return false;
}
function ProcessTheResponseShiftExChange1()
{ 
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
            var response=obj.responseText;
            
                      
            //alert(response);          
            document.getElementById('ctl00_CP_Transaction_txt_E1ActualShift').value=response;
         
         }
          
	
	}
}




function ShiftExchange2()
{
	
	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_CP_Transaction_txt_E2Date2').value
		var EmpId=document.getElementById('ctl00_CP_Transaction_txt_Ecode2').value
		
		if(E2date != "")
		{
		    obj.onreadystatechange = ProcessTheResponseShiftExChange2;		
		    obj.open("POST","AjaxShiftExchange.aspx?EDate=" + E2date + "&EmpId=" + EmpId + "&RanId=" + Math.random(),true)
		    obj.send(null);
		    
		} 
	}
	return false;
}
function ProcessTheResponseShiftExChange2()
{ 
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
            var response=obj.responseText;
          
           document.getElementById('ctl00_CP_Transaction_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;
self.close();

window.opener.assignValueShiftExchange(selVal, txtFld);



}

function assignValueShiftExchange(selValue,txtFld)
{
var txtFlds='ctl00_CP_Transaction_' + txtFld;
document.getElementById(txtFlds).value = selValue;
document.getElementById(txtFlds).focus();
}



//For Pop up windows

function OpenWindowShiftExchange(Txt)
{
 
    var url='PopUp_ShiftExchange.aspx?Txt=' + Txt + '&ID=' + Math.random();
    
        window.open(url,'','left=250px, top=245px, width=700px, height=450px, scrollbars=no, status=no, resizable=no');
        return false;
    
}

