﻿var GLOBAL_xmlMacchine = new Array();
var GLOBAL_xmlIMG = new Array();
var GLOBAL_cCategoria = "";
var GLOBAL_cLingua = "IT";

function jsvoid_LIS_ElencoCat()
{	var OBJtbl=document.getElementById('tbl_categoria'), newRow, newCell, OBJTbody, cCodice, cDescr, stApp, stCategorie=new Array(), sIdx, stOrder=new Array(), OBJ;
	GLOBAL_xmlMacchine=jsxmlDoc_XMLload('listino.xml');
	if (OBJtbl!=null && GLOBAL_xmlMacchine!=null) {
		OBJTbody=OBJtbl.getElementsByTagName("tbody").item(0);
		GLOBAL_xmlMacchine = jsdata_getDataByTagName(GLOBAL_xmlMacchine, 'LISTINO', true);
		if (GLOBAL_xmlMacchine != null && OBJTbody!=null) {
			while (true) {
				try
				{	OBJTbody.deleteRow(0);
				}
				catch(err)
				{	break;
				}
			}
			for (sIdx=0; sIdx<GLOBAL_xmlMacchine.childNodes.length; sIdx++) {
				if (GLOBAL_xmlMacchine.childNodes[sIdx].nodeType == 1 && GLOBAL_xmlMacchine.childNodes[sIdx].nodeName=='CATEGORIA' && GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[0]!=null) {
					cCodice='', cDescr='';
					stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx], 'CODICE', false);
					if (stApp!=null)
						cCodice = stApp.childNodes[0].data;
					stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx], 'DESCR', false);
					if (stApp!=null)
						cDescr= stApp.childNodes[0].data;
					stCategorie[cCodice]=new Array();
					stCategorie[cCodice]['LABEL'] = cDescr;
					stCategorie[cCodice]['DESCR'] = "";
					stCategorie[cCodice]['class'] = "2";
				}
			}
			var xmlCategorie=jsxmlDoc_XMLload('categoria.xml');
			if (xmlCategorie!=null) {
				stApp = jsdata_getDataByTagName(xmlCategorie, 'LINGUA', true);
				if (stApp!=null)
					stApp = jsdata_getDataByTagName(stApp, GLOBAL_cLingua, false);
				OBJ=document.getElementById('td_intesta');
				if (stApp!=null && OBJ!=null)
					OBJ.innerHTML = stApp.childNodes[0].data;
				xmlCategorie = jsdata_getDataByTagName(xmlCategorie, 'LISTINO', true);
			}
			if (xmlCategorie!=null) {
				for (sIdx=0; sIdx<xmlCategorie.childNodes.length; sIdx++) {
					if (xmlCategorie.childNodes[sIdx].nodeType == 1 && xmlCategorie.childNodes[sIdx].nodeName=='CATEGORIA' && xmlCategorie.childNodes[sIdx].childNodes[0]!=null) {
						cCodice='', cDescr='';
						stApp = jsdata_getDataByTagName(xmlCategorie.childNodes[sIdx], 'CODICE', false);
						if (stApp!=null)
							cCodice = stApp.childNodes[0].data;
						stApp = jsdata_getDataByTagName(xmlCategorie.childNodes[sIdx], 'LINGUA', false);
						if (stApp!=null) {
							stApp = jsdata_getDataByTagName(stApp, GLOBAL_cLingua, false);
							if (stApp!=null)
								cDescr= stApp.childNodes[0].data;
						}
						if (stCategorie[cCodice]!=null) {
							if (cDescr.length>0)
								stCategorie[cCodice]['class'] = "";
							else {
								stCategorie[cCodice]['DESCR'] = stCategorie[cCodice]['LABEL'];
								cDescr='...';
							}
							stCategorie[cCodice]['LABEL'] = cDescr;
						}
					}
				}
			}
			// ordino per descrizione
			for (cCodice in stCategorie) {
				stCategorie[cCodice]['LABEL'] += "                                  ";
				cDescr = stCategorie[cCodice]['LABEL'].substr(0, 35) + cCodice;
				stOrder.push(cDescr);
			}
			stOrder.sort();
			
			// scrivo righe tabella
			for (sIdx in stOrder) {
				cCodice = stOrder[sIdx].substr(35);
				newRow=OBJTbody.insertRow(-1);
				newCell = document.createElement("td");
				newCell.id="TD_"+cCodice;
				newCell.className='categoria_out'+stCategorie[cCodice]['class'];
				newCell.appendChild(document.createTextNode(stCategorie[cCodice]['LABEL']));
				if (stCategorie[cCodice]['DESCR'].length>0)
					newCell.setAttribute("title",stCategorie[cCodice]['DESCR']);
				newCell.setAttribute("onclick","jsvoid_LIS_click('"+cCodice+"');");
				newCell.setAttribute("onmouseover","jsvoid_LIS_mouse('"+cCodice+"', event);");
				newCell.setAttribute("onmouseout","jsvoid_LIS_mouse('"+cCodice+"', event);");
				newRow.appendChild(newCell);
			}
		}
	}
}
function jsxmlDoc_XMLload(cName)
{	var xmlDocument=null, xmlHttp=null;
	if (cName!=null && cName.length>0) {
		try //Internet Explorer
		{
			xmlDocument=new ActiveXObject("MSXML2.DOMDocument");
			xmlDocument.async=false;
			xmlDocument.load(cName);
		}
		catch(e)
		{
			try //Firefox, Mozilla, Opera
			{
				xmlDocument=document.implementation.createDocument("","",null);
				xmlDocument.async=false;
				xmlDocument.load(cName);
			}
			catch(e)
			{
				try //Safari, Chrome
				{
					xmlHttp=new XMLHttpRequest();
					xmlHttp.open("GET",cName,false);
					xmlHttp.send(null);
					xmlDocument=xmlHttp.responseXML.documentElement;
				}
				catch(e)
				{
					alert(e.message);
					return null;
				}
			}
		}
	}
	return xmlDocument;
}
function jsdata_getDataByTagName(xmlMacchine, cNodeName, bRecursion)
{	var stReturn=null;
	for (var i=0; i<xmlMacchine.childNodes.length; i++) {
		if (xmlMacchine.childNodes[i].nodeType == 1 && xmlMacchine.childNodes[i].nodeName==cNodeName && xmlMacchine.childNodes[i].childNodes[0]!=null)
			return xmlMacchine.childNodes[i];
		else {
			if (bRecursion) {
				stReturn = jsdata_getDataByTagName(xmlMacchine.childNodes[i], cNodeName, bRecursion);
				if (stReturn!=null)
					return stReturn;
			}
		}
	}
	return null;
}
function jsvoid_LIS_mouse(cCategoria, e)
{	var OBJ=document.getElementById("TD_"+cCategoria), cUltimo;
	if (OBJ!=null) {
		cUltimo = OBJ.className.slice(OBJ.className.length-1);
		if (e.type=='mouseover')
			OBJ.className='categoria_over';
		else {
			if (GLOBAL_cCategoria!=cCategoria)
				OBJ.className='categoria_out';
			else
				cUltimo = '';
		}
		if (cUltimo=='3')
			OBJ.className=OBJ.className+cUltimo;
	}
}
function jsvoid_LIS_click(cCategoria)
{	var OBJ=document.getElementById('tbl_categoria'), sIdx, stApp, i2, sCount, cCodice, cDescr, cImg1, cImg2, cImg3, newRowP, newRowI, newCell, newTbl, newA, newImg, newTbl2, newRowI2;
	if (OBJ!=null) {
		OBJ=OBJ.getElementsByTagName("tbody").item(0);
		if (OBJ!=null)
			OBJ=OBJ.getElementsByTagName("TD");
	}
	if (OBJ!=null && GLOBAL_cCategoria!=cCategoria) {
		for (sIdx=0; sIdx<OBJ.length; sIdx++)
			if (OBJ.item(sIdx).className!='categoria_out2')
				OBJ.item(sIdx).className='categoria_out';
		OBJ=document.getElementById("TD_"+cCategoria);
		if (OBJ!=null) {
			OBJ.className='categoria_over';
			GLOBAL_cCategoria=cCategoria;
			
			OBJ=this.parent.frames['principale'].document.getElementById('tbl_macchina');
			if (OBJ!=null) {
				while (true) {
					try
					{	OBJ.deleteRow(0);
					}
					catch(err)
					{	break;
					}
				}
				for (sIdx=0; sIdx<GLOBAL_xmlMacchine.childNodes.length; sIdx++) {
					if (GLOBAL_xmlMacchine.childNodes[sIdx].nodeType == 1 && GLOBAL_xmlMacchine.childNodes[sIdx].nodeName=='CATEGORIA' && GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[0]!=null) {
						stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx], 'CODICE', false);
						if (stApp!=null && cCategoria == stApp.childNodes[0].data) {
							for (i2=0, sCount=0; i2<GLOBAL_xmlMacchine.childNodes[sIdx].childNodes.length; i2++) {
								if (GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2].nodeType == 1 && GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2].nodeName=='MACCHINA' && GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2].childNodes[0]!=null) {
									cCodice='', cDescr='', cImg1='', cImg2='', cImg3='';
									stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2], 'CODICE', false);
									if (stApp!=null)
										cCodice = stApp.childNodes[0].data;
									stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2], 'IMG1', false);
									if (stApp!=null)
										cImg1= stApp.childNodes[0].data;
									stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2], 'IMG2', false);
									if (stApp!=null)
										cImg2= stApp.childNodes[0].data;
									stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2], 'IMG3', false);
									if (stApp!=null)
										cImg3= stApp.childNodes[0].data;
									stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2], 'LINGUA', false);
									if (stApp!=null) {
										stApp = jsdata_getDataByTagName(stApp, GLOBAL_cLingua, false);
										if (stApp!=null)
											cDescr= stApp.childNodes[0].data;
										else {
											stApp = jsdata_getDataByTagName(GLOBAL_xmlMacchine.childNodes[sIdx].childNodes[i2], 'DESCR_TECH', false);
											if (stApp!=null)
												cDescr= stApp.childNodes[0].data;
										}
									}
									if (!(sCount%2))
										newRowP=OBJ.insertRow(-1); // riga principale
									newCell = document.createElement("td");
									newRowP.appendChild(newCell);
									newCell.className='macchina';
									
									newTbl = document.createElement("table");
									newCell.appendChild(newTbl);
									newTbl.className='macchina';
									newTbl.setAttribute("cellpadding","0");
									newTbl.setAttribute("cellspacing","0");
									
									newRowI=newTbl.insertRow(-1);
									newCell = document.createElement("td");
									//newCell.className='macchina_descr';
									//newCell.appendChild(document.createTextNode(cDescr));
									newRowI.appendChild(newCell);
									newTbl2 = document.createElement("table");
									newTbl2.setAttribute("cellpadding","0");
									newTbl2.setAttribute("cellspacing","0");
									newCell.appendChild(newTbl2);
									newRowI2=newTbl2.insertRow(-1);
									newCell = document.createElement("td");
									newCell.className='macchina_descr';
									newCell.appendChild(document.createTextNode(cDescr));
									newRowI2.appendChild(newCell);
									
									newCell = document.createElement("td");
									newCell.className='macchina_mail';
									newA = document.createElement("a");
									newA.setAttribute("href", "mailto:vissanimacchinesrl@libero.it?Subject=RICHIESTA%20INFO:%20Articolo%20"+cCodice);
									newA.setAttribute("title", "invia una mail per maggiori informzioni");
									newA.appendChild(document.createTextNode('richiedi info'));
									newCell.appendChild(newA);
									newRowI2.appendChild(newCell);
									
									newRowI=newTbl.insertRow(-1);
									newCell = document.createElement("td");
									newRowI.appendChild(newCell);
									newTbl2 = document.createElement("table");
									newTbl2.setAttribute("cellpadding","0");
									newTbl2.setAttribute("cellspacing","0");
									newCell.appendChild(newTbl2);
									newRowI2=newTbl2.insertRow(-1);
									
									newCell = document.createElement("td");
									newCell.className='macchina_codice';
									newCell.appendChild(document.createTextNode(cCodice));
									newRowI2.appendChild(newCell);
									
									newCell = document.createElement("td");
									newCell.className='macchina_icone';
									newRowI2.appendChild(newCell);
									
									newTbl = document.createElement("table");
									newCell.appendChild(newTbl);
									newRowI=newTbl.insertRow(-1);
									newCell = document.createElement("td");
									newRowI.appendChild(newCell);
									if (cImg1.length == 0 && cImg2.length == 0 && cImg3.length == 0)
										cImg1 = 'nd_img.gif';
									if (cImg1.length > 0) {
										newImg = document.createElement("img");
										newCell.appendChild(newImg);
										newImg.className='icone';
										newImg.setAttribute("src","DBimages/"+cImg1);
										newImg.setAttribute("alt","");
										newImg.id="img_"+sCount+"_1";
										if (cImg1 != 'nd_img.gif') {
											newImg.setAttribute("onmouseover","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_1', 'V', '"+cCodice+"', '"+cImg1+"');");
											newImg.setAttribute("onmouseout","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_1', 'H');");
										}
									}
									if (cImg2.length > 0) {
										newImg = document.createElement("img");
										newCell.appendChild(newImg);
										newImg.className='icone';
										newImg.setAttribute("src","DBimages/"+cImg2);
										newImg.setAttribute("alt","");
										newImg.id="img_"+sCount+"_2";
										newImg.setAttribute("onmouseover","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_2', 'V', '"+cCodice+"', '"+cImg2+"');");
										newImg.setAttribute("onmouseout","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_2', 'H');");
									}
									if (cImg3.length > 0) {
										newImg = document.createElement("img");
										newCell.appendChild(newImg);
										newImg.className='icone';
										newImg.setAttribute("src","DBimages/"+cImg3);
										newImg.setAttribute("alt","");
										newImg.id="img_"+sCount+"_3";
										newImg.setAttribute("onmouseover","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_3', 'V', '"+cCodice+"', '"+cImg3+"');");
										newImg.setAttribute("onmouseout","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_3', 'H');");
									}
									sCount++;
								}
							}
							if (sCount>0 && sCount%2) {
								newCell = document.createElement("td");
								newRowP.appendChild(newCell);
							}
							break;
						}
					}
				}
			}
		}
	}
}
function jsvoid_OBJ_ContenitoreOpen(cID, cID_Rif, cMode, cCodice, cImg) {
	var OBJ=document.getElementById(cID);
	var stSizeXY=null;
	if (OBJ!=null) {
		if (cMode=='V') {
			if (GLOBAL_xmlMacchine.childNodes!=null) {
				document.getElementById('img_lis_zoom').src="DBimages/"+cImg;
				document.getElementById('td_zoom_codice').innerHTML=cCodice;
			} else {
				var OBJ2=this.parent.frames['sommario'];
				document.getElementById('img_lis_zoom').src="DBimages/"+OBJ2.GLOBAL_cCategoria+"/"+cImg;
				document.getElementById('td_zoom_codice').innerHTML=cImg;
			}
			OBJ.style.display="";
			stSizeXY=jsarray_GetSizeXY(cID);
			stCoord=jsarray_GetPosIntoWindow(cID_Rif,stSizeXY[0],stSizeXY[1]);
			OBJ.style.position="absolute";
			OBJ.style.left=stCoord[0]+"px";
			OBJ.style.top=stCoord[1]+"px";
		} else OBJ.style.display="none";
	}
}
function jsarray_GetPosXY(cID) {
	var OBJ=document.getElementById(cID);
	var curleft = curtop = 0;
	if (OBJ.offsetParent) {
		do {
			curleft += OBJ.offsetLeft;
			curtop += OBJ.offsetTop;
		} while (OBJ = OBJ.offsetParent);
	}
	return [curleft,curtop];
}

