// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Gestione Menu
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var cShowMenuAct = "";	// Div menu sul quale mi trovo !
var cShowInfoAct = "";	// Div che mostra attualmente il prodotto

function ShowMenu(nPos)
{
	var nInd=0;
	var nTotOpz = (document.getElementById("MainMenu").getElementsByTagName("a")).length;

	for (nInd=1; nInd <= nTotOpz; nInd++)
		eval("document.getElementById('SubMenu'+nInd).style.visibility='hidden';");

	if (cShowInfoAct.length > 0)
		eval("document.getElementById('Info." + cShowInfoAct + "').style.visibility='hidden';");

	eval("document.getElementById('SubMenu' + nPos).style.visibility='visible';");
}

function ShowInfo1(cImg, nPos)
{
	/*
	if (cImg == '')
	{
		eval("document.getElementById('ImgProd').style.visibility='hidden';");
	}
	else
	{
		eval("document.getElementById('ImgProd').src='..//ImgCatalogo//' + cImg;");
		eval("document.getElementById('ImgProd').style.visibility='visible';");
	}
	*/
}

function ShowInfoON(cPos)
{
	// eval("document.getElementById('Img322').style.visibility='hidden';");
	// eval("document.getElementById('Img321').style.visibility='hidden';");
	// if (nPos != '0')
	// alert (cShowInfoAct.length + " - " + cShowInfoAct);

	eval("document.getElementById('Intro').style.visibility='hidden';");

	if (cShowInfoAct.length > 0)
		eval("document.getElementById('Info." + cShowInfoAct + "').style.visibility='hidden';");

	eval("document.getElementById('Info." + cPos + "').style.visibility='visible';");
	cShowInfoAct = cPos;
}

function ShowInfoOFF(cPos)
{
	// 	eval("document.getElementById('Info." + cPos + "').style.visibility='hidden';");
}

function OpenSchedaProdotto(nDiv, nPos)
{
	var nInd=0;
	var cParam = '';
	var nTotOpz = (document.getElementById("MainMenu").getElementsByTagName("a")).length;

	// alert("nDiv=" + nDiv + " - nPos=" + nPos + " - nTotOpz=" + nTotOpz)
	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	for (nInd=1; nInd <= nTotOpz; nInd++)
	 	eval("document.getElementById('SubMenu'+nInd).style.visibility='hidden';");

	cShowMenuAct = nDiv;
	eval("document.getElementById('Info." + cShowInfoAct + "').style.visibility='hidden';");
	document.getElementById('Parcheggio').innerHTML = document.getElementById('GestioneProdotti').innerHTML
	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	// document.getElementById('GestioneProdotti').innerHTML = "</br></br></br><table><tr><td><a href='#' onclick='CloseSchedaProdotto(); return false;' title='chiudi'>chiudi</a></td></tr></table>"

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	if (cParam.length > 0) cParam += "&";
	cParam += ('Pos=' + encodeURI(nPos));
	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// alert(cParam);

	if (false)
	{
		xPopup = window.open ("SchedaProdotto.asp?" + cParam, "SchedaProdotto", "")
		xPopup.focus();	
	}
	else
	{
		if (!http_request && http)
		{
			Wait(1);
			http_request = true;

			// alert(cParam);
			http.open("POST", "SchedaProdotto.asp", true);
			http.onreadystatechange = Response_SchedaProdotto;
			http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			http.setRequestHeader("Content-length", cParam.length);
			http.send(cParam);
		}
	}

	return false;
}


function Response_SchedaProdotto()
{
	// alert('sono entrato nella funzione Response_GestMenu');
	if (http.readyState == 4)
	{
		Wait(0);
		http_request = false;

		if(http.status == 200) {
			document.getElementById('GestioneProdotti').innerHTML = http.responseText;
		} else {
			var results = "C'è stato un errore di Comunicazione !";
			document.getElementById('GestioneProdotti').innerHTML = results;
		}
	}
}
/* --------------------------------------------------------------------------------------- */



function CloseSchedaProdotto()
{
	// alert(cShowMenuAct)
	document.getElementById('GestioneProdotti').innerHTML = document.getElementById('Parcheggio').innerHTML
	eval("document.getElementById('SubMenu'+cShowMenuAct).style.visibility='visible';");
	eval("document.getElementById('Info." + cShowInfoAct + "').style.visibility='visible';");
	document.getElementById('Parcheggio').innerHTML = "";
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Fine Gestione Menu
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
