//★ 日期控件 Version 1.0
// main 中方法
//触发事件源
// JavaScript Document
/*-----------------add by stz 2008-4-8--------------------------
---------------------------------------------------------------------
--------------------------重要说明-----------------------------------
---------------------------------------------------------------------
---------请不要删除注释,以后统一删,现在调试有用!!! 谢谢合作-----------
---------------------------------------------------------------------
---------------------------------------------------------------------
*/
/*-----------------修改js原有类--s---------------------
---------------------------------------------------------------------
---------------------------------------------------------------------*/
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

/*-----------------一些浏览公共的或常用的方法-----------------------*/
//通过id获取页面上的对象，它是唯一的
function $(id){
  return document.getElementById(id); 
}
//通过name获取页面上的对象，页面上可以多个对象用同一个name，这返回一个数组，包含所有名字为name的对象。引用时可以用数组的形式访问按顺序出现的同名对象，如： $s("a")[1]取得第二个名字为a的对象。
function $s(name){
  return document.getElementsByName(name);
}
//列出对象所有属性----测试用
function listAllPara(obj){ //alert(obj);
   var str="";
	for(var i in obj){
		if(checkWebBrouser()!="IE"){
		  str+=i+"<br>   ";
		  if(i%5==0) str+="<br>\n";
		}else{
          str+=i+"|"+obj[i]+"<br>\n";
		}
	}
	alert(str); //ff用这个才不会跳过
	document.write(str);
	return false;
}
function test(){alert(1)}
function listAllPara2(obj){ //alert(obj);
   var str="";
   if(arguments[1]) var showType=arguments[1];
   if(showType && showType==2){ //显示方式2： 当属性值存在时【不包括null但可以为0】才打印出属性和属性值
	   for(var i in obj){
		  if(obj[i] || obj[i]==0) str+="<span style=\"color:#FF0000\">"+ i + "</span> | " + obj[i] + "<br>\n";
	   }
   }else{
	  for(var i in obj){
		 str+="<span style=\"color:#FF0000\">"+ i + "</span> | " + obj[i] + "<br>\n";
	  }
   }
	//alert(str);
  if(!$("msg")){
	if(checkWebBrouser()=="IE"){
	    var newDiv = document.createElement('<div id="msg" style="color: #154BA0; position: absolute; z-index: 40; background-color: #FFFFFF; left:0px; top: 0px; width: 600px; height: 300px; overflow:auto"></div>')
        document.body.insertBefore(newDiv);
	    $("msg").innerHTML=str;
	}else{
		var newDiv = document.createElement('DIV');
		newDiv.id="msg";
		newDiv.style.backgroundColor="#FFFFFF";
		newDiv.style.left="0px";
		newDiv.style.top="0px";
		newDiv.style.width="600px";
		newDiv.style.height="300px";
		newDiv.style.overflow="auto";
		newDiv.style.zIndex =40;
		newDiv.style.position ="absolute";
		  document.body.appendChild(newDiv);
		$("msg").innerHTML=str;
	}
  }else{
	  $("msg").innerHTML=str;
  }
	return false;
}

