forked from jpatokal/openflights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scw.js
27 lines (26 loc) · 29 KB
/
scw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Compacted by ScriptingMagic.com
// *****************************************************************************
// Simple Calendar Widget - Cross-Browser Javascript pop-up calendar.
//
// Copyright (C) 2005-2007 Anthony Garrett
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, it is available at
// the GNU web site (http://www.gnu.org/) or by writing to the
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// ************************************
// Start of Simple Calendar Widget Code
// ************************************
var scwDateNow=new Date(Date.parse(new Date().toDateString()));var scwBaseYear=scwDateNow.getFullYear()-38;var scwDropDownYears=40;var scwLanguage;function scwSetDefaultLanguage(){try{scwSetLanguage()}catch(exception){scwToday="Today:";scwClear="Clear";scwDrag="click here to drag";scwArrMonthNames=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];scwArrWeekInits=["S","M","T","W","T","F","S"];scwInvalidDateMsg="The entered date is invalid.\n";scwOutOfRangeMsg="The entered date is out of range.";scwDoesNotExistMsg="The entered date does not exist.";scwInvalidAlert=["Invalid date (",") ignored."];scwDateDisablingError=["Error "," is not a Date object."];scwRangeDisablingError=["Error "," should consist of two elements."]}}var scwWeekStart=1;var scwWeekNumberDisplay=false;var scwWeekNumberBaseDay=4;var scwShowInvalidDateMsg=true,scwShowOutOfRangeMsg=true,scwShowDoesNotExistMsg=true,scwShowInvalidAlert=true,scwShowDateDisablingError=true,scwShowRangeDisablingError=true;var scwArrDelimiters=["/","-",".",","," "];var scwDateDisplayFormat="yyyy-m-d";var scwDateOutputFormat="yyyy-mm-dd";var scwZindex=1000;var scwBlnStrict=false;var scwClearButton=true;var scwAutoPosition=true;var scwEnabledDay=[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true];var scwDisabledDates=new Array();var scwActiveToday=true;var scwOutOfMonthDisable=false;var scwOutOfMonthHide=false;var scwOutOfRangeDisable=true;var scwFormatTodayCell=true;var scwTodayCellBorderColour="red";var scwAllowDrag=false;var scwClickToHide=false;document.writeln('<style type="text/css">.scw {padding:1px;vertical-align:middle;}iframe.scw {position:absolute;z-index:'+scwZindex+";top:0px;left:0px;visibility:hidden;width:1px;height:1px;}table.scw {padding:0px;visibility:hidden;position:absolute;cursor:default;width:200px;top:0px;left:0px;z-index:"+(scwZindex+1)+";text-align:center;}</style>");document.writeln('<style type="text/css">/* IMPORTANT: The SCW calendar script requires all the classes defined here.*/table.scw {padding: 1px;vertical-align:middle;border: ridge 2px;font-size: 10pt;font-family: Verdana,Arial,Helvetica,Sans-Serif;font-weight: bold;}td.scwDrag,td.scwHead {padding: 0px 0px;text-align: center;}td.scwDrag {font-size: 8pt;}select.scwHead {margin: 3px 1px;text-align: center;}input.scwHead {height: 22px;width: 22px;vertical-align:middle;text-align: center;margin: 2px 1px;font-weight: bold;font-size: 10pt;font-family: fixedSys;}td.scwWeekNumberHead,td.scwWeek {padding: 0px;text-align: center;font-weight: bold;}td.scwNow,td.scwNowHover,td.scwNow:hover,td.scwNowDisabled {padding: 0px;text-align: center;vertical-align:middle;font-weight: normal;}table.scwCells {text-align: right;font-size: 8pt;width: 96%;}td.scwCells,td.scwCellsHover,td.scwCells:hover,td.scwCellsDisabled,td.scwCellsExMonth,td.scwCellsExMonthHover,td.scwCellsExMonth:hover,td.scwCellsExMonthDisabled,td.scwCellsWeekend,td.scwCellsWeekendHover,td.scwCellsWeekend:hover,td.scwCellsWeekendDisabled,td.scwInputDate,td.scwInputDateHover,td.scwInputDate:hover,td.scwInputDateDisabled,td.scwWeekNo,td.scwWeeks {padding: 3px;width: 16px;height: 16px;border-width: 1px;border-style: solid;font-weight: bold;vertical-align: middle;}/* Blend the colours into your page here... *//* Calendar background */table.scw {background-color: #6666CC;}/* Drag Handle */td.scwDrag {background-color: #9999CC;color: #CCCCFF;}/* Week number heading */td.scwWeekNumberHead {color: #6666CC;}/* Week day headings */td.scwWeek {color: #CCCCCC;}/* Week numbers */td.scwWeekNo {background-color: #776677;color: #CCCCCC;}/* Enabled Days *//* Week Day */td.scwCells {background-color: #CCCCCC;color: #000000;}/* Day matching the input date */td.scwInputDate {background-color: #CC9999;color: #FF0000;}/* Weekend Day */td.scwCellsWeekend {background-color: #CCCCCC;color: #CC6666;}/* Day outside the current month */td.scwCellsExMonth {background-color: #CCCCCC;color: #666666;}/* Today selector */td.scwNow {background-color: #6666CC;color: #FFFFFF;}/* Clear Button */td.scwClear {padding: 0px;}input.scwClear {padding: 0px;text-align: center;font-size: 8pt;}/* MouseOver/Hover formatting If you want to "turn off" any of the formatting then just set to the same as the standard format above. Note: The reason that the following are implemented using both a class and a :hover pseudoclass is because Opera handles the rendering involved in the class swap very poorly and IE6 (and below) only implements pseudoclasses on the anchor tag.*//* Active cells */td.scwCells:hover,td.scwCellsHover {background-color: #FFFF00;cursor: pointer;color: #000000;}/* Day matching the input date */td.scwInputDate:hover,td.scwInputDateHover {background-color: #FFFF00;cursor: pointer;color: #000000;}/* Weekend cells */td.scwCellsWeekend:hover,td.scwCellsWeekendHover {background-color: #FFFF00;cursor: pointer;color: #000000;}/* Day outside the current month */td.scwCellsExMonth:hover,td.scwCellsExMonthHover {background-color: #FFFF00;cursor: pointer;color: #000000;}/* Today selector */td.scwNow:hover,td.scwNowHover {color: #FFFF00;cursor: pointer;font-weight: bold;}/* Disabled cells *//* Week Day *//* Day matching the input date */td.scwInputDateDisabled {background-color: #999999;color: #000000;}td.scwCellsDisabled {background-color: #999999;color: #000000;}/* Weekend Day */td.scwCellsWeekendDisabled {background-color: #999999;color: #CC6666;}/* Day outside the current month */td.scwCellsExMonthDisabled {background-color: #999999;color: #666666;}td.scwNowDisabled {background-color: #6666CC;color: #FFFFFF;}</style>');var scwTargetEle,scwTriggerEle,scwMonthSum=0,scwBlnFullInputDate=false,scwPassEnabledDay=new Array(),scwSeedDate=new Date(),scwParmActiveToday=true,scwWeekStart=scwWeekStart%7,scwToday,scwClear,scwDrag,scwArrMonthNames,scwArrWeekInits,scwInvalidDateMsg,scwOutOfRangeMsg,scwDoesNotExistMsg,scwInvalidAlert,scwDateDisablingError,scwRangeDisablingError;Date.prototype.scwFormat=function(a){var b=0,c="",d="";for(var i=0;i<=a.length;i++){if(i<a.length&&a.charAt(i)==c){b++}else{switch(c){case "y":case "Y":d+=(this.getFullYear()%Math.pow(10,b)).toString().scwPadLeft(b);break;case "m":case "M":d+=(b<3)?(this.getMonth()+1).toString().scwPadLeft(b):scwArrMonthNames[this.getMonth()];break;case "d":case "D":d+=this.getDate().toString().scwPadLeft(b);break;default:while(b-->0){d+=c}}if(i<a.length){c=a.charAt(i);b=1}}}return d};String.prototype.scwPadLeft=function(a){var b="";for(var i=0;i<(a-this.length);i++){b+="0"}return (b+this)};Function.prototype.runsAfterSCW=function(){var a=this,b=new Array(arguments.length);for(var i=0;i<b.length;++i){b[i]=arguments[i]}return function(){for(var c=0;c<arguments.length;++c){b[b.length]=arguments[c]}return (b.shift()==scwTriggerEle)?a.apply(this,b):null}};function scwID(a){if(document.getElementById(a)||(!document.getElementById(a)&&document.getElementsByName(a).length==0)){return document.getElementById(a)}else{if(document.getElementsByName(a).length==1){return document.getElementsByName(a)[0]}else{if(document.getElementsByName(a).length>1){alert("SCW \nCannot uniquely identify element named: "+a+".\nMore than one identical NAME attribute defined.\nSolution: Assign the required element a unique ID attribute value.")}}}}var scwNextActionReturn,scwNextAction;function showCal(a,b){scwShow(a,b)}function scwShow(a,b){if(!b){b=window.event}if(b.tagName){var c=b;if(scwID("scwIE")){window.event.cancelBubble=true}else{c.parentNode.addEventListener("click",scwStopPropagation,false)}}else{var c=(b.target)?b.target:b.srcElement;if(b.stopPropagation){b.stopPropagation()}else{b.cancelBubble=true}}scwTriggerEle=c;scwParmActiveToday=true;for(var i=0;i<7;i++){scwPassEnabledDay[(i+7-scwWeekStart)%7]=true;for(var j=2;j<arguments.length;j++){if(arguments[j]==i){scwPassEnabledDay[(i+7-scwWeekStart)%7]=false;if(scwDateNow.getDay()==i){scwParmActiveToday=false}}}}scwSeedDate=scwDateNow;var d="";if(a.value){d=a.value.replace(/^\s+/,"").replace(/\s+$/,"")}else{if(typeof a.value=="undefined"){var e=a.childNodes;for(var i=0;i<e.length;i++){if(e[i].nodeType==3){d=e[i].nodeValue.replace(/^\s+/,"").replace(/\s+$/,"");if(d.length>0){scwTriggerEle.scwTextNode=e[i];scwTriggerEle.scwLength=e[i].nodeValue.length;break}}}}}scwSetDefaultLanguage();scwID("scwDragText").innerHTML=scwDrag;scwID("scwMonths").options.length=0;for(var i=0;i<scwArrMonthNames.length;i++){scwID("scwMonths").options[i]=new Option(scwArrMonthNames[i],scwArrMonthNames[i])}scwID("scwYears").options.length=0;for(var i=0;i<scwDropDownYears;i++){scwID("scwYears").options[i]=new Option((scwBaseYear+i),(scwBaseYear+i))}for(var i=0;i<scwArrWeekInits.length;i++){scwID("scwWeekInit"+i).innerHTML=scwArrWeekInits[(i+scwWeekStart)%scwArrWeekInits.length]}if(((new Date(scwBaseYear+scwDropDownYears,0,0))>scwDateNow&&(new Date(scwBaseYear,0,0))<scwDateNow)||(scwClearButton&&(a.readOnly||a.disabled))){scwID("scwFoot").style.display="";scwID("scwNow").innerHTML=scwToday+" "+scwDateNow.scwFormat(scwDateDisplayFormat);scwID("scwClearButton").value=scwClear;if((new Date(scwBaseYear+scwDropDownYears,0,0))>scwDateNow&&(new Date(scwBaseYear,0,0))<scwDateNow){scwID("scwNow").style.display="";if(scwClearButton&&(a.readOnly||a.disabled)){scwID("scwClear").style.display="";scwID("scwClear").style.textAlign="left";scwID("scwNow").style.textAlign="right"}else{scwID("scwClear").style.display="none";scwID("scwNow").style.textAlign="center"}}else{scwID("scwClear").style.textAlign="center";scwID("scwClear").style.display="";scwID("scwNow").style.display="none"}}else{scwID("scwFoot").style.display="none"}if(d.length==0){scwBlnFullInputDate=false;if((new Date(scwBaseYear+scwDropDownYears,0,0))<scwSeedDate||(new Date(scwBaseYear,0,1))>scwSeedDate){scwSeedDate=new Date(scwBaseYear+Math.floor(scwDropDownYears/2),5,1)}}else{function scwInputFormat(){var f=new Array(),g=d.split(new RegExp("[\\"+scwArrDelimiters.join("\\")+"]+","g"));if(g[0]!=null){if(g[0].length==0){g.splice(0,1)}if(g[g.length-1].length==0){g.splice(g.length-1,1)}}scwBlnFullInputDate=false;scwDateOutputFormat=scwDateOutputFormat.toUpperCase();var h=["D","M","Y"];var k=new Array();for(var l=0;l<h.length;l++){if(scwDateOutputFormat.search(h[l])>-1){k[scwDateOutputFormat.search(h[l])]=h[l]}}var m=k.join("");switch(g.length){case 1:if(scwDateOutputFormat.indexOf("Y")>-1&&g[0].length>scwDateOutputFormat.lastIndexOf("Y")){f[0]=parseInt(g[0].substring(scwDateOutputFormat.indexOf("Y"),scwDateOutputFormat.lastIndexOf("Y")+1),10)}else{f[0]=0}if(scwDateOutputFormat.indexOf("M")>-1&&g[0].length>scwDateOutputFormat.lastIndexOf("M")){f[1]=g[0].substring(scwDateOutputFormat.indexOf("M"),scwDateOutputFormat.lastIndexOf("M")+1)}else{f[1]="6"}if(scwDateOutputFormat.indexOf("D")>-1&&g[0].length>scwDateOutputFormat.lastIndexOf("D")){f[2]=parseInt(g[0].substring(scwDateOutputFormat.indexOf("D"),scwDateOutputFormat.lastIndexOf("D")+1),10)}else{f[2]=1}if(g[0].length==scwDateOutputFormat.length){scwBlnFullInputDate=true}break;case 2:f[0]=parseInt(g[m.replace(/D/i,"").search(/Y/i)],10);f[1]=g[m.replace(/D/i,"").search(/M/i)];f[2]=1;break;case 3:f[0]=parseInt(g[m.search(/Y/i)],10);f[1]=g[m.search(/M/i)];f[2]=parseInt(g[m.search(/D/i)],10);scwBlnFullInputDate=true;break;default:f[0]=0;f[1]=0;f[2]=0}var n=new RegExp("^(0?[1-9]|[1-2][0-9]|3[0-1])$"),o=new RegExp("^(0?[1-9]|1[0-2]|"+scwArrMonthNames.join("|")+")$","i"),p=new RegExp("^([0-9]{1,2}|[0-9]{4})$");if(p.exec(f[0])==null||o.exec(f[1])==null||n.exec(f[2])==null){if(scwShowInvalidDateMsg){alert(scwInvalidDateMsg+scwInvalidAlert[0]+d+scwInvalidAlert[1])}scwBlnFullInputDate=false;f[0]=scwBaseYear+Math.floor(scwDropDownYears/2);f[1]="6";f[2]=1}return f}scwArrSeedDate=scwInputFormat();if(scwArrSeedDate[0]<100){scwArrSeedDate[0]+=(scwArrSeedDate[0]>50)?1900:2000}if(scwArrSeedDate[1].search(/\d+/)<0){for(i=0;i<scwArrMonthNames.length;i++){if(scwArrSeedDate[1].toUpperCase()==scwArrMonthNames[i].toUpperCase()){scwArrSeedDate[1]=i+1;break}}}scwSeedDate=new Date(scwArrSeedDate[0],scwArrSeedDate[1]-1,scwArrSeedDate[2])}if(isNaN(scwSeedDate)){if(scwShowInvalidDateMsg){alert(scwInvalidDateMsg+scwInvalidAlert[0]+d+scwInvalidAlert[1])}scwSeedDate=new Date(scwBaseYear+Math.floor(scwDropDownYears/2),5,1);scwBlnFullInputDate=false}else{if((new Date(scwBaseYear,0,1))>scwSeedDate){if(scwBlnStrict&&scwShowOutOfRangeMsg){alert(scwOutOfRangeMsg)}scwSeedDate=new Date(scwBaseYear,0,1);scwBlnFullInputDate=false}else{if((new Date(scwBaseYear+scwDropDownYears,0,0))<scwSeedDate){if(scwBlnStrict&&scwShowOutOfRangeMsg){alert(scwOutOfRangeMsg)}scwSeedDate=new Date(scwBaseYear+Math.floor(scwDropDownYears)-1,11,1);scwBlnFullInputDate=false}else{if(scwBlnStrict&&scwBlnFullInputDate&&(scwSeedDate.getDate()!=scwArrSeedDate[2]||(scwSeedDate.getMonth()+1)!=scwArrSeedDate[1]||scwSeedDate.getFullYear()!=scwArrSeedDate[0])){if(scwShowDoesNotExistMsg){alert(scwDoesNotExistMsg)}scwSeedDate=new Date(scwSeedDate.getFullYear(),scwSeedDate.getMonth()-1,1);scwBlnFullInputDate=false}}}}for(var i=0;i<scwDisabledDates.length;i++){if(!((typeof scwDisabledDates[i]=="object")&&(scwDisabledDates[i].constructor==Date))){if((typeof scwDisabledDates[i]=="object")&&(scwDisabledDates[i].constructor==Array)){var f=true;if(scwDisabledDates[i].length!=2){if(scwShowRangeDisablingError){alert(scwRangeDisablingError[0]+scwDisabledDates[i]+scwRangeDisablingError[1])}f=false}else{for(var j=0;j<scwDisabledDates[i].length;j++){if(!((typeof scwDisabledDates[i][j]=="object")&&(scwDisabledDates[i][j].constructor==Date))){if(scwShowRangeDisablingError){alert(scwDateDisablingError[0]+scwDisabledDates[i][j]+scwDateDisablingError[1])}f=false}}}if(f&&(scwDisabledDates[i][0]>scwDisabledDates[i][1])){scwDisabledDates[i].reverse()}}else{if(scwShowRangeDisablingError){alert(scwDateDisablingError[0]+scwDisabledDates[i]+scwDateDisablingError[1])}}}}scwMonthSum=12*(scwSeedDate.getFullYear()-scwBaseYear)+scwSeedDate.getMonth();scwID("scwYears").options.selectedIndex=Math.floor(scwMonthSum/12);scwID("scwMonths").options.selectedIndex=(scwMonthSum%12);scwID("scwDrag").style.display=(scwAllowDrag)?"":"none";scwShowMonth(0);scwTargetEle=a;var g=parseInt(a.offsetTop,10)+parseInt(a.offsetHeight,10),h=parseInt(a.offsetLeft,10);if(!window.opera){while(a.tagName!="BODY"&&a.tagName!="HTML"){g-=parseInt(a.scrollTop,10);h-=parseInt(a.scrollLeft,10);a=a.parentNode}a=scwTargetEle}do{a=a.offsetParent;g+=parseInt(a.offsetTop,10);h+=parseInt(a.offsetLeft,10)}while(a.tagName!="BODY"&&a.tagName!="HTML");if(scwAutoPosition){var k=parseInt(scwID("scw").offsetWidth,10),l=parseInt(scwID("scw").offsetHeight,10),m=(document.body&&document.body.scrollLeft)?document.body.scrollLeft:(document.documentElement&&document.documentElement.scrollLeft)?document.documentElement.scrollLeft:0,n=(typeof (innerWidth)=="number")?innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:(document.body&&document.body.clientWidth)?document.body.clientWidth:0,o=(document.body&&document.body.scrollTop)?document.body.scrollTop:(document.documentElement&&document.documentElement.scrollTop)?document.documentElement.scrollTop:0,p=(typeof (innerHeight)=="number")?innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:(document.body&&document.body.clientHeight)?document.body.clientHeight:0;h-=(h-k+parseInt(scwTargetEle.offsetWidth,10)>=m&&h+k>m+n)?(k-parseInt(scwTargetEle.offsetWidth,10)):0;g-=(g-l-parseInt(scwTargetEle.offsetHeight,10)>=o&&g+l>o+p)?(l+parseInt(scwTargetEle.offsetHeight,10)):0}scwID("scw").style.top=g+"px";scwID("scw").style.left=h+"px";scwID("scwIframe").style.top=g+"px";scwID("scwIframe").style.left=h+"px";scwID("scwIframe").style.width=(scwID("scw").offsetWidth-(scwID("scwIE")?2:4))+"px";scwID("scwIframe").style.height=(scwID("scw").offsetHeight-(scwID("scwIE")?2:4))+"px";scwID("scwIframe").style.visibility="inherit";scwID("scw").style.visibility="inherit"}function scwHide(){scwID("scw").style.visibility="hidden";scwID("scwIframe").style.visibility="hidden";if(typeof scwNextAction!="undefined"&&scwNextAction!=null){scwNextActionReturn=scwNextAction();scwNextAction=null}}function scwCancel(a){if(scwClickToHide){scwHide()}scwStopPropagation(a)}function scwStopPropagation(a){if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}}function scwBeginDrag(a){var b=scwID("scw");var c=a.clientX,d=a.clientY,e=b;do{c-=parseInt(e.offsetLeft,10);d-=parseInt(e.offsetTop,10);e=e.offsetParent}while(e.tagName!="BODY"&&e.tagName!="HTML");if(document.addEventListener){document.addEventListener("mousemove",moveHandler,true);document.addEventListener("mouseup",upHandler,true)}else{b.attachEvent("onmousemove",moveHandler);b.attachEvent("onmouseup",upHandler);b.setCapture()}scwStopPropagation(a);function moveHandler(f){if(!f){f=window.event}b.style.left=(f.clientX-c)+"px";b.style.top=(f.clientY-d)+"px";scwID("scwIframe").style.left=(f.clientX-c)+"px";scwID("scwIframe").style.top=(f.clientY-d)+"px";scwStopPropagation(f)}function upHandler(f){if(!f){f=window.event}if(document.removeEventListener){document.removeEventListener("mousemove",moveHandler,true);document.removeEventListener("mouseup",upHandler,true)}else{b.detachEvent("onmouseup",upHandler);b.detachEvent("onmousemove",moveHandler);b.releaseCapture()}scwStopPropagation(f)}}function scwShowMonth(a){var b=new Date(Date.parse(new Date().toDateString())),c=new Date();b.setHours(12);scwSelYears=scwID("scwYears");scwSelMonths=scwID("scwMonths");if(scwSelYears.options.selectedIndex>-1){scwMonthSum=12*(scwSelYears.options.selectedIndex)+a;if(scwSelMonths.options.selectedIndex>-1){scwMonthSum+=scwSelMonths.options.selectedIndex}}else{if(scwSelMonths.options.selectedIndex>-1){scwMonthSum+=scwSelMonths.options.selectedIndex}}b.setFullYear(scwBaseYear+Math.floor(scwMonthSum/12),(scwMonthSum%12),1);scwID("scwWeek_").style.display=(scwWeekNumberDisplay)?"":"none";if(window.opera){scwID("scwMonths").style.display="inherit";scwID("scwYears").style.display="inherit"}scwTemp=(12*parseInt((b.getFullYear()-scwBaseYear),10))+parseInt(b.getMonth(),10);if(scwTemp>-1&&scwTemp<(12*scwDropDownYears)){scwSelYears.options.selectedIndex=Math.floor(scwMonthSum/12);scwSelMonths.options.selectedIndex=(scwMonthSum%12);scwCurMonth=b.getMonth();b.setDate((((b.getDay()-scwWeekStart)<0)?-6:1)+scwWeekStart-b.getDay());var d=new Date(b.getFullYear(),b.getMonth(),b.getDate()).valueOf();c=new Date(b);if((new Date(scwBaseYear+scwDropDownYears,0,0))>scwDateNow&&(new Date(scwBaseYear,0,0))<scwDateNow){var e=scwID("scwNow");function scwNowOutput(){scwSetOutput(scwDateNow)}if(scwDisabledDates.length==0){if(scwActiveToday&&scwParmActiveToday){e.onclick=scwNowOutput;e.className="scwNow";if(scwID("scwIE")){e.onmouseover=scwChangeClass;e.onmouseout=scwChangeClass}}else{e.onclick=null;e.className="scwNowDisabled";if(scwID("scwIE")){e.onmouseover=null;e.onmouseout=null}if(document.addEventListener){e.addEventListener("click",scwStopPropagation,false)}else{e.attachEvent("onclick",scwStopPropagation)}}}else{for(var k=0;k<scwDisabledDates.length;k++){if(!scwActiveToday||!scwParmActiveToday||((typeof scwDisabledDates[k]=="object")&&(((scwDisabledDates[k].constructor==Date)&&scwDateNow.valueOf()==scwDisabledDates[k].valueOf())||((scwDisabledDates[k].constructor==Array)&&scwDateNow.valueOf()>=scwDisabledDates[k][0].valueOf()&&scwDateNow.valueOf()<=scwDisabledDates[k][1].valueOf())))){e.onclick=null;e.className="scwNowDisabled";if(scwID("scwIE")){e.onmouseover=null;e.onmouseout=null}if(document.addEventListener){e.addEventListener("click",scwStopPropagation,false)}else{e.attachEvent("onclick",scwStopPropagation)}break}else{e.onclick=scwNowOutput;e.className="scwNow";if(scwID("scwIE")){e.onmouseover=scwChangeClass;e.onmouseout=scwChangeClass}}}}}function scwSetOutput(f){if(typeof scwTargetEle.value=="undefined"){scwTriggerEle.scwTextNode.replaceData(0,scwTriggerEle.scwLength,f.scwFormat(scwDateOutputFormat))}else{scwTargetEle.value=f.scwFormat(scwDateOutputFormat)}scwHide()}function scwCellOutput(f){var g=scwEventTrigger(f),h=new Date(c);if(g.nodeType==3){g=g.parentNode}h.setDate(c.getDate()+parseInt(g.id.substr(8),10));scwSetOutput(h)}function scwChangeClass(f){var g=scwEventTrigger(f);if(g.nodeType==3){g=g.parentNode}switch(g.className){case "scwCells":g.className="scwCellsHover";break;case "scwCellsHover":g.className="scwCells";break;case "scwCellsExMonth":g.className="scwCellsExMonthHover";break;case "scwCellsExMonthHover":g.className="scwCellsExMonth";break;case "scwCellsWeekend":g.className="scwCellsWeekendHover";break;case "scwCellsWeekendHover":g.className="scwCellsWeekend";break;case "scwNow":g.className="scwNowHover";break;case "scwNowHover":g.className="scwNow";break;case "scwInputDate":g.className="scwInputDateHover";break;case "scwInputDateHover":g.className="scwInputDate"}return true}function scwEventTrigger(f){if(!f){f=event}return f.target||f.srcElement}function scwWeekNumber(f){var g=new Date(f);g.setDate(g.getDate()-g.getDay()+scwWeekNumberBaseDay+((f.getDay()>scwWeekNumberBaseDay)?7:0));var h=new Date(g.getFullYear(),0,1);h.setDate(h.getDate()-h.getDay()+scwWeekNumberBaseDay);if(h<new Date(g.getFullYear(),0,1)){h.setDate(h.getDate()+7)}var l=new Date(h-scwWeekNumberBaseDay+f.getDay());if(l>h){l.setDate(l.getDate()-7)}var m="0"+(Math.round((g-h)/604800000,0)+1);return m.substring(m.length-2,m.length)}var f=scwID("scwCells");for(i=0;i<f.childNodes.length;i++){var g=f.childNodes[i];if(g.nodeType==1&&g.tagName=="TR"){if(scwWeekNumberDisplay){scwTmpEl=g.childNodes[0];scwTmpEl.innerHTML=scwWeekNumber(b);scwTmpEl.style.borderColor=(scwTmpEl.currentStyle)?scwTmpEl.currentStyle["backgroundColor"]:(window.getComputedStyle)?document.defaultView.getComputedStyle(scwTmpEl,null).getPropertyValue("background-color"):"";scwTmpEl.style.display=""}else{g.childNodes[0].style.display="none"}for(j=1;j<g.childNodes.length;j++){var h=g.childNodes[j];if(h.nodeType==1&&h.tagName=="TD"){g.childNodes[j].innerHTML=b.getDate();var l=g.childNodes[j],m=((scwOutOfRangeDisable&&(b<(new Date(scwBaseYear,0,1,b.getHours()))||b>(new Date(scwBaseYear+scwDropDownYears,0,0,b.getHours()))))||(scwOutOfMonthDisable&&(b<(new Date(b.getFullYear(),scwCurMonth,1,b.getHours()))||b>(new Date(b.getFullYear(),scwCurMonth+1,0,b.getHours())))))?true:false;l.style.visibility=(scwOutOfMonthHide&&(b<(new Date(b.getFullYear(),scwCurMonth,1,b.getHours()))||b>(new Date(b.getFullYear(),scwCurMonth+1,0,b.getHours()))))?"hidden":"inherit";for(var k=0;k<scwDisabledDates.length;k++){if((typeof scwDisabledDates[k]=="object")&&(scwDisabledDates[k].constructor==Date)&&d==scwDisabledDates[k].valueOf()){m=true}else{if((typeof scwDisabledDates[k]=="object")&&(scwDisabledDates[k].constructor==Array)&&d>=scwDisabledDates[k][0].valueOf()&&d<=scwDisabledDates[k][1].valueOf()){m=true}}}if(m||!scwEnabledDay[j-1+(7*((i*f.childNodes.length)/6))]||!scwPassEnabledDay[(j-1+(7*(i*f.childNodes.length/6)))%7]){g.childNodes[j].onclick=null;if(scwID("scwIE")){g.childNodes[j].onmouseover=null;g.childNodes[j].onmouseout=null}l.className=(b.getMonth()!=scwCurMonth)?"scwCellsExMonthDisabled":(scwBlnFullInputDate&&b.toDateString()==scwSeedDate.toDateString())?"scwInputDateDisabled":(b.getDay()%6==0)?"scwCellsWeekendDisabled":"scwCellsDisabled";l.style.borderColor=(scwFormatTodayCell&&b.toDateString()==scwDateNow.toDateString())?scwTodayCellBorderColour:(l.currentStyle)?l.currentStyle["backgroundColor"]:(window.getComputedStyle)?document.defaultView.getComputedStyle(l,null).getPropertyValue("background-color"):""}else{g.childNodes[j].onclick=scwCellOutput;if(scwID("scwIE")){g.childNodes[j].onmouseover=scwChangeClass;g.childNodes[j].onmouseout=scwChangeClass}l.className=(b.getMonth()!=scwCurMonth)?"scwCellsExMonth":(scwBlnFullInputDate&&b.toDateString()==scwSeedDate.toDateString())?"scwInputDate":(b.getDay()%6==0)?"scwCellsWeekend":"scwCells";l.style.borderColor=(scwFormatTodayCell&&b.toDateString()==scwDateNow.toDateString())?scwTodayCellBorderColour:(l.currentStyle)?l.currentStyle["backgroundColor"]:(window.getComputedStyle)?document.defaultView.getComputedStyle(l,null).getPropertyValue("background-color"):""}b.setDate(b.getDate()+1);d=new Date(b.getFullYear(),b.getMonth(),b.getDate()).valueOf()}}}}}if(window.opera){scwID("scwMonths").style.display="inline";scwID("scwYears").style.display="inline";scwID("scw").style.visibility="hidden";scwID("scw").style.visibility="inherit"}}document.writeln("<!--[if IE]><div id='scwIE'></div><![endif]-->");document.writeln("<!--[if lt IE 7]><div id='scwIElt7'></div><![endif]-->");document.write("<iframe class='scw' "+(scwID("scwIElt7")?"src='/scwblank.html '":"")+"id='scwIframe' name='scwIframe' frameborder='0'></iframe><table id='scw' class='scw'><tr class='scw'><td class='scw'><table class='scwHead' id='scwHead' width='100%' cellspacing='0' cellpadding='0'><tr id='scwDrag' style='display:none;'><td colspan='4' class='scwDrag' onmousedown='scwBeginDrag(event);'><span id='scwDragText'></span></td></tr><tr class='scwHead' ><td class='scwHead'><input class='scwHead' id='scwHeadLeft' type='button' value='<' onclick='scwShowMonth(-1);' /></td><td class='scwHead'><select id='scwMonths' class='scwHead' onchange='scwShowMonth(0);'></select></td><td class='scwHead'><select id='scwYears' class='scwHead' onchange='scwShowMonth(0);'></select></td><td class='scwHead'><input class='scwHead' id='scwHeadRight' type='button' value='>' onclick='scwShowMonth(1);' /></td></tr></table></td></tr><tr class='scw'><td class='scw'><table class='scwCells' align='center'><thead><tr><td class='scwWeekNumberHead' id='scwWeek_' ></td>");for(i=0;i<7;i++){document.write("<td class='scwWeek' id='scwWeekInit"+i+"'></td>")}document.write("</tr></thead><tbody id='scwCells' onClick='scwStopPropagation(event);'>");for(i=0;i<6;i++){document.write("<tr><td class='scwWeekNo' id='scwWeek_"+i+"'></td>");for(j=0;j<7;j++){document.write("<td class='scwCells' id='scwCell_"+(j+(i*7))+"'></td>")}document.write("</tr>")}document.write("</tbody><tfoot><tr id='scwFoot'><td colspan='8' style='padding:0px;'><table width='100%'><tr><td id='scwClear' class='scwClear'><input type='button' id='scwClearButton' class='scwClear' onclick='scwTargetEle.value = \"\";scwHide();' /></td><td class='scwNow' id='scwNow'></td></tr></table></td></tr></tfoot></table></td></tr></table>");if(document.addEventListener){scwID("scw").addEventListener("click",scwCancel,false);scwID("scwHeadLeft").addEventListener("click",scwStopPropagation,false);scwID("scwMonths").addEventListener("click",scwStopPropagation,false);scwID("scwMonths").addEventListener("change",scwStopPropagation,false);scwID("scwYears").addEventListener("click",scwStopPropagation,false);scwID("scwYears").addEventListener("change",scwStopPropagation,false);scwID("scwHeadRight").addEventListener("click",scwStopPropagation,false)}else{scwID("scw").attachEvent("onclick",scwCancel);scwID("scwHeadLeft").attachEvent("onclick",scwStopPropagation);scwID("scwMonths").attachEvent("onclick",scwStopPropagation);scwID("scwMonths").attachEvent("onchange",scwStopPropagation);scwID("scwYears").attachEvent("onclick",scwStopPropagation);scwID("scwYears").attachEvent("onchange",scwStopPropagation);scwID("scwHeadRight").attachEvent("onclick",scwStopPropagation)}if(document.addEventListener){document.addEventListener("click",scwHide,false)}else{document.attachEvent("onclick",scwHide)}