/* overwriting jQuery methods */

/* same as $.animate but with new parameter "targetdisplay" 
 * with values of e.g. 'block' (default), 'inline', 'table-row'
 * and using $.fx2
 */
jQuery.animate = jQuery.fn.animate = //function() { 
		//return this.each( 
			function( prop, speed, easing, callback, targetdisplay ) {
				return this.queue(function(){
				
					this.curAnim = jQuery.extend({}, prop);
					var opt = jQuery.speed(speed, easing, callback);
			
					for ( var p in prop ) {
						var e = new jQuery.fx( this, opt, p, targetdisplay );
						if ( prop[p].constructor == Number )
							e.custom( e.cur(), prop[p] );
						else
							e[ prop[p] ]( prop );
					}
				})
			}
		//);
	//}
/* same as $.fx but with new parameter targetdisplay */
jQuery.fx = jQuery.fn.fx = //function() { 
		//return this.each(  	
			function( elem, options, prop, targetdisplay ){
			
				var targetdisplay = targetdisplay || 'block' //PATCH
				
				var z = this;
		
				// The styles
				var y = elem.style;
				
				// Store display property
				var oldDisplay = jQuery.css(elem, "display");
		
				// Make sure that nothing sneaks out
				y.overflow = "hidden";
		
				// Simple function for setting a style value
				z.a = function(){
					if ( options.step )
						options.step.apply( elem, [ z.now ] );
		
					if ( prop == "opacity" )
						jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
					else if ( parseInt(z.now) ) // My hate for IE will never die
						y[prop] = parseInt(z.now) + "px";
					
					y.display = targetdisplay //PATCH: "block"; // Set display property to block for animation
				};
		
				// Figure out the maximum number to run to
				z.max = function(){
					return parseFloat( jQuery.css(elem,prop) );
				};
		
				// Get the current size
				z.cur = function(){
					var r = parseFloat( jQuery.curCSS(elem, prop) );
					return r && r > -10000 ? r : z.max();
				};
		
				// Start an animation from one number to another
				z.custom = function(from,to){
					z.startTime = (new Date()).getTime();
					z.now = from;
					z.a();
		
					z.timer = setInterval(function(){
						z.step(from, to);
					}, 13);
				};
		
				// Simple 'show' function
				z.show = function(){
					if ( !elem.orig ) elem.orig = {};
		
					// Remember where we started, so that we can go back to it later
					elem.orig[prop] = this.cur();
		
					options.show = true;
		
					// Begin the animation
					z.custom(0, elem.orig[prop]);
		
					// Stupid IE, look what you made me do
					if ( prop != "opacity" )
						y[prop] = "1px";
				};
		
				// Simple 'hide' function
				z.hide = function(){
					if ( !elem.orig ) elem.orig = {};
		
					// Remember where we started, so that we can go back to it later
					elem.orig[prop] = this.cur();
		
					options.hide = true;
		
					// Begin the animation
					z.custom(elem.orig[prop], 0);
				};
				
				//Simple 'toggle' function
				z.toggle = function() {
					if ( !elem.orig ) elem.orig = {};
		
					// Remember where we started, so that we can go back to it later
					elem.orig[prop] = this.cur();
		
					if(oldDisplay == "none")  {
						options.show = true;
						
						// Stupid IE, look what you made me do
						if ( prop != "opacity" )
							y[prop] = "1px";
		
						// Begin the animation
						z.custom(0, elem.orig[prop]);	
					} else {
						options.hide = true;
		
						// Begin the animation
						z.custom(elem.orig[prop], 0);
					}		
				};
		
				// Each step of an animation
				z.step = function(firstNum, lastNum){
					var t = (new Date()).getTime();
		
					if (t > options.duration + z.startTime) {
						// Stop the timer
						clearInterval(z.timer);
						z.timer = null;
		
						z.now = lastNum;
						z.a();
		
						if (elem.curAnim) elem.curAnim[ prop ] = true;
		
						var done = true;
						for ( var i in elem.curAnim )
							if ( elem.curAnim[i] !== true )
								done = false;
		
						if ( done ) {
							// Reset the overflow
							y.overflow = "";
							
							// Reset the display
							y.display = oldDisplay;
							if (jQuery.css(elem, "display") == "none")
								y.display = targetdisplay //PATCH "block";
		
							// Hide the element if the "hide" operation was done
							if ( options.hide ) 
								y.display = "none";
		
							// Reset the properties, if the item has been hidden or shown
							if ( options.hide || options.show )
								for ( var p in elem.curAnim )
									if (p == "opacity")
										jQuery.attr(y, p, elem.orig[p]);
									else
										y[p] = "";
						}
		
						// If a callback was provided, execute it
						if ( done && jQuery.isFunction( options.complete ) )
							// Execute the complete function
							options.complete.apply( elem );
					} else {
						var n = t - this.startTime;
						// Figure out where in the animation we are and set the number
						var p = n / options.duration;
						
						// If the easing function exists, then use it 
						z.now = options.easing && jQuery.easing[options.easing] ?
							jQuery.easing[options.easing](p, n,  firstNum, (lastNum-firstNum), options.duration) :
							// else use default linear easing
							((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
		
						// Perform the next step of the animation
						z.a();
					}
				};
			}
		//);
	//}