/*-----------------补充的一些浏览器兼容代码--s-----------------------
---------------------------------------------------------------------
---------------------------------------------------------------------*/
//ff子节点前后经常有#text节点【不是紧挨着的节点，或第一个子节点没有紧挨着父节点的开始标签之后，那就有(不紧挨包括换行,但无论有没有字符，不紧挨着就有且只有一个#text节点;而ie只有在有字符时才有#text节点)】，此方法取子节点排除此bug。 试验页：F:\stz\PMT\pmt-new2008-6-6\pmt-new2.1\psd\textNode.html.
//另：ie中，如果有2个子节点相邻，且前面都有小空格（也可以是换行），那第二个小空格（或换行）算文本节点！， 所以本方法是在所有子节点前都加入文本节点。
function getChildNodes(obj,childOrder){ 
		   /*
			var childNode=obj.childNodes[childOrder];
			while(childNode.nodeType!=1){
			   childNode=childNode.nextSibling;
			}
			*/
	var childNode=obj.childNodes[childOrder]; //alert(childNode.tagName); return;
	//if(checkWebBrouser()=="IE"){
		var pChilds=obj.childNodes, j=pChilds.length;
		for(var i=0; i<j; i++){ //alert(pChilds.length);
	 //	alert(pChilds[i].nodeType);
			if(pChilds[i].nodeType==1 && i%2==0){ //i%2==0 奇数位置的元素。
				obj.insertBefore(document.createTextNode(" "),pChilds[i]);
				i++;
				j++;
				pChilds=obj.childNodes;
			}
		}
		
	//}alert(obj.childNodes[0].nodeType);
// alert(obj.childNodes.length); //obj.childNodes.length  obj.childNodes[4].nodeType
	return obj.childNodes[2*childOrder+1]; //obj.childNodes[childOrder+childOrder+1]演变
}
//检查浏览器 navigator.userAgent
function checkWebBrouser(){
   if(navigator.userAgent.indexOf("MSIE")>0){
        return "IE";
   } 
   if(navigator.userAgent.indexOf("Firefox")>0){
        return "FF";
   } 
   if(navigator.userAgent.indexOf("Safari")>0){
        return "Safari";
   }  
   if(navigator.userAgent.indexOf("Camino")>0){
        return "Camino";
   } 
   if(navigator.userAgent.indexOf("Gecko")>0){
        return "Gecko";
   }
}
//这个函数用来判断ie的版本。仅在checkWebBrouser()的判断为IE的条件里使用
function getIEVersion()
{
	var verStr=navigator.appVersion;
	if(checkWebBrouser()=="IE") 
    {
           if(verStr.match(/6./i)=='6.') 
           {
                return "IE6";
           }
		 if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1)
           return "IE5.1";
    }
}
//注册firefox innerText 
if(checkWebBrouser()!="IE"){
HTMLElement.prototype.__defineGetter__("innerText", 
function(){ 
  var anyString = ""; 
  var childS = this.childNodes; 
  for(var i=0; i<childS.length; i++) {
	if(childS[i].nodeType==1) 
      anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText; 
    else if(childS[i].nodeType==3) 
      anyString += childS[i].nodeValue; 
  } 
  return anyString;
 }
);
HTMLElement.prototype.__defineSetter__("innerText", 
 function(sText){ 
   this.textContent=sText; 
 } 
);
} //if(checkWebBrouser()!="IE")


//attach事件兼容
function addEvent(oElement,sEvent,func){ 
  if (oElement.attachEvent){ 
    oElement.attachEvent(sEvent,func); 
  } 
  else{
    sEvent=sEvent.substring(2,sEvent.length); 
    oElement.addEventListener(sEvent,func,false); 
  } 
}
function removeEvent(oTarget, sEventType, fnHandler) { //alert(1);
    if (oTarget.removeEventListener) {
        oTarget.removeEventListener(sEventType, fnHandler, false);
    } else if (oTarget.detachEvent) {
        oTarget.detachEvent("on" + sEventType, fnHandler);
    } else { 
        oTarget["on" + sEventType] = null;
    }
}
//触发事件源
function eventMatchObj(e){ 
  //var webBrouser=checkWebBrouser(); 
  if(window.event){  //webBrouser=="IE";
	  return e.srcElement;
  }else if(e.target){  //alert(e.target.tagName);
	  return e.target;
  }
}

//支持事件类型
function eventMatch(e){ 
  //var webBrouser=checkWebBrouser(); 
  if(window.event){  //webBrouser=="IE";
	  return "winEvent";
  }else if(e.target){  //alert(e.target.tagName);
	  return "Target";
  }
}
//browser  position :
GetoffsetLeft = function(theObject)
	{ //return theObject's absolute offsetLeft .  translate by stz: 返回对象在页面中的绝对左距离

		var absLeft = 0; 

		var thePosition=""; 

		var tmpObject = theObject; 

		while (tmpObject != null)
		{
			thePosition = tmpObject.position; 
			tmpObject.position = "static"; 
			absLeft += tmpObject.offsetLeft; 
			tmpObject.position = thePosition; 
		 	tmpObject = tmpObject.offsetParent; 
		}
		return absLeft; 
	} 

GetoffsetTop = function(theObject)
	{ //return theObj's absolute offsetTop 
		var absTop = 0; 
		var thePosition = ""; 
		var tmpObject = theObject; 
		while (tmpObject != null)
		{ 
			thePosition = tmpObject.position; 
			tmpObject.position = "static"; 
			absTop += tmpObject.offsetTop; 
			tmpObject.position = thePosition; 
			tmpObject = tmpObject.offsetParent; 
		} 
		return absTop; 
	}
/*------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------*/
//切换图片
function changeImg(e,oldimg,newimg){
	var eventobj=eventMatchObj(e);
	eventobj.src=eventobj.src.replace(oldimg,newimg);
}
function changeImg2(imgid,oldimg,newimg){
	var srcobj=$(imgid);
	srcobj.src=srcobj.src.replace(oldimg,newimg);
}

//topdownlistarrow_iframe  下拉列表
function showiframe(e,ifid){
	var eventobj=eventMatchObj(e); //table
	var iframe=$(ifid);
	if(iframe.style.display=="none"){
	   iframe.style.display="";
	   if(checkWebBrouser()=="IE"){
	   iframe.style.left=GetoffsetLeft(eventobj)-5;
	   iframe.style.top=GetoffsetTop(eventobj)+eventobj.offsetHeight;
	   }else{ //alert(1);
		   iframe.style.left=GetoffsetLeft(eventobj);
	       iframe.style.top=GetoffsetTop(eventobj)+eventobj.offsetHeight;
	   }
	}else{
	    iframe.style.display="none"
	}
}

