;(function($) {
	/**
	* @name jCollapsibleLink
	* @class
	* @version 1.0
	* @requires jQuery 1.3.2
	* @param {Object} oOptions The Plugin options for this collection of elements
	*/
$.fn.jCollapsibleLink = function(oOptions) {
  var opts = $.extend({}, $.fn.jCollapsibleLink.defaults, oOptions);

  return this.each(function(iIndex, oElement) {
    var $this = $(this);
		var icon = $("img",$this);
		var slider = $(opts.sliderClass, $this);
		var initialWidth = slider.outerWidth();
		var initialHeight = slider.outerHeight();
		var collapseDuration = initialWidth*opts.collapseSpeedModifier;
		var expandDuration = initialWidth*opts.expandSpeedModifier;
		var collapse = function(){
			slider.stop().animate({
				width:opts.collapsedSize[0]/2,
				height: opts.collapsedSize[1]
			}, collapseDuration);
		};
		var expand = function(){
			slider.stop().animate({
				width:initialWidth,
				height: initialHeight
			}, expandDuration);
		};
		
		$this.hover(expand, collapse);
		// init
		if (opts.delay) {
			window.setTimeout(collapse, opts.delay*1000);
		} else {
			slider.stop().css({
				width:opts.collapsedSize[0]/2,
				height: opts.collapsedSize[1]
			});
		}
  });
	// end instance members
};
// end jCollapsibleLink

/**
 * default options
 */
$.fn.jCollapsibleLink.defaults = {
	collapsedSize: [16, 16],
	delay: 1, // how many seconds to show the expanded link after page load until it collapses
	iconClass: ".collapsibleIcon",
	sliderClass: ".collapsibleSlider",
	collapseSpeedModifier: 3, //the higher the number, the slower the animation
	expandSpeedModifier: 1.5
};

})(jQuery);
