var xmlDoc;
var p=new Array();
var j=0;
var id='stiri';
var id_tmp='doi';
var xml='xml/anunt_ro.xml';
var poz_stg_i=-265;

function tesa(xml)
{
  xhttp=new XMLHttpRequest();
  xhttp.open("GET",xml,false);
  xhttp.send("");
  xmlDoc=xhttp.responseXML; 
var a=xmlDoc.getElementsByTagName("stire");

 var stire=new Array();
 var linkk=new Array();
 for(i=0;i<a.length;i++)
{
	if(a[i].childNodes[0])
	{
		if(a[i].childNodes[0].nodeValue!=' ')
		{
			stire[i]=a[i].childNodes[0].nodeValue;
			linkk[i]=a[i].getAttribute("linkk");
		}
	}
}
/*
 for(i=0;i<b.length;i++)
{
	if(b[i].childNodes[0])
	{
		if(b[i].childNodes[0].nodeValue!=' ')
		{
			linkk[i]=b[i].childNodes[0].nodeValue;
		}
		else
		{
			linkk[i]="";
		}
	}
}
*/
  //var stire=new Array(xmlDoc.documentElement.childNodes[1].childNodes[0].nodeValue, xmlDoc.documentElement.childNodes[3].childNodes[0].nodeValue, xmlDoc.documentElement.childNodes[5].childNodes[0].nodeValue, xmlDoc.documentElement.childNodes[7].childNodes[0].nodeValue, xmlDoc.documentElement.childNodes[9].childNodes[0].nodeValue);
  
  var foto=new Array();

  //var foto=new Array(xmlDoc.documentElement.childNodes[1].attributes.getNamedItem("foto").nodeValue, xmlDoc.documentElement.childNodes[3].attributes.getNamedItem("foto").nodeValue, xmlDoc.documentElement.childNodes[5].attributes.getNamedItem("foto").nodeValue, xmlDoc.documentElement.childNodes[7].attributes.getNamedItem("foto").nodeValue, xmlDoc.documentElement.childNodes[9].attributes.getNamedItem("foto").nodeValue);

var stiri = new Array(stire,linkk);
  return stiri;
}
/*
function set_inf()
{
  if (i>4)
  {
    i=0;
  }

  p=tesa(xml);
  if(p[1][i] == '')
  {
    document.getElementById(id).innerHTML=p[0][i];
    document.getElementById(id_tmp).style.left= poz_stg_i+"px";
    document.getElementById(id_tmp).innerHTML=p[0][(i+1)];
  }
  else
  {
    document.getElementById(id).innerHTML="<img src='img/stiri/"+p[1][i]+"' style='float:left' />"+p[0][i];
    document.getElementById(id_tmp).style.left= poz_stg_i+"px";
    document.getElementById(id_tmp).innerHTML="<img src='img/stiri/"+p[1][(i+1)]+"' style='float:left' />"+p[0][(i+1)];
  }
  i++;
  setTimeout("schimba_inf()",5000);
}
*/

function set_inf()
{
  p=tesa(xml);
  if(j==p[0].length)
  {
	j=0;
  }

    document.getElementById(id).innerHTML="<a href='"+p[1][j]+"' target='_blank' >"+p[0][j]+"</a>";
    document.getElementById(id_tmp).style.left= poz_stg_i+"px";
    document.getElementById(id_tmp).innerHTML="<a href='"+p[1][j]+"' target='_blank' >"+p[0][j]+"</a>";

  j++;
  setTimeout("schimba_inf()",10000);
}

function schimba_inf()
{
  poz_stg_tmp=parseInt(document.getElementById(id_tmp).style.left);
  if(poz_stg_tmp<0)
  {
    poz_stg=poz_stg_tmp+10;
    document.getElementById(id_tmp).style.left= poz_stg+"px";
    setTimeout("schimba_inf()",10);
  }
  else
  {
    set_inf() ;
    return;
  }
}

