
var IBUtils={setClass:function(elm,cls){elm.className=cls;elm.setAttribute("class",cls);},evtSrcElement:function(evt){evt=evt?evt:(window.event?window.event:null);return evt.srcElement?evt.srcElement:evt.target;},isContains:function(elmRoot,elmSub){var contains=(elmRoot==elmSub);while(!contains&&elmSub.parentNode!=null&&elmSub.parentNode!=elmSub){elmSub=elmSub.parentNode;contains=(elmRoot==elmSub);}
return contains;},addMouseOver:function(elm,func){if(elm.m_arrOnMouseOver==null){elm.m_arrOnMouseOver=new Array();elm.onmouseover=function(evt){var i;for(i=0;i<this.m_arrOnMouseOver.length;i++)this.m_arrOnMouseOver[i](this,evt);}}
elm.m_arrOnMouseOver[elm.m_arrOnMouseOver.length]=func;},addMouseOut:function(elm,func){if(elm.m_arrOnMouseOut==null){elm.m_arrOnMouseOut=new Array();elm.onmouseout=function(evt){var i;for(i=0;i<this.m_arrOnMouseOut.length;i++)this.m_arrOnMouseOut[i](this,evt);}}
elm.m_arrOnMouseOut[elm.m_arrOnMouseOut.length]=func;},addMouseDown:function(elm,func){if(elm.m_arrOnMouseDown==null){elm.m_arrOnMouseDown=new Array();elm.onmousedown=function(evt){var i;for(i=0;i<this.m_arrOnMouseDown.length;i++)this.m_arrOnMouseDown[i](this,evt);}}
elm.m_arrOnMouseDown[elm.m_arrOnMouseDown.length]=func;},addMouseUp:function(elm,func){if(elm.m_arrOnMouseUp==null){elm.m_arrOnMouseUp=new Array();elm.onmouseup=function(evt){var i;for(i=0;i<this.m_arrOnMouseUp.length;i++)this.m_arrOnMouseUp[i](this,evt);}}
elm.m_arrOnMouseUp[elm.m_arrOnMouseUp.length]=func;},addClick:function(elm,func){if(elm.m_arrOnClick==null){elm.m_arrOnClick=new Array();elm.onclick=function(evt){var i;for(i=0;i<this.m_arrOnClick.length;i++)this.m_arrOnClick[i](this,evt);}}
elm.m_arrOnClick[elm.m_arrOnClick.length]=func;},attachCal:function(elm,format,className,baseurl,funcValueChanged){if(!elm.selector)
elm=$(elm);elm.each(function(i){if(this.m_calsel==null)
new IBCalSel(this,format,className,baseurl,funcValueChanged);});},invokeFunc:function(func){var code=func;code+='(';for(var i=1;i<arguments.length;i++){if(i!=1)
code+=', ';code+='"';code+=escape(arguments[i]);code+='"';}
code+=');';return function(){eval(code)};}}
var IBCMenu={menuClickFunc:function(allowSelSub){return function(elm,evt){IBCMenu.menuClick(IBUtils.evtSrcElement(evt),elm,allowSelSub);}},menuClick:function(elm,holderElm,allowSelSub){if(elm==null||elm==holderElm)
return;if(elm.m_option!=null){if(elm.m_option.type=="option")
if(elm.m_option.sub==null||allowSelSub){if(holderElm.m_cascadedMenu.onSelect!=null)
holderElm.m_cascadedMenu.onSelect(elm.m_option.value);holderElm.m_cascadedMenu.hide();}
return;}
if(elm.parentNode!=null&&elm.parentNode!=elm)
IBCMenu.menuClick(elm.parentNode,holderElm,allowSelSub);},menuMouseOverFunc:function(){return function(elm,evt){IBCMenu.menuMouseOver(IBUtils.evtSrcElement(evt),elm);}},menuMouseOver:function(elm,holderElm){holderElm.m_overTime=new Date().getTime();if(elm==null||elm==holderElm)
return;if(elm.m_option!=null&&(elm.m_option.type=='option'||elm.m_option.type=='sub')){if(elm.m_menu.m_lastHighLight!=null){if(elm.m_menu.m_lastHighLight==elm)
return;IBUtils.setClass(elm.m_menu.m_lastHighLight,"normal");if(elm.m_menu.m_lastHighLight.m_sub!=null)
elm.m_menu.m_lastHighLight.m_sub.hide();elm.m_menu.m_lastHighLight=null;}
IBUtils.setClass(elm,"highlight");if(elm.m_sub!=null)
elm.m_sub.show();elm.m_menu.m_lastHighLight=elm;return;}
if(elm.parentNode!=null&&elm.parentNode!=elm)
IBCMenu.menuMouseOver(elm.parentNode,holderElm);},menuMouseOutFunc:function(){return function(elm,evt){IBCMenu.menuMouseOut(IBUtils.evtSrcElement(evt),elm);}},checkClose:function(holderElm){return function(){if(holderElm.m_outTime>holderElm.m_overTime)
holderElm.m_cascadedMenu.hide();}},menuMouseOut:function(elm,holderElm){holderElm.m_outTime=new Date().getTime();setTimeout(IBCMenu.checkClose(holderElm),100);},setOptionsParent:function(options,parent){if(options==null)
return;var i;for(i=0;i<options.length;i++){if(options[i].oparent==null){options[i].oparent=parent;if(options[i].sub)
IBCMenu.setOptionsParent(options[i].sub,options[i]);}}},clickElsewhere:function(evt){if(IBCMenu.currentMenu)
if(!IBUtils.isContains(IBCMenu.currentMenu.m_holderElm,IBUtils.evtSrcElement(evt)))
IBCMenu.currentMenu.hide();},attach:function(elm,options,iconRoot,allowSelSub,className,valueChanged,onHide){if(!this.inited){$(document).mousedown(this.clickElsewhere);this.inited=true;}
if(elm.m_cascadedMenu!=null)
return;new IBCascadedMenu(elm,options,iconRoot,allowSelSub,className,true,valueChanged,onHide);}}
function IBCascadedMenu(holderElm,opts,iconRoot,allowSelSub,className,isRoot,onSelect,onHide){this.m_holderElm=holderElm;this.m_iconRoot=iconRoot;this.m_arrOptions=opts;this.m_className=className||"cmenu";this.m_isRoot=isRoot;if(isRoot){this.onSelect=onSelect;this.onHide=onHide;IBCMenu.setOptionsParent(this.m_arrOptions,null);IBUtils.addClick(holderElm,IBCMenu.menuClickFunc(allowSelSub));IBUtils.addMouseOver(holderElm,IBCMenu.menuMouseOverFunc());IBUtils.addMouseOut(holderElm,IBCMenu.menuMouseOutFunc());}
holderElm.m_cascadedMenu=this;this.complete();}
IBCascadedMenu.prototype.complete=function(){this.m_div=document.createElement('div');this.m_div.style.position="absolute";this.m_div.style.zIndex=1000;this.m_div.style.display="none";this.m_holderElm.appendChild(this.m_div);var table=document.createElement('table');table.cellSpacing="0";table.cellPadding="0";table.cellSpacing="0";table.border="0";IBUtils.setClass(table,this.m_className);this.m_div.appendChild(table);var tbody=document.createElement('tbody');table.appendChild(tbody);var i;for(i=0;i<this.m_arrOptions.length;i++){this.completeOption(this.m_arrOptions[i],tbody);}
return this;}
IBCascadedMenu.prototype.completeOption=function(option,tbody){var tr=document.createElement('tr');tr.m_option=option;tr.m_menu=this;var td;var img;if(option.type=='sep'){td=document.createElement('td');IBUtils.setClass(td,"line");tr.appendChild(td);td=document.createElement('td');IBUtils.setClass(td,"line");td.colSpan="2";tr.appendChild(td);tbody.appendChild(tr);return;}
if(option.type=='label'){td=document.createElement('td');IBUtils.setClass(td,"text");td.colSpan="3";td.noWrap=true;td.appendChild(document.createTextNode(option.label));tr.appendChild(td);tbody.appendChild(tr);return;}
IBUtils.setClass(tr,"normal");td=document.createElement('td');IBUtils.setClass(td,"img");td.noWrap=true;if(option.logo==null)
td.appendChild(document.createTextNode(" "));else{var img=document.createElement('img');img.border="0";if(this.m_iconRoot!=null&&this.m_iconRoot!="")
img.src=this.m_iconRoot+option.logo;else
img.src=option.logo;td.appendChild(img);}
tr.appendChild(td);td=document.createElement('td');td.noWrap=true;if(option.tip!=null&&option.tip!=""){abbr=document.createElement('abbr');abbr.title=option.tip;abbr.appendChild(document.createTextNode(option.label));td.appendChild(abbr);}else
td.appendChild(document.createTextNode(option.label));tr.appendChild(td);if(option.sub==null){td=document.createElement('td');td.noWrap=true;td.appendChild(document.createTextNode(" "));}else{td=document.createElement('td');td.noWrap=true;IBUtils.setClass(td,"expand");td.appendChild(document.createTextNode("}"));tr.m_sub=new IBCascadedMenu(td,option.sub,this.m_iconRoot,false,this.m_className,false).complete();}
tr.appendChild(td);tbody.appendChild(tr);}
IBCascadedMenu.prototype.show=function(){if(this.m_div.style.display=="block")
return;var holderPosi=$(this.m_holderElm).position();var top=0;var left=0;if(this.m_isRoot){if(IBCMenu.currentMenu)
IBCMenu.currentMenu.hide();IBCMenu.currentMenu=this;if(arguments.length==2){top=arguments[1];left=arguments[0];this.m_div.style.top=top+"px";this.m_div.style.left=left+"px";}else{top=holderPosi.top+this.m_holderElm.offsetHeight;left=holderPosi.left;this.m_div.style.top=top+"px";this.m_div.style.left=left+"px";}}else{top=$(this.m_holderElm).position().top;left=$(this.m_holderElm).position().left+this.m_holderElm.offsetWidth-1;this.m_div.style.top=top+"px";this.m_div.style.left=left+"px";}
this.m_div.style.display="block";try{var doc=document.documentElement;var elm=$(this.m_div);var t=elm.offset().top;var l=elm.offset().left;var b=t+elm[0].offsetHeight;var r=l+elm[0].offsetWidth;;var scrollY=0;if(doc.scrollTop+doc.clientHeight<b)
scrollY=b-doc.scrollTop-doc.clientHeight;if(doc.scrollTop+scrollY>t)
scrollY=t-doc.scrollTop;if(scrollY!=0)
this.m_div.style.top=(top-scrollY)+"px";var scrollX=0;if(doc.scrollLeft+doc.clientWidth<r)
scrollX=r-doc.scrollLeft-doc.clientWidth;if(doc.scrollLeft+scrollX>l)
scrollX=l-doc.scrollLeft;if(scrollX!=0)
this.m_div.style.left=(left-scrollX)+"px";}catch(e){}}
IBCascadedMenu.prototype.hide=function(){if(IBCMenu.currentMenu==this)
IBCMenu.currentMenu=null;this.m_div.style.display="none";if(this.onHide!=null)
this.onHide();}
IBCascadedMenu.prototype.getOptionByValue=function(options,value){var i;if(options==null)
options=this.m_arrOptions;if(options==null)
return null;for(i=0;i<options.length;i++){if(options[i].value==value)
return options[i];if(options[i].sub!=null){var opt=this.getOptionByValue(options[i].sub,value);if(opt!=null)
return opt;}}
return null;}
var IconSel={updateIconSel:function(elm,txt,val){var opt=elm.m_cascadedMenu.getOptionByValue(null,val);if(opt!=null){var str="";while(opt!=null&&(opt.type=="option"||str!=""&&opt.type=="sub")){if(str!="")
str=" - "+str;if(opt.logo==null)
str=opt.label+str;else if(elm.m_cascadedMenu.m_iconRoot!=null&&elm.m_cascadedMenu.m_iconRoot!="")
str='<img border=0 align=absmiddle src="'+elm.m_cascadedMenu.m_iconRoot+opt.logo+'"> '+opt.label+str;else
str='<img border=0 align=absmiddle src="'+opt.logo+'"> '+opt.label+str;opt=opt.oparent;}
if(str!="")
txt.innerHTML=str;}},iconSelSelected:function(elm,txt,inp){return function(val){IconSel.updateIconSel(elm,txt,val);if(inp!=null)
inp.value=val;elm.m_cascadedMenu.hide();if(elm.onchange!=null)
elm.onchange(val);}},attach:function(elm,options,menuClassName,iconRoot,allowSelSub,defval,inp){if(!elm.selector)
elm=$(elm);elm.each(function(i){if(this.m_cascadedMenu==null){new IBCascadedMenu(this,options,iconRoot,allowSelSub,menuClassName,true);this.m_input=inp;var txt=null;var i;for(i=0;i<this.childNodes.length;i++)
if(this.childNodes[i].tagName=='SPAN'&&this.childNodes[i].id=='menu'){txt=this.childNodes[i];break;}
if(txt==null){txt=document.createElement('span');this.appendChild(txt);}
IconSel.updateIconSel(this,txt,defval);if(inp!=null)
inp.value=defval;this.onSelect=IconSel.iconSelSelected(this,txt,inp);}});}}
var IBWink={doWink:function(elm,evtElm,name){if(evtElm==null)
return;var cls=evtElm.getAttribute("class");if(cls==null)
cls=evtElm.className;if(cls!=null&&cls!=""&&cls.indexOf("__")!=-1){className=cls.substr(0,cls.indexOf("__")+2)+name;evtElm.className=className;evtElm.setAttribute("class",className);}
if(evtElm==elm||evtElm.parentNode==null||evtElm.parentNode==evtElm)
return;IBWink.doWink(elm,evtElm.parentNode,name);},setWinkFunc:function(name){return function(elm,evt){IBWink.doWink(elm,IBUtils.evtSrcElement(evt),name);}},attach:function(elm){IBUtils.addMouseOver(elm,IBWink.setWinkFunc("over"));IBUtils.addMouseOut(elm,IBWink.setWinkFunc("normal"));IBUtils.addMouseDown(elm,IBWink.setWinkFunc("down"));IBUtils.addMouseUp(elm,IBWink.setWinkFunc("over"));}}
$(document).ready(function(){IBWink.attach($("body")[0]);});var IBCal={m_arrMonthNames:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],m_tmplCalendar:'<table border="0" cellspacing="0" cellpadding="2" class="cal"><tr><td nowrap><span class="button__normal" id="prevyear"><img border="0" src="_BASE_/left.gif" align=absmiddle></span> _YEAR_ <span class="button__normal" id="nextyear"><img border="0" src="_BASE_/right.gif" align=absmiddle></span></td><td align="right" nowrap><span class="button__normal" id="prevmonth"><img border="0" src="_BASE_/left.gif" align=absmiddle></span> _MONTH_ <span class="button__normal" id="nextmonth"><img border="0" src="_BASE_/right.gif" align=absmiddle></span></td></tr><tr><td colspan="2"><table class="content" border="0" cellspacing="0" cellpadding="5"><tr align="center" class="headline"><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>_ROW_</table></td></tr></table>',m_tmplRow:'<tr align="center">_CELL_</tr>',m_tmplCell:'<td class="btnhide__normal" id="day">_DAY_</td>',m_tmplCellSelected:'<td class="btnsel__normal" id="day">_DAY_</td>',m_tmplCellEmpty:'<td>&nbsp;</td>',calClick:function(evtElm,cal){if(evtElm.id=="prevyear"){cal.prevYear();return;}else if(evtElm.id=="nextyear"){cal.nextYear();return;}else if(evtElm.id=="prevmonth"){cal.prevMonth();return;}else if(evtElm.id=="nextmonth"){cal.nextMonth();return;}else if(evtElm.id=="day"){cal.setDay(evtElm.childNodes[0].data);return;}
if(evtElm==cal.m_elm||evtElm.parentNode==null||evtElm.parentNode==evtElm)
return;IBCal.calClick(evtElm.parentNode,cal);},calClickFunc:function(cal){return function(evt){IBCal.calClick(IBUtils.evtSrcElement(evt),cal);}},getDaysInMonth:function(iYear,iMonth){var iDays;switch(iMonth){case 1:case 3:case 5:case 7:case 8:case 10:case 12:iDays=31;break;case 2:if(0==iYear%4){iDays=29;if((0==iYear%100)&&(0!=iYear%8))
iDays=28;}
else
iDays=28;break;default:iDays=30;}
return iDays;},packAllSpace:function(str)
{var strTemp,ch
var i,lenOfString
strTemp="";lenOfString=str.length;for(i=0;i<lenOfString;i++)
if(str.charAt(i)!=" ")
strTemp=strTemp+str.charAt(i);return strTemp;},calHideDelay:function(cal,time){return function(){if(time>cal.m_showTime)
cal.hide();}}}
function IBCalSel(elm,format,className,baseurl,funcValueChanged){this.m_elm=elm;this.m_date=new Date();if(format!=null&&format!="")
this.m_format=format;else
this.m_format="y-m-d";this.m_baseurl=baseurl;this.onValueChanged=funcValueChanged;this.m_div=document.createElement('div');this.m_div.style.position="absolute";this.m_div.style.display="none";this.m_div.className=className;this.m_div.setAttribute("class",className);this.m_div.onclick=IBCal.calClickFunc(this);elm.appendChild(this.m_div);elm.m_calsel=this;this.m_showTime=0;IBUtils.addMouseOver(this.m_div,function(elm){elm.parentNode.m_calsel.m_showTime=new Date().getTime()});IBUtils.addMouseOut(this.m_div,function(elm){setTimeout(IBCal.calHideDelay(elm.parentNode.m_calsel,new Date().getTime()),100)});}
IBCalSel.prototype.getDate=function(){var strFormat="y-m-d";if(this.m_format!=null)
strFormat=this.m_format;var strDate=""
var ch;var i,lenOfFormat
strFormat=IBCal.packAllSpace(strFormat);lenOfFormat=strFormat.length;j=0;for(i=0;i<lenOfFormat;i++){ch=strFormat.charAt(i);if(ch=="Y"||ch=="y")
strDate=strDate+this.m_date.getFullYear();else if(ch=="m")
strDate=strDate+(this.m_date.getMonth()+1);else if(ch=="M"){var m=this.m_date.getMonth()+1;if(m<10)strDate=strDate+"0"+m;else strDate=strDate+m;}else if(ch=="d")
strDate=strDate+(this.m_date.getDate());else if(ch=="D"){var d=this.m_date.getDate();if(d<10)strDate=strDate+"0"+d;else strDate=strDate+d;}else
strDate=strDate+ch;}
return strDate;}
IBCalSel.prototype.setDate=function(strDateIn)
{try{var strFormat="y-m-d";if(this.m_format!=null)
strFormat=this.m_format;var strTemp,ch1,ch2
var i,j,k,lenOfFormat,lenOfDate
strDate=IBCal.packAllSpace(strDateIn);strFormat=IBCal.packAllSpace(strFormat);lenOfDate=strDate.length;lenOfFormat=strFormat.length;j=0;for(i=0;i<lenOfFormat;i++){ch1=strFormat.charAt(i);if(ch1=="Y"||ch1=="y"){strTemp="";for(k=0;k<4;k++){ch2=strDate.charAt(j);if(ch2<"0"||ch2>"9")
break;j++;strTemp=strTemp+ch2;}
if(k==0)
return false;iYear=parseInt(strTemp);if(ch1=="Y")
if(iYear<30)
iYear=iYear+2000;else if(iYear<100)
iYear=iYear+1900;this.m_date.setFullYear(iYear);}
else if(ch1=="M"||ch1=="m"){strTemp="";for(k=0;k<2;k++){ch2=strDate.charAt(j);if(ch2<"0"||ch2>"9")
break;j++;if(!(strTemp==""&&ch2=="0"))
strTemp=strTemp+ch2;}
if(k==0)
return false;iMonth=parseInt(strTemp);if(iMonth>12)
iMonth=12;else if(iMonth<1)
iMonth=1;this.m_date.setMonth(iMonth-1);}
else if(ch1=="D"||ch1=="d"){strTemp="";for(k=0;k<2;k++){ch2=strDate.charAt(j);if(ch2<"0"||ch2>"9")
break;j++;if(!(strTemp==""&&ch2=="0"))
strTemp=strTemp+ch2;}
if(k==0)
return false;iDay=parseInt(strTemp);iMaxDay=IBCal.getDaysInMonth(this.m_date.getFullYear(),this.m_date.getMonth()+1);if(iDay<1)
iDay=1;if(iDay>iMaxDay)
iDay=iMaxDay;this.m_date.setDate(iDay);}
else{ch2=strDate.charAt(j);j++;if(ch2!=ch1)
return false;}}}catch(e){}
return true;}
IBCalSel.prototype.show=function(){var year=this.m_date.getFullYear();var month=this.m_date.getMonth();var day=this.m_date.getDate();var str=IBCal.m_tmplCalendar.replace("_MONTH_",IBCal.m_arrMonthNames[month]);str=str.replace("_YEAR_",year+"年");var dateFirst=new Date(year,month,1);var iDays=IBCal.getDaysInMonth(year,month+1);var iWeek=dateFirst.getDay();var strWeek="";for(i=0;i<iWeek;i++)
strWeek=strWeek+IBCal.m_tmplCellEmpty;for(i=1;i<=iDays;i++){if(i==day)
strWeek=strWeek+IBCal.m_tmplCellSelected.replace(/_DAY_/g,i);else
strWeek=strWeek+IBCal.m_tmplCell.replace(/_DAY_/g,i);iWeek++;if(iWeek==7){str=str.replace("_ROW_",IBCal.m_tmplRow.replace("_CELL_",strWeek)+"_ROW_");iWeek=0;strWeek="";}}
if(iWeek!=0){for(i=iWeek;i<7;i++)
strWeek=strWeek+IBCal.m_tmplCellEmpty;str=str.replace("_ROW_",IBCal.m_tmplRow.replace("_CELL_",strWeek)+"_ROW_");}
str=str.replace("_ROW_","");str=str.replace(/_BASE_/g,this.m_baseurl);this.m_div.innerHTML=str;var holderPosi=$(this.m_elm).position();this.m_div.style.top=(holderPosi.top+this.m_elm.offsetHeight)+"px";this.m_div.style.left=holderPosi.left+"px";this.m_div.style.display="block";}
IBCalSel.prototype.hide=function(){this.m_div.style.display="none";}
IBCalSel.prototype.setDay=function(day){this.m_date.setDate(day);if(this.onValueChanged!=null)
this.onValueChanged(this.getDate());this.hide();}
IBCalSel.prototype.prevMonth=function(){var year=this.m_date.getFullYear();var month=this.m_date.getMonth();if(month==0){this.m_date.setMonth(11);this.m_date.setFullYear(year-1);}else
this.m_date.setMonth(month-1);if(this.onValueChanged!=null)
this.onValueChanged(this.getDate());if(this.m_div.style.display=="block")
this.show();}
IBCalSel.prototype.nextMonth=function(){var year=this.m_date.getFullYear();var month=this.m_date.getMonth();if(month==11){this.m_date.setMonth(0);this.m_date.setFullYear(year+1);}else
this.m_date.setMonth(month+1);if(this.onValueChanged!=null)
this.onValueChanged(this.getDate());if(this.m_div.style.display=="block")
this.show();}
IBCalSel.prototype.prevYear=function(){this.m_date.setFullYear(this.m_date.getFullYear()-1);if(this.onValueChanged!=null)
this.onValueChanged(this.getDate());if(this.m_div.style.display=="block")
this.show();}
IBCalSel.prototype.nextYear=function(){this.m_date.setFullYear(this.m_date.getFullYear()+1);if(this.onValueChanged!=null)
this.onValueChanged(this.getDate());if(this.m_div.style.display=="block")
this.show();}