// 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(){	
	
		xOffset = 10;
		yOffset = -200;
		xOffset1 = 200;
		yOffset1 = -200;
		xOffset2 = 200;
		yOffset2 = -380;
		xOffset3 = 100;
		yOffset3 = 150;
	
	// for country masks
	$("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.name +"' alt='Image preview' />"+ c +"</p>");
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			

	// for one team mask
	$("a.preview1").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview1'><img src='"+ this.name +"-1.jpg' alt='Image preview' />"+ c +"</p>");
		$("#preview1")
			.css("top",(e.pageY - xOffset1) + "px")
			.css("left",(e.pageX + yOffset1) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview1").remove();
    });	
	$("a.preview1").mousemove(function(e){
		$("#preview1")
			.css("top",(e.pageY - xOffset1) + "px")
			.css("left",(e.pageX + yOffset1) + "px");
	});
	
	//for two team masks
	$("a.preview2").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview2'><img src='"+ this.name +"-1.jpg' alt='Image preview' />&nbsp;<img src='"+ this.name +"-2.jpg' alt='Image preview' />"+ c +"</p>");
		$("#preview2")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview2").remove();
    });	
	$("a.preview2").mousemove(function(e){
		$("#preview2")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px");
	});	

	// for gallery
	$("a.preview3").hover(function(e){
		this.t = this.title;
		this.title = "";	
		this.c = (this.t != "") ? parseInt(this.t) : 0;
		//var c = "";
		$("body").append("<p id='preview3'><img src='"+ this.name +"' alt='Image preview' /></p>");
		$("#preview3")
			.css("top",(e.pageY - yOffset3 + this.c) + "px")
			.css("left",(e.pageX + xOffset3) + "px")
			.fadeIn("fast");						
    },
	function(){
		//var c = (this.t != "") ? parseInt(this.t) : 0;		
		this.title = this.t;
				
		$("#preview3").remove();
    });	
	$("a.preview3").mousemove(function(e){
		$("#preview3")
			.css("top",(e.pageY - yOffset3 + this.c) + "px")
			.css("left",(e.pageX + xOffset3) + "px");
	});	
	
	
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});