this.bubblePreview = function(){  

		// Offset from cursor    
        xOffset = 10;
        yOffset = 20;           
  
        $(".preview").hover(function(e){                                                                                         
                this.t = this.title;
                this.title = "";                                                                          
                $("body").append("<p id='preview' class='texte'>"+ this.t +"</p>");
                $("#preview")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px")
                        .fadeIn("fast");                
    },
        function(){
                this.title = this.t;            
                $("#preview").remove();
    }); 
        $(".preview").mousemove(function(e){
                $("#preview")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px");
        });                     
};

this.valide = function(){

	$(".preview").focus(function(){ 
		var info_form=$(this).next(".info"); 
		info_form.empty(); 
	}); 
	
	$(".preview").blur(function(){ 
		var name = ($(this).attr("id")); 
		var value = ($(this).attr("value")); 
		var info_form = $(this).next(".info");
		
		$.ajax({ 
			type: "GET", 
			url: "includes/verif.php?x="+name+"&v="+value, 
			success:function(data){
				if(data=="1"){ 
					info_form.append("&nbsp;<img src='includes/icono_unchecked.png' title='champ v&eacute;rifi&eacute; et invalide' />"); 
				} 
				else{
					info_form.append("&nbsp;<img src='includes/icono_checked.png' title='champ v&eacute;rifi&eacute; et valide' />");
				} 
			} 
		});

	});

	$("textarea").focus(function(){			
		var info_form = $(".checkinfo");
		info_form.empty();
		var compteur = 0;
		$('input:checkbox').each( function() {
	    	if(this.checked) compteur++;
   		 			});
		if(compteur == 0) info_form.append("&nbsp;<img src='includes/icono_unchecked.png' title='champ v&eacute;rifi&eacute; et invalide' />");
		else info_form.append("&nbsp;<img src='includes/icono_checked.png' title='champ v&eacute;rifi&eacute; et valide' />");
	}); 
		
};


$(document).ready(function() {

	bubblePreview();
	valide();
	
});
