
// stores the reference to the XMLHttpRequest object 
var xmlHttp2 = createXmlHttpRequestObject();
var xmlHttp3 = createXmlHttpRequestObject();
var subfirstlim=0;
var subsecondlim=1;
var subcount=10;

// retrieves the XMLHttpRequest object 
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 processsub(userid,limitsensor,vidcount) 
{ 
	
	if(limitsensor == 0)
	{
	//	usersecondlim=userfirstlim;
		subfirstlim=subfirstlim-4;
	}
	if(limitsensor == 1)
	{
		subfirstlim=subfirstlim+4;
	//	usersecondlim=usersecondlim+4;
		
	}
	if(limitsensor == 3)
	{
		subfirstlim=0;
		subsecondlim=4;
	}
		
	tempvar2=subfirstlim+4
	
	subcount=vidcount;
	
	/*alert(userfirstlim+ "temp--" +tempvar +"count--" + subcount)*/
			if( subfirstlim==0)
			{
					document.getElementById("img5").disabled= true;
					
			}
			else
			{
					document.getElementById("img5").disabled= false;
			}
			if(subfirstlim>=subcount-1||tempvar2>=subcount)
			{
					document.getElementById("img6").disabled= true;
			
			}
			else
			{
					document.getElementById("img6").disabled= false;
			}
	
// proceed only if the xmlHttp object isn't busy 
			if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == 0) 
			{ 
				
						
				var url="userprofilesubscribe_ajx.php?userid="+userid+"&subfirstlim="+subfirstlim+"&subsecondlim="+subsecondlim;
				xmlHttp2.open("GET",url,true)
											
						// define the method to handle server responses 
						xmlHttp2.onreadystatechange = handleServerResponse2; 
						// make the server request 
						xmlHttp2.send(null); 
			} 
			
						// if the connection is busy, try again after one second 
} 
// executed automatically when a message is received from the server 
function handleServerResponse2() 
{ 
			// move forward only if the transaction has completed 
			if (xmlHttp2.readyState == 4) 
			{ 
			// status of 200 indicates the transaction completed successfully 
			
					if (xmlHttp2.status == 200) 
					{
							// extract the XML retrieved from the server 
							
							xmlResponse =  xmlHttp2.responseText;
							//alert(xmlResponse);
							var info=document.getElementById("sub_info");
							info.innerHTML=xmlResponse;
							
							
							// obtain the document element (the root element) of the XML structure 
							//xmlDocumentElement = xmlResponse.documentElement; 
							// get the text message, which is in the first child of 
							// the the document element 
							//helloMessage = xmlDocumentElement.firstChild.data; 
							// update the client display using the data received from the server 
							//alert(helloMessage);
							//document.getElementById("company_name").value = 
							//'<i>' + helloMessage + '</i>'; 
							// restart sequence 
							//setTimeout('process()', 1000); 
					} 
					// a HTTP status different than 200 signals an error 
					else 
					{ 
							alert("There was a problem accessing the server: " + xmlHttp2.statusText); 
					} 
			} 
} 


