var request = false;


function worg(nid)
	{
	
	request = false;

	
	if (window.XMLHttpRequest)
		{
		request = new XMLHttpRequest();
		} 
		else if (window.ActiveXObject) 
		{
		request = new ActiveXObject("Microsoft.XMLHTTP");
		}

	
	if (!request)
		{
		alert('Browser does not support AJAX!');
		return false;
		}

	request.onreadystatechange = grow;

	request.open('GET', 'xreferenza.xml.php?id='+nid, true);
//	request.open('GET', 'xreferenza.xml', true);
	request.send(null);
	
	}
	
	
	
function grow()
	{
	
	if (request.readyState == 4)
		{
		if (request.status == 200)
			{
					
			var xml = request.responseXML;
			
			var nodes=xml.getElementsByTagName('installazioni').item(0);
			
			var nnodes = nodes.childNodes.length;
			
			var strContent = ''; // 
			
			for(i=0;i<nnodes;i++)
				{
				var id;
				var foto = '';
				var localita = '';
				var diocesi = '';
				var parroco = '';
				
				var strFoto = ''; var strFoto1 = ''; var strFoto2 = '';
				
				var nFoto=0;
				
				var nazione = '';
				var idnazione = 0;
				
				var htm = '';
				
				curnode = nodes.childNodes.item(i);
				
				if( curnode.nodeName == 'installazione' )
					{
					for( var ii=0; ii < curnode.childNodes.length; ii++ )
						{
						curfield = curnode.childNodes.item(ii);
						
						
						if( curfield.nodeName != '#text' )
									{
																		
									
									cnt = curfield.childNodes.item(0);
									switch(curfield.nodeName)											
										{
										case 'idinst':
										id = cnt.data;
										break;
										
										case 'foto':
										foto = cnt.data;
										if(nFoto == 0)
											strFoto1 += '<a href="progettirealizzati_installazione.php?id='+id+'"><img src="resizexcuty.php?pic=fotoinstallazioni/'+foto+'&width=140&height=150" style="border: 2px solid #d0d0d0;" /></a>';
										else
											strFoto2 += '<td width="68" align="center" valign="bottom"><a href="progettirealizzati_installazione.php?id='+id+'"><img src="resizexcuty.php?pic=fotoinstallazioni/'+foto+'&width=60&height=40" style="border: 2px solid #d0d0d0;"  /></a></td>';
										nFoto++;
										break;
										
										case 'localita':
										localita = cnt.data;
										break;
										
										case 'diocesi':
										diocesi = cnt.data;
										break;
										
										case 'parroco':
										parroco = cnt.data;
										break;
										
										case 'htm':
										htm = cnt.data;
										break;
										
										case 'idnazione':
										idnazione = cnt.data;
										break;
										
										case 'nazione':
										nazione = cnt.data;
										break;
										
										default:
										break;
										}
									}
						
						
						
						
						}
					}
				
				if( foto || localita || diocesi || parroco)
					{
					strContent += '<table width="700" border="0"><tr><td>';
					
					strContent += '<table border="0" cellspacing="4" cellpadding="0" height="140">';
					strContent += '<tr>';
					strContent += '<td rowspan="2" valign="bottom" height="80">'+strFoto1+'</td>';
					strContent += '<td valign="bottom" >';
					/* strContent += '<div style="padding-bottom: 0px; padding-left: 3px;"><b>'+diocesi+'</b><br>'+localita+'<br>'+parroco+'<br>'+htm+'</div>'; */
					strContent += '<div style="padding-bottom: 0px; padding-left: 3px;"><b>'+diocesi+'</b><br>'+localita+'<br>'+parroco +'<br><a href="progettirealizzati_installazione.php?id='+id+'" class="lnk0"><u>' + strDettagli + '</u></a></a></div>';
					strContent += '</td>';
					strContent += '</tr>';
					
					strContent += '<tr>';
					strContent += '<td valign="bottom" align="left" height="60"><table border="0" cellspacing="0" cellpadding="0"><tr>' + strFoto2 + '</tr></table></td>';
					strContent += '</tr>';
					strContent += '</table>';
					strContent += '</td><td valign="middle" align="center">';
					strContent += '<a href="progettirealizzati_elenco.php?idNazione='+idnazione+'" class="lnk0">vedi tutte le installazioni nella nazione:<br><b>'+nazione+'</b></a>';
					strContent += '</td><tr></table>';
					}
				}
			
			}
		
		
		
		// chiamata a setpanel
		
		// alert(strContent);
		setPanel(strContent);
		
		
		}
	
	}
