// JavaScript Document

/*
 * Bubbleup - Spicing up menu jQuery plugin
 *
 * Tranform the images inside the list items like Mac Dock effect
 *
 * Homepage: http://aext.net/2010/04/bubbleup-jquery-plugin/
 *
 * Copryright? I don't have any!
 *
 * First written by Lam Nguyen (yah, it's me)
 * Written again by Jonathan Uhlmann http://jonnitto.ch
 * Thanks to Icehawg (Hey, I don't know anything from him, just a name http://aext.net/2010/02/learn-jquery-first-jquery-plugin-bubbleup/#comment-6777)
 *
 */


(function($){
	$.fn.bubbleup = function(options) {
		//Extend the default options of plugin
		var opt = $.extend({}, $.fn.bubbleup.defaults, options),tip = null;
		
		return this.each(function() {
			//var w=$(this).width();
			//var w=this.width;
			var w = 0;
			$(this).mouseover(function(){
				
				w = this.width;
				
				var oldPic1 = $(this).attr("src");
				var newPic1 = oldPic1.replace("fileadmin/templates/images/ql/", "fileadmin/templates/images/");

				$(this).attr("src", newPic1).load(function(){});
				
					if(opt.tooltip) {
						tip = $('<div class="quick02"><div class="quick">' + $(this).attr('alt') + '</div></div>').css({
							fontFamily: opt.fontFamily,
							color: opt.color, 
							fontSize: opt.fontSize, 
							fontWeight: opt.fontWeight, 
							position: 'absolute', 
							zIndex: 89
						}).remove().css({top:0,left: 0,visibility:'hidden',display:'block'}).appendTo(document.body);
						var position = $.extend({},$(this).offset(),{width:this.offsetWidth,height:this.offsetHeight}),tipWidth = tip[0].offsetWidth, tipHeight = tip[0].offsetHeight;
						tip.stop().css({
							top: position.top - tipHeight, 
							left: position.left + position.width / 2 - tipWidth / 2,
							visibility: 'visible'
						}).animate({top:'-='+(opt.scale/2-w/2)},opt.inSpeed); 
					}
					
					$(this).closest('li').css({'z-index':89});
					$(this).stop().css({'z-index':89,'top':0,'left':0,'width':w}).animate({
						left:-opt.scale/2+w/2,
						top:-opt.scale/2+w/2,
						width:opt.scale
					},opt.inSpeed);
				
				
			}).mouseout(function(){
		
				$(this).closest('li').css({'z-index':88});
				$(this).closest('li').next().css({'z-index':0});
				$(this).closest('li').next().children('img').css({'z-index':0});
				
				if(opt.tooltip){tip.remove()}
				$(this).stop().animate({left:0,top:0,width:w},opt.outSpeed,function(){
					$(this).css({'z-index':0});
					
					var oldPic2 = $(this).attr("src");
					var newPic2 = oldPic2.replace("fileadmin/templates/images/", "fileadmin/templates/images/ql/");
					$(this).attr("src", newPic2).load(function(){});
				});
				
			});
		})
	}
	$.fn.bubbleup.defaults = {
		tooltip: false,
		scale:30,
		fontFamily:'Arial, sans-serif',
		color:'#000000',
		fontSize:11,
		fontWeight:'normal',
		inSpeed:'fast',
		outSpeed:'fast'
	}
})(jQuery);
