// JScript File
var objShiftPattern;
var objCheckPattern;
function changeShiftRoaster(DdlNo, NewValue)
{ 
    if(window.ActiveXObject)
    {    
        try
        {
            objShiftPattern = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                objShiftPattern = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                objShiftPattern = null;
            }
        }
    }  
     else if(window.XMLHttpRequest)
     {
        try
        {
            objShiftPattern = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                objShiftPattern = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                objShiftPattern = null;
            }
        }
     }       
//    try
//    {
//        objShiftPattern = new ActiveXObject("Msxml2.XMLHTTP");
//    }
//    catch(e)
//    {
//        objShiftPattern = new XMLHttpRequest();
//    }
        var link = "ShiftRoasterServer.aspx?ddlno="+DdlNo+"&newvalue="+document.getElementById(NewValue)[document.getElementById(NewValue).selectedIndex].value+"";
        if(window.ActiveXObject)
        { 
            objShiftPattern.open("POST", link , true);
            objShiftPattern.onreadystatechange = hanldeResponse;
            objShiftPattern.send(null);
        }
        else if(window.XMLHttpRequest)
        {
            objShiftPattern.open("POST", link , false);
            objShiftPattern.send(null);
            objShiftPattern.onreadystatechange = hanldeResponse();
        }
}
function hanldeResponse()
{    
    if(objShiftPattern.readyState == 200 && objShiftPattern.status == 4)
    {
    }   
}
function CheckShiftRosterTime(shiftValue,rost)
{
    if(window.ActiveXObject)
    {    
        try
        {
            objCheckPattern = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                objCheckPattern = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                objCheckPattern = null;
            }
        }
    }  
     else if(window.XMLHttpRequest)
     {
        try
        {
            objCheckPattern = new XMLHttpRequest("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                objCheckPattern = new XMLHttpRequest("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                objCheckPattern = null;
            }
        }
     }         
//    try
//	{
//		objCheckPattern = new XmlHttpRequest();
//	}
//	catch(e)
//	{
//		try
//		{
//			objCheckPattern = new ActiveXObject("Microsoft.XMLHTTP");
//		}
//		catch(e1)
//		{
//			objCheckPattern = new ActiveXObject("Msxml2.XMLHTTP");
//		}
//	}
    if(objCheckPattern!=null)
	{
        var rndValue=Math.floor(Math.random()*111);
        if(window.ActiveXObject)
        {
            objCheckPattern.onreadystatechange = ResponseCheckShiftRosterTime;
            objCheckPattern.open("POST", "../Masters/ShiftRosterRemote.aspx?shiftPatternValue="+ shiftValue +"&rost="+rost+"&rndValue="+rndValue,  false);
	        objCheckPattern.send(null);
	    }
	    else if(window.XMLHttpRequest)
        {
            objCheckPattern.open("POST", "../Masters/ShiftRosterRemote.aspx?shiftPatternValue="+ shiftValue +"&rost="+rost+"&rndValue="+rndValue,  false);
            objCheckPattern.send(null);
            objCheckPattern.onreadystatechange = ResponseCheckShiftRosterTime();
        }
	}
}
function ResponseCheckShiftRosterTime()
{
    if (objCheckPattern.readyState == 4)
	{	           	
		if(objCheckPattern.status == 200)
		{    
		 var response=objCheckPattern.responseText;                        
            if (response=="Success")
             {
                    // no overlapping of shift time   
                    document.getElementById("hidFlag").value=0;
                    return 1;
             }
           else
           {
              // over laps of the shift time
               document.getElementById("hidFlag").value=response;
               alert(response);
               return 0;
           }          
		}
	}
}