(function($) {
	$.fn.image_kwicksmenu = function(options) {
		var isIE 	= $.browser.ie,
			isIE6	= isIE && $.browser.version < 7,
			isIE7	= isIE && $.browser.version < 8;
		

		var opts  = $.extend({}, $.fn.image_kwicksmenu.defaults, options);
			
		var height = 0;
		var count = 0;
		$(this).find('a>img').each(function(){
			if ($(this).height()>height) height = $(this).height();
			var bg = $(this).attr('src');
			$(this).parent().css({
				'background-image':'url('+bg+')',
				'background-repeat':'repeat',
				'background-attachment':'scroll',
				'background-position': '0%'
			});
			count++;
		});

		if (height==0) height = $(this).parent('.wrapper').height();
		
		$(this).parent().css({
			'height':height,
			'width':(opts.normalsize * count)
			});
		$(this).find('>li>a').empty().andSelf().css('height',height);
		
		//	Sublevel formatieren
		$(this).find('>li>ul').wrapInner('<span class="sub">').find('.sub').unwrap().find('a').unwrap().wrap('<div>');
		
		$(this).find('a:last').css('border-right-style','none');
		
		
		$(this).kwicks({max: opts.max * 1, duration: opts.duration * 1, easing: 'easeOutQuad', complete: 'callback'});
	};
		
	$.fn.image_kwicksmenu.zIndex 	= 1000;
	$.fn.image_kwicksmenu.defaults 	= {
		max			: 310,
		normalsize	: 50,
		duration	: 300
	};
})(jQuery);
