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

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

		return this.each(function() {

			$(this).css('position', 'relative');
   	   	 	
			var itemNr = jQuery.data(this);
			
			// get distinct item id
   			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 style="z-index:500; 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>';
   			
   			var divZoomElement = $(divZoom);
   			
   			// check for bergfex map
   			if ((typeof(bergfex) != "undefined") &&
   			    (typeof(bergfex.MapUtil) != "undefined") && 
   				bergfex.MapUtil.isLoaded()) {
   				
   				divZoomElement.find('a').jssm('click');
   			}
   			
   			$(this).prepend(divZoomElement);
   			$(this).hover( 
				function() { divZoomElement.show(); },
				function() { divZoomElement.hide(); }
   			);
		});
	}
}); 
