// JScript File
//Insert Shift Details
var obj;
var drpcount;
var count =0;
var Count1,link;
function InsertShift()
{
    alert("testinsert");
    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 link1=Getlink();
	    alert("s" + count);
	    if(window.ActiveXObject)
        {
		    obj.onreadystatechange = ProcessTheResponse;		
		    obj.open("POST",link1, true);
		    obj.send(null);
		}
		else if(window.XMLHttpRequest)
        {
		    obj.open("POST",link1, false);
		    obj.send(null);
		    obj.onreadystatechange = ProcessTheResponse();		
        }
	}
	return false;
}
function ProcessTheResponse()
{
	if (obj.readyState == 4)
	{
		if(obj.status == 200)
		{
        	var response=obj.responseText;
		}
	}
}
function Getlink()
{
    alert("getlink");
    alert("Count" + Count1);
    var patterntype=document.aspnetForm.ddl_Pattern.value;
   var PatternName,Sday,day1id,day2id,day3id,day4id,day5id,day6id,day7id,day8id,day9id,day10id,day11id,day12id,day13id,day14id,day15id,
        day16id,day17id,day18id,day19id,day20id,day21id,day22id,day23id,day24id,day25id,day26id,day27id,day28id,day29id,day30id;
    if(patterntype=="Daily")
    {
        alert("daily");
        if(Count1 == 1)
        {
            PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            Sday=document.aspnetForm.ddl_Sday.value;
            day1id=document.aspnetForm.ddl_DPattern1.value;
            link = "RemoteDaily.aspx?";
            link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
            alert(link);
            return false;
        }
        else if(Count1 == 2)
        {
            PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            Sday=document.aspnetForm.ddl_Sday.value;
            day1id=document.aspnetForm.ddl_DPattern1.value;
            day2id=document.aspnetForm.ddl_DPattern2.value;
            link = "RemoteDaily.aspx?";
            link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
            link = link + "&" + "day2id=" + day2id;
            return false;
        }
        else if(Count1 == 3)
        {
            PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            Sday=document.aspnetForm.ddl_Sday.value;
            day1id=document.aspnetForm.ddl_DPattern1.value;
            day3id=document.aspnetForm.ddl_DPattern3.value;
            link = "RemoteDaily.aspx?";
            link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
            link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id;
            return false;
        }
        else if(Count1 == 4)
        {
            PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            Sday=document.aspnetForm.ddl_Sday.value;
            day1id=document.aspnetForm.ddl_DPattern1.value;
            day3id=document.aspnetForm.ddl_DPattern3.value;
            day4id=document.aspnetForm.ddl_DPattern4.value;
            link = "RemoteDaily.aspx?";
            link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
            link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id + "&" + "day4id=" + day4id;
            return false;
        }
        else if(Count1 == 5)
        {
            PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            Sday=document.aspnetForm.ddl_Sday.value;
            day1id=document.aspnetForm.ddl_DPattern1.value;
            day3id=document.aspnetForm.ddl_DPattern3.value;
            day4id=document.aspnetForm.ddl_DPattern4.value;
            day5id=document.aspnetForm.ddl_DPattern5.value;
            link = "RemoteDaily.aspx?";
            link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
            link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id + "&" + "day4id=" + day4id + "&" + "day5id=" + day5id;
            return false;
        }
        else if(Count1 == 6 )
        {
            PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            Sday=document.aspnetForm.ddl_Sday.value;
            day1id=document.aspnetForm.ddl_DPattern1.value;
            day3id=document.aspnetForm.ddl_DPattern3.value;
            day4id=document.aspnetForm.ddl_DPattern4.value;
            day5id=document.aspnetForm.ddl_DPattern5.value;
            day6id=document.aspnetForm.ddl_DPattern6.value;
            link = "RemoteDaily.aspx?";
            link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
            link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id + "&" + "day4id=" + day4id + "&" + "day5id=" + day5id + "&" + "day6id=" + day6id ;
            return false;
        }
    }
    else if(patterntype=="Weekly")
    {
        PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
        Sday=document.aspnetForm.ddl_Sday.value;
        day1id=document.aspnetForm.ddl_WeeklyPattern1.value;
        day2id=document.aspnetForm.ddl_WeeklyPattern2.value;
        day3id=document.aspnetForm.ddl_WeeklyPattern3.value;
        day4id=document.aspnetForm.ddl_WeeklyPattern4.value;
        day5id=document.aspnetForm.ddl_WeeklyPattern5.value;
        day6id=document.aspnetForm.ddl_WeeklyPattern6.value;
        day7id=document.aspnetForm.ddl_WeeklyPattern7.value;
        link = "RemoteDaily.aspx?";
        link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
        link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id + "&" + "day4id=" + day4id + "&" + "day5id=" + day5id + "&" + "day6id=" + day6id + "&" + "day7id=" + day7id; 
        return false;
    }
    else if(patterntype == "Fortnightly")
    {
         PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
         Sday=document.aspnetForm.ddl_Sday.value;
         day1id=document.aspnetForm.ddl_ForthNight1.value;
         day2id=document.aspnetForm.ddl_ForthNight2.value;
         day3id=document.aspnetForm.ddl_ForthNight3.value;
         day4id=document.aspnetForm.ddl_ForthNight4.value;
         day5id=document.aspnetForm.ddl_ForthNight5.value;
         day6id=document.aspnetForm.ddl_ForthNight6.value;
         day7id=document.aspnetForm.ddl_ForthNight7.value;   
         day8id=document.aspnetForm.ddl_ForthNight8.value;
         day9id=document.aspnetForm.ddl_ForthNight9.value;
         day10id=document.aspnetForm.ddl_ForthNight10.value;
         day11id=document.aspnetForm.ddl_ForthNight11.value;
         day12id=document.aspnetForm.ddl_ForthNight12.value;
         day13id=document.aspnetForm.ddl_ForthNight13.value; 
         day14id=document.aspnetForm.ddl_ForthNight14.value;
         day15id=document.aspnetForm.ddl_ForthNight15.value;
        link = "RemoteDaily.aspx?";
        link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
        link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id + "&" + "day4id=" + day4id + "&" + "day5id=" + day5id + "&" + "day6id=" + day6id + "&" + "day7id=" + day7id; 
        link = link + "&" + "day8id=" + day8id + "&" + "day9id=" + day9id + "&" + "day10id=" + day10id + "&" + "day11id=" + day11id + "&" + "day12id=" + day12id + "&" + "day13id=" + day13id; 
        link = link + "&" + "day14id=" + day14id + "&" + "day15id=" + day15id; 
         alert(link);
         return false;
    }
    else if(patterntype == "Monthly")
    {
         PatternName=document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
         Sday=document.aspnetForm.ddl_Sday.value;
         day1id=document.aspnetForm.ddl_Monthly1.value;
         day2id=document.aspnetForm.ddl_Monthly2.value;
         day3id=document.aspnetForm.ddl_Monthly3.value;
         day4id=document.aspnetForm.ddl_Monthly4.value;
         day5id=document.aspnetForm.ddl_Monthly5.value;
         day6id=document.aspnetForm.ddl_Monthly6.value;
         day7id=document.aspnetForm.ddl_Monthly7.value;   
         day8id=document.aspnetForm.ddl_Monthly8.value;
         day9id=document.aspnetForm.ddl_Monthly9.value;
         day10id=document.aspnetForm.ddl_Monthly10.value;
         day11id=document.aspnetForm.ddl_Monthly11.value;
         day12id=document.aspnetForm.ddl_Monthly12.value;
         day13id=document.aspnetForm.ddl_Monthly13.value;
         day14id=document.aspnetForm.ddl_Monthly14.value;
         day15id=document.aspnetForm.ddl_Monthly15.value;
         day16id=document.aspnetForm.ddl_Monthly16.value;
         day17id=document.aspnetForm.ddl_Monthly17.value;
         day18id=document.aspnetForm.ddl_Monthly18.value;
         day19id=document.aspnetForm.ddl_Monthly19.value;
         day20id=document.aspnetForm.ddl_Monthly20.value;
         day21id=document.aspnetForm.ddl_Monthly21.value;
         day22id=document.aspnetForm.ddl_Monthly22.value;   
         day23id=document.aspnetForm.ddl_Monthly23.value;
         day24id=document.aspnetForm.ddl_Monthly24.value;
         day25id=document.aspnetForm.ddl_Monthly25.value;
         day26id=document.aspnetForm.ddl_Monthly26.value;
         day27id=document.aspnetForm.ddl_Monthly27.value;
         day28id=document.aspnetForm.ddl_Monthly28.value;
         day29id=document.aspnetForm.ddl_Monthly29.value;
         day30id=document.aspnetForm.ddl_Monthly30.value;
        link = "RemoteDaily.aspx?";
        link = link + "patternname=" + PatternName + "&" + "patterntype=" + patterntype + "&" + "startingday="+ Sday + "&" + "day1id=" + day1id;
        link = link + "&" + "day2id=" + day2id + "&" + "day3id=" + day3id + "&" + "day4id=" + day4id + "&" + "day5id=" + day5id + "&" + "day6id=" + day6id + "&" + "day7id=" + day7id; 
        link = link + "&" + "day8id=" + day8id + "&" + "day9id=" + day9id + "&" + "day10id=" + day10id + "&" + "day11id=" + day11id + "&" + "day12id=" + day12id + "&" + "day13id=" + day13id; 
        link = link + "&" + "day14id=" + day14id + "&" + "day15id=" + day15id; 
        link = link + "&" + "day16id=" + day16id + "&" + "day17id=" + day17id + "&" + "day18id=" + day18id + "&" + "day19id=" + day19id + "&" + "day20id=" + day20id + "&" + "day21id=" + day21id;  
        link = link + "&" + "day22id=" + day22id + "&" + "day23id=" + day23id + "&" + "day24id=" + day24id + "&" + "day25id=" + day25id + "&" + "day26id=" + day26id + "&" + "day27id=" + day27id;  
        link = link + "&" + "day28id=" + day28id + "&" + "day29id=" + day29id + "&" + "day30id=" + day30id ;        
       // alert(link);
    }
 return link;
}
///Daily pattern
function AjaxDvia(Errorretrievingdata)
{
	    Count1=GetCount();
	    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 ActiveXObject("Msxml2.XMLHTTP");
//		    
//	    }
//	    catch(e)
//	    {
//		    try
//		    {
//			    obj = new ActiveXObject("Microsoft.XMLHTTP");
//			    
//		    }
//		    catch(e1)
//		    {
//			    obj = null;
//		    }
//	    }
	    if(obj!=null)
	    {
    		alert("test");
		    var url;
		    var c;
                c=document.getElementById('sel_daily').value
                alert("test" + c);
                if(window.ActiveXObject)
                {
                    obj.onreadystatechange = ProcessResponse;
		            url="RemoteDaily.aspx?Daily=" + c;
		            alert(url);
		            obj.open("POST", url,  true);
		            obj.send(null);  
		        }  
		        else if(window.XMLHttpRequest)
                {
                    url="RemoteDaily.aspx?Daily=" + c;
                    alert(url);
                    obj.open("POST", url,  false);
                    obj.send(null); 
                    obj.onreadystatechange = ProcessResponse();
                } 
	    }
	    return false;
   }
   function ProcessResponse()
    {
	    if(obj.readyState == 4)
	    {
		    if(obj.status == 200)
		    {
		       var te=obj.responseText;
		       document.getElementById('div__Pattern').innerHTML=te;
		    }
		    else
		    {
			    //alert("Error retrieving data!" );
			    alert(Errorretrievingdata);
		    }
	    }
    } 
 function GetCount()
 {
        count =document.getElementById('sel_daily').value;
}
