 
  (function ($) {
     $.fn.wait = function(time, type) {
        time = time || 400;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
	})(jQuery);
  
  
  
  /**
 * scaleImage 0.1
 * 
 * Rendez vos sites glissant !
 *
 * Copyright (c) 2008 Benoit G (http://www.tim-burton.net) based upon
 * Licensed under the Creative Commons License:
 * http://creativecommons.org/licenses/by/3.0/
 *
 * Date: 2008-08-25
 */
 
	(function($){
		$.fn.scaleImage = function(options) {
 
			var defaults = {
			maxwidth: 200,
			linkclass:'',
			icon:true,
			highslide:false
			};
			var options = $.extend(defaults, options);
 
			return this.each(function() {
				obj = $(this);
 
				var width = obj.width();
				var height = obj.height();
			
	            // ALT & TITLE ermitteln		
			    var Lastzeichen = obj.attr('src').lastIndexOf("/");
				var Newtitle = '';
					if (Lastzeichen > 0) 
					   {Newtitle = obj.attr('src').substr(Lastzeichen+1); }
					else {Newtitle = obj.attr('src');}  
					
					Newtitle = Newtitle.substr(0,Newtitle.length -4);
	                obj.attr('alt',Newtitle).attr('title',Newtitle);
				
				if (width > options.maxwidth) {
					//Set variables	for manipulation
					var ratio = (height / width );
					var new_width = options.maxwidth;
					var new_height = (new_width * ratio);
					var classes = options.linkclass+' scaleImage';
					
                  //zoom icon
					if (options.icon == true) {
						obj.after('<div class="highslide-caption">'+Newtitle+'</div>');
						//obj.hover(function(){
						//	$(this).next('.highslide-caption').addClass("hover");
						//},function(){
						//	$(this).next('.highslide-caption').removeClass("hover");
						//});
					}
					
					
					//highslide
					if (options.highslide == true) {
						var img_full_link = obj.attr('src');
						obj.wrap('<a class="highslide" title="'+Newtitle+'" onclick="return hs.expand(this)" href="'+img_full_link+'"></a>');
						//tb_init(obj.parent('a'));
					}
 
					//Shrink the image and add link to full-sized image
					obj.height(new_height).width(new_width);
					obj.addClass(classes);
 
					
 
				}
				
			});
		};
	})(jQuery);
	
	
	
	
	
	
	(function($) {
$.fn.batchImageLoad = function(options) {
	var images = $(this);
	var originalTotalImagesCount = images.size();
	var totalImagesCount = originalTotalImagesCount;
	var elementsLoaded = 0;

	// Init
	$.fn.batchImageLoad.defaults = {
		loadingCompleteCallback: null, 
		imageLoadedCallback: null
	}
    var opts = $.extend({}, $.fn.batchImageLoad.defaults, options);
		
	// Start
	images.each(function() {
		// The image has already been loaded (cached)
		if ($(this)[0].complete) {
			totalImagesCount--;
			if (opts.imageLoadedCallback) opts.imageLoadedCallback(elementsLoaded, originalTotalImagesCount,$(this),'suc');
		// The image is loading, so attach the listener
		} else {
			$(this).load(function() {
				elementsLoaded++;
				
				if (opts.imageLoadedCallback) opts.imageLoadedCallback(elementsLoaded, originalTotalImagesCount,$(this),'suc');

				// An image has been loaded
				if (elementsLoaded >= totalImagesCount)
					if (opts.loadingCompleteCallback) opts.loadingCompleteCallback();
			});
			$(this).error(function() {
				elementsLoaded++;
				
				if (opts.imageLoadedCallback) opts.imageLoadedCallback(elementsLoaded, originalTotalImagesCount,$(this),'err');
					
				// The image has errored
				if (elementsLoaded >= totalImagesCount)
					if (opts.loadingCompleteCallback) opts.loadingCompleteCallback();
			});
		}
	});

	// There are no unloaded images
	if (totalImagesCount <= 0)
		if (opts.loadingCompleteCallback) opts.loadingCompleteCallback();
};
})(jQuery);
