<!--
/* - www.MiglioriSiti.net production [Do not remove this copyright notice] copyright 2009

You are free to consult, to use or to modify the following HTML and/or Javascript code for your personal purposes.
miglioriSiti.Net hopes that, for facilities that will derive you from these practices, appreciating our work,
you could send us a compensation, decide you the price, variable from 5 to 50 dollars or euro,
depending on the kind of your use (ex. learning, personal use, commercial use).
The donation will allow improving and a continuous work of our free services.
For more information contact us

Best regards,	MiglioriSiti.NET
*/
var PATH='/';
var CLASS_HOME = '0WBhome';
var formMain = null;

	function initPage(){
//		for(var i=0 ; i<listSCat.length ; i++ ){
//			listSCat[i][0][0]=' Sottocategoria: ';//lingua inglese?
//		}
		PreloadImages( '/imgWB/frecSele.gif','/imgWB/frec.gif','/imgWB/menu2_L1cent_trasp.gif'
				,'/imgWB/botGiu.gif','/imgWB/botSu.gif','/imgWB/loading_acqua_2.gif'
				,'/imgWB/cercaOn.gif','/imgWB/cercaOnBright.gif' );

		var yCima = document.getElementById('cima').offsetTop;
		if(yCima!=0 ){
			document.getElementById('sinistra').style.top = 130 + yCima;
			document.getElementById('destra').style.top =  130 + yCima;
			if( !isIE ){
				document.getElementById('linkCima').style.top =  104 + yCima;
			}
		}

		formMain = document.getElementById('main');
		if(typeof(document.addEventListener)!='undefined'){
			formMain.addEventListener('submit', returnSubmit, true);
		}else if(typeof(document.attachEvent)!='undefined') {
			formMain.attachEvent('onsubmit',returnSubmit);
		}
		//HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
		//HTMLFormElement.prototype.submit = newsubmit;

		var isHome = formMain.elements['idCat'].value.substring(1)==CLASS_HOME;
		if(isHome){
			PreloadImages('/imgWB/occhiBo.gif','/imgWB/occhiFissi.gif','/imgWB/occhiRidono.gif');
			//Anim();
		}
		writeDate();
		imgAltToTitle();
		if( document.getElementById('motoreDiv0')!=undefined ){
			motoreDown(0);//bottone default
		}
	}

	function translate(langu){
		var urlTraslation = 'http://translate.google.com/translate?hl=en&sl=it&tl=';
		var currentCat = siteName + '/?idCat='+ document.getElementById('main').elements['idCat'].value; //urlWebBook
		if( 'it'==langu ){
			top.location.href = 'http://'+ currentCat;
		}else{
			top.location.href = urlTraslation + langu +'&u='+ currentCat;
		}
		return false;
	}

			//################################# TextArea nota
	function clickCancText(obj, txtToCanc){
		obj.focus()
		if( trim(obj.value)==txtToCanc ){
			obj.value=''
			obj.style.color = '#000000'
			obj.style.fontWeight = 'bold'
		}
	}
	function blurWriteText(obj, txtToWrite){
		if( trim(obj.value)=='' ){
			obj.value=txtToWrite
			obj.style.color = '#777777'
			obj.style.fontWeight = 'normal'
		}
	}


	function addBannId(bannId){	//salvo gli id dei banner cliccati
		var objBannClic = document.getElementById('main').elements['bannersClick'];
		objBannClic.value = objBannClic.value +' '+ bannId
	}

			//################################# BOTTONI MOTORI

