/*
 * jQuery Lock Size 1.0
 * http://blog.betabong.com/jquery/locksize
 *
 * Copyright (c) 2009-2010 Severin Klaus
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Date: 2010-11-25
 */
	(function($)
	{
	   $.fn.lockSize = function(options)
	   {
	      return this.each(function()
	      {
	         // The element to be modified
	         var el = $(this);
	
				var lock = options === true || options === undefined;
	
				var lockedSize = el.data('locked-size');
				
				if ( lock ) {
					// store the original css values for width and height
					if ( lockedSize == null ) {
						el.data('locked-size',{width: this.style.width, height: this.style.height});
					}
					el.css( {width: el.width() , height: el.height()} );
				}
				else {
					if ( typeof(options) == 'object' ) {
						el.stop();
						var oldSize = {width: el.width() , height: el.height()};
						el.css( lockedSize );
						var newSize = {width: el.width() , height: el.height()};
						el.css( oldSize );
						// var opt = $.extend( options , { complete: function() {
						// 	el.css( lockedSize );
						// 	el.removeData('locked-size');
						// }});
						opt = options;
						opt.complete = function() {
							el.css( lockedSize );
							el.removeData('locked-size');
						}
						el.animate( newSize , options.duration , function() {
							el.css( lockedSize );
							el.removeData('locked-size');
						} );
					} else {
						el.css( lockedSize );
						el.removeData('locked-size');
					}
				}
			});
	   };

	})(jQuery);

