//pageing field id must be : pageCurrent pageTotal pageAction pageMax gotoPageValue
//pageform form for submit	
	var gotopv = 1;
	function validatePage(action,pageform){
		//alert(action);
		var current = document.getElementById('pageCurrent').value;
		var total = document.getElementById('pageTotal').value;
		var max = document.getElementById('pageMax').value;
		if(action=='lastPage'&& current <= 1 ){
			alert('没有那一页');       
			return false;
		}else if(action=='nextPage'){
			if(total%max==0){
					if(current>=Math.floor(total/max)){
					alert('没有那一页');
						return false;
					}
			}else{
				if(current>=Math.floor(total/max)+1){
				alert('没有那一页');
						return false;
					}
			}
		}else if(action=='gotoPage'){
			var gotoInput = document.getElementById('gotoPageValue');
			gotopv = document.getElementById('gotoPageValue').value;
			if(!gotopv.match(new RegExp("^[0-9]+$"))){ 
				alert("必须输入数字"); 
				gotoInput.select();
				gotoInput.focus(); 
				return false; 
			} 			
			if(gotopv<=0){
				alert('没有那一页');
				gotoInput.select();
				gotoInput.focus(); 
				return false;
			}else if(total%max==0){
					if(gotopv>Math.floor(total/max)){
						alert('没有那一页');
						gotoInput.select();
						gotoInput.focus(); 
						return false;
					}
			}else if(total%max!=0){
				if(gotopv>Math.floor(total/max)+1){
					alert('没有那一页');
					gotoInput.select();
					gotoInput.focus(); 
					return false;
				}
			}
		}
	}
	

	function pageing(action,pageform){
		//alert('pageing');
		if(validatePage(action,pageform)!=false){	
			if(action == 'gotoPage')
				document.getElementById('pageCurrent').value = gotopv;
			//alert(document.getElementById('pageCurrent').value);
			document.getElementById('pageAction').value=action;
			if(document.getElementById('pageUrl')!=null){
				pageform.action=document.getElementById('pageUrl').value;
			}			
			if(gosubmit!=null){
				gosubmit(pageform);
			}
			else{
				pageform.submit();
			}
			return ;
		}
	}
	
	function enterEvent(win,action,pageform){
		//alert('enterEvent');
		if(win.event.keyCode==13){
			if(validatePage(action,pageform)!=false){
				if(action == 'gotoPage')
					document.getElementById('pageCurrent').value = gotopv;
				//alert(document.getElementById('pageCurrent').value + 'enter submit');
				document.getElementById('pageAction').value=action;
				pageform.submit();
				return false;
			}else{
				//alert('else');
				return false;
			}
		}
		
	}
	

function datacolor(o,a,b,c,d){
 var t=document.getElementById(o).getElementsByTagName("tr");
 for(var i=0;i<t.length;i++){
  t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
  t[i].onclick=function(){
   if(this.x!="1"){
    this.x="1";//本来打算直接用背景色判断，FF获取到的背景是RGB值，不好判断
    this.style.backgroundColor=d;
   }else{
    this.x="0";
    this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
   }
  }
  t[i].onmouseover=function(){
   if(this.x!="1")this.style.backgroundColor=c;
  }
  t[i].onmouseout=function(){
   if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
  }
 }
}
