var xmlHttp
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//==================================================================================
var url = 'include/get_products.php?new_product_id=';
function get_new_product(type)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	if(type == 'left')
	{
		var new_product_id = document.getElementById("id_left").value; 
	}
	else
	{
		var new_product_id = document.getElementById("id_right").value; 
	}
	

	xmlHttp.open("GET", url + new_product_id, true); 
	xmlHttp.onreadystatechange = handleHttpResponse_products; 
	xmlHttp.send(null);
}

//======================================================================================
function handleHttpResponse_products()
{
	//alert("ok");
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;
		document.getElementById("id_image_thumb").innerHTML = "<a href='"+xmlDoc.getElementsByTagName("link")[0].childNodes[0].nodeValue+"' target='_blank' title='"+xmlDoc.getElementsByTagName("text_link")[0].childNodes[0].nodeValue+"' class='text_blue_link_2'><img src='"+xmlDoc.getElementsByTagName("image")[0].childNodes[0].nodeValue+"' border='0' width='150px' height='133px'></a>";
		document.getElementById("id_left").value = xmlDoc.getElementsByTagName("id_left")[0].childNodes[0].nodeValue;
		document.getElementById("id_right").value = xmlDoc.getElementsByTagName("id_right")[0].childNodes[0].nodeValue;
		document.getElementById("id_link").innerHTML = "<a href='"+xmlDoc.getElementsByTagName("link")[0].childNodes[0].nodeValue+"' target='_blank' title='"+xmlDoc.getElementsByTagName("text_link")[0].childNodes[0].nodeValue+"' class='text_blue_link_2'>"+xmlDoc.getElementsByTagName("text_link")[0].childNodes[0].nodeValue+"</a>";
	} 
}

//=======================
var milisec=0; 
var seconds=30;
function display(){ 
 if (milisec<=0){ 
    milisec=9 
    seconds-=1 
 } 
 if (seconds<=-1){ 
    milisec=0 
    seconds+=1 
 } 
 else 
    milisec-=1;
	get_new_product('right');
	//document.getElementById('id_left').value = ;
    //document.counter.d2.value=seconds+"."+milisec 
    setTimeout("display()",5000);
} 