function evaluateDonwList(e,downlisttdid){
   $(downlisttdid).innerText=eventMatchObj(e).innerText;	
}
function showPopDiv(e,divId,showMode,path){ //alert(2);return;
	var div=$(divId), divMarkId=divId+"_mark";
	if(div.style.display=="" || div.style.display=="block" ){
		div.style.display="none";
		closeMarkDiv(e,divMarkId);
	}else{
		div.style.display="";
		div.style.zIndex =101;
		if(showMode==1){
			div.style.top="125px";
			div.style.left=(parseInt(document.body.scrollWidth)-parseInt(div.clientWidth))/2+"px";
		}
		showMarkDiv(e,divMarkId,path);
	}
}
// 背景半透明遮罩层-----------------------------------------------------
function showMarkDiv(e,divMarkId,path){
	var div_mark=$(divMarkId);
	if(!div_mark){
		var newDiv = document.createElement('DIV');
		newDiv.id=divMarkId;
		newDiv.style.backgroundColor="#000";
		newDiv.style.left="0px";
		newDiv.style.top="0px";
		newDiv.style.width="100%";
		newDiv.style.height=document.body.scrollHeight;
		newDiv.style.overflow="hidden";
		newDiv.style.zIndex =100;
		newDiv.style.position ="absolute";
		newDiv.className="alpha70p";
		newDiv.innerHTML="<img src='"+ path +"/none.gif' width='"+ document.body.scrollWidth +"' height='"+ document.body.scrollHeight +"'></img>";
		  document.body.appendChild(newDiv);
	}else{
		$(divMarkId).style.display="";
		
	}
}
function closeMarkDiv(e,divMarkId){
	$(divMarkId).style.display="none";
}
//表格行变色
function tdoverclass(obj){
	obj.style.backgroundColor="#0066FF";
	obj.style.color="#fff";
	obj.style.cursor='pointer';
}
function tdnormalclass(obj){
	obj.style.backgroundColor="#fff";
	obj.style.color="#000";
}
//
function submit_serchForm(formId){
	var form=$(formId);
	form.submit();
}
/*+++++++++++++++++++++++++++++++++++++++++++++  new +++++++++++++++++++++++++++++++++++++++++++++ 
+++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++ 
+++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++ */
//显示层, 若有第二个参数则表示要换箭头符号的控件。
function showDiv(divId){
	var div=$(divId),arrow=null;
	if(arguments[1]){
        arrow=$(arguments[1]);
	}

	if(div.style.display=='' ||div.style.display=='block'){
		div.style.display='none';
		if(arrow) arrow.innerText="►";
	}else{
		div.style.display='';
		if(arrow) arrow.innerText="▼";
	}
}

/*-----------------tab页效果---------------------------------*/
var CurComId=1,widthed=0;
function switchComment(Id,tabbar){
	var tab=$("tab");
	for(var i=0;i<tab.childNodes.length;i++) {
		if(tab.childNodes[i].className!="horizontalSpace")
		tab.childNodes[i].className="unitOff"	
	}//alert(tabbar.outerHTML);
	tabbar.className="unitOn"

	if (Id!=CurComId){
		eval("document.getElementById('tab" + Id.toString() + "').style.display='block';");
		eval("document.getElementById('tab" + CurComId.toString() + "').style.display='none';");
		CurComId=Id;
	} 
}
function switchComment2(Id,tabbar){
	var tab=$("tab"), imgBg=tab.style.backgroundImage; //alert(imgBg.substring(imgBg.indexOf("."),imgBg.length));
	var imgNumPos=imgBg.lastIndexOf("."); //alert(imgBg.substring(imgNumPos-1,imgNumPos)); return;
	tab.style.backgroundImage=imgBg.replace(imgBg.substring(imgNumPos-1,imgNumPos),Id);
	//tab.style.backgroundImage=imgBg.replace(imgBg.substr(imgBg.length),Id);
	if (Id!=CurComId){
		eval("document.getElementById('tab" + Id.toString() + "').style.display='block';");
		eval("document.getElementById('tab" + CurComId.toString() + "').style.display='none';");
		CurComId=Id;
	}
}

function showFAQlist(curObj){
	var oprObj=curObj.nextSibling; 
	while(oprObj.nodeType!=1){
		oprObj=oprObj.nextSibling; 
	}//alert(oprObj.nodeType); return;//.parentNode.childNodes[1]  word_bold cursorHand
	if(oprObj.style.display==""){
		oprObj.style.display="none";
		curObj.className="word_bold cursorHand";
	}else{
		oprObj.style.display="";
		curObj.className="word_666 word_bold cursorHand"; //word_black
	}
}




