function DateSelector(InstanceName){
//对象名称
  this.instanceName=InstanceName;
//保存结果的表单域
  this.oResultField=null;

//选择器的标题
  this.strTitle="日期选择";
  
//放置选择器的div的id
  this.divId=InstanceName+"Div";

//点击的按钮
  this.but=null;
	
//函数
  this.Init=dateSelectorInit;
  this.checkedBox=dateCheckedBox;
  this.setTitle=dateSetTitle
  this.showSelector=showDateSelector;
  this.initResult=initDateResult;
  
  //this.chooseType=chooseType;//用于点击父类：当子类隐藏时，父类选中并添加到结果中，当子类显示父类设为没选中
  
}

 function dateSetTitle(strTitle){
   	this.strTitle=strTitle;
 }

//建立selector的各个层次的容器（div，span等）
function dateSelectorInit(){
  
  var objJobType=document.getElementById(this.divId);
  if(objJobType!=null){
    return;
  }

  var divHtml="<DIV id=\""+this.divId+"\" style=\'width:450px;height:100px;DISPLAY:none; Z-INDEX:999; POSITION:absolute;  BACKGROUND-COLOR:#ffffff; bordercolor:#ffffff';>";
  divHtml+="<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
//  divHtml+="<form name=\""+curRecordFieldId+"chooseJobForm\"><input name=\""+curRecordFieldId+"choosedJobTypeId\" type=\"hidden\" value=\"\">";
  divHtml+="<tr>";
  divHtml+="<td width=\"5\" height=\"5\">";
  divHtml+="<img src=\"images/div_01.gif\"></td>";
  divHtml+="<td background=\"images/div_02.gif\">";
  divHtml+="</td>";
  divHtml+="<td>";
  divHtml+="<img src=\"images/div_03.gif\"></td>";
  divHtml+="</tr>";
  divHtml+="<tr>";
  divHtml+="<td background=\"images/div_04.gif\">";
  divHtml+="</td>";
  divHtml+="<td valign=\"top\" bgcolor=\"#FFFFFF\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"divtt\">";
  divHtml+="<tr>";
  divHtml+="<td class=\"tt\">"+this.strTitle+"</td>";
  divHtml+="<td align=\"right\" height=\"19px\" valign=\"bottom\"><a href=\"javascript:showSelect('"+this.divId+"');divClose('"+this.divId+"');\">[确定]</a> <a href=\"javascript:showSelect('"+this.divId+"');divClose('"+this.divId+"');\">[关闭]</a></td>";
  divHtml+="</tr>";     
  divHtml+="</table>";
  divHtml+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
  divHtml+="<tr><td align=\"center\" onclick=\"dateClick(0,'近一天',"+this.instanceName+")\" style='cursor:hand'>近一天</td><td align=\"center\" onclick=\"dateClick(2,'近三天',"+this.instanceName+")\" style='cursor:hand'>近三天</td><td align=\"center\" onclick=\"dateClick(6,'近一周',"+this.instanceName+")\" style='cursor:hand'>近一周</td></tr>";
  divHtml+="<tr><td align=\"center\" onclick=\"dateClick(15,'近半月',"+this.instanceName+")\" style='cursor:hand'>近半月</td><td align=\"center\" onclick=\"dateClick(30,'近一月',"+this.instanceName+")\" style='cursor:hand'>近一月</td><td align=\"center\" onclick=\"dateClick(90,'近三月',"+this.instanceName+")\" style='cursor:hand'>近三月</td></tr>";
  divHtml+="</table>";
  divHtml+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"divtt\">";
  divHtml+="<tr>";
  divHtml+="<td align=\"right\" height=\"19px\" valign=\"bottom\"><a href=\"javascript:showSelect('"+this.divId+"');divClose('"+this.divId+"');\">[确定]</a> <a href=\"javascript:showSelect('"+this.divId+"');divClose('"+this.divId+"');\">[关闭]</a></td>";
  divHtml+="</tr>";   
  divHtml+="<tr><td height=\"5\" bgcolor=\"#FFF3E1\"></td></tr></table></td>";
  divHtml+="<td background=\"images/div_06.gif\">";
  divHtml+="</td></tr>";
  divHtml+="<tr><td>";
  divHtml+="<img src=\"images/div_07.gif\"></td>";
  divHtml+="<td background=\"images/div_08.gif\"></td>";
  divHtml+="<td width=\"1\" height=\"1\">";
  divHtml+="<img src=\"images/div_09.gif\"></td>";
  divHtml+="</tr></form></table></div>";
  
  //document.getElementById("showhtml").value=divHtml;  
  document.write(divHtml);

}

/**显示选择器，如果选择器的第一层还没有创建则要创建
@param oInstance 选择器对象
*/

function showDateSelector(objBut,resultField){
//alert(curRecordField.name);
//alert(oInstance.span1Id);
   this.but=objBut;
   this.oResultField=resultField;
  
  setDivInCenter(this.divId);
  
  objJobType=document.getElementById(this.divId);
  objJobType.style.display=""; 
   hiddenSelect(this.divId);
  
  return;
}

/**选中某一类型后显示下一级所有类型或没有下级时更改选择结果
@param cityId 选中的类型
@param level 选中的类型所处的级别的下一级别。级别从1开始
*/
function dateCheckedBox(days,strName){
  this.oResultField.value=days;
  this.but.value=strName;
  showSelect(this.divId);  
  divClose(this.divId);
}



function dateClick(days,strName,oInstance){
  oInstance.checkedBox(days,strName);
}

/*显示默认结果
oResultField:保存结果的隐藏域对象
objBut触发选择器的按钮对象
*/
function initDateResult(oResultField,objBut){
   this.oResultField=oResultField;	
   this.but=objBut;
   if(this.oResultField.value==0){
	  this.but.value="近一天";
   }else if(this.oResultField.value==2){
	  this.but.value="近三天";
   }else if(this.oResultField.value==6){
	  this.but.value="近一周";
   }else if(this.oResultField.value==15){
	  this.but.value="近半月";
   }else if(this.oResultField.value==30){
	  this.but.value="近一月";
   }else if(this.oResultField.value==90){
	  this.but.value="近三月";
   }
}