// JavaScript Document

//左右滑动块 
$(function(){ 
         var dangqian = 0;
		 var kuandu= $(".sliding_main").width();

		 var page='';
		 var spac = $("#numberOfPageShow").val();
		 if(spac != undefined){
			 page=Math.ceil(parseFloat($("#numberOfElements").val())/spac);
		 }else{
			 page=Math.ceil(parseFloat($("#numberOfElements").val())/6);
		 }
		 if(page<=1){
			 $(".sliding_left").hide();
			 $(".sliding_right").hide();
			 $(".sliding_px").css("margin-right","6px");
		 }
		 $(".sliding_left").hide();
		 var total = kuandu*page;
		 $(".sliding_con").css({"width":total});
		 $(".sliding_blo").css({"float":"left","width":kuandu});
		 
		$(".sliding_right").click(function(){
			$(".sliding_left").show();
			if(kuandu*(dangqian+1)<total){
				dangqian++;
				$(".sliding_con").animate({right:kuandu*dangqian});
				}
			if(dangqian==page-1){
				$(".sliding_right").hide();
				$(".sliding_px").css("margin-right","6px");
			}
	    });
		
		$(".sliding_left").click(function(){
			$(".sliding_right").show();
			$(".sliding_px").css("margin-right","-60px");
			if(dangqian>0){
				dangqian--;
				$(".sliding_con").animate({right:kuandu*dangqian});
			}
			if(dangqian==0){
					$(".sliding_left").hide();
			}
	    });
 /*
		 $("#sliding_right").click(function(){
				if( parseFloat($("#totalPages").val())==0 || parseFloat($("#page").val())==parseFloat($("#totalPages").val()-1)  ){
					return false;
				}
				$("#page").val(parseFloat($("#page").val())+1);
				submitPageForm();
			}); 
			
			
			$("#sliding_left").click(function(){
				if($("#page").val()=='0'){
					return false;
				}
				$("#page").val(parseFloat($("#page").val())-1);
				submitPageForm();
				});
				*/
}
)