var motoreSel = 0	//il tipo di ricerca da effettuare
	function motoreOver(numImg){
		swapImg('motoreImg'+numImg, PATH +'imgWB/botSu.gif')
		document.getElementById('motoreDiv'+numImg).style.backgroundPosition='2px 2px'
	}
	function motoreOut(numImg){
		if(motoreSel==numImg){
			swapImg('motoreImg'+numImg, PATH +'imgWB/botGiu.gif')
			document.getElementById('motoreDiv'+numImg).style.backgroundPosition='4px 4px'
		}else{
			swapImg('motoreImg'+numImg, PATH +'imgWB/nulla.gif')
		}
	}
	function motoreDown(numImg){
		if(numImg!=motoreSel){
			swapImg('motoreImg'+numImg, PATH +'imgWB/botGiu.gif')
			document.getElementById('motoreDiv'+numImg).style.backgroundPosition='4px 4px'
			swapImg('motoreImg'+motoreSel, PATH +'imgWB/nulla.gif')
			document.getElementById('motoreDiv'+motoreSel).style.backgroundPosition='2px 2px'
			motoreSel=numImg
		}else{
			swapImg('motoreImg'+numImg, PATH +'imgWB/botGiu.gif')
			document.getElementById('motoreDiv'+numImg).style.backgroundPosition='4px 4px'
		}
	}


			//################################# SUBMIT JS

function getCatName(idCat,isCombo){
	var nomeCat = '';
	var idCatSub = '';
	var idCatArray = idCat.split('_')
	if(idCatArray.length>1){
		idCatSub = idCatArray[0] +'_'+ idCatArray[1];
		nomeCat = isCombo ? '' : menuTree[idCatSub].n;
		for (var i=2; i < idCatArray.length; i++) {
			idCatSub = idCatSub +'_'+ idCatArray[i];
			var nomeMenu = menuTree[idCatSub]!=undefined ? menuTree[idCatSub].n : 'xxx';
			nomeCat = nomeCat +' > '+ nomeMenu;
		}
	}
	return nomeCat;
}
function getCatPath( idCat ){
	var nomeCat = '';
	var idCatSub = '';
	var idCatArray = idCat.split('_');
	if(idCatArray.length>1){
		idCatSub = idCatArray[0] +'_'+ idCatArray[1];
		nomeCat = convertToPath( menuTree[idCatSub].n );
		for (var i=2; i < idCatArray.length; i++) {
			idCatSub = idCatSub +'_'+ idCatArray[i];
			var nomeMenu = menuTree[idCatSub]!=undefined ? menuTree[idCatSub].n : 'xxx';
			nomeCat = nomeCat +'-'+ convertToPath( nomeMenu );
		}
	}
	return nomeCat;
}
function convertToPath( categ ){
	var converted = categ; //trim(categ);
	converted = converted.replace(/[ -]/g, '');
	converted = converted.replace(/&agrave;/g,'a');
	converted = converted.replace(/&egrave;/g,'e');
	converted = converted.replace(/&eacute;/g,'e');
	converted = converted.replace(/&igrave;/g,'i');
	converted = converted.replace(/&ograve;/g,'o');
	converted = converted.replace(/&ugrave;/g,'u');
	converted = converted.toLowerCase();
	converted = encodeURI(converted); //no encode: , / ? : @ & = + $ # Use the encodeURIComponent() to encode these
	return converted;
}


function returnSubmit(){
	setTimeout("inviaRicerca()",0)
	return false;
}

