
// stores the reference to the XMLHttpRequest object 
var xmlHttp = createXmlHttpRequestObject();
var xmlHttp1= createXmlHttpRequestObject();
// retrieves the XMLHttpRequest object 
var chafirstlim=0;
var chasecondlim=1;
var chacount=10;
var vdofirstlim=0;
var vdosecondlim=1;
var vdocount=10;
var vdo_oldfirstlim=0;
var vdo_oldsecondlim=1;
var vdo_oldcount=10;
var action ;
function createXmlHttpRequestObject() 
{ 
// will store the reference to the XMLHttpRequest object 
	var xmlHttp; 
// if running Internet Explorer 
			if(window.ActiveXObject) 
			{ 
					try 
					{ 
							xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
					} 
					catch (e) 
					{ 
							xmlHttp = false; 
					} 
			} 
			// if running Mozilla or other browsers 
			else 
			{ 
					try 
					{ 
							xmlHttp = new XMLHttpRequest(); 
							
					} 
					catch (e) 
					{ 
							xmlHttp = false; 
					} 
			} 	
			// return the created object or display an error message 
			if (!xmlHttp) 
					alert("Error creating the XMLHttpRequest object."); 
			else 
					return xmlHttp; 
} 
function process_channel_result(action1,network_id,schedul_id,limitsensor,vidcount1,videoid,fixsize)
{
		
		
	action=action1;
	var firstlimit;
	if(action==3)
	{
				
				if(limitsensor == 0)
				{
				//	usersecondlim=userfirstlim;
					vdofirstlim=vdofirstlim-4;
				}
				if(limitsensor == 1)
				{
					vdofirstlim=vdofirstlim+4;
				//	usersecondlim=usersecondlim+4;
					
				}
				
				
				
				tempvar1=vdofirstlim+4
				vdocount=vidcount1;	
					/*alert(userfirstlim+ "temp--" +tempvar +"count--" + subcount)*/
				
				if(vdofirstlim==0)
						{
								document.getElementById("img3").disabled= true;
								
						}
						else
						{
								document.getElementById("img3").disabled= false;
						}
						if(vdofirstlim>=vdocount-1||tempvar1>=vdocount)
						{
								
								document.getElementById("img4").disabled= true;
						
						}
						else
						{
								document.getElementById("img4").disabled= false;
						}
						firstlimit=vdofirstlim;
	}
	if(action==4)
	{
				
				if(limitsensor == 0)
				{
				//	usersecondlim=userfirstlim;
					vdo_oldfirstlim=vdo_oldfirstlim-4;
				}
				if(limitsensor == 1)
				{
					vdo_oldfirstlim=vdo_oldfirstlim+4;
				//	usersecondlim=usersecondlim+4;
					
				}
				
				
				
				tempvar1=vdo_oldfirstlim+4
				vdo_oldcount=vidcount1;	
					/*alert(userfirstlim+ "temp--" +tempvar +"count--" + subcount)*/
				
				if(vdo_oldfirstlim==0)
						{
								document.getElementById("img5").disabled= true;
								
						}
						else
						{
								document.getElementById("img5").disabled= false;
						}
						if(vdofirstlim>=vdocount-1||tempvar1>=vdocount)
						{
								
								document.getElementById("img6").disabled= true;
						
						}
						else
						{
								document.getElementById("img6").disabled= false;
						}
				firstlimit=vdo_oldfirstlim;		
	}
	if(action==1)
	{
		vdofirstlim=0;
		vdosecondlim=4;	
	}
	
	if (xmlHttp1.readyState == 4 || xmlHttp1.readyState == 0) 
			{ 
				
						
		      var url="revo_network_channel_id_ajx.php?action="+action+"&network_id="+network_id+"&schedul_id="+schedul_id+"&userfirstlim="+firstlimit+"&videoid="+videoid+"&fixsize="+fixsize;
			  
				xmlHttp1.open("GET",url,true)
											
						// define the method to handle server responses 
						xmlHttp1.onreadystatechange = handleServerResponse1; 
						// make the server request 
						xmlHttp1.send(null); 
			} 
	
}
function processchannel(limitsensor,vidcount) 
{ 

	if(limitsensor == 0)
	{
	//	usersecondlim=userfirstlim;
		chafirstlim=chafirstlim-4;
	}
	if(limitsensor == 1)
	{
		chafirstlim=chafirstlim+4;
	//	usersecondlim=usersecondlim+4;
		
	}
	if(limitsensor == 3)
	{
		chafirstlim=0;
		chasecondlim=4;
	}
	
	
	tempvar1=chafirstlim+4
	chacount=vidcount;	
		/*alert(userfirstlim+ "temp--" +tempvar +"count--" + subcount)*/
	if(chafirstlim==0)
			{
					document.getElementById("img1").disabled= true;
					
			}
			else
			{
					document.getElementById("img1").disabled= false;
			}
			if(chafirstlim>=chacount-1||tempvar1>=chacount)
			{
					document.getElementById("img2").disabled= true;
			
			}
			else
			{
					document.getElementById("img2").disabled= false;
			}
	
// proceed only if the xmlHttp object isn't busy 
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) 
			{ 
				
						
				var url="revo_network_channel_ajx.php?userfirstlim="+chafirstlim+"&usersecondlim="+chasecondlim;
				xmlHttp.open("GET",url,true)
											
						// define the method to handle server responses 
						xmlHttp.onreadystatechange = handleServerResponse; 
						// make the server request 
						xmlHttp.send(null); 
			} 
			
						// if the connection is busy, try again after one second 
} 


function handleServerResponse() 
{ 
		
		// move forward only if the transaction has completed 
			if (xmlHttp.readyState == 4) 
			{ 
			// status of 200 indicates the transaction completed successfully 
			
					if (xmlHttp.status == 200) 
					{
							// extract the XML retrieved from the server 
							
							xmlResponse =  xmlHttp.responseText;
							//alert(xmlResponse);
							
								var info=document.getElementById("channel_dispaly");
								info.innerHTML=xmlResponse;
							
							
							
							
							
					} 
					// a HTTP status different than 200 signals an error 
					else 
					{ 
							alert("There was a problem accessing the server: " + xmlHttp.statusText); 
					} 
			} 
} 
function handleServerResponse1() 
{ 
		
		// move forward only if the transaction has completed 
			if (xmlHttp1.readyState == 4) 
			{ 
			// status of 200 indicates the transaction completed successfully 
			
					if (xmlHttp1.status == 200) 
					{
							// extract the XML retrieved from the server 
							
							xmlResponse =  xmlHttp1.responseText;
							//alert(xmlResponse);
							if(action==1)
							{
								var info=document.getElementById("channel_detail_dispaly");
								info.innerHTML=xmlResponse;
							}
							if(action==2)
							{
								var info=document.getElementById("video_dispaly");
								info.innerHTML=xmlResponse;
							}
							if(action==3)
							{
								var info=document.getElementById("video_list_dispaly");
								info.innerHTML=xmlResponse;
							}
							if(action==4)
							{
								var info=document.getElementById("video_old_list_dispaly");
								info.innerHTML=xmlResponse;
							}
							
							
					} 
					// a HTTP status different than 200 signals an error 
					else 
					{ 
							alert("There was a problem accessing the server: " + xmlHttp.statusText); 
					} 
			} 
} 
