document.write("")
//
var datew=2;
var dateh=5;
var datel=300;
//var isSet=true;//更新时间时使用
var dateObj;//填写时间的对象
var overWidth=0;//溢出宽度
//var oldDateStr="";//原始时间
var dateboxCursor=null;
var inDateHtml="";
function datebox_btn_over(obj){
if(obj.readonly || obj.disabled){
}
else{
dateboxCursor=obj.currentStyle.cursor;
obj.style.cursor="hand"
}
}
function datebox_btn_out(obj){
if(obj.readonly || obj.disabled){
}
else{
obj.style.cursor=dateboxCursor;
dateboxCursor=null;
}
}
function datebox_btn_press(obj){
var t=obj.parentNode.firstChild;
var ieVersion=navigator.appVersion;
//if (true){
if (ieVersion.indexOf("MSIE 5.0")!=-1){
var sPath = "/common/controls/calendar5.jsp";
var dw=285;
var dh=212;
var ex=event.screenX-event.offsetX-2;
var ey=event.screenY-event.offsetY-2;
var strFeatures = "dialogTop="+ey+"px;dialogLeft="+(ex-dw)+"px;dialogWidth="+dw+"px;dialogHeight="+dh+"px;help=no;status: No";
st = t.value;
sDate = showModalDialog(sPath,st,strFeatures);
if (sDate!=null){
t.value = sDate;
}
}
else{
var ex=event.clientX-event.offsetX-3+document.body.scrollLeft;
var ey=event.clientY-event.offsetY-2+document.body.scrollTop;
if (dateboxDiv.style.display==""){
dateboxDiv.style.display="none";
}
if (dateboxDiv.style.display=="none"){
datel=ex;
}
dateboxDiv.style.top=ey+"px";
opendate(t);
dateObj=t;
//oldDateStr=t.value;
//isSet=true;
}
}
function opendate(iobj){
if (dateboxDiv.style.display=="none"){
dopen();
}else{
dateboxDiv.innerHTML="";
dclose();
}
}
function dopen(){
dateboxDiv.style.display="block";
if (datew<242||dateh<145){
dateboxDiv.style.width=datew+"px";
datew=datew+10;
dateboxDiv.style.left=datel+"px";
if (datel>(10+document.body.scrollLeft)){
datel=datel-10;
}else{
overWidth=overWidth+10;
}
dateboxDiv.style.height=dateh+"px";
if (dateh!=145){
dateh=dateh+10;
}
setTimeout("dopen();",1);
}else{
dateboxDiv.innerHTML=inDateHtml;
}
}
function dclose(){
if (datew==2&&dateh==5){
dateboxDiv.style.display="none";
}else{
datew=datew-10;
dateboxDiv.style.width=datew+"px";
datel=datel+10;
if (overWidth!=0){
datel=datel-5;
overWidth=overWidth-5;
}
dateboxDiv.style.left=datel+"px";
if (dateh!=5){
dateh=dateh-10;
}
dateboxDiv.style.height=dateh+"px";
setTimeout("dclose();",1);
}
}
function dateWindowClose(){
dateboxDiv.innerHTML="";
dclose();
}
function checkDateboxIsValidateDate(obj,pattern){
var str=obj.value.trim();
if(str=="") return true;
var b=isValidateDate(str,pattern)
if(!b){
alert("请输入正确的日期\n日期格式:"+pattern+"或yyyy/mm/dd \n例 如:2004-01-09或2004/01/09");
obj.value="";
obj.focus();
}
}
function isValidateDate(str,pattern)
{ var r,d;
if(pattern=="yyyy-mm-dd"){
if(str.length!=pattern.length) return false;
r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if(r==null)return false;
d= new Date(r[1], r[3]-1, r[4]);
return (d.getFullYear()==r[1] && (d.getMonth()+1)==r[3] && d.getDate()==r[4]);
}
}
function closeDatebox(){
try{
if(event.srcElement.name==undefined || event.srcElement.name.indexOf("_datebox_btn")==-1){
dateboxDiv.innerHTML="";
dclose();
}
}catch(e){}
}
function appendDateboxDiv(){
var dateboxDivVar=document.createElement("DIV");
dateboxDivVar.id="dateboxDiv";
dateboxDivVar.className="dateboxDiv";
document.body.appendChild(dateboxDivVar)
}