// CSS Styles : calWeekHeadColor, calbody, calTodayColor, calSelDateColor var dateformat = 'yyyymmdd'; // can be either ddmmyyyy or yyyymmdd document.write('') function calactivate(obj,caltype){ //focus if (caltype=='focus'){ obj.select();lcs(obj);obj.parentNode.focus(); } //click if (caltype=='click'){ //window.event.cancelBubble=true; obj.select();lcs(obj);obj.parentNode.focus(); } } //---------------------------------------- // Calendar script var now = new Date; var sccm=now.getMonth(); var sccy=now.getFullYear(); var ccm=now.getMonth(); var ccy=now.getFullYear(); var updobj; function Calseloption(obj, objvalue) { if (!hasOptions(obj)) { return; } for (var i=0; i-1){ return obj.options[obj.selectedIndex].value; } } function Calchangemonth(){ ccy = Seloptionvalue(getObj('drpselectyear')); ccm = Seloptionvalue(getObj('drpmonth')); prepcalendar('',ccm,ccy); } function getObj(objID) { if (document.getElementById) {return document.getElementById(objID);} else if (document.all) {return document.all[objID];} else if (document.layers) {return document.layers[objID];} } function checkClick(e) { e?evt=e:evt=event; CSE=evt.target?evt.target:evt.srcElement; if (getObj('fc')){ if (!isChild(CSE,getObj('fc'))){ clearcalperiod(); getObj('fc').style.display='none'; RemoveShim(getObj('fc'),'calshim'); } } } function checkClose() { clearcalperiod(); getObj('fc').style.display='none'; RemoveShim(getObj('fc'),'calshim'); } function isChild(s,d) { while(s) { if (s==d) return true; s=s.parentNode; } return false; } function Left(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } function Top(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } function lcs(ielem) { document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick,false); checkClick(ielem); updobj=ielem; newleft = Left(ielem); newtop = Top(ielem)+ielem.offsetHeight; getObj('fc').style.left="" + newleft + "px";; // Added -200 for fixing issue from ticket 6210 getObj('fc').style.top="" + newtop + "px"; getObj('fc').style.display=''; AddShim(getObj('fc')); // First check date is valid curdt=ielem.value; curdtarr=curdt.split('/'); isdt=true; for(var k=0;k= (cd -(-1))) && (d<=cd-(-marr[cm]))) { htd=((hd!='')&&(d-cd==hd)); if (htd) f_hds(getObj('v'+parseInt(d))); else f_cps(getObj('v'+parseInt(d))); getObj('v'+parseInt(d)).onmouseover=cs_over; getObj('v'+parseInt(d)).onmouseout=cs_out; getObj('v'+parseInt(d)).onclick=cs_click; getObj('v'+parseInt(d)).innerHTML=d-cd; // check dateformat here if ((dateformat.toUpperCase()=="DDMMYYYY") || (dateformat.toUpperCase()=="DDMMYY")) { calvalarr[d]=''+(d-cd)+'/'+(cm-(-1))+'/'+cy; } if ((dateformat.toUpperCase()=="YYYYMMDD") || (dateformat.toUpperCase()=="YYMMDD")) { calvalarr[d]=''+cy +'/'+(cm-(-1))+'/'+(d-cd); } } else { getObj('v'+d).innerHTML=' '; getObj('v'+parseInt(d)).onmouseover=null; getObj('v'+parseInt(d)).onmouseout=null; getObj('v'+parseInt(d)).style.cursor='default'; } } } function caddm() { ccy = parseInt(Seloptionvalue(getObj('drpselectyear'))); ccm = parseInt(Seloptionvalue(getObj('drpmonth'))); ccm+=1; if (ccm>=12) { ccm=0; ccy++; } // test if year exists in drop down if it does then continue otherwise stop if (FNoptionexists(getObj('drpselectyear'), ccy)){ prepcalendar('',ccm,ccy); } } function csubm() { ccy = parseInt(Seloptionvalue(getObj('drpselectyear'))); ccm = parseInt(Seloptionvalue(getObj('drpmonth'))); ccm-=1; if (ccm<0) { ccm=11; ccy--; } // test if year exists in drop down if it does then continue otherwise stop if (FNoptionexists(getObj('drpselectyear'), ccy)){ prepcalendar('',ccm,ccy); } } //---------------------------------------------------- function AddShim(eobj) { //add iframe shim var s = document.createElement("iframe"); s.id = "calshim"; s.frameBorder = "0"; s.style.position = "absolute"; s.style.zIndex = "1"; s.style.top = eobj.offsetTop; s.style.left = eobj.offsetLeft; s.width = eobj.offsetWidth; s.height = eobj.offsetHeight; s.scrolling="no"; eobj.shimElement = s; eobj.parentNode.insertBefore(s, eobj); } function RemoveShim(eobj, sid) { childid = document.getElementById(sid); parentid = eobj.parentNode; if (parentid!=null && childid ) {eobj.parentNode.removeChild(childid); eobj = null; } } function fnparsedate(datestr,dateformat, DateSeparator){ // set format defaults.. if (!dateformat){dateformat="yyyymmdd";} if (!DateSeparator){DateSeparator="-";} if (datestr.length>0){ // find the breaks in the passed date string Sp1=datestr.indexOf(DateSeparator,0) Sp2=datestr.indexOf(DateSeparator,(parseInt(Sp1)+1)); // parse the string passed the the date format...... if ((dateformat.toUpperCase()=="DDMMYYYY") || (dateformat.toUpperCase()=="DDMMMYYYY")) { strYear=datestr.substring(Sp2+1); strMonth=datestr.substring(Sp1+1,Sp2); strDate=datestr.substring(0,Sp1); } else if ((dateformat.toUpperCase()=="MMDDYYYY") || (dateformat.toUpperCase()=="MMMDDYYYY")) { strYear=datestr.substring(Sp2+1); strMonth=datestr.substring(0,Sp1); strDate=datestr.substring(Sp1+1,Sp2); } else if ((dateformat.toUpperCase()=="YYYYMMDD") || (dateformat.toUpperCase()=="YYYYMMMDD")) { strYear=datestr.substring(0,Sp1); strMonth=datestr.substring(Sp1+1,Sp2); strDate=datestr.substring(Sp2+1); } // check the Month if (isNaN(strMonth)) intMonth=GetMonthIndex(strMonth); else intMonth=parseInt(strMonth,10)-1; return new Date(strYear,intMonth, strDate); } else { return "";} }// end fnparsedate //------------------------------ function fnpopselected(popurl,fieldname,wwidth,wheight){ if (getObj(fieldname).selectedIndex >=0){ var selvalue = getObj(fieldname).options[getObj(fieldname).selectedIndex].value; wwidth = wwidth.length==0?400:wwidth; wheight = wheight.length==0?400:wheight; popurl = popurl.replace("VAR",selvalue) createWindow(popurl,'previewselected',wwidth,wheight,50,50,1,1,1) ; } else { alert("A Selection has not been made."); } } //------------------------------ function clearcalfields(){ // clear calendar fields if period selectbox changes if (fieldexists ("startdate")){ getObj("startdate").value=""; } if (fieldexists ("enddate")){ getObj("enddate").value=""; } } //------------------------------ function clearcalperiod(){ // clear calendar fields if period selectbox changes if (fieldexists ("reportperiod")){ customdate = getObj("startdate").value; if (customdate.length>1){ if (hasOptions(getObj("reportperiod"))) { getObj("reportperiod").options[0].selected = true; } } } } function isObject(o) {return 'object' == typeof o;} function findPosX(obj) { var curleft = 0; if(obj.offsetParent) while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.x)curleft += obj.x; return curleft; } function findPosY(obj){ var curtop = 0; if(obj.offsetParent) while(1) { curtop += obj.offsetTop; if(!obj.offsetParent)break; obj = obj.offsetParent; } else if(obj.y) curtop += obj.y; return curtop; } function movePos(objname){ movetoname = getObj(objname); if (isObject(movetoname)){ thisx = findPosX(movetoname); thisy = findPosY(movetoname); window.scrollTo(thisx,thisy); } }