/*
 * 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 = 50;
		yOffset = -90;
		xOffset2 = 50;
		yOffset2 = -60;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		/*$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");*/
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='' /></p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });		
	/****************************************************************/
	
	$("a.preview2").hover(function(e){
		//alert(this.className);
		
		if (this.className == "preview2 listenbutton"){
			var imgsrc="<img src='http://image.ez-tracks.com/v2/tip_listennow.png' width='59' height='50'>";
		}
		else if (this.className == "preview2 downloadbutton"){
			var imgsrc="<img src='http://image.ez-tracks.com/v2/tip_download.png' width='59' height='50'>";
		}
		else if (this.className == "preview2 ringtonebutton"){
			var imgsrc="<img src='http://image.ez-tracks.com/v2/tip_getringtone.png' width='59' height='50'>";
		}
		else if (this.className == "preview2 embedbutton"){
			var imgsrc="<img src='http://image.ez-tracks.com/v2/tip_postwebsite.png' width='59' height='50'>";
		}
		else if (this.className == "preview2 downloadbutton 2"){
			var imgsrc="<img src='http://image.ez-tracks.com/v2/tip_partnerdownload.png' width='59' height='50'>";
		}
		
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview2'>"+ imgsrc +"</p>");								 
		$("#preview2")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview2").remove();
    });		
	/****************************************************************/
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});		
	/****************************************************************/
	$("a.preview2").mousemove(function(e){
		$("#preview2")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px");
	});		
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});