// JavaScript Document

(function($) {
		  
$.upanddown = function(el, options) {
    
        var base = this;
        base.$el = $(el);
		base.init = function() {
			base.options = $.extend({},$.upanddown.defaultOptions, options);

			base.$el.delegate("img", "click", function() {
				var source = $(this).attr("src");
				var parent = $(this).parent().parent();
				
				var toscroll = parent.children("div.year_details");

				
				if(source.indexOf("down") != -1){
					var pos = toscroll.scrollTop();
					toscroll.animate({scrollTop: pos+200 }, 500);
					}
				else if(source.indexOf("up") != -1){
					var pos = toscroll.scrollTop();
					toscroll.animate({scrollTop: pos-200 }, 500);
				}
			});
			
			base.$el.delegate("img", "hover", function(event) {
				var source = $(this).attr("src");
				if(source.indexOf("down") != -1){
					if( event.type == 'mouseenter'){
					$(this).attr("src","assets/scroll_down-a.png");
					}else if(event.type == 'mouseleave'){
					$(this).attr("src","assets/scroll_down-b.png");
					}
				}
				else if(source.indexOf("up") != -1){
					if( event.type == 'mouseenter'){
					$(this).attr("src","assets/scroll_up-a.png");
					}else if(event.type == 'mouseleave'){
					$(this).attr("src","assets/scroll_up-b.png");
					}
				}
							
			});	
			  

		};
	base.init();
		
};

      $.upanddown.defaultOptions = {
		"path":"images/slidingShow/"
    };
    $.fn.upanddown = function(options) {
        return this.each(function() {
            (new $.upanddown(this, options));
        });
    };

})(jQuery);
