/**
 * jquery.sv.slide-top.js defines the behavior of the top slide-out area
 */
(function($){
	$.fn.extend({
		svSlideTopInit: function(options) {
			var defaults = {
				'topContainer': '.topSlide'
				,'topAnchor': '.arrow'
				,'topContent': '.topSlideCont'
				,'topOpenClass': 'topSlide-open'
				,'topClosedClass': 'topSlide-closed'
			};				
			
			var options = $.extend(defaults, options);
			
			this.each(function() {
				var o = options;				
				var contHeight = $(o.topContent).height();
				$(o.topContent).hide();
				$(o.topContainer).each(function() {					
					$(this).find(o.topAnchor).click(function() {						
						if ($(this).parent().hasClass(o.topClosedClass)) {							
							var bottom = 0;
							var top = 0;							
							var classToRemove = o.topClosedClass;
							var classToAdd = o.topOpenClass;
							//$(o.topContent).show(40);
							$(o.topContent).slideDown();
							
						} else {
							var bottom = 0;
							var top = '-' + contHeight;
							var classToRemove = o.topOpenClass;
							var classToAdd = o.topClosedClass;
							$(o.topContent).slideUp();
						}
						$(this).parent().animate(
							{'bottom':bottom},
							0
						).removeClass(classToRemove).addClass(classToAdd);						
						//$(o.topContainer).animate({'top':top},300, 'linear');
						
						return false;
					});
				});
			});
			
			return this;
		}
	});
})(jQuery);

$(document).svSlideTopInit();
