var xmlHttp;

function ajax_get_videos(page)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	xmlHttp.onreadystatechange=stateChanged; 
	var url="/videos.php";
	url=url+"?page="+page;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	//alert(str);	
}

function ajax_get_all_videos()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	xmlHttp.onreadystatechange=stateChanged; 
	var url="/videos.php";
	url=url+"?showall=1";
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	document.getElementById('container_video').style.height = "";
	//alert(str);	
}

function ajax_get_tab(div)
{
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=tabChanged; 
	var url="/data.php?data_id="+div;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function tabChanged()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		
		var arr_div = new Array();
	
		arr_div[0] = "bonds";
		arr_div[1] = "capital";
		arr_div[2] = "currency";
		//arr_div[3] = "commodities";
		//arr_div[4] = "indexes";

		for(i=0;i<arr_div.length;i++)
		{
			var el = document.getElementById('reuters_'+arr_div[i]+'_container');
			
			if (el.style.display != "none") 
			{
				el.innerHTML = xmlHttp.responseText; 
				break;
			}
		}
	}
}


function stateChanged()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("area_video").innerHTML=xmlHttp.responseText 
		//document.getElementById("loading_image").style.display = "none";
	} 
	else
	{	
		//document.getElementById("loading_image").style.display = "block";
	}
}

function GetXmlHttpObject(handler)
{ 
	var objXmlHttp = null;
	try 
	{
		// Firefox, Opera 8.0+, Safari
		objXmlHttp = new XMLHttpRequest();
		return objXmlHttp;
	}
	catch (e) 
	{
		 // Internet Explorer
		try 
		{ 
			objXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			return objXmlHttp;
		}
		catch (e) 
		{
			try 
			{
				objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				return objXmlHttp;
		  	}
		  	catch (e) 
		  	{
				alert("Your browser does not support AJAX!");
				return false;
		  	}
		}	
	}
}