﻿( function($) {
	
    $.fn.APS_ToolTipMensaje = function(opciones){

				var porDefecto = {  
				    posicionX : 10,
						posicionY : 10,
						tiempo: 550,
						orientacion:"derecha",
						estiloFondo1:"WEB_toolTipFondo1",
						estiloFondo2:"WEB_toolTipFondo2",
						estiloTexto1: "WEB_toolTipTexto1",
						estiloTexto2: "WEB_toolTipTexto2",
						estiloTexto3: "WEB_toolTipTexto3"
				};  
    		
        var opc = $.extend(porDefecto, opciones );

        return this.each( function(){
        		if(this.title!=""){
	        		$(this).hover(function(e){
	        			
	        			this.contenido= this.title.split("|");
					    	this.t = this.title;
								this.title = "";									  
								$("body").append("<div class='"+opc.estiloFondo1+"'><div class='"+opc.estiloFondo2+"'><p class='"+opc.estiloTexto1+"'>"+ this.contenido[0] +"</p><p class='"+opc.estiloTexto2+"'>"+ this.contenido[1] +"</p><p class='"+opc.estiloTexto2+"'>"+ this.contenido[2] +"</p><p class='"+opc.estiloTexto3+"'>"+ this.contenido[3] +"</p></div></div>");
								
								if(opc.orientacion=="derecha"){
									var posX=e.pageX + opc.posicionX+20;
								}else{
									var posX=e.pageX - (opc.posicionX+$("."+opc.estiloFondo1).width()+40);
								}
								
								var posY=e.pageY + opc.posicionY;
								
								$("."+opc.estiloFondo1).css({
										"top":(posY) + "px",
										"left":(posX) + "px"}).fadeIn(opc.tiempo);
	    					}
	        		
	        		,function(){
								this.title = this.t;		
								$("."+opc.estiloFondo1).remove();
					
					    });
					    
	        		$(this).mousemove(function(e){
	        			
	        			if(opc.orientacion=="derecha"){
									var posX=e.pageX + opc.posicionX+20;
								}else{
									var posX=e.pageX - (opc.posicionX+$("."+opc.estiloFondo1).width()+40);
								}
								
	        			var posY=e.pageY + opc.posicionY;
	        			
	    					$("."+opc.estiloFondo1).css({
			    					"top":(posY) + "px",
			    					"left":(posX) + "px"});
	    				})
    				}
        });
    };
    
})(jQuery);