window.onload=initImg;
function initImg(){
  cur=0;
  get_imgs();
}

function chImg(){
  if(imagini.length<=cur) cur=0;
  var im=document.getElementById("img");
  im.src="gen_img_index.php?i="+imagini[cur];
  var im_det=document.getElementById("img_det");
  im_det.value=imagini_d[cur];
  cur++;
  setTimeout("chImg()",5000);
}

function get_imgs(){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }
	var url="get_img.php";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
      var resp=xmlHttp.responseText; 
	  resp=resp.split("<#>");
	  set_img(resp[0],resp[1]);
 } 


}

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;
}


function set_img(img,det){
	imagini=img.split("<+>");
	imagini_d=det.split("<+>");
	chImg();
}