 this.simple_tooltip = function(){	
 
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.simple_tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='simple_tooltip'>"+ this.t +"</p>");
		$("#simple_tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn(800);		
    },
	function(){
		this.title = this.t;		
		$("#simple_tooltip").remove();
    });	
	$("a.simple_tooltip").mousemove(function(e){
		$("#simple_tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
	
	//img
		$("img.simple_tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='simple_tooltip'>"+ this.t +"</p>");
		$("#simple_tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn(800);		
    },
	function(){
		this.title = this.t;		
		$("#simple_tooltip").remove();
    });	
	$("img.simple_tooltip").mousemove(function(e){
		$("#simple_tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
};


function clearPresentationDesc() { 
    $('#home_presentazione_desc').html(""); 
} 
function fillPresentationDesc() { 
    $('#home_presentazione_desc').html(this.alt) 

}

function cambiaSlideAlbergodx() { 
    $('#alberghi_pres_desc_dx').html(this.alt) 

}


 //notify
 function playNotifySound(){
    $('embed').remove();
    $('body').append('<embed src="http://www.vainvacanza.it/sounds/notify.mp3" autostart="true" hidden="true" loop="false">');
}
 
 $(document).ready(function(){
   $('#frasi_famose_box').fadeIn(3000);
   $('div.col2,h3').fadeIn(2000);
   simple_tooltip();
   
   $("#info_alberghi_link").click(function(){
   $("#info_alberghi_content").slideToggle('slow');
   });
   
   $("#suggerisci_frase_viaggi").click(function(){
   $("#suggerisci_frase_viaggi_content").slideToggle('slow');
   });
   
   $("#mostra_amici_fb").click(function(){
   $("#fb_amici_foto").slideToggle('slow');
   });
   
   $("#mostra_imp_fb").click(function(){
   $("#permessi_fb").slideToggle('slow');
   });
   
   $("#mostra_pdr_alberghi").click(function(){
   $("#lista_pdr_alberghi").slideToggle('slow');
   });

   $('#home_presentazione').cycle({ 
    fx:     'toss', 
    timeout: 10000, 
    //before:  clearPresentationDesc, 
    after:   fillPresentationDesc 
 });
 
    $('#alberghi_pres_dx').cycle({ 
    fx:     'fade', 
    timeout: 12000, 
    before:   cambiaSlideAlbergodx 
 });
 
 
	$('.head_menu_text').animate({ opacity: 0.1 }, "slow");
 
	$("#menucsn").mousemove(function(){
	  $('#menucsn_link').animate({ opacity: 1 }, "slow");
	});

	$("#menualb").mousemove(function(){
	  $('#menualb_link').animate({ opacity: 1 }, "slow");
	});
	
	$("#menudiv").mousemove(function(){
	  $('#menudiv_link').animate({ opacity: 1 }, "slow");
	});
	
	$("#menueve").mousemove(function(){
	  $('#menueve_link').animate({ opacity: 1 }, "slow");
	});
  
  	$("#menucon").mousemove(function(){
	  $('#menucon_link').animate({ opacity: 1 }, "slow");
	});
 
	$("#menucsn").mouseleave(function(){
	  $('#menucsn_link').animate({ opacity: 0.1 }, "slow");
	});

	$("#menualb").mouseleave(function(){
	  $('#menualb_link').animate({ opacity: 0.1 }, "slow");
	});
	
	$("#menudiv").mouseleave(function(){
	  $('#menudiv_link').animate({ opacity: 0.1 }, "slow");
	});
	
	$("#menueve").mouseleave(function(){
	  $('#menueve_link').animate({ opacity: 0.1 }, "slow");
	});
  
  	$("#menucon").mouseleave(function(){
	  $('#menucon_link').animate({ opacity: 0.1 }, "slow");
	}); 
   
	//MODAL POPUP
	    //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();  
    });           
	
	//END MODAL POPUP
	
	//ALBERGHI DESCR
	
	$('#contenair_hotel_didascalia .close').click(function (e) {  
        //Cancel the link behavior  
        e.preventDefault();  
        $('#contenair_hotel_didascalia').fadeOut(200);  
    });       
   
   
//Validazione per registrare un nuovo utente
var validateUsername = $('#verificaUsername');  

$('#username').keyup(function () {    
var t = this;     
if (this.value != this.lastValue) {      
if (this.timer) clearTimeout(this.timer);      
validateUsername.removeClass('error').html('<img src="http://www.vainvacanza.it/images/loading.gif" /> Sto verificando...');            

this.timer = setTimeout(function () {        
$.ajax({          
url: 'http://www.vainvacanza.it/registrazione_utente/check/convalida_input.php',          
data: 'azione=verifica_username&username=' + t.value,          
dataType: 'json',          
type: 'post',          
success: function (j) {            
validateUsername.html(j.msg);          
}        
});      }, 200);           

this.lastValue = this.value;    

}  

});
   
   
 });
 
 
 	//MODAL POPUP
	
	 //select all the a tag with name equal to modal  
    function openModalWindow(id) { 
        //Cancel the link behavior  
        e.preventDefault();  
        //Get the A tag  
        //var id = $(this).attr('href');  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width();  
      
        //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('left', winW/2-$(id).width()/2);  
      
        //transition effect  
        $(id).fadeIn(2000);   
      
    };  
      
	//END MODAL POPUP
	
	//DIDASCALIA ALBERGO DESCRIZIONE
	    function seeHotelDescription(id_hotel) {
		
		$.get('http://www.vainvacanza.it/home/alberghi/get_dettagli_hotel_popup.php?hid='+escape(id_hotel), function(data) {
			$('#hotel_didascalia_html').html(data);
		});
		
        //Get the screen height and width  
        var contHeight = $(window).height() ;  
        var contWidth = $(window).width() / 3; 
			
      
        //Set height and width to mask to fill up the whole screen  
        $('#contenair_hotel_didascalia').css({'width':contWidth,'height':contHeight});  
 
        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  
                
        //Set the popup window to center  
        $('#contenair_hotel_didascalia').css('top',  winH/2-$('#contenair_hotel_didascalia').height()/2+30);  
        $('#contenair_hotel_didascalia').css('right', 30);  
      
        //transition effect  
        $('#contenair_hotel_didascalia').fadeIn(1000);   
      
    };  
      
	  
	//END DESCRIZIONE ALBERGO

