

window.onload=function()

{
	if(!document.getElementsByTagName) return;
l=document.getElementsByTagName("a");
for(i=0;i<l.length;i++)
   {
    if(l[i].className.indexOf("blank")!=-1)
      {
       l[i].onclick=function(){window.open(this.href);return(false)};
      }
   }
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = caricaDati;
	}
       else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) caricaDati()
		};
 	}
 	


	else
	{
		return;
	}
	xmlDoc.load("/innovazione/templates/ricerca/progetto.xml");
}
function caricaDati()

{
  /*var frm1=  document.getElementById('frm');

var k = frm1.sel1.options[frm1.sel1.selectedIndex].value;

if (k=="vuoto")
{
return;
}    */

	 var x = xmlDoc.getElementsByTagName('progetto');
         var z = xmlDoc.getElementsByTagName('tematica');
          var controllo = xmlDoc.getElementsByTagName('ancora');
var newEl = document.createElement('select');

newEl.setAttribute('name', 'sel1');

newEl.setAttribute('onclick', 'scriviDati()');
newEl.setAttribute('onkeypress', 'scriviDati()');

newEl.setAttribute('id', 'idsel');
    /*@cc_on

    newEl.onclick=scriviDati;
    newEl.onkeypress=scriviDati;
    newEl.name='sel2';
    newEl.id='idsel';
@*/
        var op0 = document.createElement('option');
        op0.setAttribute('value','vuoto')
            var createstoop0 = document.createTextNode("Seleziona tematica");
             op0.appendChild(createstoop0);
                 newEl.appendChild(op0)      

	for (i=0;i<x.length;i++)
 {
  var container = document.createElement('option');
 if (i==0){
    var createsto0 = document.createTextNode(z[0].firstChild.nodeValue);

			     var valoreop0 = z[0].firstChild.nodeValue;
				container.appendChild(createsto0);
	                     container.setAttribute('value', valoreop0);
	                     newEl.appendChild(container);
 }




                         if(i>0&&z[i].firstChild.nodeValue!=z[i-1].firstChild.nodeValue)
                    {



                                  
								 
                             var createsto = document.createTextNode(z[i].firstChild.nodeValue);

			     var valoreop = z[i].firstChild.nodeValue;
							 
	                     container.setAttribute('value', valoreop);

                  
                 container.appendChild(createsto);
                 newEl.appendChild(container);
                      

                     }
  }

if (document.getElementById('caricadati')){

	document.getElementById('caricadati').appendChild(newEl);
}

else{
	return false;
}

}
function scriviDati()

