(function($) {
	$.fn.vslide = function(total_show) {
		return this.each(function() {
			// start
      var $this = $(this);
     	var $up_btn = $(".vslide_up");
     	var $down_btn = $(".vslide_down");
     	/*
     	var $up_btn = $this.find(".vslide_up");
     	var $down_btn = $this.find(".vslide_down");
     	*/
     	//var $all_slides = $this.children("div").eq(1);
     	//var $all_slides = $this.find(".blogfeed");
     	//var $slides = $all_slides.children("div");
     	var $slides = $this.find(".item");
     	var total_slides = $slides.length;
     	var current_pos = 0;
     	var slide_height = 224;
     	
     	var mouseover_downbtn = false;
     	var mouseover_upbtn = false;
 	
     	$slides.wrapAll('<div id="slideinner"></div>');
     	$('#slideinner').css('height', slide_height * total_slides);

     	$down_btn.mouseover(function() {
     		mouseover_downbtn = true;
     		current_pos = (current_pos < total_slides - total_show + 1) ? ++current_pos : total_slides - total_show + 1;
     		//current_pos = (current_pos < total_slides - total_show) ? ++current_pos : total_slides - total_show;

     		$('#slideinner').animate({
					'marginTop' : slide_height*(-current_pos)
				},600,function() {
					keep_godown();
				});

				if (current_pos == total_slides - total_show + 1) {
				 		$down_btn.css("cursor","default");
				} else {
						$down_btn.css("cursor","pointer");
				}
				if (current_pos > 0) {
     				$up_btn.css("cursor","pointer");
     		}	
     	});
     	$down_btn.mouseout(function() {
     		mouseover_downbtn = false;
     	});
     	
     	
     	
     	$up_btn.mouseover(function() {
     		mouseover_upbtn = true;
     		current_pos = (current_pos == 0) ? 0 : --current_pos;
     		$('#slideinner').animate({
				  'marginTop' : slide_height*(-current_pos)
				},600,function() {
					keep_goup();
				});
				if (current_pos == 0) {
				 		$up_btn.css("cursor","default");
				} else {
						$up_btn.css("cursor","pointer");
				}
     		if (current_pos < total_slides - total_show) {
     				$down_btn.css("cursor","pointer");
     		}
     	});
     	$up_btn.mouseout(function() {
     		mouseover_upbtn = false;
     	});
     	
     	
     	
     	if (total_slides > total_show) {
     			$down_btn.css("cursor","pointer");
     	}
     	
     	var keep_godown = function() {
     		if (mouseover_downbtn) {
	     		if (current_pos < total_slides - total_show + 1) {
	     				$down_btn.trigger("mouseover");
	     		}	
     		}	
     	}
     	var keep_goup = function() {
     		if (mouseover_upbtn) {
     				if (current_pos > 0) {
     						$up_btn.trigger("mouseover");		
     				}
     		}
     	}
     	
      // end
    });
	};
})( jQuery );
