(function($){
$.fn.extend({
toonelOut:function(d,e,c,hold){
	if(typeof d=='object')		
		e=d.easing,
		c=d.complete,
		hold=d.hold,
		d=d.duration
	var th=this,
		w,h,l,t,k,
		wrap=$('<div></div>'),
		chi=hold?$(hold,th):th.children()	
	w=th.prop('offsetWidth')
	h=th.prop('offsetHeight')
	l=th.prop('offsetLeft')
	t=th.prop('offsetTop')
	k=h/w
	wrap
		.css({
			position:'absolute',
			left:0,
			top:0,
			width:w,
			height:h
		})
		.appendTo(th)
		.append(chi)
	
	th
		.stop()
		.animate({
			width:0
		},{
			step:function(now){
				th
					.css({
						height:now*k,
						left:(w-now)/2+l,
						top:(h-now*k)/2+t
					})
				wrap
					.css({
						 left:-(w-now)/2+l,
						 top:-(h-now*k)/2+t
					})
			},
			duration:d,
			easing:e,
			complete:function(){
				chi.appendTo(th)
				wrap.remove()
				if(c)
					c.call(th)
				th
					.hide()
					.css({
						width:w,
						height:h,
						left:l,
						top:t
					})
			}
		})
	return th
},
toonelIn:function(d,e,c,hold){
	if(typeof d=='object')		
		e=d.easing,
		c=d.complete,
		hold=d.hold,
		d=d.duration
	var th=this,
		w,h,l,t,k,
		wrap=$('<div></div>'),
		chi=hold?$(hold,th):th.children()	
	th
		.css({visibility:'hidden'})
		.show()
	w=th.prop('offsetWidth')
	h=th.prop('offsetHeight')
	l=th.prop('offsetLeft')
	t=th.prop('offsetTop')
	k=h/w

	wrap
		.css({
			position:'absolute',
			left:-w/2,
			top:-h/2,
			width:w,
			height:h
		})
		.appendTo(th)
		.append(chi)

	th
		.stop()
		.css({width:0,height:0,visibility:'visible'})
		.animate({
			width:w
		},{
			step:function(now){
				th
					.css({
						height:now*k,
						left:(w-now)/2+l,
						top:(h-now*k)/2+t
					})
				wrap
					.css({
						 left:-(w-now)/2+l,
						 top:-(h-now*k)/2+t
					})
			},
			duration:d,
			easing:e,
			complete:function(){
				chi.appendTo(th)
				wrap.remove()
				if(c)
					c.call(th)
			}
		})

	return th
}})
})(jQuery)