{
var frm1=  document.getElementById('frm');

var k = frm1.idsel.value.toUpperCase();

if (k=="VUOTO")
{

   return;
}
            var tabella =document.createElement('table');
            
            tabella.setAttribute('class', 'tblprogetto');
             /*@cc_on

    tabella.className="tblprogetto";

@*/


   var tabody =document.createElement('tbody');
   var capt =document.createElement('caption');
        var createstocapt= document.createTextNode(k);
             capt.appendChild(createstocapt)
              tabella.appendChild(capt);
        var firsttr =document.createElement('tr');
        
          var tahead =document.createElement('thead');

         var z = xmlDoc.getElementsByTagName('tematica');
	 var x = xmlDoc.getElementsByTagName('progetto');
         var c = xmlDoc.getElementsByTagName('titolo');
         var l = xmlDoc.getElementsByTagName('ente');
         var n = xmlDoc.getElementsByTagName('sottoente');
         var p = xmlDoc.getElementsByTagName('link');
         var u = xmlDoc.getElementsByTagName('url');
         var g = xmlDoc.getElementsByTagName('categoria');




           var testo="";


                  var thtbl1 = document.createElement('th');
            var createstthtbl1 = document.createTextNode("Titolo");
             thtbl1.appendChild(createstthtbl1);
                firsttr.appendChild(thtbl1)
             tahead.appendChild (firsttr)
                 tabella.appendChild(tahead);
                 
                  var thtbl2 = document.createElement('th');
            var createstthtbl2 = document.createTextNode("Ente");
             thtbl2.appendChild(createstthtbl2);
                firsttr.appendChild(thtbl2)
             tahead.appendChild (firsttr)
                 tabella.appendChild(tahead);
                 
                   var thtbl3 = document.createElement('th');
            var createstthtbl3 = document.createTextNode("Sottoente");
             thtbl3.appendChild(createstthtbl3);
                firsttr.appendChild(thtbl3)
             tahead.appendChild (firsttr)
                 tabella.appendChild(tahead);

                    var thtbl4 = document.createElement('th');
            var createstthtbl4 = document.createTextNode("Categoria");
             thtbl4.appendChild(createstthtbl4);
                firsttr.appendChild(thtbl4)
             tahead.appendChild (firsttr)
                 tabella.appendChild(tahead);


            var thtbl = document.createElement('th');
            var createstthtbl = document.createTextNode("Abstract");
             thtbl.appendChild(createstthtbl);
             firsttr.appendChild(thtbl)
             tahead.appendChild (firsttr)
                 tabella.appendChild(tahead);
                 
                  



                 
                 
                 

	for (i=0;i<x.length;i++)
 {

            if (document.getElementById('scrivirisultato').firstChild) {

document.getElementById('scrivirisultato').removeChild(document.getElementById('scrivirisultato').firstChild);
         }

       var titolo = c[i].firstChild.nodeValue;
       var ente = l[i].firstChild.nodeValue;
       var sottoente = n[i].firstChild.nodeValue;
       var lnk = p[i].firstChild.nodeValue;
       var url = u[i].firstChild.nodeValue;
       var tematica = z[i].firstChild.nodeValue;
       var categoria = g[i].firstChild.nodeValue;


		var dati = z[i].firstChild.nodeValue.toUpperCase();



                       if (dati==k)
                       {



                                var lista = document.createElement('tr');
                                
                                   

                            var container = document.createElement('td');
                            var testo=titolo;

                            var createsto = document.createTextNode(testo);
                            container.appendChild(createsto);
                            lista.appendChild(container);
                            tabody.appendChild(lista);
                            tabella.appendChild(tabody);
                            
                            var container2 = document.createElement('td');
                            var testo2=ente;

                            var createsto2 = document.createTextNode(testo2);
                            container2.appendChild(createsto2);
                            lista.appendChild(container2);
                            tabody.appendChild(lista);
                            tabella.appendChild(tabody);
                            
                            var container3 = document.createElement('td');
                            var testo3=sottoente;

                            var createsto3 = document.createTextNode(testo3);
                            container3.appendChild(createsto3);
                            lista.appendChild(container3);
                            tabody.appendChild(lista);
                            tabella.appendChild(tabody);
                            
                             var container5 = document.createElement('td');
                            var testo5=categoria;

                            var createsto5 = document.createTextNode(testo5);
                            container5.appendChild(createsto5);
                            lista.appendChild(container5);
                            tabody.appendChild(lista);
                            tabella.appendChild(tabody);


                            var container4 = document.createElement('td');
                             var crealink = document.createElement('a');
                             var valorelink=url;
                             var attachlink =crealink.setAttribute('href', url)
                             crealink.setAttribute('onclick', "window.open(this.href, ''); return false;");
/*@cc_on

    crealink.onclick = function(){ window.open(this.href, ''); return false; };


@*/
                            var testo4=lnk;
                            var createsto4 = document.createTextNode(testo4);
                            crealink.appendChild(createsto4);
                            container4.appendChild(crealink);
                            lista.appendChild(container4);
                            tabody.appendChild(lista);
                            tabella.appendChild(tabody);
                            

                           
                            

                            
                 
 }


		 




  }

	document.getElementById('scrivirisultato').appendChild(tabella);
	
}