//兼容的取年方法： getFullYear 代替 getYear !!
// main 中方法end



function showMark(oInstance){ //ie6 解决select挡住div问题。
	if(getIEVersion()=="IE6"){
	  var CalendarDiv=$(oInstance.sDIVID);
	  var maskDiv=document.getElementById("bottom_"+ oInstance.sDIVID);
			   if(CalendarDiv.style.display=="none")
			     maskDiv.style.visibility="hidden";
			   else
			      maskDiv.style.visibility="visible";
	}
}
//以上 +stz

function PopupCalendar(InstanceName)
{   
	///Global Tag
	this.instanceName=InstanceName;
	///Properties
	this.separator="-";
	this.separatorTime=":"; //+stz 时间分隔符
	this.canmove=false; //+stz  控件层是否可拖动
	this.oBtnTodayTitle="Today";
	this.oBtnCancelTitle="Cancel";
	this.weekDaySting=new Array("S","M","T","W","T","F","S");
	this.monthSting=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	this.Width=300;
	this.currDate=new Date();
	this.today=new Date();
	this.startYear=1970;
	this.endYear=2010;
	///Css
	this.normalfontColor="#666666";
	this.selectedfontColor="red";
	this.divBorderCss="1px solid #BCD0DE";
	this.titleTableBgColor="#E8F1FF";
	this.tableBorderColor="#CCCCCC"
	///Method
	this.Init=CalendarInit; //初始化函数
	this.Fill=CalendarFill;
	this.Refresh=CalendarRefresh;
	this.Restore=CalendarRestore;
	///HTMLObject
	this.oTaget=null;
	this.oPreviousCell=null;
	this.sDIVID=InstanceName+"_Div";
	this.sTABLEID=InstanceName+"_Table";
	this.sMONTHID=InstanceName+"_Month";
	this.sYEARID=InstanceName+"_Year";
	this.sTODAYBTNID=InstanceName+"_TODAYBTN";
	//add by stz
	this.sHOURID=InstanceName+"_Hour";
	this.sMINUTEID=InstanceName+"_Minute";
	this.sSECONDID=InstanceName+"_Second";
	this.movePicPath="";

}
function CalendarInit()				///Create panel
{
	var sMonth,sYear
	sMonth=this.currDate.getMonth();
	sYear=this.currDate.getFullYear();
	htmlAll="<div id='"+this.sDIVID+"' style='display:none;position:absolute; z-index:1000; width:"+this.Width+"px;border:"+this.divBorderCss+";padding:2px;background-color:#FFFFFF; left:0px; top:0px;'>"; //moveStart(event,\'"+ this.sDIVID +"\'); ondeactivate ='alert(1)'
	htmlAll+="<div align='center'>";
	/// Month
	if(this.canmove){  //alert(this.movePicPath);
	htmloMonth="<select id='"+this.sMONTHID+"' onchange=CalendarMonthChange("+this.instanceName+") style='width:25%'>"; //<img src='"+ this.movePicPath +"moveCursor.gif' width=17 height=17 style='cursor:move'  onmousedown='moveStart(event,\""+ this.sDIVID +"\");' onmouseup='moveEnd(\""+ this.sDIVID +"\")'> 
	}else{
		htmloMonth="<select id='"+this.sMONTHID+"' onchange=CalendarMonthChange("+this.instanceName+") style='width:25%'>"; 
	}
	for(i=0;i<12;i++)
	{
		htmloMonth+="<option value='"+i+"'>"+this.monthSting[i]+"</option>";
	}
	htmloMonth+="</select>";
	/// Year
	htmloYear="<select id='"+this.sYEARID+"' onchange=CalendarYearChange("+this.instanceName+") style='width:25%'>";
	for(i=this.startYear;i<=this.endYear;i++)
	{
		htmloYear+="<option value='"+i+"'>"+i+"</option>";
	}
	htmloYear+="</select>"; //alert(this.currDate.getHours());
	
	if(this.instanceName=="oCalendarChs"){
		htmloYear+=" <input id='"+this.sHOURID+"' value="+ this.currDate.getHours() +" maxlength=2   class='input_time'>时 <input id='"+this.sMINUTEID+"' value="+ this.currDate.getMinutes() +" maxlength=2  class='input_time'>分 <input id='"+this.sSECONDID+"' value="+ this.currDate.getSeconds() +" maxlength=2 class='input_time'>秒</div>"; //+stz
	}else{
		htmloYear+=" <input id='"+this.sHOURID+"' value="+ this.currDate.getHours() +" maxlength=2   class='input_time'> H <input id='"+this.sMINUTEID+"' value="+ this.currDate.getMinutes() +" maxlength=2  class='input_time'> M <input id='"+this.sSECONDID+"' value="+ this.currDate.getSeconds() +" maxlength=2 class='input_time'> S</div>"; //+stz
	}
	
	
	
	/// Day
	htmloDayTable="<table id='"+this.sTABLEID+"' width='100%' border=0 cellpadding=0 cellspacing=1 bgcolor='"+this.tableBorderColor+"'>";
	htmloDayTable+="<tbody bgcolor='#ffffff'style='font-size:13px'>";
	for(i=0;i<=6;i++)
	{
		if(i==0)
			htmloDayTable+="<tr bgcolor='" + this.titleTableBgColor + "'>";
		else
			htmloDayTable+="<tr>";
		for(j=0;j<7;j++)
		{

			if(i==0)
			{
				htmloDayTable+="<td height='20' align='center' valign='middle' style='cursor:pointer'>";
				htmloDayTable+=this.weekDaySting[j]+"</td>"
			}
			else
			{
				htmloDayTable+="<td height='20' align='center' valign='middle' style='cursor:pointer'";
				htmloDayTable+=" onmouseover=CalendarCellsMsOver(event,"+this.instanceName+")";
				htmloDayTable+=" onmouseout=CalendarCellsMsOut(event,"+this.instanceName+")";
				htmloDayTable+=" onclick=CalendarCellsClick(this,"+this.instanceName+")>";
				htmloDayTable+="&nbsp;</td>"
			}
		}
		htmloDayTable+="</tr>";
	}
	htmloDayTable+="</tbody></table>";
	/// Today Button
	htmloButton="<div align='center' style='padding:3px'>"
	htmloButton+="<button id='"+this.sTODAYBTNID+"' style='width:40%;border:1px solid #BCD0DE;background-color:#eeeeee;cursor:pointer'"
	htmloButton+=" onclick=CalendarTodayClick("+this.instanceName+")>"+this.oBtnTodayTitle  +"</button>&nbsp;"
	htmloButton+="<button style='width:40%;border:1px solid #BCD0DE;background-color:#eeeeee;cursor:pointer'"
	htmloButton+=" onclick=CalendarCancel("+this.instanceName+");CalendarClear("+this.instanceName+")>"+this.oBtnCancelTitle+"</button> "
	htmloButton+="</div>"
	/// All
	htmlAll=htmlAll+htmloMonth+htmloYear+htmloDayTable+htmloButton+"</div>"; //$("msg").innerHTML=htmlAll;
	//document.write("asdf<a href='#'>111111aaaaaaaa</a>");
	document.write(htmlAll); //document.write("|stz|"+htmlAll); $("msg").innerText=htmlAll; return;
	//$("msg").innerText=htmlAll;
//	document.body.insertAdjacentHTML("beforeEnd",htmlAll); //mfy +stz
 	this.Fill();
}
function CalendarFill()			///
{
	var sMonth,sYear,sWeekDay,sToday,oTable,currRow,MaxDay,iDaySn,sIndex,rowIndex,cellIndex,oSelectMonth,oSelectYear;
	sMonth=this.currDate.getMonth();
	sYear=this.currDate.getFullYear(); //alert(sYear);  getYear在ie里不同
	sWeekDay=(new Date(sYear,sMonth,1)).getDay();
	sToday=this.currDate.getDate();
	iDaySn=1; //alert(this.sTABLEID);
	oTable=$(this.sTABLEID);
	currRow=oTable.rows[1];
	MaxDay=CalendarGetMaxDay(sYear,sMonth);

	oSelectMonth=$(this.sMONTHID)
	oSelectMonth.selectedIndex=sMonth;
	oSelectYear=$(this.sYEARID)
	for(i=0;i<oSelectYear.length;i++)
	{
		if(parseInt(oSelectYear.options[i].value)==sYear)oSelectYear.selectedIndex=i;
	}
	////
	for(rowIndex=1;rowIndex<=6;rowIndex++)
	{
		if(iDaySn>MaxDay)break;
		currRow = oTable.rows[rowIndex];
		cellIndex = 0;
		if(rowIndex==1)cellIndex = sWeekDay;
		for(;cellIndex<currRow.cells.length;cellIndex++)
		{
			if(iDaySn==sToday)
			{
				currRow.cells[cellIndex].innerHTML="<font color='"+this.selectedfontColor+"'><i><b>"+iDaySn+"</b></i></font>";
				this.oPreviousCell=currRow.cells[cellIndex];
			}
			else
			{
				currRow.cells[cellIndex].innerHTML=iDaySn;
				currRow.cells[cellIndex].style.color=this.normalfontColor;
			}
			CalendarCellSetCss(0,currRow.cells[cellIndex]);
			iDaySn++;
			if(iDaySn>MaxDay)break;
		}
	}
}
function CalendarRestore()					/// Clear Data
{
	var i,j,oTable
	oTable=$(this.sTABLEID)
	for(i=1;i<oTable.rows.length;i++)
	{
		for(j=0;j<oTable.rows[i].cells.length;j++)
		{
			CalendarCellSetCss(0,oTable.rows[i].cells[j]);
			oTable.rows[i].cells[j].innerHTML="&nbsp;";
		}
	}
}
function CalendarRefresh(newDate)					///
{
	this.currDate=newDate; //alert(newDate);
	this.Restore();
	this.Fill();
}
function CalendarCellsMsOver(e,oInstance)				/// Cell MouseOver
{
	var myCell = eventMatchObj(e); //event.srcElement;
	CalendarCellSetCss(0,oInstance.oPreviousCell);
	if(myCell)
	{
		CalendarCellSetCss(1,myCell);
		oInstance.oPreviousCell=myCell;
	}
}
function CalendarCellsMsOut(e,oInstance)				////// Cell MouseOut
{
	var myCell = eventMatchObj(e);
	CalendarCellSetCss(0,myCell);
}
function CalendarYearChange(oInstance)				/// Year Change
{
	var sDay,sMonth,sYear,newDate
	sDay=oInstance.currDate.getDate();
	sMonth=oInstance.currDate.getMonth();
	sYear=$(oInstance.sYEARID).value
	newDate=new Date(sYear,sMonth,sDay);
	oInstance.Refresh(newDate);
}
function CalendarMonthChange(oInstance)				/// Month Change
{
	var sDay,sMonth,sYear,newDate
	sDay=oInstance.currDate.getDate();
	sMonth=$(oInstance.sMONTHID).value
	sYear=oInstance.currDate.getFullYear();
	newDate=new Date(sYear,sMonth,sDay);
	oInstance.Refresh(newDate);
}
function checkTime(sHour,sMinute,sSecond,oInstance){ //参数是input里填的时间
	var oldTime=new Array(oInstance.currDate.getHours(),oInstance.currDate.getMinutes(),oInstance.currDate.getSeconds()); //初始化时的时间
	var r,re;  
    re=/\d/i;
	r=sHour.match(re);
	if(r!=null && sHour>=0 && sHour<24 && sHour!="") oldTime[0]=sHour;
	else document.getElementById(oInstance.sHOURID).value=oldTime[0];
	r=sMinute.match(re);
	if(r!=null && sMinute>=0 && sMinute<59 && sMinute!="" ) oldTime[1]=sMinute;
	else document.getElementById(oInstance.sMINUTEID).value=oldTime[1];
	r=sSecond.match(re);
	if(r!=null && sSecond>=0 && sSecond<59 && sSecond!="" ) oldTime[2]=sSecond;
	else document.getElementById(oInstance.sSECONDID).value=oldTime[2];
	return oldTime;
}//+stz
function CalendarCellsClick(oCell,oInstance)
{
	var sDay,sMonth,sYear,  sHour,sMinute,sSecond,newDate;
	sYear=oInstance.currDate.getFullYear();
	sMonth=oInstance.currDate.getMonth();
	sDay=oInstance.currDate.getDate();
	//+stz
	sHour=document.getElementById(oInstance.sHOURID).value.trim();//oInstance.currDate.getHours();
	sMinute=document.getElementById(oInstance.sMINUTEID).value.trim();//oInstance.currDate.getMinutes();
	sSecond=document.getElementById(oInstance.sSECONDID).value.trim();//oInstance.currDate.getSeconds();
	//+stz
	
	var checkedTime=checkTime(sHour,sMinute,sSecond,oInstance);
	sHour=checkedTime[0];
	sMinute=checkedTime[1];
	sSecond=checkedTime[2];
	//ie 只要判断 oCell.innerText!=" "
	//alert(parseInt(oCell.innerText));
	if(parseInt(oCell.innerText))
	{ //alert(oCell.childNodes[0].nodeType);
		sDay=parseInt(oCell.innerText);
		if(sDay!=oInstance.currDate.getDate())
		{
			newDate=new Date(sYear,sMonth,sDay,sHour,sMinute,sSecond);
			oInstance.Refresh(newDate);
		}
	}
	sDateString=sYear+oInstance.separator+CalendarDblNum(sMonth+1)+oInstance.separator+CalendarDblNum(sDay)+ " "+CalendarDblNum(sHour)+oInstance.separatorTime+CalendarDblNum(sMinute)+oInstance.separatorTime+CalendarDblNum(sSecond)  ;	 //alert(sDateString);	///+stz return sDateString
	if(oInstance.oTaget.tagName.toLowerCase()=="input") oInstance.oTaget.value = sDateString;
	CalendarCancel(oInstance);
	return sDateString;
}
function CalendarTodayClick(oInstance)				/// "Today" button Change
{
   
	oInstance.Refresh(new Date());
	// add by stz
	var sDay,sMonth,sYear,  sHour,sMinute,sSecond,newDate;
	sYear=oInstance.currDate.getFullYear();
	sMonth=oInstance.currDate.getMonth();
	sDay=oInstance.currDate.getDate();
	sHour=document.getElementById(oInstance.sHOURID).value.trim();//oInstance.currDate.getHours();
	sMinute=document.getElementById(oInstance.sMINUTEID).value.trim();//oInstance.currDate.getMinutes();
	sSecond=document.getElementById(oInstance.sSECONDID).value.trim();//oInstance.currDate.getSeconds();
	var checkedTime=checkTime(sHour,sMinute,sSecond,oInstance);
	sHour=checkedTime[0];
	sMinute=checkedTime[1];
	sSecond=checkedTime[2];
	sDateString=sYear+oInstance.separator+CalendarDblNum(sMonth+1)+oInstance.separator+CalendarDblNum(sDay)+ " "+CalendarDblNum(sHour)+oInstance.separatorTime+CalendarDblNum(sMinute)+oInstance.separatorTime+CalendarDblNum(sSecond);
	if(oInstance.oTaget.tagName.toLowerCase()=="input") oInstance.oTaget.value = sDateString;
	CalendarCancel(oInstance);
	// add by stz
}

