(function($) {
$.fn.customAcc = function(start)
{
	return $(this).each(function() {
		var holder = $(this);
		var accVisible, accNext;
		var accSpeed = 0.1; // Don't touch a lot; [sec/Speed]
		var accStep = 50; // This is more accurate; [px/Step]
	
		function accAnimate()
		{
			accVisibleWidth = accVisible.width();
			var con1 = accVisibleWidth>accStep;
			var con2 = accNext.find("div").width() - accNext.width()>accStep;
			if(con1 && con2)
			{
				accVisible.css("width", accVisibleWidth - accStep);
				accNext.css("width", accNext.width()+accStep);
				setTimeout(accAnimate, accSpeed);
			}	
			else if(!con1 && !con2)
			{
				accNext.css("width", accNext.find("div").width());
				accVisible.prev("dt").removeClass("active");
				accVisible.css("display", "none");
				accNext.prev("dt").addClass("active");
			}
			else if(con1 && !con2) // There is more to hide, but nothing to show
			{
				accVisible.css("width", accVisibleWidth - accStep);
				accNext.css("width", accNext.find("div").width());
				setTimeout(accAnimate, accSpeed);
			}
			else // There is nothing to show but some to hide
			{
				accNext.css("width", accNext.width()+accStep);		
				setTimeout(accAnimate, accSpeed);
			}
		}
		
		
		var holder = $(holder);
		
		$("dd", holder).each(function(){
			var prevHtml = $(this).html();
			$(this).html("<div class='dd-inner'>"+prevHtml+"</div'>");
			$(this).css("overflow", "hidden")
		});
		
		if( typeof(start) == "undefined" ) start = 0;
		$("dd", holder).hide().eq(start).show().addClass("active").next().find(".handleInnerWrapper").addClass("active");
		
		$("dt", holder).hover(function(){
			$(this).find('.handleInnerWrapper').addClass('hover');
		}, function () {
			$(this).find('.handleInnerWrapper').removeClass('hover');
		});
		
		$("dt", holder).click(function(){
			$(this).parents('#side-slider').find('.handleInnerWrapper').removeClass('active');
			$(this).find('.handleInnerWrapper').addClass('active');
			if($(this).prev("dd").is(":visible") || !$(this).prev("dd").size()) return false;
			
			accVisible = $("dd:visible", holder);
			accNext = $(this).prev("dd");
			accNext.css("width", 0).css("display", "block")
			
			accAnimate();
		});
	});
}
})(jQuery);
