// JavaScript Document

// 1 parametro: id dell'oggetto sul quale applicare l'effetto
// 2 parametro: valore di opacità
function setOpacity(id, opacity) {
 
  var element = document.getElementById(id);
 
  /*if(document.all) // se sto usando internet explorer
    element.style.filter = "alpha(opacity=" + opacity + ")";
  else*/
    element.style.opacity = opacity / 100;
 
}

// 1 parametro: id dell'oggetto sul quale applicare l'effetto
// 2 parametro: tempo dell'animazione
function fadeIn(divID, time) {
 
  var speed = Math.round(time / 30); //arrotonda il valore della divisione
  var frame = 0;
 
  for(fade = 0; fade < 100; fade++) {
    setTimeout("setOpacity('"+divID+"', "+fade+")", (speed * frame));
    frame++;
  }
 
}

function ElementId(id_elemento) {
 var elemento;
 if(document.getElementById)
  elemento = document.getElementById(id_elemento);
 else
  elemento = document.all[id_elemento];
 return elemento;
};

function tipoerq() {
	var XHR = null;
	browserUtente = navigator.userAgent.toUpperCase();
	if (window.XMLHttpRequest)
		{
			XHR = new XMLHttpRequest();
		  }
	
	else
	{
		if( window.ActiveXObject &&  browserUtente.indexOf("MSIE 4") < 0 ) 
		{
		if(browserUtente.indexOf("MSIE 5") < 0)
		XHR = new ActiveXObject("Msxml2.XMLHTTP");
		else
		XHR = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return XHR;
}

function prendicontenuto(pagina,iddestinazione,attesa) {
  var ajax = tipoerq(),    elemento = ElementId(iddestinazione);
    ajax.open("get", pagina, true);
	ajax.setRequestHeader("connection", "close");
	if(attesa=='1')
	{
	}
	else
{		elemento.innerHTML ='<center><img src="images/attesa.gif"/></center>';

		}
	
    ajax.onreadystatechange = function() {
      if(ajax.readyState === 4) {
        if(ajax.status  == 200){
          elemento.innerHTML = ajax.responseText;
		}
        else {
          elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
          elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
        }
      } 
    }
    ajax.send(null);

}

function hideobj(obj){
ElementId(obj).style.display="none";
}

function showobj(obj){
ElementId(obj).style.display="";
}

function valore(idinput)
{
	
var toreturn=encodeURIComponent(ElementId(idinput).value);
return toreturn;
	}
	
	function prendicontenutopost(pagina,iddestinazione,post) {
  var ajax = tipoerq(),  elemento = ElementId(iddestinazione);
    ajax.open("post", pagina, true);
 	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(post);
	elemento.innerHTML ='<center><img src="images/attesa.gif"/></center>';
    ajax.onreadystatechange = function() {
      if(ajax.readyState === 12) {
        if(ajax.status  == 2000)
          elemento.innerHTML = ajax.responseText;
        else {
          elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
          elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
        }
      } 
    }
}

function scrollalok(secondi){
	
	var temp=secondi/60;
	while(temp){
		
		temp--;
	}
	if(temp==0){
		setTimeout('document.location.href=\'location1.html\'',4770);
	}
}

function mete(vai_a){
	
	switch(vai_a){
		case 'venezia': setTimeout('document.location.href=\'venezia1.html\'',9990); break;
		case 'venezia1': setTimeout('document.location.href=\'venezia2.html\'',9990); break;
		case 'venezia2': setTimeout('document.location.href=\'venezia3.html\'',9990); break;
		case 'venezia3': setTimeout('document.location.href=\'venezia4.html\'',9990); break;
		case 'venezia4': setTimeout('document.location.href=\'venezia5.html\'',9990); break;
		case 'venezia5': setTimeout('document.location.href=\'venezia6.html\'',9990); break;
		
		case 'lisbona': setTimeout('document.location.href=\'lisbona1.html\'',9990); break;
		case 'lisbona1': setTimeout('document.location.href=\'lisbona2.html\'',9990); break;
		case 'lisbona2': setTimeout('document.location.href=\'lisbona3.html\'',9990); break;
		case 'lisbona3': setTimeout('document.location.href=\'lisbona4.html\'',9990); break;
		case 'lisbona4': setTimeout('document.location.href=\'lisbona5.html\'',9990); break;
		
		case 'malta': setTimeout('document.location.href=\'malta1.html\'',9990); break;
		case 'malta1': setTimeout('document.location.href=\'malta2.html\'',9990); break;
		case 'malta2': setTimeout('document.location.href=\'malta3.html\'',9990); break;
		case 'malta3': setTimeout('document.location.href=\'malta4.html\'',9990); break;
		case 'malta4': setTimeout('document.location.href=\'malat5.html\'',9990); break;
		case 'malta5': setTimeout('document.location.href=\'malta6.html\'',9990); break;
		
		case 'newyork': setTimeout('document.location.href=\'new_york1.html\'',9990); break;
		case 'newyork1': setTimeout('document.location.href=\'new_york2.html\'',9990); break;
		case 'newyork2': setTimeout('document.location.href=\'new_york3.html\'',9990); break;
		case 'newyork3': setTimeout('document.location.href=\'new_york4.html\'',9990); break;
		case 'newyork4': setTimeout('document.location.href=\'new_york5.html\'',9990); break;
		case 'newyork5': setTimeout('document.location.href=\'new_york6.html\'',9990); break;
		
		case 'sardegna': setTimeout('document.location.href=\'sardegna1.html\'',9990); break;
		case 'sardegna1': setTimeout('document.location.href=\'sardegna2.html\'',9990); break;
		case 'sardegna2': setTimeout('document.location.href=\'sardegna3.html\'',9990); break;
		case 'sardegna3': setTimeout('document.location.href=\'sardegna4.html\'',9990); break;
		case 'sardegna4': setTimeout('document.location.href=\'sardegna5.html\'',9990); break;
		case 'sardegna5': setTimeout('document.location.href=\'sardegna6.html\'',9990); break;
		
		case 'vienna': setTimeout('document.location.href=\'vienna1.html\'',9990); break;
		case 'vienna1': setTimeout('document.location.href=\'vienna2.html\'',9990); break;
		case 'vienna2': setTimeout('document.location.href=\'vienna3.html\'',9990); break;
		case 'vienna3': setTimeout('document.location.href=\'vienna4.html\'',9990); break;
		case 'vienna4': setTimeout('document.location.href=\'vienna5.html\'',9990); break;
		case 'vienna5': setTimeout('document.location.href=\'vienna6.html\'',9990); break;
		
		case 'pevero': setTimeout('document.location.href=\'pevero_golf_club1.html\'',9990); break;
		case 'pevero1': setTimeout('document.location.href=\'pevero_golf_club2.html\'',9990); break;
		case 'pevero2': setTimeout('document.location.href=\'pevero_golf_club3.html\'',9990); break;
		case 'pevero3': setTimeout('document.location.href=\'pevero_golf_club4.html\'',9990); break;
		case 'pevero4': setTimeout('document.location.href=\'pevero_golf_club5.html\'',9990); break;
		case 'pevero5': setTimeout('document.location.href=\'pevero_golf_club6.html\'',9990); break;
		case 'pevero6': setTimeout('document.location.href=\'pevero_golf_club7.html\'',9990); break;
		
		case 'portoc': setTimeout('document.location.href=\'porto_cervo1.html\'',9990); break;
		case 'portoc1': setTimeout('document.location.href=\'porto_cervo2.html\'',9990); break;
		case 'portoc2': setTimeout('document.location.href=\'porto_cervo3.html\'',9990); break;
		case 'portoc3': setTimeout('document.location.href=\'porto_cervo4.html\'',9990); break;
		case 'portoc4': setTimeout('document.location.href=\'porto_cervo5.html\'',9990); break;
		case 'portoc5': setTimeout('document.location.href=\'porto_cervo6.html\'',9990); break;
		case 'portoc6': setTimeout('document.location.href=\'porto_cervo7.html\'',9990); break;
		case 'portoc7': setTimeout('document.location.href=\'porto_cervo8.html\'',9990); break;
		case 'portoc8': setTimeout('document.location.href=\'porto_cervo9.html\'',9990); break;
		case 'portoc9': setTimeout('document.location.href=\'porto_cervo10.html\'',9990); break;
		case 'portoc10': setTimeout('document.location.href=\'porto_cervo11.html\'',9990); break;
		case 'portoc11': setTimeout('document.location.href=\'porto_cervo12.html\'',9990); break;
		
		case 'calag': setTimeout('document.location.href=\'cala_dei_ginepri1.html\'',9990); break;
		case 'calag1': setTimeout('document.location.href=\'cala_dei_ginepri2.html\'',9990); break;
		case 'calag2': setTimeout('document.location.href=\'cala_dei_ginepri3.html\'',9990); break;
		case 'calag3': setTimeout('document.location.href=\'cala_dei_ginepri4.html\'',9990); break;
		case 'calag4': setTimeout('document.location.href=\'cala_dei_ginepri5.html\'',9990); break;
		case 'calag5': setTimeout('document.location.href=\'cala_dei_ginepri6.html\'',9990); break;
		case 'calag6': setTimeout('document.location.href=\'cala_dei_ginepri7.html\'',9990); break;
		
		case 'portor': setTimeout('document.location.href=\'porto_rose1.html\'',9990); break;
		case 'portor1': setTimeout('document.location.href=\'porto_rose2.html\'',9990); break;
		case 'portor2': setTimeout('document.location.href=\'porto_rose3.html\'',9990); break;
		case 'portor3': setTimeout('document.location.href=\'porto_rose4.html\'',9990); break;
		case 'portor4': setTimeout('document.location.href=\'porto_rose5.html\'',9990); break;
		case 'portor5': setTimeout('document.location.href=\'porto_rose6.html\'',9990); break;
		case 'portor6': setTimeout('document.location.href=\'porto_rose7.html\'',9990); break;
		
}}


var xmlhttp;
var timerId = 0;
var op = 1;
function getPageFx()
{
url = "location_1.php";
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=xmlhttpChange
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
else
getPageIE();
}

function xmlhttpChange()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
if(timerId!=0)
window.clearTimeout(timerId);
timerId = window.setTimeout("trans();",100);
}
else
{
alert(xmlhttp.status)
}
}
}

function trans(){
op -= .1;
document.body.style.opacity = op;
if(op<.4){ window.clearTimeout(timerId); timerId = 0; document.body.style.opacity = 1; document.open(); document.write(xmlhttp.responseText); document.close(); return; } timerId = window.setTimeout("trans();",100); }

function getPageIE(){ window.location.href = "location_1.php"; }


