/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * produced by patrick harvey
 * pat@green-shoots-productions.co.uk
 *
 */
 
this.imagePreview = function(){	

	$("a.preview").click(function(e){
		this.t = this.title;
		this.title = "";	
//		var c = (this.t != "") ? "<br/>" + this.t : "";
		var c = "<br>Click to close image";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Click to close image' />"+ c +"</p>");
		// locate the center position horizontally
		var p = $("#container");
		var position = p.position();
		// calculate top position for preview
		var topPos = e.pageY - 600;
		if (topPos <0)
		{
			topPos = 0;
		}
		$("#preview")
			.css("top", (topPos) + "px")
			.css("left",(position.left -25) + "px")
			.fadeIn("slow");
			
		$("#preview").click(function(){
			// alert("shut");
			this.title = this.t;	
			$("#preview").remove();
		 });
		recordPicPreview(location.href, 'View Large Image', this.href)
		return false;
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	
								 
};

function recordPicPreview(link, category, action) {  
try{    
var pageTracker = _gat._getTracker("UA-17476814-1");
pageTracker._trackEvent(category, action);
//setTimeout('document.location = "' + link.href + '"', 100)
} catch(err) {}
}


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