this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 20;
		yOffset = 10;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("img.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.src +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("slow");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("img.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


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

//Browser
function GetBrowserSize() {
	var bodyWidth = document.documentElement.clientWidth;
	var bodyHeight = document.documentElement.clientHeight;
    	
	var bodyWidth, bodyHeight; 
	if (self.innerHeight){
		bodyWidth = self.innerWidth; 
		bodyHeight = self.innerHeight; 
	}  else if (document.documentElement && document.documentElement.clientHeight) {
		bodyWidth = document.documentElement.clientWidth; 
		bodyHeight = document.documentElement.clientHeight; 
	} else if (document.body) {// other Explorers 		 
		bodyWidth = document.body.clientWidth; 
		bodyHeight = document.body.clientHeight; 
	} 
	
	return [bodyWidth,bodyHeight];
}

function ShowModalDialog(ID) {
	var GetSize = GetBrowserSize();
	var w = GetSize[0];
	var h = GetSize[1];
	var c = document.getElementById(ID);

    	c.style.left = Math.ceil((w - 550) / 2) + 'px';;

	if(c.style.display == 'none') {
		c.style.display = 'block';
	}

	return true;
}

function HideModalDialog(ID) {
	var c = document.getElementById(ID);

	if(c.style.display == 'block') {
		c.style.display = 'none';
	}

	return true;
}
