/*
 * Url 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.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 150;
		yOffset = -430; //nando image large is 400 px
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	jQuery("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		jQuery("body").append("<p id='screenshot'><img src='/img/despieces/"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		jQuery("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#screenshot").remove();
    });	
	jQuery("a.screenshot").mousemove(function(e){
		jQuery("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});		
	
		xOffsetw = -100;
		yOffsetw = -10;
	jQuery("a.sc-weather").hover(function(e){
		this.t = this.title;
		this.title = "";
		this.href = "http://weather.yahoo.com/forecast/SPXX0050_c.html";
		var c = (this.t != "") ? "<br />" + this.t : "";
		jQuery("body").append("<p id='sc-weather'><img src='/weather/61x61/"+ this.rel +"' alt='"+c+"' /><br /><span>&copy; Yahoo! Weather</span></p>");								 
		jQuery("#sc-weather")
			.css("top",(e.pageY + yOffsetw) + "px")
			.css("left",(e.pageX + xOffsetw) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;
		jQuery("#sc-weather").remove();
    });	
	jQuery("a.sc-weather").mousemove(function(e){
		jQuery("#sc-weather")
			.css("top",(e.pageY + yOffsetw) + "px")
			.css("left",(e.pageX + xOffsetw) + "px");
	});	
	
		xOffsetw_junta = 20;
		yOffsetw_junta = -40; //nando image large is 400 px
	jQuery("a.sc-junta").hover(function(e){
		if (!this.t) this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br />" + this.t : "";
		jQuery("body").append("<p id='sc-junta'><img src='/img/juntas/"+ this.rel +"' alt='"+c+"' />"+ c +"</p>");								 
		jQuery("#sc-junta")
			.css("top",(e.pageY + yOffsetw_junta) + "px")
			.css("left",(e.pageX + xOffsetw_junta) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#sc-junta").remove();
    });	
	jQuery("a.sc-junta").mousemove(function(e){
		jQuery("#sc-junta")
			.css("top",(e.pageY + yOffsetw_junta) + "px")
			.css("left",(e.pageX + xOffsetw_junta) + "px");
	});	
	
		xOffsetw_racor = 20;
		yOffsetw_racor = -60; //nando image large is 400 px
	jQuery("a.sc-racor").hover(function(e){
		if (!this.t) this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br />" + this.t : "";
		jQuery("body").append("<p id='sc-racor'><img src='/img/racores/"+ this.rel +"' alt='"+c+"' />"+ c +"</p>");								 
		jQuery("#sc-racor")
			.css("top",(e.pageY + yOffsetw_racor) + "px")
			.css("left",(e.pageX + xOffsetw_racor) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#sc-racor").remove();
    });	
	jQuery("a.sc-racor").mousemove(function(e){
		jQuery("#sc-racor")
			.css("top",(e.pageY + yOffsetw_racor) + "px")
			.css("left",(e.pageX + xOffsetw_racor) + "px");
	});	
	
		xOffsetw_abzdra = 20;
		yOffsetw_abzdra = -60; //nando image large is 400 px
	jQuery("a.sc-abzdra").hover(function(e){
		if (!this.t) this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br />" + this.t : "";
		jQuery("body").append("<p id='sc-abzdra'><img src='"+ this.rel +"' alt='"+c+"' />"+ c +"</p>");								 
		jQuery("#sc-abzdra")
			.css("top",(e.pageY + yOffsetw_abzdra) + "px")
			.css("left",(e.pageX + xOffsetw_abzdra) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#sc-abzdra").remove();
    });	
	jQuery("a.sc-abzdra").mousemove(function(e){
		jQuery("#sc-abzdra")
			.css("top",(e.pageY + yOffsetw_abzdra) + "px")
			.css("left",(e.pageX + xOffsetw_abzdra) + "px");
	});	
	
		xOffsetw_caracola = 20;
		yOffsetw_caracola = -60; //nando image large is 400 px
	jQuery("a.sc-caracola").hover(function(e){
		if (!this.t) this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br />" + this.t : "";
		jQuery("body").append("<p id='sc-caracola'><img src='/img/caracolas/"+ this.rel +"' alt='"+c+"' />"+ c +"</p>");								 
		jQuery("#sc-caracola")
			.css("top",(e.pageY + yOffsetw_caracola) + "px")
			.css("left",(e.pageX + xOffsetw_caracola) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#sc-caracola").remove();
    });	
	jQuery("a.sc-caracola").mousemove(function(e){
		jQuery("#sc-caracola")
			.css("top",(e.pageY + yOffsetw_caracola) + "px")
			.css("left",(e.pageX + xOffsetw_caracola) + "px");
	});
	
};


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