function getDateString(oInputSrc,oInstance,content)
{ //content指定控件所在的父元素中 第一个带滚动条的父元素
	//alert(oInputSrc); alert(oInstance);
	//alert(22); return;
	if(oInputSrc&&oInstance)
	{
		var CalendarDiv=$(oInstance.sDIVID);
		oInstance.oTaget=oInputSrc;
	 
		/* mfb +stz*/
		//	alert(CalendargetPos(oInputSrc,"Left")+oInstance.Width); // alert(screen.width)
		CalendarDiv.style.display="";
		CalendarDiv.style.pixelLeft=-oInstance.Width-100;
		CalendarDiv.style.pixelTop=-CalendarDiv.offsetHeight-100;
		// alert(CalendarDiv);
		if(checkWebBrouser()!="IE"){
			CalendarDiv.style.left=-oInstance.Width-100;
		    CalendarDiv.style.top=-CalendarDiv.offsetHeight-100;
		}
		//alert(CalendarDiv.scrollHeight); //alert(CalendarDiv.clientHeight);  alert(CalendarDiv.offsetHeight); 
		var posleft=CalendargetPos(oInputSrc,"Left"), postop=CalendargetPos(oInputSrc,"Top") + oInputSrc.offsetHeight;
	//	CalendarDiv.style.display=(CalendarDiv.style.display=="none")?"":"none";
		//if(!content){
		//}else{
		  var content=$(content); 
		//}
		if(!content) content=document.body;
	    if(CalendarDiv.style.pixelLeft<0){ //显示或隐藏【其实是移动到负的一段的距离】
			if(content!=document.body){ //alert(1);
				if(posleft+oInstance.Width <content.scrollWidth){
					CalendarDiv.style.left=posleft-content.scrollLeft+"px";
					CalendarDiv.style.top=postop-content.scrollTop+"px"; //pixelTop
				}else{
					CalendarDiv.style.left=content.offsetWidth+parseInt(content.currentStyle.paddingLeft)+parseInt(content.currentStyle.paddingRight)-oInstance.Width+"px";  //中间多那些是因为content的scrollWidth没算入padding的空间
					CalendarDiv.style.top=postop-content.scrollTop+"px";
				}
			}else{ // if(content!=document.body)
				if(posleft+oInstance.Width <content.scrollWidth){
					if(postop+CalendarDiv.clientHeight<content.scrollHeight){
						CalendarDiv.style.left=posleft+"px";
						CalendarDiv.style.top=postop+"px";
				    }else{
						CalendarDiv.style.left=posleft+"px";
						CalendarDiv.style.top=CalendargetPos(oInputSrc,"Top")-CalendarDiv.offsetHeight+"px";
				    }
				}else{
					if(postop+CalendarDiv.clientHeight<content.scrollHeight){
						CalendarDiv.style.left=content.scrollWidth-oInstance.Width+"px"; 
						CalendarDiv.style.top=postop+"px"; 
				    }else{
						CalendarDiv.style.left=content.scrollWidth-oInstance.Width+"px";
						CalendarDiv.style.top=CalendargetPos(oInputSrc,"Top")-CalendarDiv.offsetHeight+"px";
				    }
				}
			}
		}else{
			CalendarDiv.style.left=-oInstance.Width-100+"px";
		    CalendarDiv.style.top=-CalendarDiv.offsetHeight-100+"px";
		}
		if(getIEVersion()=="IE6"){ //+stz 解决ie6 层被select挡住的bug
		//alert(1);
		   var maskDiv=document.getElementById("bottom_"+ oInstance.sDIVID);
		   if(!maskDiv){
		   var framemask = "<iframe src='' frameborder='0' id='bottom_"+ oInstance.sDIVID +"'  style='visibility:visible;position:absolute;width:0px;height:0px;left:0px;top:0px;background-color:#ffffff; z-index:999'></iframe>" // allowtransparency='true'
		   document.body.insertAdjacentHTML("beforeEnd", framemask);
		   maskDiv=document.getElementById("bottom_"+ oInstance.sDIVID);
		   maskDiv.style.width = CalendarDiv.offsetWidth; 
			maskDiv.style.height = CalendarDiv.offsetHeight;
			maskDiv.style.left = CalendarDiv.style.pixelLeft;
			maskDiv.style.top = CalendarDiv.style.pixelTop;
			
			if(content!=document.body){ //alert(1);
				if(posleft+oInstance.Width <content.scrollWidth){  //alert(2);
					//maskDiv.style.left=posleft-content.scrollLeft; //alert(postop-content.scrollTop);
					//maskDiv.style.top=postop-content.scrollTop;
					maskDiv.style.left=posleft-content.scrollLeft;//alert(postop-content.scrollTop);
					maskDiv.style.top=postop-content.scrollTop;
				}else{ //alert(3);
					maskDiv.style.pixelLeft=content.offsetWidth+parseInt(content.currentStyle.paddingLeft)+parseInt(content.currentStyle.paddingRight)-oInstance.Width;  //中间多那些是因为content的scrollWidth没算入padding的空间
					maskDiv.style.pixelTop=postop-content.scrollTop;
				}
			}
			//alert(maskDiv);
		   }else{
			  showMark(oInstance);
			  //-------这段和上面的完全一样
			  if(content!=document.body){ //alert(1);
				if(posleft+oInstance.Width <content.scrollWidth){  //alert(2);
					//maskDiv.style.left=posleft-content.scrollLeft; //alert(postop-content.scrollTop);
					//maskDiv.style.top=postop-content.scrollTop;
					maskDiv.style.left=posleft-content.scrollLeft;//alert(postop-content.scrollTop);
					maskDiv.style.top=postop-content.scrollTop;
				}else{ //alert(3);
					maskDiv.style.pixelLeft=content.offsetWidth+parseInt(content.currentStyle.paddingLeft)+parseInt(content.currentStyle.paddingRight)-oInstance.Width;  //中间多那些是因为content的scrollWidth没算入padding的空间
					maskDiv.style.pixelTop=postop-content.scrollTop;
				}
			}
			//-------这段和上面的完全一样
		   }
		}
	//	CalendarDiv.focus();
	}
}

