(function($){
	$.fn.scrollCliente = function(opciones){
		var opts = $.extend({}, $.fn.scrollCliente.defaults, opciones);

		return this.each(function(){
			var o = $(this);
			var a = 0;
			o.find("div[class^='pane']").each(function(i){
				var c = ($(this).attr("class")).split(" ");				
				if(c.length == 2 && a == 0){
					a = i;
				}
			});
			o.attr("count",a);
			function move_item (){
				var valor = parseInt($(this).attr("valor"));	
				var ant = o.attr("count");
				var count = parseInt(o.attr("count"));
				switch(valor){
					case 1:
					count -= 1;
					break;
					case 2: 
					count += 1;  
					break;
				}
				o.attr("count",count);
				o.find("div[class^='pane']:eq("+ant+")").css({display:"none"});
				o.find("div[class^='pane']:eq("+count+")").css({display:"block"});
				build_menu();
			}				 
			function build_menu(){
				var count = o.attr("count");
				var html = "<table border='0' cellpadding='0' cellspacing='0' width='90%' align='center'><tr>";
				if(count > 0){
				html += "<td width='50%' align='left'><a class='button button_num1' valor='1'><img src='images/prev.png' alt='' />Anterior</a></td>";
				}
				
				if(count < (o.find("div[class^='pane']").length-1)){
				html += "<td width='50%' align='right'><a class='button button_num2' valor='2'><img src='images/next.png' alt='' />Siguiente</a></td>";
				}  
				html += "</tr></table>";
				o.find("div[class='content_menu']").html(html);
				$(".button",o).unbind("hover");				
				o.find("a[class$='button_num1']").bind("click",move_item);
				o.find("a[class$='button_num2']").bind("click",move_item);
				o.find("a[class$='button_num2']").hover(function(){
				$(this).find("img")
				.animate({top:"-10px"}, 200).animate({top:"-4px"}, 200) // first jump
				.animate({top:"-7px"}, 100).animate({top:"-4px"}, 100) // second jump
				.animate({top:"-6px"}, 100).animate({top:"-4px"}, 100); // the last jump
				});
				o.find("a[class$='button_num1']").hover(function(){
				$(this).find("img")
				.animate({top:"-10px"}, 200).animate({top:"-4px"}, 200) // first jump
				.animate({top:"-7px"}, 100).animate({top:"-4px"}, 100) // second jump
				.animate({top:"-6px"}, 100).animate({top:"-4px"}, 100); // the last jump
				});
			}		
			if(o.find("div[class^='pane']").length > 1){
				build_menu();
			}
		});
	}
})(jQuery);

$.fn.scrollCliente.defaults = {
};
