// JavaScript Document
var xmlHttp;

function GetXmlHttpObject() 
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function cambiaLavoroHP (id)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		//alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="/ajax/cambiaLavoroHP.php";
	url+="?i="+id;
	url+="&sid="+Math.random();

	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "") {
				//cambio portfolio
				risp = new Array();
				risp = xmlHttp.responseText.split("#@#");
				for (i=1; i<=3; i++)
				{
					document.getElementById("aHP"+i).className = "colNero";
					document.getElementById("CaHP"+i).value = "colNero";
				}
				document.getElementById("aHP"+risp[0]).className = risp[1];
				document.getElementById("CaHP"+risp[0]).value = risp[1];
				document.getElementById("idBody").className = risp[2];
				
				//document.getElementById("portHP").innerHTML = xmlHttp.responseText;
				document.getElementById("portHP").innerHTML = risp[3];
				document.getElementById("aHP"+risp[0]).blur();
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function evidenziaHP(idO, classe)
{
	document.getElementById(idO).className = classe;
}

function galleryAvanti(id)
{
	
	pag = document.getElementById("npag").value;
	pag++;
	document.getElementById("npag").value = pag;
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		//alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="/ajax/cambiaGallery.php";
	url+="?p="+pag;
	url+="&i="+id;
	url+="&sid="+Math.random();

	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "") {
				//cambio portfolio
				risp = new Array();
				risp = xmlHttp.responseText.split("#@#");
				
				document.getElementById("navGallery").innerHTML = risp[0];
				document.getElementById("spazioGallery").innerHTML = risp[1];
				document.getElementById("avanti").blur();
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function galleryIndietro(id)
{
	
	pag = document.getElementById("npag").value;
	pag--;
	document.getElementById("npag").value = pag;
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		//alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="/ajax/cambiaGallery.php";
	url+="?p="+pag;
	url+="&i="+id;
	url+="&sid="+Math.random();

	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "") {
				//cambio portfolio
				risp = new Array();
				risp = xmlHttp.responseText.split("#@#");
				
				document.getElementById("navGallery").innerHTML = risp[0];
				document.getElementById("spazioGallery").innerHTML = risp[1];
				document.getElementById("avanti").blur();
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function portfolioAvanti()
{
	
	pag = document.getElementById("npag").value;
	pag++;
	document.getElementById("npag").value = pag;
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		//alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="/ajax/cambiaPortfolio.php";
	url+="?p="+pag;
	url+="&sid="+Math.random();

	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "") {
				//cambio portfolio
				risp = new Array();
				risp = xmlHttp.responseText.split("#@#");
				
				document.getElementById("navPortfolio").innerHTML = risp[0];
				document.getElementById("spazioPortfolio").innerHTML = risp[1];
				document.getElementById("avanti").blur();
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function portfolioIndietro()
{
	
	pag = document.getElementById("npag").value;
	pag--;
	document.getElementById("npag").value = pag;
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		//alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="/ajax/cambiaPortfolio.php";
	url+="?p="+pag;
	url+="&sid="+Math.random();

	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "") {
				//cambio portfolio
				risp = new Array();
				risp = xmlHttp.responseText.split("#@#");
				
				document.getElementById("navPortfolio").innerHTML = risp[0];
				document.getElementById("spazioPortfolio").innerHTML = risp[1];
				document.getElementById("avanti").blur();
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function ripristinaHP(idO)
{
	document.getElementById(idO).className = document.getElementById("C"+idO).value;
}
