var xmlHttp

function poll(poll_option_id)
{
/* 	if (cateogry_id.length == 0)
	{
		document.getElementById("category").innerHTML = "";
		return null;
	}
 */	
	xmlHttp = GetXmlHttpObject();
	
	if (xmlHttp == null)
	{
		alert ('Browser does not support HTTP Request');
		return null;
	}
	
 	var url = 'pages/poll_process.php';
	url     = url + '?poll_option_id=' + poll_option_id;
	url     = url + "&sid="+Math.random();
	
	xmlHttp.onreadystatechange = function()
	{ 
		// 0 = The request is not initialized, 1 = The request has been set up, 2 = The request has been sent, 3 = The request is in process
		if (xmlHttp.readyState == 0 || xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3)
		{
			document.getElementById('poll').innerHTML = '<img src="templates/filmykhabar/images/loading.gif" />Loading...';
		}
		//4 = The request has been completed
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{ 
			document.getElementById('poll').innerHTML = xmlHttp.responseText;
		} 
	}
	
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
}

function top_ten_tab(top_ten_category)
{
	xmlHttp = GetXmlHttpObject();
	
	if (xmlHttp == null)
	{
		alert ('Browser does not support HTTP Request');
		return null;
	}
	
 	var url = 'templates/filmykhabar/top_ten_tab.php';
	url     = url + '?top_ten_category=' + top_ten_category;
	url     = url + "&sid="+Math.random();
	
	xmlHttp.onreadystatechange = function()
	{ 
		// 0 = The request is not initialized, 1 = The request has been set up, 2 = The request has been sent, 3 = The request is in process
		if (xmlHttp.readyState == 0 || xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3)
		{
			document.getElementById('top_ten_tab').innerHTML = '<img src="templates/filmykhabar/images/loading.gif" />Loading...';
		}
		//4 = The request has been completed
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{ 
			document.getElementById('top_ten').innerHTML = xmlHttp.responseText;
		} 
	}
	
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
}



function GetXmlHttpObject()
{
	var xmlHttp = null;
	try
	{
		// Creates the XMLHttpRequest object (Firefox, Opera 8.0+, Safari)
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Creates the XMLHttpRequest object (Internet Explorer)
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}