
// Looks for all anchors with a class of 'img'.
// For these, it's assumed the url is a full url to the image itself.
// This file traps the click and instead opens up an image viewer to dispaly the image.

	$(document).ready(function() {

		// Image zoom
		function closeImg() {
			$("#fulldiv").fadeTo(100,0,function(){
				$("#fulldiv").empty();
				$("#fulldiv").remove();
				$("#greyout").fadeTo(400,0,function(){
					$(this).remove();
					});
				});
		}
		
		$("a.img").click(function(e) {
					
			var fullpath = $(this).attr("href");
			var y = $(window).scrollTop()+100;
					
			$("<div>").attr("id", "greyout").appendTo("body").css({opacity:0}).height($("body").height()).fadeTo(400,0.7,function(){
				$("<div>").attr("id", "fulldivOutter").appendTo("body");
				$("<div>").attr("id", "fulldiv").appendTo("#fulldivOutter").css({'top':y});
				$("<img>").attr("src", fullpath).attr("id", "fullimg").appendTo("#fulldiv");
				$("img#fullimg").bind("click",closeImg);
				$("<div>").attr("id", "closediv").appendTo("#fulldiv");
				$("<button>Close</button>").attr("id", "close").appendTo("#closediv").bind("click", closeImg);
			});
			
			return false; // propagates up to <a> to cancel default behavior of click

		});

	});