var motoriNomi=new Array( 'MS','google','wiki','dmoz','yahoo','live' );
var isOutSG = 1; //0=uscitaControllata 1=uscitaBrusca
var invioCount = 0
var invioMax = 2	//permetto max 2 submit consecutivi
var MSG_LOADING = '<div>loading &nbsp;<img align="middle" src="'+ PATH +'imgWB/loading_acqua_2.gif" width="148" height="27" alt=""></div>';

	function inviaRicerca(){

		var problem = false;
		if(motoreSel==0){//WebBook search:
			formMain.elements['pageName'].value = '';
			formMain.elements['idCat'].value = 'I0Cerca';
			formMain.elements['nPag'].value = '1';
			return invia( 'Ricerca in corso' );
		}else{
			var urlRicerca = '';
			var txtRicerca = formMain.elements['q'].value

			try{
				var req = false;
				req = newXMLHttpRequest();
				if (req.overrideMimeType) {
					req.overrideMimeType('text/html');
				}
				if (!req){
					logAccess('inviaRic-req=false', true);
					return false;
				}
				var paramToSend = txtRicerca.replace(/^\s/g, ' ');
				paramToSend = '?act=writeLog&idCat=Note&note=SRC-'+motoriNomi[motoreSel]+': '+ paramToSend +'&usr='+formMain.elements['usr'].value +'&time='+getTimeStamp(new Date());
				req.onreadystatechange = getReadyStateHandler(req, vuota);
				req.open("GET", urlAjax + paramToSend , true);
				req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				req.send(null);

				for(i=0; i==300; i++){	//perdiTempo:
					formMain = document.getElementById('main');
				}
			}catch(e){
				logAccess( 'inviaRic-catch '+ eToString(e), true );
			}
	//logAccess( 'SRC-'+motoriNomi[motoreSel]+': '+txtRicerca, true );

			txtRicerca = escape(txtRicerca);
			if(motoreSel==1){
				//document.forms[1].elements['q'].value = txtRicerca
				//document.forms[1].submit()
				urlRicerca='http://www.google.it/search?hl=it&q='+ txtRicerca;
			}else if(motoreSel==2){
				urlRicerca='http://it.wikipedia.org/wiki/Speciale:Ricerca?search='+ txtRicerca;	// http://it.wikipedia.org/wiki/Special:Search?search=motori&go=Vai

			}else if(motoreSel==3){
				urlRicerca='http://search.dmoz.org/cgi-bin/search?all=yes&cs=UTF-8&cat=World%2FItaliano&search='+ txtRicerca;

			}else if(motoreSel==4){
				urlRicerca='http://it.search.yahoo.com/search?p='+ txtRicerca +'&y=i&ei=UTF-8';

			}else if(motoreSel==5){
				urlRicerca='http://search.live.com/results.aspx?q='+ txtRicerca; 	//http://search.msn.it/results.aspx?q=
			}
isOutSG = 0;
			document.location.href = urlRicerca;
		}
		return problem;
	}
	function inviaUrl(pagArray){
		var formMain = document.getElementById('main');
		var problem = false;
//		if( invioCount<invioMax ){
			var usr = formMain.elements['usr'].value;
			if(usr!=null && usr!=''){
				usr= '&usr='+ usr;
			}else{
				usr='';
			}
			formMain.elements['act'].value = 'url';
			formMain.elements['pageName'].value = 'http://'+ siteName +'/'+ pagArray[1] +'#WBpag'+ usr;
			formMain.elements['idCat'].value = pagArray[0];
			problem = invia(pagArray[1], '', urlAjax );
//		}
		return problem;
	}

	function inviaHome(linguaSigla){
		var nome = 'Home page '+ linguaSigla;
		document.getElementById('main').elements['pageName'].value = nome;
		document.getElementById('main').elements['idCat'].value = linguaSigla + CLASS_HOME;
		return invia(nome);
	}
	function inviaCat( catId ){
		var catNome = getCatName(catId);
		formMain.elements['pageName'].value = catNome;
		formMain.elements['idCat'].value = catId;
		formMain.elements['nPag'].value = '1';
		return invia( catNome.replace(/&gt;|>/g,'&gt;') );		//catNome.replace(/&/g,'%26');
	}
	function relo(){   //used only by reload button
		return invia( 'Ricaricamento ...')
	}
	function pag(from, to){
		window.scroll(0,0);
		formMain = document.getElementById('main');
		formMain.elements['nPag'].value = to;

		var messLoading = '';
		var catId = formMain.elements['idCat'].value
		if(catId.indexOf('0Cerca')>-1){
			messLoading = 'Ricerca';
		}else{
			messLoading = getCatName(catId).replace(/&gt;|>/g,'&gt;');
		}
		if(to!='1'){
				messLoading += ' '+ to;
		}
		return invia(messLoading);
	}
	function invia( messLoading, urlParam, urlToUse ){  //metodo privato
		if(urlParam==null || urlParam==''){
	   		urlParam=''
		}else{
			urlParam = '?'+urlParam
		}
		if(!inManuten){
		if(urlToUse==null){
			var urlRelative = '';
			var idCatInvio = formMain.elements['idCat'].value;
			if(idCatInvio.indexOf('HTTP_ERR')>-1){
				return false;
			}else if(idCatInvio.indexOf('0Send')>-1){
				urlRelative = '?idCat=I0Send';
			}else if(idCatInvio.indexOf('0Cerca')>-1){
				var txtRicerca = formMain.elements['q'].value
				txtRicerca = txtRicerca.replace(/^\s/g, ' ');
				txtRicerca = escape(txtRicerca);
				urlRelative = '?q='+txtRicerca;
				var nPagInvio = formMain.elements['nPag'].value;
				if(nPagInvio!='1'){
					urlRelative += '&nPag='+ nPagInvio;
				}
			}else{
				urlRelative = getCatPath(idCatInvio);
				var nPagInvio = formMain.elements['nPag'].value;
				if(nPagInvio!='1'){
					urlRelative += '-'+ nPagInvio;
				}
			}
			urlToUse= 'http://'+ siteName +'/'+ urlRelative;

		}
// TIMEOUT_DISABLED if( invioCount==0 ) setTimeout('location.href="http://www.migliorisiti.net/index.htm#idCat=timeout&da='+formMain.elements['da'].value+'"', 30000) ;

		if( invioCount<invioMax ){
			invioCount++
			document.body.className += " waitStyle"

			obj = document.getElementById('sendMsg')
			obj.setAttribute('class', 'send_msg');
			obj.setAttribute('className', 'send_msg');
			obj.innerHTML = '<div id="send_msg_bord">'+ messLoading + MSG_LOADING +'</div>';

			formMain.action = urlToUse + urlParam;
isOutSG = 0;
			formMain.submit()
	   }else{					//old:  location.href='about:blank';  //per l'onUnload
			obj = document.getElementById('sendMsg')
			obj.innerHTML = '<div id="send_msg_bord"> Servizio in attesa di risposta .......' + MSG_LOADING +'</div>';
	   }
	   }
	   return false;
	}


			//##################	AJAX - unload - salvaLog	############

