function DBNavigator(parent){	//构造
	var pdiv;
	if(parent){pdiv=parent;}else pdiv=document.body;//获取父块
	var obj=new Div(pdiv);
	obj.style.backgroundColor = clHightGray;
	obj.Button=new Array();//按钮button
	obj.Number=10;//button个数    
	obj.ButtonWidth=75;	
	obj.ButtonHeight=21;	
	obj.style.height = 27;
	obj.style.borderWidth=1;
	obj.style.borderStyle='solid';
	obj.style.borderColor=clBorder;
//	obj.style.borderRightWidth=0;
//	obj.style.borderLeftWidth=0;
	obj.DataSet=null;
    obj.CreateButton=DBN_createbutton;//创建按钮对象
	obj.HandleMessage=DBN_handlemessage;//消息处理
	obj.Refresh=DBN_refresh;
  if(isIE)
	obj.onpropertychange=DC_onpropertychange
  else
	addEventTimerListener(obj,DC_onpropertychange);

	obj.CreateButton();
    obj.oncontextmenu=div_oncontextmenu;
	return obj;
} 

function DBN_onpropertychange()//属性变化处理
{
  var n=event.propertyName;
  switch(n){
	case 'DataSet':
	  if(this.OldDataSet)this.OldDataSet.RemoveLink(this);//从原来的DATASET中移除
      this.DataSet.LinkObj(this);
	  this.OldDataSet=this.DataSet;
	  break;
  }
}
function DBN_createbutton(){  //创建button	
    var spea = null;
	var toolbar = new Div(this);
	toolbar.style.backgroundColor = clHightGray;
	toolbar.style.position='relative';		
    toolbar.style.top  = 0;		
	var left = 2;
	for(var i=0;i<this.Number;i++){//创建10个button对象
	  if(i!=7&&i!=9) {
		this.Button[i]=new SpeedButton(toolbar);
		this.Button[i].style.position = 'absolute';		
		this.Button[i].style.width=this.ButtonWidth;//设置按钮大小
		this.Button[i].style.height=this.ButtonHeight;//设置按钮大小
		this.Button[i].style.left=left;//设置按钮left
		this.Button[i].style.top=2;
		left += this.ButtonWidth;
		this.Button[i].index=i;//保存按钮的位置，当点击该按钮的时候直接确定它该做的动作
		this.Button[i].parent=this;	
		this.Button[i].onclick=DBN_onclick; //添加onclick事件
		this.Button[i].style.backgroundRepeat='no-repeat'; 
		if(i<this.Number-2) {
			spea = new Span(toolbar);
			spea.innerHTML = "|";
			spea.style.top = 6;		
			spea.style.width = 7;
			spea.style.left = left;
			left += 7;
			spea.style.position = 'absolute';		
			spea.style.color = clLtGray;
			spea.style.fontSize = 11;
		}
      }
	}	 
	for(var j=0;j<this.Number;j++){	//向块中添加按钮	 
	  switch(j){
		case 0:this.Button[j].Text.innerHTML='First';break;//first
		case 1:this.Button[j].Text.innerHTML='Previous';break;//prev
		case 2:this.Button[j].Text.innerHTML='Next';break;//next
		case 3:this.Button[j].Text.innerHTML='Last';break;//last
		case 4:this.Button[j].Text.innerHTML='Add';this.Button[j].style.backgroundImage='url('+jcl_ResourceURL+image_AppendRecord+')';break;//append
		case 5:this.Button[j].Text.innerHTML='Delete';this.Button[j].style.backgroundImage='url('+jcl_ResourceURL+image_DeleteRecord+')';break;//delete
		case 6:this.Button[j].Text.innerHTML='Save';this.Button[j].style.backgroundImage='url('+jcl_ResourceURL+image_SaveRecord+')';break;//save
//		case 7:this.Button[j].Text.innerHTML='Post';break;//post
		case 8:this.Button[j].Text.innerHTML='Cancel';break;//cancel
//		case 9:this.Button[j].Text.innerHTML='Refresh';break;//refresh
	  }	  
	}	
} 

function DBN_onclick(){
	var d=this.parent.DataSet;
	switch(this.index){
		case 0: d.First();break;
		case 1: d.Prev();break;
		case 2: d.Next();break;
		case 3: d.Last();break;
		case 4: d.Append();	break;
		case 5: d.Delete();	break;
		case 6: d.Apply(); break;
		case 7: d.Post();break;
		case 8: d.Cancel();break;
        case 9: d.Refresh();break;
		}
}
function DBN_refresh(msg)//设置按钮状态
{
 var d=this.DataSet;
 if(!d){
  return;
 }
 if(d.Active==false){
  this.disabled=true;
  return;
 }
 else
  this.disabled=false;
 if(d.DeltaChanges.row.length<1&&!d.Fields.State&&msg!=12){//12 is detail edit
  this.Button[6].SetUp();
  this.Button[8].SetUp();
  this.Button[6].disabled=true;
  this.Button[8].disabled=true;
 }
 else{
  this.Button[6].disabled=false;
  this.Button[8].disabled=false;
 }
// if(!d.Fields.State){this.Button[7].SetUp();this.Button[7].disabled=true;}
// else this.Button[7].disabled=false;
 if(d.Bof){this.Button[0].SetUp();this.Button[1].SetUp();} 	
 if(d.Eof){this.Button[2].SetUp();this.Button[3].SetUp();} 	
 this.Button[0].disabled=d.Bof;
 this.Button[1].disabled=d.Bof;
 this.Button[2].disabled=d.Eof;
 this.Button[3].disabled=d.Eof;
 this.Button[4].disabled=false;
 if(d.RecordCount>0)this.Button[5].disabled=false;
 else {this.Button[5].SetUp(); this.Button[5].disabled=true;}
}
function DBN_handlemessage(sender,msg,recno){		
  this.Refresh(msg);
}