 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) 

}
 
 $(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');
   });

   $('#home_presentazione').cycle({ 
    fx:     'toss', 
    timeout: 10000, 
    //before:  clearPresentationDesc, 
    after:   fillPresentationDesc 
 });
 








   
   
//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;    

}  

});
   
   
 });