// eseguito sull'onUnload --> serve per registrare bannersClick e soprattutto i SITI cliccati
//(meglio php di passaggio per il click sito)
// le votazioni e le note però non le può registrare perché serve un submit
// ==> per il momento NON UTILIZZATO
	function unloadDo(){
/*		if(isOutSG==1){
		  try{
			var req = false;
			req = newXMLHttpRequest();
			if (req.overrideMimeType) {
				req.overrideMimeType('text/html');
			}
			if (!req){
				logAccess('unloadDo-req=false', true);
				return false;
			}
			req.onreadystatechange = getReadyStateHandler(req, vuota);
			req.open("GET", urlAjax +'?'+ getPostDati(), true);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(null);

		for(i=0; i==500; i++){	//perdiTempo:
			formMain = document.getElementById('main');
		}

		  }catch(e){
				logAccess( 'unloadDo-catch '+ eToString(e), true );
		  }
		}//if()
*///alert( getPostDati() )
	}

	function getPostDati() {

var urlDati = 'act=salvaLog'
+ '&bannersClick='+ formMain.elements['bannersClick'].value
+ '&idCat=Exit'
+ '&da='+ formMain.elements['da'].value
+ '&votaz='+ formMain.elements['votaz'].value
+ '&usr='+ formMain.elements['usr'].value;

var nota = formMain.elements['nota'];
if(nota!=undefined){
	nota = nota.value;
	if(nota!=txtNotaGen && nota!=''){
		urlDati = urlDati + '&nota='+ nota;
	}
}
if(formMain.elements['adm']!=undefined){
	urlDati = urlDati + '&adm='+ formMain.elements['adm'].value
}

	var objIdLink = document.getElementById('main').elements['idLink']
		if(objIdLink!=undefined){//se ci sono indirizzi
			if( objIdLink.length==undefined ){
				urlDati = urlDati + '&idLink='+ objIdLink.value
				+ '&voto-'+objIdLink.value+'='+ formMain.elements['voto-'+objIdLink.value].value
				+ '&click-'+objIdLink.value+'='+ formMain.elements['click-'+objIdLink.value].value;
				nota = formMain.elements['nota-'+objIdLink.value].value;
				if(nota!=COMMENTO_LINK && nota!='')
					urlDati = urlDati +'&nota-'+objIdLink.value+'='+ nota;
			}else{
				for (var j=0; j<objIdLink.length; j++){
					urlDati = urlDati + '&idLink='+ objIdLink[j].value
					+ '&voto-'+objIdLink[j].value+'='+ formMain.elements['voto-'+objIdLink[j].value].value
					+ '&click-'+objIdLink[j].value+'='+ formMain.elements['click-'+objIdLink[j].value].value;
					nota = formMain.elements['nota-'+objIdLink[j].value].value;
					if(nota!=COMMENTO_LINK && nota!='')
						urlDati = urlDati +'&nota-'+objIdLink[j].value+'='+ nota;
				}
			}
		}
		return urlDati;
	}
	function vuota(nulla) {
		//alert( nulla );
	}

			//################	setIdUser()	AJAX	############

