/**
 * zoom hovering, jquery externsion
 * @usage: $(".panorama").zoomhover();
 */

$.extend($.fn, {
   	zoomhover: function() {

		return this.each(function() {

			$(this).css('position', 'relative');
   	   	 	
			var itemNr = jQuery.data(this);
   			var itemId = "pzoom" + itemNr;

   			// calc offsets
   			var left = Math.round($(this).width()/2 - 20);
   			var top  = Math.round($(this).height()/2 - 20);
   			
   			var link = $(this).find("a");
   			   			
   			divZoom =  '<div id="' + itemId + '" style="position: absolute; left: ' + left + 'px; top: ' + top + 'px; display: none;">';
   			divZoom += '<a href="' + link.attr('href') + '" title="' + link.attr('title') + '"><img src="/images/zoom.png" width="53" height="46" alt="Zoom" style="border: none;"/></a>';
   			divZoom += '</div>';
   					
   			$(this).prepend(divZoom);
   			$(this).hover( 
				function() { $("#" + itemId).show(); },
				function() { $("#" + itemId).hide(); }
   			);
		});
	}
}); 