﻿function script3() {
    var e = document.getElementById("menu_contenuti");
    e.innerHTML = "Benone!";
}

function scarica() {
    myRequest = CreateXmlHttpReq(myHandler);
    var e = document.getElementById("menu_contenuti");
    e = myRequest.open("GET", "prova.html", true);
    myRequest.send(null);
}

/* Funzione per creare L'oggetto XMLHttpReqeust */
function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}

function myHandler() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        alert(myRequest.responseText);
    }
}

function switchMC(target) {
    var oXHR = new XMLHttpRequest();
    var testoPar = document.getElementById("menu_contenuti");
    oXHR.open("GET", target, true);
    oXHR.onreadystatechange = function() {
	if (oXHR.readyState==4) /* && oXHR.status==200)*/ {
	    testoPar.innerHTML = oXHR.responseText;
	} else {
	    testoPar.innerHTML = "Errore: " + oXHR.status + " " + oXHR.statusText;
	}
    }
    oXHR.send(null);
}

function loadPopupOfferte(target,contenitore) {
    var oXHR = new XMLHttpRequest();
    var testoPar = document.getElementById(contenitore);
    oXHR.open("get", target, true);
    oXHR.onreadystatechange = function() {
	if (oXHR.readyState==4) /* && oXHR.status==200)*/ {
	    testoPar.innerHTML = oXHR.responseText;
	} else {
	    testoPar.innerHTML = "Errore: " + oXHR.status + " " + oXHR.statusText;
	}
    }
    oXHR.send(null);
}

// Jquery, al caricamento della pagina index.html, fa apparire i vari elementi in successione

$('#prodotti_vetrina').ready(function() {
	$('#prodotti_vetrina').fadeIn('5000');
	$('#home').fadeIn('slow', function() {
		$('#centro_benessere').fadeIn('slow', function() {
		    	$('#ristorante').fadeIn('slow', function() {
				$('#alloggi').fadeIn('slow', openPopUp('#dialog'))})})})});

//***************************************************************************************************************
// Funzioni per gestire il popup!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

function openPopUp(nomediv) {
    //Get the A tag
    var id = nomediv; 
    
    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //alert(id + ' maskHeight=' + maskHeight + ' maskWidth=' + maskWidth);

    //Set height and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});
    
    //transition effect		
    $('#mask').fadeIn(1000);	
    $('#mask').fadeTo("slow",0.8);	
    
    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();
         
    //Set the popup window to center
    // $(id).css('top',  winH/2-$(id).height()/2);
    $(id).css('top',  55);
    $(id).css('left', winW/2-$(id).width()/2);
	
    //transition effect
    $(id).fadeIn(2000);
    
    //Carico il popup delle offerte pagina delle offerte
    $('#offerte').load('pacchetti_offerta_popup_capodanno.html');
    //$('#offerte').load('prova_02.html');

    //if close button is clicked
    $('.window .close').click(function (e) {
	    //Cancel the link behavior
	    e.preventDefault();
	    $('#mask, .window').hide();
    });	
    
    //if mask is clicked
    $('#mask').click(function () {
	    $(this).hide();
	    $('.window').hide();
    });
}

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//***************************************************************************************************************