function chkIdUser() {
	var usrObj = document.getElementById('main').elements['usr'];
	var usr = usrObj.value;

	if(usr==undefined || usr=='' || usr=='0' || usr=='-2'){
		var idUser = readCookie('webbook_ck');
//alert( '>'+idUser+'<' );
		if(idUser=='' || idUser.indexOf(' ')>-1 ){
		  try{
			var req = false;
			req = newXMLHttpRequest();
	if (req.overrideMimeType) {
		req.overrideMimeType('text/html');	//text/xml
	}
	if (!req){
		logAccess('req.false', true);//Cannot create XMLHTTP instance
		return false;
	}
			writeCookie('webbook_ck_test','freedom');
			var cookieTest = readCookie('webbook_ck_test')
//alert( '>'+cookieTest+'<' );
			var params = '';
			if(cookieTest!=''){//cookies enabled
				params = 'act=getIdUser&cookie=1';
			}else{
				params = 'act=getIdUser&cookie=0';
			}
			req.onreadystatechange = getReadyStateHandler(req, setIdUser);
			req.open("GET", urlAjax +'?'+ params, true);	//possibile Runtime ERROR: Autorizzazione negata	si deve usare http://
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(null);
		  }catch(e){
				logAccess( 'req.catch '+ eToString(e), true );
		  }
		}else{
			usrObj.value = idUser;
			logAccess('acc1');	//log solo se vi è usr
		}
	}
}

function setIdUser(idUser) {
	idUser = trim(idUser);
	document.getElementById('main').elements['usr'].value = idUser;
	if(idUser>0){
		writeCookie('webbook_ck',''+idUser, 61320);//7anni
	}
//alert( '>'+document.getElementById('main').elements['usr'].value+'<' );
	logAccess('NewId='+idUser);
}

// Usato solo nelle pagine di tipo webI.htm
	function logAccess(txt, isNote){
		formMain = document.getElementById('main');

		if(isNote==null){
			isNote = false;
		}
		var paramIdCat = formMain.elements['da'].value;	//getParamCgi(location.href, 'idCat=');
		var paramDa = getParamCgi(location.href, 'da=');
		txt = txt.replace(/^\s/g, ' ');
		var paramNota = '';
		if(isNote){
			paramIdCat = 'Note';
			paramNota = '&note='+ txt;
		}else{
			paramDa = paramDa!='' ? txt +'|'+ paramDa : txt;
		}
		paramDa = paramDa!='' ? '&da='+ paramDa : '';
		var urlTrasl = ''+location.href;
		if( urlTrasl.indexOf('translate')==-1 ){
			PreloadImages( urlAjax +'?act=writeLog&idCat='+ paramIdCat + paramDa + paramNota +'&usr='+formMain.elements['usr'].value );
			//document.getElementById('PopUp').innerHTML = '<img src="'+
			//urlAjax +'?act=writeLog&idCat='+ paramIdCat + paramDa + paramNota +'&usr='+formMain.elements['usr'].value +'">' ;
		}
	}

			//#################### OCCHIETTI:	############
