/*

	Quick Lightbox type code for artworks projects

*/
 
this.imagePreview = function(){	
			
	var locationY = ($(window).height() / 2) - 150; /* the subtracted amount is height of pop-up */
	var locationX = ($(window).width() / 2) - 275;  /* the subtracted amount is width of pop-up */
	
	var pageheight = $(window).height();
	var pagewidth = $(window).width();
			
	$("a.preview").click(function(e){
		e.preventDefault();
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<div id='pagescreen'></div>");
		$("#pagescreen")
			.css("width",pagewidth + "px")
			.css("height",pageheight + "px")
			.css("top","0px")
			.css("left","0px")
			.fadeIn("fast");	
		$("body").append("<div id='nutritionPreview'><div id='windowcloser'><a class='windowclosera' href='#'>[X] Close Window</a></div><img src='"+ this.href +"' alt='Image preview' />"+ c +"</div>");								 
		$("#nutritionPreview")
			.css("top",locationY + "px")
			.css("left",locationX + "px")
			.fadeIn("fast");	

		$("#nutritionPreview").click(function(){
    		$("#nutritionPreview").fadeOut("fast");
    		$("#nutritionPreview").remove();
    		$("#pagescreen").fadeOut("fast");
    		$("#pagescreen").remove();
    	});
    	
    	$("#pagescreen").click(function(){
    		$("#nutritionPreview").fadeOut("fast");
    		$("#nutritionPreview").remove();
    		$("#pagescreen").fadeOut("fast");
    		$("#pagescreen").remove();
    	});
    
    });
    
    
    
		
};


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