function jsarray_GetSizeXY(cID) {
	var OBJ=null, sWidth=0, sHeight=0;
	switch(cID) {
	  case 'document':	// dimensioni totali della pagina
		sWidth=document.body.clientWidth;
		sHeight=document.body.clientHeight;
		break;
	  case 'frame':	// dimensioni dell'area visibile della pagina
		sWidth=document.documentElement.clientWidth;
		sHeight=document.documentElement.clientHeight;
		break;
	  default:	// dimensioni dell'oggetto
		OBJ=document.getElementById(cID);
		sWidth=OBJ.clientWidth;
		sHeight=OBJ.clientHeight;
		break;
	}
	return [sWidth,sHeight];
}

function jsarray_GetScrollXY() {
	var scrOfX = scrOfY = 0;
	if (typeof(window.pageYOffset)=='number') {
		// Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		// DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		// IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [scrOfX,scrOfY];
}

function jsarray_GetPosIntoWindow(cID, sWidth, sHeight) {
	var stObjXY=jsarray_GetPosXY(cID);
	var stObjSizeXY=jsarray_GetSizeXY(cID);
	var stScrollXY=jsarray_GetScrollXY();
	var stWinXY=jsarray_GetSizeXY('frame');
	var sMarginLeft=5, sMarginTop=5;

	stObjXY[0]=stObjXY[0]+(stObjSizeXY[0]/2);
	stObjXY[1]=stObjXY[1]+(stObjSizeXY[1]/2);
	if ((stObjXY[1]+sMarginTop+sHeight) <= (stWinXY[1]+stScrollXY[1]) &&
		(stObjXY[0]+sMarginLeft+sWidth) <= (stWinXY[0]+stScrollXY[0])) {	// In basso a destra
		stObjXY[1]+=sMarginTop;
		stObjXY[0]+=sMarginLeft;
	} else {
		if ((stObjXY[1]-sMarginTop-sHeight) > stScrollXY[1] &&
			(stObjXY[0]+sMarginLeft+sWidth) <= (stWinXY[0]+stScrollXY[0])) {	// In alto a destra
			stObjXY[1]-=(sMarginTop+sHeight);
			stObjXY[0]+=sMarginLeft;
		} else {
			if ((stObjXY[1]-sMarginTop-sHeight) > stScrollXY[1] &&
				(stObjXY[0]-sMarginLeft-sWidth) > stScrollXY[0]) {	// In alto a sinistra
				stObjXY[1]-=(sMarginTop+sHeight);
				stObjXY[0]-=(sMarginLeft+sWidth);
			} else {	// In basso a sinistra
				stObjXY[1]+=sMarginTop;
				stObjXY[0]-=(sMarginLeft+sWidth);
			}
		}
	}
	if (stObjXY[0]<0)
		stObjXY[0]=sMarginLeft;
	if (stObjXY[1]<0)
		stObjXY[1]=sMarginTop;
	return [stObjXY[0],stObjXY[1]];
}
function jsvoid_LIS_ElencoLingua()
{	var xmlCategorie=jsxmlDoc_XMLload('categoria.xml'), OBJ=document.getElementById('td_lingua'), sIdx, newTbl, newRow, newCell, newImg;
	if (xmlCategorie!=null)
		xmlCategorie = jsdata_getDataByTagName(xmlCategorie, 'LINGUA', true);
	if (xmlCategorie!=null && OBJ!=null) {
		newTbl = document.createElement("table");
		newTbl.className='lingua';
		OBJ.appendChild(newTbl);
		newRow=newTbl.insertRow(-1);
		for (sIdx=0, sCount=0; sIdx<xmlCategorie.childNodes.length; sIdx++) {
			if (xmlCategorie.childNodes[sIdx].nodeType == 1 && xmlCategorie.childNodes[sIdx].childNodes[0]!=null) {
				newCell = document.createElement("td");
				newCell.className='lingua';
				newRow.appendChild(newCell);
				newImg = document.createElement("img");
				newCell.appendChild(newImg);
				newImg.className='lingua';
				newImg.setAttribute("src","images/"+xmlCategorie.childNodes[sIdx].nodeName+".gif");
				newImg.setAttribute("alt", xmlCategorie.childNodes[sIdx].nodeName);
				newImg.setAttribute("onclick","jsvoid_LIS_lingua('"+xmlCategorie.childNodes[sIdx].nodeName+"');");
			}
		}
	}
}
function jsvoid_LIS_lingua(cLingua)
{	var OBJ=this.parent.frames['sommario'];
	OBJ.GLOBAL_cLingua=cLingua;
	if (OBJ.GLOBAL_xmlMacchine.childNodes!=null)
		OBJ.jsvoid_LIS_ElencoCat();
	else
		OBJ.jsvoid_LIS_ElencoCat2();
	if (OBJ.GLOBAL_cCategoria.length>0) {
		var cCategoria = OBJ.GLOBAL_cCategoria;
		OBJ.GLOBAL_cCategoria = "";
		if (OBJ.GLOBAL_xmlMacchine.childNodes!=null)
			OBJ.jsvoid_LIS_click(cCategoria);
		else
			OBJ.jsvoid_LIS_click2(cCategoria);
	}
}
function jsvoid_LIS_News()
{	var xmlNews=jsxmlDoc_XMLload('banner.xml'), OBJ=document.getElementById('marquee_news'), sIdx, stApp, cTitolo, cTesto, cInnerHTML='';
	if (xmlNews!=null) {
		xmlNews2 = jsdata_getDataByTagName(xmlNews, 'XML', true);
		if (xmlNews2!=null)
			xmlNews = xmlNews2;
	}
	if (xmlNews!=null && OBJ!=null) {
		for (sIdx=0; sIdx<xmlNews.childNodes.length; sIdx++) {
			if (xmlNews.childNodes[sIdx].nodeType == 1 && xmlNews.childNodes[sIdx].childNodes[0]!=null) {
				cTitolo=cTesto='';
				stApp = jsdata_getDataByTagName(xmlNews.childNodes[sIdx], 'TX_D_TITOLO', false);
				if (stApp!=null)
					cTitolo = stApp.childNodes[0].data;
				stApp = jsdata_getDataByTagName(xmlNews.childNodes[sIdx], 'TX_D_TEXT', false);
				if (stApp!=null)
					cTesto = stApp.childNodes[0].data;
				cInnerHTML += '<b>'+cTitolo+'</b><br />'+cTesto+'<br />';
			}
		}
		OBJ.innerHTML = cInnerHTML;
	}
}
function jsvoid_LIS_mouse2(cID)
{	var OBJ=document.getElementById(cID), cClass;
	if (OBJ!=null) {
		cClass=OBJ.className.substr(OBJ.className.length-3);
		OBJ.className=OBJ.className.substr(0, OBJ.className.length-3);
		if (cClass=='out')
			OBJ.className+='ovr';
		else
			OBJ.className+='out';
	}
}
function jsvoid_LIS_ElencoCat2()
{	var OBJtbl=document.getElementById('tbl_categoria'), newRow, newCell, OBJTbody, cCodice, cDescr, stApp, stCategorie=new Array(), sIdx, OBJ, stDescr=new Array();
	GLOBAL_xmlIMG=jsxmlDoc_XMLload('immagini.xml');
	if (OBJtbl!=null && GLOBAL_xmlIMG!=null) {
		OBJTbody=OBJtbl.getElementsByTagName("tbody").item(0);
		GLOBAL_xmlIMG = jsdata_getDataByTagName(GLOBAL_xmlIMG, 'LISTINO', true);
		if (GLOBAL_xmlIMG != null && OBJTbody!=null) {
			while (true) {
				try
				{	OBJTbody.deleteRow(0);
				}
				catch(err)
				{	break;
				}
			}
			var xmlCategorie=jsxmlDoc_XMLload('categoria.xml');
			if (xmlCategorie!=null) {
				stApp = jsdata_getDataByTagName(xmlCategorie, 'LINGUA', true);
				if (stApp!=null)
					stApp = jsdata_getDataByTagName(stApp, GLOBAL_cLingua, false);
				OBJ=document.getElementById('td_intesta');
				if (stApp!=null && OBJ!=null)
					OBJ.innerHTML = stApp.childNodes[0].data;
				xmlCategorie = jsdata_getDataByTagName(xmlCategorie, 'LISTINO', true);
			}
			if (xmlCategorie!=null) {
				for (sIdx=0; sIdx<xmlCategorie.childNodes.length; sIdx++) {
					if (xmlCategorie.childNodes[sIdx].nodeType == 1 && xmlCategorie.childNodes[sIdx].nodeName=='CATEGORIA' && xmlCategorie.childNodes[sIdx].childNodes[0]!=null) {
						cCodice='', cDescr='';
						stApp = jsdata_getDataByTagName(xmlCategorie.childNodes[sIdx], 'CODICE', false);
						if (stApp!=null)
							cCodice = stApp.childNodes[0].data;
						stApp = jsdata_getDataByTagName(xmlCategorie.childNodes[sIdx], 'LINGUA', false);
						if (stApp!=null) {
							stApp = jsdata_getDataByTagName(stApp, GLOBAL_cLingua, false);
							if (stApp!=null)
								cDescr= stApp.childNodes[0].data;
						}
						stCategorie[cCodice]=new Array();
						stCategorie[cCodice]['LABEL'] = cDescr;
					}
				}
			}
			var stSizeXY1=jsarray_GetSizeXY('frame');
			var stSizeXY2=jsarray_GetSizeXY('td_intesta');
			var sHeight = (stSizeXY1[1] - stSizeXY2[1]) / stCategorie.length;
			// scrivo righe tabella
			for (cCodice in stCategorie) {
				newRow=OBJTbody.insertRow(-1);
				newCell = document.createElement("td");
				newCell.id="TD_"+cCodice;
				newCell.className='categoria_out3';
				newCell.height = sHeight+"px";
				stDescr = stCategorie[cCodice]['LABEL'].split(' ');
				for (sIdx in stDescr) {
					if (sIdx > 0)
						newCell.appendChild(document.createElement("br"));
					newCell.appendChild(document.createTextNode(stDescr[sIdx]));
				}
				newCell.setAttribute("onclick","jsvoid_LIS_click2('"+cCodice+"');");
				newCell.setAttribute("onmouseover","jsvoid_LIS_mouse('"+cCodice+"', event);");
				newCell.setAttribute("onmouseout","jsvoid_LIS_mouse('"+cCodice+"', event);");
				newRow.appendChild(newCell);
			}
			
			/*if (GLOBAL_cCategoria.length==0)
				jsvoid_LIS_click2('1');*/
		}
	}
}
function jsvoid_LIS_click2(cCategoria)
{	var OBJ=document.getElementById('tbl_categoria'), sIdx, stApp, i2, sCount, cCodice, cDescr, cImg1, cImg2, cImg3, newRowP, newRowI, newCell, newTbl, newA, newImg, newTbl2, newRowI2;
	if (OBJ!=null) {
		OBJ=OBJ.getElementsByTagName("tbody").item(0);
		if (OBJ!=null)
			OBJ=OBJ.getElementsByTagName("TD");
	}
	if (OBJ!=null && GLOBAL_cCategoria!=cCategoria) {
		for (sIdx=0; sIdx<OBJ.length; sIdx++)
			if (OBJ.item(sIdx).className!='categoria_out3')
				OBJ.item(sIdx).className='categoria_out3';
		OBJ=document.getElementById("TD_"+cCategoria);
		if (OBJ!=null) {
			OBJ.className='categoria_over3';
			GLOBAL_cCategoria=cCategoria;
			
			OBJ=this.parent.frames['principale'].document.getElementById('tbl_macchina');
			if (OBJ!=null) {
				while (true) {
					try
					{	OBJ.removeChild(OBJ.firstChild);
					}
					catch(err)
					{	break;
					}
				}
				for (sIdx=0; sIdx<GLOBAL_xmlIMG.childNodes.length; sIdx++) {
					if (GLOBAL_xmlIMG.childNodes[sIdx].nodeType == 1 && GLOBAL_xmlIMG.childNodes[sIdx].nodeName=='CATEGORIA_'+cCategoria && GLOBAL_xmlIMG.childNodes[sIdx].childNodes[0]!=null) {
						for (i2=0, sCount=0; i2<GLOBAL_xmlIMG.childNodes[sIdx].childNodes.length; i2++) {
							if (GLOBAL_xmlIMG.childNodes[sIdx].childNodes[i2].nodeType == 1 && GLOBAL_xmlIMG.childNodes[sIdx].childNodes[i2].nodeName=='NOMEFILE') {
								cImg1 = GLOBAL_xmlIMG.childNodes[sIdx].childNodes[i2].childNodes[0].data;
								if (!(sCount%5)) {
									newTbl = document.createElement("table");
									OBJ.appendChild(newTbl);
									newTbl.className='riep_img';
									newTbl.setAttribute("cellpadding","0");
									newTbl.setAttribute("cellspacing","5");
									
									newRowP=newTbl.insertRow(-1); // riga principale
								}
								newCell = document.createElement("td");
								newRowP.appendChild(newCell);
								newCell.className='macchina_icone';
								
								newImg = document.createElement("img");
								newCell.appendChild(newImg);
								newImg.className='icone';
								newImg.setAttribute("src","DBimages/"+cCategoria+"/"+cImg1);
								newImg.setAttribute("alt","");
								newImg.id="img_"+sCount+"_1";
								newImg.setAttribute("onmouseover","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_1', 'V', '', '"+cImg1+"');");
								newImg.setAttribute("onmouseout","jsvoid_OBJ_ContenitoreOpen('div_lis_zoom', 'img_"+sCount+"_1', 'H');");
								
								sCount++;
							}
						}
						break;
					}
				}
			}
		}
	}
}