var occhiImgSel = 0
var occhi = new Array()
occhi[0] = PATH +'imgWB/occhiFissi.gif';
occhi[1] = PATH +'imgWB/occhiBo.gif';
occhi[2] = PATH +'imgWB/occhiRidono.gif';
occhi[3] = PATH +'imgWB/occhi.gif';

function occhiOver(){
	document.getElementById('occhiImg').src = occhi[occhiImgSel];
	showaltHelp_off_y = -34;
	MessaggioMostra('Cliccami piu volte lentamente! :-)', 210, 22);
}
function occhiOut(){
	document.getElementById('occhiImg').src=occhi[3];
	MessaggioNascondi();
}
function occhiUp(){
	occhiImgSel=(occhiImgSel+1)%3;
	document.getElementById('occhiImg').src = occhi[occhiImgSel];
}

			//#################### TITLE ANIMATION:	############
var messageTitle = new Array();
messageTitle[0] = 'Web guida';
messageTitle[1] = 'www.miglioriSiti.NET';

var frame = new Array();
frame[0] = '>-)>__________';
frame[1] = '___>-)>_______';
frame[2] = '______>-)>____';
frame[3] = '_________>-)>_';
frame[4] = '__________<(-<';
frame[5] = '_______<(-<___';
frame[6] = '____<(-<______';
frame[7] = '_<(-<_________';

var f = 0; //controlla un ciclo completo di animazione
var cicl = 0;
var nMess = 0;
var reps = 2; //numero di volte che deve ripetere l'aminazione per ogni messaggio del vettore-->  non deve essere minore di 1
var msec = 200;
var setT = null;

function Anim(){
  document.title = frame[f]+messageTitle[nMess]+'     ';
  f++;
  if (f > 7) { f = 0;}
  if (cicl < (8 * reps)) //allora proietto la scritta dopo il tempo specificato da msec
  {
    cicl++;
    setT = setTimeout("Anim()", msec);
  }
  else //reimposto il messaggio al termine del ciclo*le-ripetizioni
  {
    nMess++;
    if(nMess > messageTitle.length - 1) nMess = 0;
    f = 0;
    cicl = 0;
    setT = null;
    Anim();
  }
}

			//####################	status bar messages V.3	############
var msg = new Array()
var nMess2 = 0
var msec2 = 100
var pez=0

function Scorri1()
{
  window.status = msg[nMess2].substring(0, pez+1)
  pez++
  if ( pez >= msg[nMess2].length )
  {
    pez = 0
    window.setTimeout("Scorri2();", msec2 )
  }
  else window.setTimeout("Scorri1();", msec2 )
}

var cicl2=0
function Scorri2()
{
  var out="";
  for (i=1; i<=pez; i++) out += " "; //metto in out n?pez spazi
  if(pez>=0) out = out + " " + msg[nMess2] ; //lo spazio evita che rimane visualizzato l'ultimo carattere quando passo alla frase successiva
  else out = msg[nMess2].substring(-pez, msg[nMess2].length) + " "; //anche adesso lo spazio evita il "Done"
  window.status=out.substring(0, 130)
  pez++;
  if ( pez >= 130 ) { pez = -msg[nMess2].length ; cicl2++;}
  if (cicl2<1)  window.setTimeout("Scorri2();", msec2 )
  else //passo alla frase successiva
  {
     nMess2++;
     if(nMess2 > msg.length - 1) nMess2 = 0
	 cicl2=0
	 pez=0
	 window.setTimeout("Scorri1();", 2000 )
  }
}
			//####################	WRITE DATE	############
var mesiElenco = new Array('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre');
var giorniElenco = new Array('Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato');