function CalendarCellSetCss(sMode,oCell)			/// Set Cell Css
{
	// sMode
	// 0: OnMouserOut 1: OnMouseOver
	if(sMode)
	{
		oCell.style.border="1px solid #5589AA";
		oCell.style.backgroundColor="#BCD0DE";
	}
	else
	{
		oCell.style.border="1px solid #FFFFFF";
		oCell.style.backgroundColor="#FFFFFF";
	}
}
function CalendarGetMaxDay(nowYear,nowMonth)			/// Get MaxDay of current month
{
	var nextMonth,nextYear,currDate,nextDate,theMaxDay
	nextMonth=nowMonth+1;
	if(nextMonth>11)
	{
		nextYear=nowYear+1;
		nextMonth=0;
	}
	else
	{
		nextYear=nowYear;
	}
	currDate=new Date(nowYear,nowMonth,1);
	nextDate=new Date(nextYear,nextMonth,1);
	theMaxDay=(nextDate-currDate)/(24*60*60*1000);
	return theMaxDay;
}
function CalendargetPos(el,ePro)				/// Get Absolute Position
{
	var ePos=0;
	while(el!=null)
	{
		ePos+=el["offset"+ePro];
		el=el.offsetParent;
	}
	return ePos;
}
function CalendargetScroll(el,ePro)				/// +stz
{
	var ePos=0;
	while(el!=null)
	{
		ePos+=el["scroll"+ePro];
		el=el.offsetParent;
	}
	return ePos;
}
function CalendarDblNum(num)
{
	if(num < 10)
		return "0"+num;
	else
		return num;
}
function CalendarCancel(oInstance)			///Cancel
{
	var CalendarDiv=$(oInstance.sDIVID);
	CalendarDiv.style.display="none";
	showMark(oInstance);
}
function CalendarClear(oInstance)
{
    oInstance.oTaget.value="";
}