// JavaScript Document
function nextQuestion(){
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			  document.getElementById("fade").innerHTML=xmlHttp.responseText;
		  }
		 /* else
		  {
			document.getElementById("fade").style= "opacity:0.4;filter:alpha(opacity=40)";
		  }*/
		}
	   var limit = document.countform.count.value;
	    if(limit == 6)
		{
			document.countform.count.value=0;
		}
		 else
		 {
			document.countform.count.value= eval(limit)+1;
		 }
		 
	  xmlHttp.open("GET","indexBestAnswer.php?id="+limit,true);
	  xmlHttp.send(null);
}


function init()
{
	
	showtime = setInterval("nextQuestion()",9000);
}

function stopRotation()
{
	clearInterval(showtime);	
}


function showQuestions(cat){
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			  document.getElementById("answerslist").innerHTML=xmlHttp.responseText;
		  }
		  else
		  {
			document.getElementById("answerslist").innerHTML= "<div align='center' style='height:100px;padding-top:60px;'><img src='http://static.commodityonline.com/qaimages/ajax-loader-red.gif' width='31' height='31' /></div>";
		  }
		}
	  xmlHttp.open("GET","indexAnswerList.php?cat="+cat,true);
	  xmlHttp.send(null);
}


function moveUp(id)
{
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			    document.getElementById("up-"+id).innerHTML=xmlHttp.responseText;
		  }
		 /* else
		  {
			document.getElementById("fade").innerHTML= "<div align='center' style='height:100px;padding-top:60px;'><img src='staticimg/ajax-loader-red.gif' width='31' height='31' /></div>";
		  }*/
		}
/*	  xmlHttp.open("GET","http://192.168.1.104/websites/qa/upRate.php?id="+id+"&name="+name+"&ucount="+ucount+"&dcount="+dcount,true);
	  xmlHttp.send(null);	*/	
	  
	  xmlHttp.open("GET","http://qa.commodityonline.com/upRate.php?id="+id,true);
	 /*xmlHttp.open("GET","http://localhost/qa/upRate.php?id="+id,true);*/
	  xmlHttp.send(null);	

}

function moveDown(id)
{
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			  document.getElementById("down-"+id).innerHTML=xmlHttp.responseText;
		  }
		 /* else
		  {
			document.getElementById("fade").innerHTML= "<div align='center' style='height:100px;padding-top:60px;'><img src='staticimg/ajax-loader-red.gif' width='31' height='31' /></div>";
		  }*/
		}
	  xmlHttp.open("GET","http://qa.commodityonline.com/downRate.php?id="+id,true);
	  /*xmlHttp.open("GET","http://localhost/qa/downRate.php?id="+id,true);*/
	  xmlHttp.send(null);		
}

function moveUpAnswer(id,name,ucount,dcount)
{
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			  document.getElementById("id").innerHTML=xmlHttp.responseText;
			  
		  }
		 /* else
		  {
			document.getElementById("fade").innerHTML= "<div align='center' style='height:100px;padding-top:60px;'><img src='staticimg/ajax-loader-red.gif' width='31' height='31' /></div>";
		  }*/
		}
	  xmlHttp.open("GET","http://192.168.1.104/websites/qa/upRateAnswer.php?id="+id+"&name="+name+"&ucount="+ucount+"&dcount="+dcount,true);
	  xmlHttp.send(null);		

}

function moveDownAnswer(id,name,ucount,dcount)
{
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			  document.getElementById("id").innerHTML=xmlHttp.responseText;
		  }
		 /* else
		  {
			document.getElementById("fade").innerHTML= "<div align='center' style='height:100px;padding-top:60px;'><img src='staticimg/ajax-loader-red.gif' width='31' height='31' /></div>";
		  }*/
		}
	  xmlHttp.open("GET","http://192.168.1.104/websites/qa/downRateAnswer.php?id="+id+"&name="+name+"&ucount="+ucount+"&dcount="+dcount,true);
	  xmlHttp.send(null);		
}

function chkQuestion()
{
	if(document.searchform.searchquest.value=="")
		{
		alert("Please Enter a question");
		document.searchform.searchquest.focus();
		return false;				
		}
		return true;	
}