function writeDate() {
	dataNow = new Date();
	var dataStr = giorniElenco[dataNow.getDay()] + ', ' + dataNow.getDate() + ' ' + mesiElenco[dataNow.getMonth()] + ' ' + dataNow.getFullYear();
	document.getElementById('tagDate').innerHTML = dataStr ;
}


			//####################	MENU	############
			// menuTree[ idCat ].n=name  .e=expa  .b=bold  .s=numSite  .c=child
                  //     0          1          2          3         4           5        6           7          8         9           10        11          12         13         14         15          16         17       18	      19=sfondo  (19%19=0) allora questo non ? mai usato
//var bgCol=new Array( '#FF0000','#777039', '#00B000', '#000099', '#444444', '#AA0000', '#E060E0', '#00E000', '#0000FF', '#005555', '#D000D0', '#3399FF', '#666666', '#CC0000', '#007700', '#660000', '#006699', '#CC7700', '#993399', '#FDE7D2' );
var bgCol=new Array( 
'#990000','#DD0000','#FF0000','#F85000',  '#CC7700',
'#005555', '#007700', '#777039', '#00B000', '#00E000',
'#000099', '#0000FF', '#006699', '#3399FF', 
'#993399', '#D000D0', '#E060E0',
'#222222', '#444444', '#666666',
'#FDE7D2' );
//scostamento verticale menu di primo livello
var timeO=new Array();
var pathMenu="1a";

	function m1(row){
		row.style.backgroundImage = 'url('+ PATH + 'imgWB/menu2_L1cent_trasp.gif)';
		//background-color:#AA9966
		if( menuTree[menuTopChild[row.value+1]].e == 1) show(row.value+1) ;
		else document.getElementById('Liv1').style.visibility='hidden';
	}
	function m0(row){
		menuBgOut(row);
		if( menuTree[menuTopChild[row.value+1]].e == 1) hide(row.value+1) ;
	}
	function menuBgOut(row){
		row.style.backgroundImage = 'url('+ PATH + 'imgWB/menu2_L1cent.gif)'
		//backgroundColor=#999977
	}

function getGrossOffsetTop(elem){
	var offset = 0
		// correct for IE/Mac discrepancy between offset and style coordinates,
		// but not if the parent is HTML element (NN6)
		offset += (elem.offsetParent.tagName != 'HTML') ?
		parseInt(elem.style.top) - parseInt(elem.offsetTop) : 0
		elem = elem.offsetParent
		offset += elem.offsetTop
	return offset
}

function show(){
  var args=show.arguments

  var i, temp, rig;
  var pass=false;
  var xMenu = document.getElementById('menuLato').offsetWidth
  		+ document.getElementById('container').offsetLeft;
  var yMenu = document.getElementById('cima').offsetTop
		+ document.getElementById('cima').offsetHeight	//= 130		offsetLeft
		- 6;
  var x = -7 + xMenu;
  var y =  7 + yMenu;
  var r = document.getElementById('mF').offsetHeight;  //altezza riga menu

  y = y + ( r * (args[0]-1));//args[0]=numero riga menu

  clearTimeout(timeO[args.length-1]) ;

//document.getElementById('linkCima').innerHTML =  'x'+ args[0] +'x' ;
  for (i=0; i<args.length ; i++) {         //se non vengono passati parametri in ingresso le istruzioni del for non vengono eseguite

     //pathMenu=pathMenu + args[i] + "a";
     if( i<(args.length-1) ) {             //eseguito solo se viene passato piu di un parametro in ingresso

       temp = document.getElementById('Liv'+(i+1) ).offsetWidth;
       if (temp==null) temp=70;//Usato quando Opera sballa
       x = x-3+temp
       //sostitutivo del numero fisso 22
       //temp =  document.getElementById(nome).offsetHeight;
       //temp = temp-2;
       //temp = temp/ numero righe tabella
       y = y-2+ 25*(args[i+1]);    //args[i+1]=numero riga dove va posizionata la tabella
     }
  }//for

  var nome= 'Liv'+ args.length;
  var livObj = document.getElementById(nome)
  if(livObj!=undefined){
	livObj.style.left=x;
	livObj.style.top=y;
	crea(args);
	livObj.style.visibility = 'visible';
  }
}//show


