function ngg_remove_loading() {

	updateIVW();
	
	/* rest aus nextgen */
	jQuery(document).unbind("mousemove");
	jQuery(loadingImage).remove();

}

function ngg_ajax_browser_navigation(e, obj) {
	

	// try to find gallery number
	if ("ngg-prev-" == jQuery(obj).attr("id").substr(0, 9) || "ngg-next-" == jQuery(obj).attr("id").substr(0, 9)) {
		
		// extract the image-id
		var imageNumber = jQuery(obj).attr("id").substr(9);

		// find the image-browser-container
		var currentNode = obj;
		while (null != currentNode.parentNode && !jQuery.nodeName(currentNode.parentNode, "body") && !jQuery(currentNode.parentNode).hasClass("ngg-imagebrowser")) {
			currentNode = currentNode.parentNode;
		}
		
		if (jQuery(currentNode.parentNode).hasClass("ngg-imagebrowser")) {
			var gallery = jQuery(currentNode.parentNode);

			// let's extract the post id & gallery id
			var payload = gallery.attr("id").substring(17);
			var separatorPosition = parseInt(payload.indexOf("-"));
			
			var galleryId = payload.substr(0, separatorPosition);
			var postId = payload.substr(separatorPosition + 1);
			
			if ( (galleryId.length == 0) || (postId.length == 0) ) {
				return true;
			}
			
			ngg_show_loading(e);
						
			// BEGIN - amatheis: show ad
			var direction = 'next';			
			if ("ngg-prev-" == jQuery(obj).attr("id").substr(0, 9)) direction = 'prev';
		    if ("ngg-next-" == jQuery(obj).attr("id").substr(0, 9)) direction = 'next';
		    var adCount = jQuery('#adCount').val();		    
			// END	
		    
			// get content
			jQuery.get(ngg_ajax.callback, {p: postId, galleryid: galleryId, pid: imageNumber, type: "browser", direction: direction, adCount: adCount}, function (data, textStatus) {
				// delete old content
				gallery.children().remove();
				
				// add new content
				gallery.replaceWith(data);
				
				// add ajax-navigation, again
				jQuery("document").ready(function(){
					// remove old listeners to avoid double-clicks
					jQuery("a.ngg-browser-next").unbind("click");
					jQuery("a.ngg-browser-prev").unbind("click");
					
					// add shutter-listeners again
					shutterReloaded.init('sh');
					
					// register ajax browser-navigation listeners
					jQuery("a.ngg-browser-next").click(function(e) {
						return ngg_ajax_browser_navigation(e, this);
					});
					jQuery("a.ngg-browser-prev").click(function(e) {
						return ngg_ajax_browser_navigation(e, this);
					});
					
					ngg_remove_loading();
				});
			});
	
			// deactivate HTML link
			return false;
		}
	}
	
	return true;
}
