/* --------------------------------------------------------------------------------------- */
// Richiamato da MenuCatalogoT.asp e MenuCatalogoB.asp
/* --------------------------------------------------------------------------------------- */

function PageLoad(cPage)
{
	if (cPage.length == 0)
	{
		alert("Impossibile Identificare la Pagina");
		return false;
	}

	/*
	else if (!IsNumber(nPos))
	{
		alert("Numero Pagina Errato !");
		return false;
	}

	else if (parseInt(nPos) <= 0)
	{
		alert("Numero Pagina non puņ essere Negativo !");
		return false;
	}
	*/

	else
	{
		var cParam = '';

		// document.getElementById('ImgTop').src = "../ImgTop/"+cTop+".jpg";

		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// if (cParam.length > 0) cParam += "&"
		// cParam += ('Pos=' + encodeURI(cPage));
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// if (cParam.length > 0) cParam += "&"
		// cParam += ('Pos=' + encodeURI(nPos));
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// alert(cParam);

		if (false)
		{
			// xPopup = window.open ("../Catalogo/exe/exeSumCarrello.asp?" + cParam, "SumCarrello", "")
			xPopup = window.open (cPage + ".asp?" + cParam, "PageLoad", "")
			xPopup.focus();	
		}
		else
		{
			if (!http_request && http)
			{
				Wait(1);
				http_request = true;

				// alert(cParam);
				http.open("POST", cPage + ".asp", true);
				http.onreadystatechange = Response_PageLoad;
				http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				http.setRequestHeader("Content-length", cParam.length);
				http.send(cParam);
			}
		}
	}
	return false;
}

function PageLoadItem(cPage, nPos)
{
	if (cPage.length == 0)
	{
		alert("Impossibile Identificare la Pagina");
		return false;
	}

	else if (!IsNumber(nPos))
	{
		alert("Impossibile Identificare il Titolo !");
		return false;
	}

	else if (parseInt(nPos) <= 0)
	{
		alert("Il Titolo non puņ essere Negativo !");
		return false;
	}

	else
	{
		var cParam = '';

		// document.getElementById('ImgTop').src = "../ImgTop/"+cTop+".jpg";

		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// if (cParam.length > 0) cParam += "&"
		// cParam += ('Pos=' + encodeURI(cPage));
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		if (cParam.length > 0) cParam += "&"
		cParam += ('Pos=' + encodeURI(nPos));
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// alert(cParam);

		if (false)
		{
			// xPopup = window.open ("../Catalogo/exe/exeSumCarrello.asp?" + cParam, "SumCarrello", "")
			xPopup = window.open (cPage + ".asp?" + cParam, "PageLoad", "")
			xPopup.focus();	
		}
		else
		{
			if (!http_request && http)
			{
				Wait(1);
				http_request = true;

				// alert(cParam);
				http.open("POST", cPage + ".asp", true);
				http.onreadystatechange = Response_PageLoad;
				http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				http.setRequestHeader("Content-length", cParam.length);
				http.send(cParam);
			}
		}
	}
	return false;
}

function Response_PageLoad()
{
	// alert('sono entrato nella funzione Response');
	if (http.readyState == 4)
	{
		Wait(0);
		http_request = false;

		if(http.status == 200) {
			document.getElementById('divprincipale').innerHTML = http.responseText;
			ExecuteJS('divprincipale');
			
		} else {
			var results = "C'č stato un errore di Comunicazione !";
			document.getElementById('divprincipale').innerHTML = results; 
		}
	}
}
/* --------------------------------------------------------------------------------------- */
