// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject(); 
// 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 tag_radio_search(searchby)
{
	document.getElementById("open_hidden").value="openopen";
	var hidden_field = document.getElementById("hidden_field").value;
	//alert("fas");
	document.getElementById("open").innerHTML ="<img src='images/ajax-loader.gif'>";
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		xmlHttp.open("GET", "popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby,true); 
	}

	xmlHttp.onreadystatechange = load_ques;
	xmlHttp.send(null);
}

function load_ques()
{
 if (xmlHttp.readyState == 4) 
  {
		if (xmlHttp.status == 200) 
		{			
			 document.getElementById('open').innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
  }
  else 
    {
      //alert("here was a problem accessing the server: " );
    }
}

/*/////-------------------Starting for Index Resolved --------------------/*/

function tag_radio_search_resolved(searchby)
{
	document.getElementById("open_hidden").value='resolvedresolved';
	var hidden_field = document.getElementById("hidden_field1").value;
	document.getElementById("resolved").innerHTML ="<img src='images/ajax-loader.gif'>";
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{
				xmlHttp.open("GET", "popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby,true); 
			}
				xmlHttp.onreadystatechange = load_ques_resolved;
		xmlHttp.send(null);
	}

function load_ques_resolved()
{
 if (xmlHttp.readyState == 4) 
  {
		if (xmlHttp.status == 200) 
		{			
			 document.getElementById('resolved').innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
  }
  else 
    {
      //alert("here was a problem accessing the server: " );
    }
}
/*/////-------------------Ending for Index Resolved ---------------------/*/ 

/*/////-------------------Starting for All ------------------------------/*/

function tag_radio_search_all(searchby)
{
	document.getElementById("open_hidden").value="all";
	var hidden_field = document.getElementById("hidden_field2").value;
	document.getElementById("all").innerHTML ="<img src='images/ajax-loader.gif'>";
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		xmlHttp.open("GET", "popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby,true); 
	}
					xmlHttp.onreadystatechange = load_ques2;
		xmlHttp.send(null);
}

function load_ques2()
{
	if (xmlHttp.readyState == 4) 
	{
		if (xmlHttp.status == 200) 
		{			
			 //alert(ta);
			 document.getElementById('all').innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
	else 
	{
	//alert("here was a problem accessing the server: " );
	}
}


/*/////-------------------Starting for Open1 ------------------------------/*/

function tag_radio_search_open1(searchby)
{
	document.getElementById("open_hidden").value="open1";
	var hidden_field = document.getElementById("hidden_field3").value;
	document.getElementById("open1").innerHTML ="<img src='images/ajax-loader.gif'>";
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		xmlHttp.open("GET", "popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby,true); 
	}
					xmlHttp.onreadystatechange = load_ques3;
		xmlHttp.send(null);
}

function load_ques3()
{
	if (xmlHttp.readyState == 4) 
	{
		if (xmlHttp.status == 200) 
		{			
			 //alert(ta);
			 document.getElementById('open1').innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
	else 
	{
	//alert("here was a problem accessing the server: " );
	}
}

///// End open1 /////

/*/////-------------------Starting for noanswer ------------------------------/*/

function tag_radio_search_noanswer(searchby)
{
	document.getElementById("open_hidden").value="noanswer";
	var hidden_field = document.getElementById("hidden_field4").value;
	//alert(hidden_field);
	document.getElementById("noanswer").innerHTML ="<img src='images/ajax-loader.gif'>";
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		//alert("popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby);
		xmlHttp.open("GET", "popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby,true); 
	}
					xmlHttp.onreadystatechange = load_ques4;
		xmlHttp.send(null);
}

function load_ques4()
{
	if (xmlHttp.readyState == 4) 
	{
		if (xmlHttp.status == 200) 
		{			
			 //alert(ta);
			 document.getElementById('noanswer').innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
	else 
	{
	//alert("here was a problem accessing the server: " );
	}
}

///// End noanswer /////


function page_content(mode,tab)
{
	ta = tab;
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		//alert(mode);
		xmlHttp.open("GET", "page_content.php?mode="+mode,true); 
	}
	// define the method to handle server responses
			xmlHttp.onreadystatechange = load_tab;
			//alert("awadhaldjf");
	
	xmlHttp.send(null);
}

function load_tab()
{
	if (xmlHttp.readyState == 4) 
	{
		if (xmlHttp.status == 200) 
		{			
			 //alert(ta);
			 document.getElementById(ta).innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
	else 
	{
	  //alert("here was a problem accessing the server: " );
	}
}

function channel(cat,subcat,title,subtitle)
{
	document.getElementById("mention").innerHTML='Category: Home ->'+title+' -> '+subtitle;
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		//alert("channel_session.php?cat="+cat+"&subcat="+subcat);
		xmlHttp.open("GET", "channel_session.php?cat="+cat+"&subcat="+subcat,true); 
	}
		xmlHttp.onreadystatechange = channel_load;
	
		xmlHttp.send(null);
}

function channel_load()
{
	if (xmlHttp.readyState == 4) 
	{
		if (xmlHttp.status == 200) 
		{			
			 var aa=document.getElementById("open_hidden").value;
			 if(aa=='openopen')
			 {
			 tag_radio_search("recent");
			 }
			 else if(aa=='resolvedresolved')
			 {
				 tag_radio_search_resolved("recent");
			 }
			 else if(aa=='all')
			 {
				 tag_radio_search_all("recent");
			 }
			 else if(aa=='open1')
			 {
				 tag_radio_search_open1("recent");
			 }
			  else if(aa=='noanswer')
			 {
				 tag_radio_search_noanswer("recent");
			 }
		} 
		else 
		{
		  //alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
	else 
	{
	  //alert("here was a problem accessing the server: " );
	}
}

//////////////////////////////


function channel1(cat,subcat)
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		alert("fdshfksdfh");
		xmlHttp.open("GET", "channel_session.php?cat="+cat+"&subcat="+subcat,true); 
	}
		xmlHttp.onreadystatechange = channel_load1;
	
		xmlHttp.send(null);
}

function channel_load1()
{
	if (xmlHttp.readyState == 4) 
	{
		if (xmlHttp.status == 200) 
		{			
			 //var aa=document.getElementById("open_hidden").value;
			 //alert(aa);
			/* if(aa=='openopen')
			 {
			 	//tag_radio_search("recent");
			 }
			 else
			 {
				 //tag_radio_search_resolved("recent");
			}*/
			document.getElementById('awadh').innerHTML = xmlHttp.responseText ;
			
		} 
		else 
		{
		  //alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
	else 
	{
	  //alert("here was a problem accessing the server: " );
	}
}

///////////////////////////////


////////////////// Ranjan ////////////////////

function getsub(id)
{ 
	var url="select_sub_category.php";
	url=url+"?sub_cat_id="+id;
	//alert(url);
	//url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=subChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function subChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	//alert(xmlHttp.responseText);
	document.getElementById("subdiv").innerHTML=xmlHttp.responseText;
	}
}

////////////////// End  /////////////////////////////

////////////////// Start pagging  /////////////////////////////
var hidden_field;
function pagging(p,rt,show)
{
	hidden_field = rt;
	//alert(hidden_field);
	var searchby=show;
	//alert(searchby);
	var page =p;
	
	//document.getElementById("errormsg").innerHTML ="<img src='images/indicator.gif'>";	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{			
		 //if(rt==) // pagging review terminal
		//{
			xmlHttp.open("GET", "popular_qa.php?tab_tab="+hidden_field+"&searchby="+searchby+"&page="+page, true);
			// define the method to handle server responses
			xmlHttp.onreadystatechange = search_pagging;
			// make the server request
			xmlHttp.send(null);	
		//}
	}
}
function search_pagging()
{
   if (xmlHttp.readyState == 4) 
  {
		if (xmlHttp.status == 200) 
		{			
			 document.getElementById(hidden_field).innerHTML = xmlHttp.responseText ;
		} 
		else 
		{
		  alert("here was a problem accessing the server: " + xmlHttp.statusText);
		}
  }
  else 
    {
      //alert("here was a problem accessing the server: " );
    }
}


//////////////////  End pagging  /////////////////////////////
