/*
 * Image preview / tooltip 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 = 15;
		yOffset = 0;

		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result

	/* END CONFIG */
	$j(".preview").hover(function(e){
		this.t = this.title;
		this.title = "";
		var c = (this.t != "") ? "<br/>" + this.t : "";
		var link = this.href
		if(link==undefined){// && validURL(this.t)){
			link = this.t;
			c = "";
		}
		$j("body").append("<p id='preview'><img width='220px' src='"+ link +"' alt='Loading Preview...' />"+ c +"</p>");
		$j("#preview")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$j("#preview").remove();
    });
	$j(".preview").mousemove(function(e){
		$j("#preview")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});
};

this.tooltip = function(){
	/* CONFIG */
		xOffset = 15;
		yOffset = 0;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
	/* END CONFIG */
	$j(".tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$j("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$j("#tooltip").remove();
    });
	$j(".tooltip").mousemove(function(e){
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});
	
	/*$j("input.tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$j("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$j("#tooltip").remove();
    });
	$j("input.tooltip").mousemove(function(e){
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});
	
	$j("a.tooltip").mousemove(function(e){
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});
	
	$j("img.tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$j("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$j("#tooltip").remove();
    });
	$j("img.tooltip").mousemove(function(e){
		$j("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});*/
};



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

