$(document).ready(function() {
          
	$("img[id!='']").mouseover(function() {
								
		// goes to <a> then to sibling <p>								
		$(this).parent().next().fadeIn("slow");
    });
           
	$("img[id!='']").mouseout(function() {
    
		// goes to <a> then to sibling <p>	
		$(this).parent().next().fadeOut("slow");
	});
		
    function closeImg() {
		$("#fulldiv").empty();
        $("#fulldiv").remove();
        $("#greyout").remove();
    }
		   
   	$("img[id!='']").click(function() {
                
		var fullpath = "" + $(this).attr("id");
                
		$("<div>").attr("id", "fulldiv").appendTo("body");
        $("<img>").attr("src", fullpath).attr("id", "fullimg").appendTo("#fulldiv");
        $("<div>").attr("id", "closediv").appendTo("#fulldiv");
        $("<button><img src=\"custom/templates/images/close.gif\" alt=\"Close\"></button>").attr("id", "close").appendTo("#closediv").bind("click", closeImg);
		return false; // propagates up to <a> to cancel default behavior of click

	});	
});