function Item(sid,url,pret,cat){
    this.sid=sid;
    this.url=url;
    this.pret=pret;
    this.cat=cat;
}

var arr=new Array();
var xmlhttp;
var count=0;

function loadXML(url){

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function stateChanged()
{
if (xmlhttp.readyState==4){
    clearTable("lista");
  xmlDoc=xmlhttp.responseXML;
for(i=0;i<25;i++){
if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion <= "7.0"){
   arr[i]=new Item(xmlDoc.getElementsByTagName("sid")[i].text,
                   xmlDoc.getElementsByTagName("url")[i].text,
                   xmlDoc.getElementsByTagName("pret")[i].text,
                   xmlDoc.getElementsByTagName("cat")[i].text);
}else{
   arr[i]=new Item( xmlDoc.getElementsByTagName("sid")[i].firstChild.nodeValue,
                    xmlDoc.getElementsByTagName("url")[i].firstChild.nodeValue,
                    xmlDoc.getElementsByTagName("pret")[i].firstChild.nodeValue,
                    xmlDoc.getElementsByTagName("cat")[i].firstChild.nodeValue);
}
printItem(i);
}

}
}
function clearTable(id){
     var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
    while (tbody.firstChild) {
    tbody.removeChild(tbody.firstChild);
    }
}

function printItem(index){
    addRow("lista",index);
}

function addRow(id,index){
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
    var row = document.createElement("TR")
    var td0 = document.createElement("TD");
    td0.setAttribute("class", "p1");
    td0.appendChild(document.createTextNode(index+1));
    var td1 = document.createElement("TD");
    td1.setAttribute("class", "p2");
    td1.innerHTML='<a href="detalii='+arr[index].url+'">'+arr[index].url+'</a>';
    var td2 = document.createElement("TD");
    td2.setAttribute("class", "p4");
    td2.appendChild (document.createTextNode(arr[index].pret));
    var td3 = document.createElement("TD");
    td3.setAttribute("class", "p5");
    td3.appendChild (document.createTextNode(arr[index].cat));
    row.appendChild(td0);
    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    tbody.appendChild(row);
  }
  
function sizeIt(x)
{
if (document.getElementById(x).width != 160)
{
    document.getElementById(x).width = 160;
}
if (document.getElementById(x).height != 160)
{
    document.getElementById(x).height = 160;
}
}

