/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = 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 */
	
// LOGO			

	$("a.tool_logo").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='tool_logo'><img src='"+ this.href +"' />"+ c +"</p>");								 
		$("#tool_logo")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#tool_logo").remove();
    });	
	$("a.tool_logo").mousemove(function(e){
		$("#tool_logo")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});		
	
// TEXTO

	$("a.tool_texto").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='tool_texto'><img src='"+ this.href +"' />"+ c +"</p>");								 
		$("#tool_texto")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#tool_texto").remove();
    });	
	$("a.tool_texto").mousemove(function(e){
		$("#tool_texto")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	

// MOCKUP

	$("a.tool_mockup").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='tool_mockup'><img src='"+ this.href +"' />"+ c +"</p>");								 
		$("#tool_mockup")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#tool_mockup").remove();
    });	
	$("a.tool_mockup").mousemove(function(e){
		$("#tool_mockup")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	

// WEB

	$("a.tool_web").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='tool_web'><img src='"+ this.href +"' />"+ c +"</p>");								 
		$("#tool_web")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#tool_web").remove();
    });	
	$("a.tool_web").mousemove(function(e){
		$("#tool_web")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	

// EMBALAGEM

	$("a.tool_embalagem").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='tool_embalagem'><img src='"+ this.href +"' />"+ c +"</p>");								 
		$("#tool_embalagem")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#tool_embalagem").remove();
    });	
	$("a.tool_embalagem").mousemove(function(e){
		$("#tool_embalagem")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	

// DESIGN

	$("a.tool_design").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='tool_design'><img src='"+ this.href +"' />"+ c +"</p>");								 
		$("#tool_design")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#tool_design").remove();
    });	
	$("a.tool_design").mousemove(function(e){
		$("#tool_design")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	


};

// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