function stop(){
  var args=stop.arguments;
  for (i=args.length-1; i>=0 ; i--) clearTimeout(timeO[i]) ;
}

function hide(){
	var n = hide.arguments.length ;
	timeO[n-1] =setTimeout("document.getElementById('Liv"+ n + "').style.visibility='hidden'",600) ;
}
function hide2(){
	var n = hide2.arguments.length ;
	for (var i=n; i>0 ; i--)
		timeO[i-1] = setTimeout("document.getElementById('Liv"+ i + "').style.visibility='hidden'",600)
}

function crea(chi) { //es.: chi=[1,3,5,6] = menu level index
	var para = '';
	var idSupCat = '';
	for (i=0; i<(chi.length); i++){
		if (i==0)	idSupCat = menuTopChild[chi[i]];
		else		idSupCat = menuTree[ idSupCat ].c[chi[i]];
		para = para + chi[i] + ','
	}
	para = para.substring(0, para.length-1); //para='1,3,5,6'
	var subCatTab = menuTree[ idSupCat ];

	var nomeT = 'Liv'+ (chi.length) ;
	var tabella = '<table border="0" cellpadding="0" cellspacing="1" class="menuLiv2Tab" onMouseOver="stop('+ para +')" onMouseOut="hide2('+ para +')">'

	for (i=0; i<subCatTab.c.length ; i++){

		var idSubCatRow = subCatTab.c[i];
		var subCatRow = menuTree[ idSubCatRow ];
		var espa = subCatRow.e;
		var numSiti = subCatRow.s;
		var rBold = subCatRow.b;

		var nomeCat = subCatRow.n;
		if(rBold=='1') nomeCat = '<b>'+ nomeCat +'</b>';

		tabella = tabella+ '<tr bgcolor="'+ bgCol[bgCol.length-1] +'"'
				 + ' onMouseOver="' + (espa ? 'show('+para+','+ i +');'  :  '')    + 'selez('+chi[0]+',\''+ nomeT +'-r'+i+'\',\'on\')" '
				 + ' onMouseOut ="' + (espa ? 'hide('+para+','+ i +');'  :  '')    + 'selez('+chi[0]+',\''+ nomeT +'-r'+i+'\',\'\')" '
				 + ' onClick="inviaCat(\''+ idSubCatRow +'\')">'
				 + '    <td id="'+ nomeT +'-r' +i+ '-c1" class="menuLiv2aOff"> &gt; ' + nomeCat +'&nbsp; (<font size="-2">'+ numSiti +'</font>) </td>'
				 + '    <td id="'+ nomeT +'-r' +i+ '-c2" class="menuLiv2bOff">' + (espa ? '<img name="f'+nomeT+'-r'+i+'" src="'+ PATH +'imgWB/frec.gif"alt="">'  :  '&nbsp; &nbsp;')   + '&nbsp;</td>'
				 + '</tr>\n'
	}
	tabella = tabella + '</table>'
	document.getElementById( nomeT ).innerHTML =  tabella  ;
}

// col = colore da considerare
// nome = nome dell'oggetto
// stato = indica quale operazione eseguire
 function selez(col, nome, stato)
 {
 	var cella1 = document.getElementById(nome+"-c1")
 	var cella2 = document.getElementById(nome+"-c2")
   if(stato=='')
   {
     cella1.style.color="#000000"
     cella2.style.color="#000000"
     cella1.style.backgroundColor=bgCol[bgCol.length-1]
     cella2.style.backgroundColor=bgCol[bgCol.length-1]
     if (document["f"+nome]!=null)  document["f"+nome].src = PATH + "imgWB/frec.gif" ;
   }
   else
   {
     cella1.style.color="#ffffff"
     cella2.style.color="#ffffff"
     cella1.style.backgroundColor=bgCol[( (col-1)%(bgCol.length-1) )]
     cella2.style.backgroundColor=bgCol[( (col-1)%(bgCol.length-1) )]
     if (document["f"+nome]!=null)  document["f"+nome].src = PATH + "imgWB/frecSele.gif" ;
   }
 }

// :* *- -->
