javascript英文日期(有时间)选择器
程序员文章站
2023-11-17 18:42:04
var languagecode = 'en'; // possible v...
var languagecode = 'en'; // possible values: en,ge,no,nl,es,pt-br,fr
// en = english, ge = german, no = norwegian,nl = dutch, es = spanish, pt-br = portuguese, fr = french, da = danish, hu = hungarian(use utf-8 doctype for hungarian)
var calendar_display_time = true;
// format of current day at the bottom of the calendar
// [todaystring] = the value of todaystring
// [daystring] = day of week (examle: mon, tue, wed...)
// [ucfdaystring] = day of week (examle: mon, tue, wed...) ( first letter in uppercase)
// [day] = day of month, 1..31
// [monthstring] = name of current month
// [year] = current year
var todaystringformat = '[todaystring] [ucfdaystring]. [day]. [monthstring] [year]';
var pathtoimages = 'images/'; // relative to your html file
var speedofselectboxsliding = 200; // milliseconds between changing year and hour when holding mouse over "-" and "+" - lower value = faster
var intervalselectbox_minutes = 5; // minute select box - interval between each option (5 = default)
var calendar_offsettop = 0; // offset - calendar placement - you probably have to modify this value if you're not using a strict doctype
var calendar_offsetleft = 0; // offset - calendar placement - you probably have to modify this value if you're not using a strict doctype
var calendardiv = false;
var msie = false;
var opera = false;
if(navigator.useragent.indexof('msie')>=0 && navigator.useragent.indexof('opera')<0)msie=true;
if(navigator.useragent.indexof('opera')>=0)opera=true;
switch(languagecode){
case "en": /* english */
var montharray = ['january','february','march','april','may','june','july','august','september','october','november','december'];
var montharrayshort = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
var dayarray = ['mon','tue','wed','thu','fri','sat','sun'];
var weekstring = 'week';
var todaystring = '';
break;
case "ge": /* german */
var montharray = ['januar','februar','m鋜z','april','mai','juni','juli','august','september','oktober','november','dezember'];
var montharrayshort = ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','dez'];
var dayarray = ['mon','die','mit','don','fre','sam','son'];
var weekstring = 'woche';
var todaystring = 'heute';
break;
case "no": /* norwegian */
var montharray = ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'];
var montharrayshort = ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','des'];
var dayarray = ['man','tir','ons','tor','fre','lør','søn'];
var weekstring = 'uke';
var todaystring = 'dagen i dag er';
break;
case "nl": /* dutch */
var montharray = ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'];
var montharrayshort = ['jan','feb','mar','apr','mei','jun','jul','aug','sep','okt','nov','dec'];
var dayarray = ['ma','di','wo','do','vr','za','zo'];
var weekstring = 'week';
var todaystring = 'vandaag';
break;
case "es": /* spanish */
var montharray = ['enero','febrero','marzo','april','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'];
var montharrayshort =['ene','feb','mar','abr','may','jun','jul','ago','sep','oct','nov','dic'];
var dayarray = ['lun','mar','mie','jue','vie','sab','dom'];
var weekstring = 'semana';
var todaystring = 'hoy es';
break;
case "pt-br": /* brazilian portuguese (pt-br) */
var montharray = ['janeiro','fevereiro','março','abril','maio','junho','julho','agosto','setembro','outubro','novembro','dezembro'];
var montharrayshort = ['jan','fev','mar','abr','mai','jun','jul','ago','set','out','nov','dez'];
var dayarray = ['seg','ter','qua','qui','sex','sáb','dom'];
var weekstring = 'sem.';
var todaystring = 'hoje é';
break;
case "fr": /* french */
var montharray = ['janvier','f関rier','mars','avril','mai','juin','juillet','ao鹴','septembre','octobre','novembre','d閏embre'];
var montharrayshort = ['jan','fev','mar','avr','mai','jun','jul','aou','sep','oct','nov','dec'];
var dayarray = ['lun','mar','mer','jeu','ven','sam','dim'];
var weekstring = 'sem';
var todaystring = "aujourd'hui";
break;
case "da": /*danish*/
var montharray = ['januar','februar','marts','april','maj','juni','juli','august','september','oktober','november','december'];
var montharrayshort = ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'];
var dayarray = ['man','tirs','ons','tors','fre','lør','søn'];
var weekstring = 'uge';
var todaystring = 'i dag er den';
break;
case "hu": /* hungarian - remember to use utf-8 encoding, i.e. the <meta> tag */
var montharray = ['janu谩r','febru谩r','m谩rcius','?prilis','m谩jus','j煤nius','j煤lius','augusztus','szeptember','okt贸ber','november','december'];
var montharrayshort = ['jan','feb','m谩rc','?pr','m谩j','j煤n','j煤l','aug','szep','okt','nov','dec'];
var dayarray = ['h茅','ke','sze','cs','p茅','szo','vas'];
var weekstring = 'h茅t';
var todaystring = 'mai nap';
break;
case "it": /* italian*/
var montharray = ['gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto','settembre','ottobre','novembre','dicembre'];
var montharrayshort = ['gen','feb','mar','apr','mag','giu','lugl','ago','set','ott','nov','dic'];
var dayarray = ['lun',';mar','mer','gio','ven','sab','dom'];
var weekstring = 'settimana';
var todaystring = 'oggi è il';
break;
case "sv": /* swedish */
var montharray = ['januari','februari','mars','april','maj','juni','juli','augusti','september','oktober','november','december'];
var montharrayshort = ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'];
var dayarray = ['mån','tis','ons','tor','fre','lör','sön'];
var weekstring = 'vecka';
var todaystring = 'idag är det den';
break;
}
var daysinmontharray = [31,28,31,30,31,30,31,31,30,31,30,31];
var currentmonth;
var currentyear;
var currenthour;
var currentminute;
var calendarcontentdiv;
var returndateto;
var returnformat;
var activeselectboxmonth;
var activeselectboxyear;
var activeselectboxhour;
var activeselectboxminute;
var iframeobj = false;
//// fix for ei frame problem on time dropdowns 09/30/2006
var iframeobj2 =false;
function eis_fix_ei1(where2fixit)
{
if(!iframeobj2)return;
iframeobj2.style.display = 'block';
iframeobj2.style.height =document.getelementbyid(where2fixit).offsetheight+1;
iframeobj2.style.width=document.getelementbyid(where2fixit).offsetwidth;
iframeobj2.style.left=getleftpos(document.getelementbyid(where2fixit))+1-calendar_offsetleft;
iframeobj2.style.top=gettoppos(document.getelementbyid(where2fixit))-document.getelementbyid(where2fixit).offsetheight-calendar_offsettop;
}
function eis_hide_frame()
{ if(iframeobj2)iframeobj2.style.display = 'none';}
//// fix for ei frame problem on time dropdowns 09/30/2006
var returndatetoyear;
var returndatetomonth;
var returndatetoday;
var returndatetohour;
var returndatetominute;
var inputyear;
var inputmonth;
var inputday;
var inputhour;
var inputminute;
var calendardisplaytime = false;
var selectboxhighlightcolor = '#d60808'; // highlight color of select boxes
var selectboxrolloverbgcolor = '#e2ebed'; // background color on drop down lists(rollover)
var selectboxmovementinprogress = false;
var activeselectbox = false;
function cancelcalendarevent()
{
return false;
}
function isleapyear(inputyear)
{
if(inputyear%400==0||(inputyear%4==0&&inputyear%100!=0)) return true;
return false;
}
var activeselectboxmonth = false;
var activeselectboxdirection = false;
function highlightmonthyear()
{
if(activeselectboxmonth)activeselectboxmonth.classname='';
activeselectbox = this;
if(this.classname=='monthyearactive'){
this.classname='';
}else{
this.classname = 'monthyearactive';
activeselectboxmonth = this;
}
if(this.innerhtml.indexof('-')>=0 || this.innerhtml.indexof('+')>=0){
if(this.classname=='monthyearactive')
selectboxmovementinprogress = true;
else
selectboxmovementinprogress = false;
if(this.innerhtml.indexof('-')>=0)activeselectboxdirection = -1; else activeselectboxdirection = 1;
}else selectboxmovementinprogress = false;
}
function showmonthdropdown()
{
if(document.getelementbyid('monthdropdown').style.display=='block'){
document.getelementbyid('monthdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('monthdropdown').style.display='block';
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
if (msie)
{ eis_fix_ei1('monthdropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function showyeardropdown()
{
if(document.getelementbyid('yeardropdown').style.display=='block'){
document.getelementbyid('yeardropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('yeardropdown').style.display='block';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
if (msie)
{ eis_fix_ei1('yeardropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function showhourdropdown()
{
if(document.getelementbyid('hourdropdown').style.display=='block'){
document.getelementbyid('hourdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('hourdropdown').style.display='block';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
if (msie)
{ eis_fix_ei1('hourdropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function showminutedropdown()
{
if(document.getelementbyid('minutedropdown').style.display=='block'){
document.getelementbyid('minutedropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('minutedropdown').style.display='block';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
if (msie)
{ eis_fix_ei1('minutedropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function selectmonth()
{
document.getelementbyid('calendar_month_txt').innerhtml = this.innerhtml
currentmonth = this.id.replace(/[^\d]/g,'');
document.getelementbyid('monthdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
for(var no=0;no<montharray.length;no++){
document.getelementbyid('monthdiv_'+no).style.color='';
}
this.style.color = selectboxhighlightcolor;
activeselectboxmonth = this;
writecalendarcontent();
}
function selecthour()
{
document.getelementbyid('calendar_hour_txt').innerhtml = this.innerhtml
currenthour = this.innerhtml.replace(/[^\d]/g,'');
document.getelementbyid('hourdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
if(activeselectboxhour){
activeselectboxhour.style.color='';
}
activeselectboxhour=this;
this.style.color = selectboxhighlightcolor;
}
function selectminute()
{
document.getelementbyid('calendar_minute_txt').innerhtml = this.innerhtml
currentminute = this.innerhtml.replace(/[^\d]/g,'');
document.getelementbyid('minutedropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
if(activeselectboxminute){
activeselectboxminute.style.color='';
}
activeselectboxminute=this;
this.style.color = selectboxhighlightcolor;
}
function selectyear()
{
document.getelementbyid('calendar_year_txt').innerhtml = this.innerhtml
currentyear = this.innerhtml.replace(/[^\d]/g,'');
document.getelementbyid('yeardropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
if(activeselectboxyear){
activeselectboxyear.style.color='';
}
activeselectboxyear=this;
this.style.color = selectboxhighlightcolor;
writecalendarcontent();
}
function switchmonth()
{
if(this.src.indexof('left')>=0){
currentmonth=currentmonth-1;;
if(currentmonth<0){
currentmonth=11;
currentyear=currentyear-1;
}
}else{
currentmonth=currentmonth+1;;
if(currentmonth>11){
currentmonth=0;
currentyear=currentyear/1+1;
}
}
writecalendarcontent();
}
function createmonthdiv(){
var div = document.createelement('div');
div.classname='monthyearpicker';
div.id = 'monthpicker';
for(var no=0;no<montharray.length;no++){
var subdiv = document.createelement('div');
subdiv.innerhtml = montharray[no];
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selectmonth;
subdiv.id = 'monthdiv_' + no;
subdiv.style.width = '56px';
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentmonth && currentmonth==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxmonth = subdiv;
}
}
return div;
}
function changeselectboxyear(e,inputobj)
{
if(!inputobj)inputobj =this;
var yearitems = inputobj.parentnode.getelementsbytagname('div');
if(inputobj.innerhtml.indexof('-')>=0){
var startyear = yearitems[1].innerhtml/1 -1;
if(activeselectboxyear){
activeselectboxyear.style.color='';
}
}else{
var startyear = yearitems[1].innerhtml/1 +1;
if(activeselectboxyear){
activeselectboxyear.style.color='';
}
}
for(var no=1;no<yearitems.length-1;no++){
yearitems[no].innerhtml = startyear+no-1;
yearitems[no].id = 'yeardiv' + (startyear/1+no/1-1);
}
if(activeselectboxyear){
activeselectboxyear.style.color='';
if(document.getelementbyid('yeardiv'+currentyear)){
activeselectboxyear = document.getelementbyid('yeardiv'+currentyear);
activeselectboxyear.style.color=selectboxhighlightcolor;;
}
}
}
function changeselectboxhour(e,inputobj)
{
if(!inputobj)inputobj = this;
var houritems = inputobj.parentnode.getelementsbytagname('div');
if(inputobj.innerhtml.indexof('-')>=0){
var starthour = houritems[1].innerhtml/1 -1;
if(starthour<0)starthour=0;
if(activeselectboxhour){
activeselectboxhour.style.color='';
}
}else{
var starthour = houritems[1].innerhtml/1 +1;
if(starthour>14)starthour = 14;
if(activeselectboxhour){
activeselectboxhour.style.color='';
}
}
var prefix = '';
for(var no=1;no<houritems.length-1;no++){
if((starthour/1 + no/1) < 11)prefix = '0'; else prefix = '';
houritems[no].innerhtml = prefix + (starthour+no-1);
houritems[no].id = 'hourdiv' + (starthour/1+no/1-1);
}
if(activeselectboxhour){
activeselectboxhour.style.color='';
if(document.getelementbyid('hourdiv'+currenthour)){
activeselectboxhour = document.getelementbyid('hourdiv'+currenthour);
activeselectboxhour.style.color=selectboxhighlightcolor;;
}
}
}
function updateyeardiv()
{
var div = document.getelementbyid('yeardropdown');
var yearitems = div.getelementsbytagname('div');
for(var no=1;no<yearitems.length-1;no++){
yearitems[no].innerhtml = currentyear/1 -6 + no;
if(currentyear==(currentyear/1 -6 + no)){
yearitems[no].style.color = selectboxhighlightcolor;
activeselectboxyear = yearitems[no];
}else{
yearitems[no].style.color = '';
}
}
}
function updatemonthdiv()
{
for(no=0;no<12;no++){
document.getelementbyid('monthdiv_' + no).style.color = '';
}
document.getelementbyid('monthdiv_' + currentmonth).style.color = selectboxhighlightcolor;
activeselectboxmonth = document.getelementbyid('monthdiv_' + currentmonth);
}
function updatehourdiv()
{
var div = document.getelementbyid('hourdropdown');
var houritems = div.getelementsbytagname('div');
var addhours = 0;
if((currenthour/1 -6 + 1)<0){
addhours = (currenthour/1 -6 + 1)*-1;
}
for(var no=1;no<houritems.length-1;no++){
var prefix='';
if((currenthour/1 -6 + no + addhours) < 10)prefix='0';
houritems[no].innerhtml = prefix + (currenthour/1 -6 + no + addhours);
if(currenthour==(currenthour/1 -6 + no)){
houritems[no].style.color = selectboxhighlightcolor;
activeselectboxhour = houritems[no];
}else{
houritems[no].style.color = '';
}
}
}
function updateminutediv()
{
for(no=0;no<60;no+=intervalselectbox_minutes){
var prefix = '';
if(no<10)prefix = '0';
document.getelementbyid('minutediv_' + prefix + no).style.color = '';
}
if(document.getelementbyid('minutediv_' + currentminute)){
document.getelementbyid('minutediv_' + currentminute).style.color = selectboxhighlightcolor;
activeselectboxminute = document.getelementbyid('minutediv_' + currentminute);
}
}
function createyeardiv()
{
if(!document.getelementbyid('yeardropdown')){
var div = document.createelement('div');
div.classname='monthyearpicker';
}else{
var div = document.getelementbyid('yeardropdown');
var subdivs = div.getelementsbytagname('div');
for(var no=0;no<subdivs.length;no++){
subdivs[no].parentnode.removechild(subdivs[no]);
}
}
var d = new date();
if(currentyear){
d.setfullyear(currentyear);
}
var startyear = d.getfullyear()/1 - 5;
var subdiv = document.createelement('div');
subdiv.innerhtml = ' - ';
subdiv.onclick = changeselectboxyear;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
for(var no=startyear;no<(startyear+10);no++){
var subdiv = document.createelement('div');
subdiv.innerhtml = no;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selectyear;
subdiv.id = 'yeardiv' + no;
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentyear && currentyear==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxyear = subdiv;
}
}
var subdiv = document.createelement('div');
subdiv.innerhtml = ' + ';
subdiv.onclick = changeselectboxyear;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
return div;
}
/* this function creates the hour div at the bottom bar */
function slidecalendarselectbox()
{
if(selectboxmovementinprogress){
if(activeselectbox.parentnode.id=='hourdropdown'){
changeselectboxhour(false,activeselectbox);
}
if(activeselectbox.parentnode.id=='yeardropdown'){
changeselectboxyear(false,activeselectbox);
}
}
settimeout('slidecalendarselectbox()',speedofselectboxsliding);
}
function createhourdiv()
{
if(!document.getelementbyid('hourdropdown')){
var div = document.createelement('div');
div.classname='monthyearpicker';
}else{
var div = document.getelementbyid('hourdropdown');
var subdivs = div.getelementsbytagname('div');
for(var no=0;no<subdivs.length;no++){
subdivs[no].parentnode.removechild(subdivs[no]);
}
}
if(!currenthour)currenthour=0;
var starthour = currenthour/1;
if(starthour>14)starthour=14;
var subdiv = document.createelement('div');
subdiv.innerhtml = ' - ';
subdiv.onclick = changeselectboxhour;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
for(var no=starthour;no<starthour+10;no++){
var prefix = '';
if(no/1<10)prefix='0';
var subdiv = document.createelement('div');
subdiv.innerhtml = prefix + no;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selecthour;
subdiv.id = 'hourdiv' + no;
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentyear && currentyear==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxyear = subdiv;
}
}
var subdiv = document.createelement('div');
subdiv.innerhtml = ' + ';
subdiv.onclick = changeselectboxhour;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
return div;
}
/* this function creates the minute div at the bottom bar */
function createminutediv()
{
if(!document.getelementbyid('minutedropdown')){
var div = document.createelement('div');
div.classname='monthyearpicker';
}else{
var div = document.getelementbyid('minutedropdown');
var subdivs = div.getelementsbytagname('div');
for(var no=0;no<subdivs.length;no++){
subdivs[no].parentnode.removechild(subdivs[no]);
}
}
var startminute = 0;
var prefix = '';
for(var no=startminute;no<60;no+=intervalselectbox_minutes){
if(no<10)prefix='0'; else prefix = '';
var subdiv = document.createelement('div');
subdiv.innerhtml = prefix + no;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selectminute;
subdiv.id = 'minutediv_' + prefix + no;
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentyear && currentyear==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxyear = subdiv;
}
}
return div;
}
function highlightselect()
{
if(this.classname=='selectboxtime'){
this.classname = 'selectboxtimeover';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down_time_over.gif';
}else if(this.classname=='selectboxtimeover'){
this.classname = 'selectboxtime';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down_time.gif';
}
if(this.classname=='selectbox'){
this.classname = 'selectboxover';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down_over.gif';
}else if(this.classname=='selectboxover'){
this.classname = 'selectbox';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down.gif';
}
}
function highlightarrow()
{
if(this.src.indexof('over')>=0){
if(this.src.indexof('left')>=0)this.src = pathtoimages + 'left.gif';
if(this.src.indexof('right')>=0)this.src = pathtoimages + 'right.gif';
}else{
if(this.src.indexof('left')>=0)this.src = pathtoimages + 'left_over.gif';
if(this.src.indexof('right')>=0)this.src = pathtoimages + 'right_over.gif';
}
}
function highlightclose()
{
if(this.src.indexof('over')>=0){
this.src = pathtoimages + 'close.gif';
}else{
this.src = pathtoimages + 'close_over.gif';
}
}
function closecalendar(){
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
calendardiv.style.display='none';
if(iframeobj){
iframeobj.style.display='none';
//// //// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();}
if(activeselectboxmonth)activeselectboxmonth.classname='';
if(activeselectboxyear)activeselectboxyear.classname='';
}
function writetopbar()
{
var topbar = document.createelement('div');
topbar.classname = 'topbar';
topbar.id = 'topbar';
calendardiv.appendchild(topbar);
// left arrow
var leftdiv = document.createelement('div');
leftdiv.style.marginright = '1px';
var img = document.createelement('img');
img.src = pathtoimages + 'left.gif';
img.onmouseover = highlightarrow;
img.onclick = switchmonth;
img.onmouseout = highlightarrow;
leftdiv.appendchild(img);
topbar.appendchild(leftdiv);
if(opera)leftdiv.style.width = '16px';
// right arrow
var rightdiv = document.createelement('div');
rightdiv.style.marginright = '1px';
var img = document.createelement('img');
img.src = pathtoimages + 'right.gif';
img.onclick = switchmonth;
img.onmouseover = highlightarrow;
img.onmouseout = highlightarrow;
rightdiv.appendchild(img);
if(opera)rightdiv.style.width = '16px';
topbar.appendchild(rightdiv);
// month selector
var monthdiv = document.createelement('div');
monthdiv.id = 'monthselect';
monthdiv.onmouseover = highlightselect;
monthdiv.onmouseout = highlightselect;
monthdiv.onclick = showmonthdropdown;
var span = document.createelement('span');
span.innerhtml = montharray[currentmonth];
span.id = 'calendar_month_txt';
monthdiv.appendchild(span);
var img = document.createelement('img');
img.src = pathtoimages + 'down.gif';
img.style.position = 'absolute';
img.style.right = '0px';
monthdiv.appendchild(img);
monthdiv.classname = 'selectbox';
if(opera){
img.style.csstext = 'float:right;position:relative';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
topbar.appendchild(monthdiv);
var monthpicker = createmonthdiv();
monthpicker.style.left = '37px';
monthpicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
monthpicker.style.width ='60px';
monthpicker.id = 'monthdropdown';
calendardiv.appendchild(monthpicker);
// year selector
var yeardiv = document.createelement('div');
yeardiv.onmouseover = highlightselect;
yeardiv.onmouseout = highlightselect;
yeardiv.onclick = showyeardropdown;
var span = document.createelement('span');
span.innerhtml = currentyear;
span.id = 'calendar_year_txt';
yeardiv.appendchild(span);
topbar.appendchild(yeardiv);
var img = document.createelement('img');
img.src = pathtoimages + 'down.gif';
yeardiv.appendchild(img);
yeardiv.classname = 'selectbox';
if(opera){
yeardiv.style.width = '50px';
img.style.csstext = 'float:right';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
var yearpicker = createyeardiv();
yearpicker.style.left = '113px';
yearpicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
yearpicker.style.width = '35px';
yearpicker.id = 'yeardropdown';
calendardiv.appendchild(yearpicker);
var img = document.createelement('img');
img.src = pathtoimages + 'close.gif';
img.style.stylefloat = 'right';
img.onmouseover = highlightclose;
img.onmouseout = highlightclose;
img.onclick = closecalendar;
topbar.appendchild(img);
if(!document.all){
img.style.position = 'absolute';
img.style.right = '2px';
}
}
function writecalendarcontent()
{
var calendarcontentdivexists = true;
if(!calendarcontentdiv){
calendarcontentdiv = document.createelement('div');
calendardiv.appendchild(calendarcontentdiv);
calendarcontentdivexists = false;
}
currentmonth = currentmonth/1;
var d = new date();
d.setfullyear(currentyear);
d.setdate(1);
d.setmonth(currentmonth);
var daystartofmonth = d.getday();
if(daystartofmonth==0)daystartofmonth=7;
daystartofmonth--;
document.getelementbyid('calendar_year_txt').innerhtml = currentyear;
document.getelementbyid('calendar_month_txt').innerhtml = montharray[currentmonth];
document.getelementbyid('calendar_hour_txt').innerhtml = currenthour;
document.getelementbyid('calendar_minute_txt').innerhtml = currentminute;
var existingtable = calendarcontentdiv.getelementsbytagname('table');
if(existingtable.length>0){
calendarcontentdiv.removechild(existingtable[0]);
}
var caltable = document.createelement('table');
caltable.width = '100%';
caltable.cellspacing = '0';
calendarcontentdiv.appendchild(caltable);
var caltbody = document.createelement('tbody');
caltable.appendchild(caltbody);
var row = caltbody.insertrow(-1);
row.classname = 'calendar_week_row';
var cell = row.insertcell(-1);
cell.innerhtml = weekstring;
cell.classname = 'calendar_week_column';
cell.style.backgroundcolor = selectboxrolloverbgcolor;
for(var no=0;no<dayarray.length;no++){
var cell = row.insertcell(-1);
cell.innerhtml = dayarray[no];
}
var row = caltbody.insertrow(-1);
var cell = row.insertcell(-1);
cell.classname = 'calendar_week_column';
cell.style.backgroundcolor = selectboxrolloverbgcolor;
var week = getweek(currentyear,currentmonth,1);
cell.innerhtml = week; // week
for(var no=0;no<daystartofmonth;no++){
var cell = row.insertcell(-1);
cell.innerhtml = ' ';
}
var colcounter = daystartofmonth;
var daysinmonth = daysinmontharray[currentmonth];
if(daysinmonth==28){
if(isleapyear(currentyear))daysinmonth=29;
}
for(var no=1;no<=daysinmonth;no++){
d.setdate(no-1);
if(colcounter>0 && colcounter%7==0){
var row = caltbody.insertrow(-1);
var cell = row.insertcell(-1);
cell.classname = 'calendar_week_column';
var week = getweek(currentyear,currentmonth,no);
cell.innerhtml = week; // week
cell.style.backgroundcolor = selectboxrolloverbgcolor;
}
var cell = row.insertcell(-1);
if(currentyear==inputyear && currentmonth == inputmonth && no==inputday){
cell.classname='activeday';
}
cell.innerhtml = no;
cell.onclick = pickdate;
colcounter++;
}
if(!document.all){
if(calendarcontentdiv.offsetheight)
document.getelementbyid('topbar').style.top = calendarcontentdiv.offsetheight + document.getelementbyid('timebar').offsetheight + document.getelementbyid('topbar').offsetheight -1 + 'px';
else{
document.getelementbyid('topbar').style.top = '';
document.getelementbyid('topbar').style.bottom = '0px';
}
}
if(iframeobj){
if(!calendarcontentdivexists)settimeout('resizeiframe()',350);else settimeout('resizeiframe()',10);
}
}
function resizeiframe()
{
iframeobj.style.width = calendardiv.offsetwidth + 'px';
iframeobj.style.height = calendardiv.offsetheight + 'px' ;
}
function picktodaysdate()
{
var d = new date();
currentmonth = d.getmonth();
currentyear = d.getfullyear();
pickdate(false,d.getdate());
}
function pickdate(e,inputday)
{
var month = currentmonth/1 +1;
if(month<10)month = '0' + month;
var day;
if(!inputday && this)day = this.innerhtml; else day = inputday;
if(day/1<10)day = '0' + day;
if(returnformat){
returnformat = returnformat.replace('dd',day);
returnformat = returnformat.replace('mm',month);
returnformat = returnformat.replace('yyyy',currentyear);
returnformat = returnformat.replace('hh',currenthour);
returnformat = returnformat.replace('ii',currentminute);
returnformat = returnformat.replace('d',day/1);
returnformat = returnformat.replace('m',month/1);
returndateto.value = returnformat;
try{
returndateto.onchange();
}catch(e){
}
}else{
for(var no=0;no<returndatetoyear.options.length;no++){
if(returndatetoyear.options[no].value==currentyear){
returndatetoyear.selectedindex=no;
break;
}
}
for(var no=0;no<returndatetomonth.options.length;no++){
if(returndatetomonth.options[no].value==month){
returndatetomonth.selectedindex=no;
break;
}
}
for(var no=0;no<returndatetoday.options.length;no++){
if(returndatetoday.options[no].value==day){
returndatetoday.selectedindex=no;
break;
}
}
if(calendardisplaytime){
for(var no=0;no<returndatetohour.options.length;no++){
if(returndatetohour.options[no].value==currenthour){
returndatetohour.selectedindex=no;
break;
}
}
for(var no=0;no<returndatetominute.options.length;no++){
if(returndatetominute.options[no].value==currentminute){
returndatetominute.selectedindex=no;
break;
}
}
}
}
closecalendar();
}
// this function is from http://www.codeproject.com/csharp/gregorianwknum.asp
// only changed the month add
function getweek(year,month,day){
day = day/1;
year = year /1;
month = month/1 + 1; //use 1-12
var a = math.floor((14-(month))/12);
var y = year+4800-a;
var m = (month)+(12*a)-3;
var jd = day + math.floor(((153*m)+2)/5) +
(365*y) + math.floor(y/4) - math.floor(y/100) +
math.floor(y/400) - 32045; // (gregorian calendar)
var d4 = (jd+31741-(jd%7))%146097%36524%1461;
var l = math.floor(d4/1460);
var d1 = ((d4-l)%365)+l;
numberofweek = math.floor(d1/7) + 1;
return numberofweek;
}
function writetimebar()
{
var timebar = document.createelement('div');
timebar.id = 'timebar';
timebar.classname = 'timebar';
var subdiv = document.createelement('div');
subdiv.innerhtml = 'time:';
//timebar.appendchild(subdiv);
// year selector
var hourdiv = document.createelement('div');
hourdiv.onmouseover = highlightselect;
hourdiv.onmouseout = highlightselect;
hourdiv.onclick = showhourdropdown;
hourdiv.style.width = '30px';
var span = document.createelement('span');
span.innerhtml = currenthour;
span.id = 'calendar_hour_txt';
hourdiv.appendchild(span);
timebar.appendchild(hourdiv);
var img = document.createelement('img');
img.src = pathtoimages + 'down_time.gif';
hourdiv.appendchild(img);
hourdiv.classname = 'selectboxtime';
if(opera){
hourdiv.style.width = '30px';
img.style.csstext = 'float:right';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
var hourpicker = createhourdiv();
hourpicker.style.left = '130px';
//hourpicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
hourpicker.style.width = '35px';
hourpicker.id = 'hourdropdown';
calendardiv.appendchild(hourpicker);
// add minute picker
// year selector
var minutediv = document.createelement('div');
minutediv.onmouseover = highlightselect;
minutediv.onmouseout = highlightselect;
minutediv.onclick = showminutedropdown;
minutediv.style.width = '30px';
var span = document.createelement('span');
span.innerhtml = currentminute;
span.id = 'calendar_minute_txt';
minutediv.appendchild(span);
timebar.appendchild(minutediv);
var img = document.createelement('img');
img.src = pathtoimages + 'down_time.gif';
minutediv.appendchild(img);
minutediv.classname = 'selectboxtime';
if(opera){
minutediv.style.width = '30px';
img.style.csstext = 'float:right';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
var minutepicker = createminutediv();
minutepicker.style.left = '167px';
//minutepicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
minutepicker.style.width = '35px';
minutepicker.id = 'minutedropdown';
calendardiv.appendchild(minutepicker);
return timebar;
}
function writebottombar()
{
var d = new date();
var bottombar = document.createelement('div');
bottombar.id = 'bottombar';
bottombar.style.cursor = 'pointer';
bottombar.classname = 'todaysdate';
// var todaystringformat = '[todaystring] [daystring] [day] [monthstring] [year]'; ;;
var subdiv = document.createelement('div');
subdiv.onclick = picktodaysdate;
subdiv.id = 'todaysdatestring';
subdiv.style.width = (calendardiv.offsetwidth - 95) + 'px';
var day = d.getday();
if(day==0)day = 7;
day--;
var bottomstring = todaystringformat;
bottomstring = bottomstring.replace('[monthstring]',montharrayshort[d.getmonth()]);
bottomstring = bottomstring.replace('[day]',d.getdate());
bottomstring = bottomstring.replace('[year]',d.getfullyear());
bottomstring = bottomstring.replace('[daystring]',dayarray[day].tolowercase());
bottomstring = bottomstring.replace('[ucfdaystring]',dayarray[day]);
bottomstring = bottomstring.replace('[todaystring]',todaystring);
subdiv.innerhtml = todaystring + ': ' + d.getdate() + '. ' + montharrayshort[d.getmonth()] + ', ' + d.getfullyear() ;
subdiv.innerhtml = bottomstring ;
bottombar.appendchild(subdiv);
var timediv = writetimebar();
bottombar.appendchild(timediv);
calendardiv.appendchild(bottombar);
}
function gettoppos(inputobj)
{
var returnvalue = inputobj.offsettop + inputobj.offsetheight;
while((inputobj = inputobj.offsetparent) != null)returnvalue += inputobj.offsettop;
return returnvalue + calendar_offsettop;
}
function getleftpos(inputobj)
{
var returnvalue = inputobj.offsetleft;
while((inputobj = inputobj.offsetparent) != null)returnvalue += inputobj.offsetleft;
return returnvalue + calendar_offsetleft;
}
function positioncalendar(inputobj)
{
calendardiv.style.left = getleftpos(inputobj) + 'px';
calendardiv.style.top = gettoppos(inputobj) + 'px';
if(iframeobj){
iframeobj.style.left = calendardiv.style.left;
iframeobj.style.top = calendardiv.style.top;
//// fix for ei frame problem on time dropdowns 09/30/2006
iframeobj2.style.left = calendardiv.style.left;
iframeobj2.style.top = calendardiv.style.top;
}
}
function initcalendar()
{
if(msie){
iframeobj = document.createelement('iframe');
iframeobj.style.filter = 'alpha(opacity=0)';
iframeobj.style.position = 'absolute';
iframeobj.border='0px';
iframeobj.style.border = '0px';
iframeobj.style.backgroundcolor = '#ff0000';
//// fix for ei frame problem on time dropdowns 09/30/2006
iframeobj2 = document.createelement('iframe');
iframeobj2.style.position = 'absolute';
iframeobj2.border='0px';
iframeobj2.style.border = '0px';
iframeobj2.style.height = '1px';
iframeobj2.style.width = '1px';
document.body.appendchild(iframeobj2);
//// fix for ei frame problem on time dropdowns 09/30/2006
// added fixed for https
iframeobj2.src = 'blank.html';
iframeobj.src = 'blank.html';
document.body.appendchild(iframeobj);
}
calendardiv = document.createelement('div');
calendardiv.id = 'calendardiv';
calendardiv.style.zindex = 1000;
slidecalendarselectbox();
document.body.appendchild(calendardiv);
writebottombar();
writetopbar();
if(!currentyear){
var d = new date();
currentmonth = d.getmonth();
currentyear = d.getfullyear();
}
writecalendarcontent();
}
function settimeproperties()
{
if(!calendardisplaytime){
document.getelementbyid('timebar').style.display='none';
document.getelementbyid('timebar').style.visibility='hidden';
document.getelementbyid('todaysdatestring').style.width = '100%';
}else{
document.getelementbyid('timebar').style.display='block';
document.getelementbyid('timebar').style.visibility='visible';
document.getelementbyid('hourdropdown').style.top = document.getelementbyid('calendar_minute_txt').parentnode.offsetheight + calendarcontentdiv.offsetheight + document.getelementbyid('topbar').offsetheight + 'px';
document.getelementbyid('minutedropdown').style.top = document.getelementbyid('calendar_minute_txt').parentnode.offsetheight + calendarcontentdiv.offsetheight + document.getelementbyid('topbar').offsetheight + 'px';
document.getelementbyid('minutedropdown').style.right = '50px';
document.getelementbyid('hourdropdown').style.right = '50px';
document.getelementbyid('todaysdatestring').style.width = '115px';
}
}
function calendarsortitems(a,b)
{
return a/1 - b/1;
}
function displaycalendar(inputfield,format,buttonobj,displaytime,timeinput)
{
if(displaytime)calendardisplaytime=true; else calendardisplaytime = false;
if(inputfield.value.length>0){
if(!format.match(/^[0-9]*?$/gi)){
var items = inputfield.value.split(/[^0-9]/gi);
var positionarray = new array();
positionarray['m'] = format.indexof('mm');
if(positionarray['m']==-1)positionarray['m'] = format.indexof('m');
positionarray['d'] = format.indexof('dd');
if(positionarray['d']==-1)positionarray['d'] = format.indexof('d');
positionarray['y'] = format.indexof('yyyy');
positionarray['h'] = format.indexof('hh');
positionarray['i'] = format.indexof('ii');
var positionarraynumeric = array();
positionarraynumeric[0] = positionarray['m'];
positionarraynumeric[1] = positionarray['d'];
positionarraynumeric[2] = positionarray['y'];
positionarraynumeric[3] = positionarray['h'];
positionarraynumeric[4] = positionarray['i'];
positionarraynumeric = positionarraynumeric.sort(calendarsortitems);
var itemindex = -1;
currenthour = '00';
currentminute = '00';
for(var no=0;no<positionarraynumeric.length;no++){
if(positionarraynumeric[no]==-1)continue;
itemindex++;
if(positionarraynumeric[no]==positionarray['m']){
currentmonth = items[itemindex]-1;
continue;
}
if(positionarraynumeric[no]==positionarray['y']){
currentyear = items[itemindex];
continue;
}
if(positionarraynumeric[no]==positionarray['d']){
tmpday = items[itemindex];
continue;
}
if(positionarraynumeric[no]==positionarray['h']){
currenthour = items[itemindex];
continue;
}
if(positionarraynumeric[no]==positionarray['i']){
currentminute = items[itemindex];
continue;
}
}
currentmonth = currentmonth / 1;
tmpday = tmpday / 1;
}else{
var monthpos = format.indexof('mm');
currentmonth = inputfield.value.substr(monthpos,2)/1 -1;
var yearpos = format.indexof('yyyy');
currentyear = inputfield.value.substr(yearpos,4);
var daypos = format.indexof('dd');
tmpday = inputfield.value.substr(daypos,2);
var hourpos = format.indexof('hh');
if(hourpos>=0){
tmphour = inputfield.value.substr(hourpos,2);
currenthour = tmphour;
}else{
currenthour = '00';
}
var minutepos = format.indexof('ii');
if(minutepos>=0){
tmpminute = inputfield.value.substr(minutepos,2);
currentminute = tmpminute;
}else{
currentminute = '00';
}
}
}else{
var d = new date();
currentmonth = d.getmonth();
currentyear = d.getfullyear();
currenthour = '08';
currentminute = '00';
tmpday = d.getdate();
}
inputyear = currentyear;
inputmonth = currentmonth;
inputday = tmpday/1;
if(!calendardiv){
initcalendar();
}else{
if(calendardiv.style.display=='block'){
closecalendar();
return false;
}
writecalendarcontent();
}
returnformat = format;
returndateto = inputfield;
positioncalendar(buttonobj);
calendardiv.style.visibility = 'visible';
calendardiv.style.display = 'block';
if(iframeobj){
iframeobj.style.display = '';
iframeobj.style.height = '140px';
iframeobj.style.width = '195px';
iframeobj2.style.display = '';
iframeobj2.style.height = '140px';
iframeobj2.style.width = '195px';
}
settimeproperties();
updateyeardiv();
updatemonthdiv();
updateminutediv();
updatehourdiv();
}
function displaycalendarselectbox(yearinput,monthinput,dayinput,hourinput,minuteinput,buttonobj)
{
if(!hourinput)calendardisplaytime=false; else calendardisplaytime = true;
currentmonth = monthinput.options[monthinput.selectedindex].value/1-1;
currentyear = yearinput.options[yearinput.selectedindex].value;
if(hourinput){
currenthour = hourinput.options[hourinput.selectedindex].value;
inputhour = currenthour/1;
}
if(minuteinput){
currentminute = minuteinput.options[minuteinput.selectedindex].value;
inputminute = currentminute/1;
}
inputyear = yearinput.options[yearinput.selectedindex].value;
inputmonth = monthinput.options[monthinput.selectedindex].value/1 - 1;
inputday = dayinput.options[dayinput.selectedindex].value/1;
if(!calendardiv){
initcalendar();
}else{
writecalendarcontent();
}
returndatetoyear = yearinput;
returndatetomonth = monthinput;
returndatetoday = dayinput;
returndatetohour = hourinput;
returndatetominute = minuteinput;
returnformat = false;
returndateto = false;
positioncalendar(buttonobj);
calendardiv.style.visibility = 'visible';
calendardiv.style.display = 'block';
if(iframeobj){
iframeobj.style.display = '';
iframeobj.style.height = calendardiv.offsetheight + 'px';
iframeobj.style.width = calendardiv.offsetwidth + 'px';
//// fix for ei frame problem on time dropdowns 09/30/2006
iframeobj2.style.display = '';
iframeobj2.style.height = calendardiv.offsetheight + 'px';
iframeobj2.style.width = calendardiv.offsetwidth + 'px'
}
settimeproperties();
updateyeardiv();
updatemonthdiv();
updatehourdiv();
updateminutediv();
}
// en = english, ge = german, no = norwegian,nl = dutch, es = spanish, pt-br = portuguese, fr = french, da = danish, hu = hungarian(use utf-8 doctype for hungarian)
var calendar_display_time = true;
// format of current day at the bottom of the calendar
// [todaystring] = the value of todaystring
// [daystring] = day of week (examle: mon, tue, wed...)
// [ucfdaystring] = day of week (examle: mon, tue, wed...) ( first letter in uppercase)
// [day] = day of month, 1..31
// [monthstring] = name of current month
// [year] = current year
var todaystringformat = '[todaystring] [ucfdaystring]. [day]. [monthstring] [year]';
var pathtoimages = 'images/'; // relative to your html file
var speedofselectboxsliding = 200; // milliseconds between changing year and hour when holding mouse over "-" and "+" - lower value = faster
var intervalselectbox_minutes = 5; // minute select box - interval between each option (5 = default)
var calendar_offsettop = 0; // offset - calendar placement - you probably have to modify this value if you're not using a strict doctype
var calendar_offsetleft = 0; // offset - calendar placement - you probably have to modify this value if you're not using a strict doctype
var calendardiv = false;
var msie = false;
var opera = false;
if(navigator.useragent.indexof('msie')>=0 && navigator.useragent.indexof('opera')<0)msie=true;
if(navigator.useragent.indexof('opera')>=0)opera=true;
switch(languagecode){
case "en": /* english */
var montharray = ['january','february','march','april','may','june','july','august','september','october','november','december'];
var montharrayshort = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
var dayarray = ['mon','tue','wed','thu','fri','sat','sun'];
var weekstring = 'week';
var todaystring = '';
break;
case "ge": /* german */
var montharray = ['januar','februar','m鋜z','april','mai','juni','juli','august','september','oktober','november','dezember'];
var montharrayshort = ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','dez'];
var dayarray = ['mon','die','mit','don','fre','sam','son'];
var weekstring = 'woche';
var todaystring = 'heute';
break;
case "no": /* norwegian */
var montharray = ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'];
var montharrayshort = ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','des'];
var dayarray = ['man','tir','ons','tor','fre','lør','søn'];
var weekstring = 'uke';
var todaystring = 'dagen i dag er';
break;
case "nl": /* dutch */
var montharray = ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'];
var montharrayshort = ['jan','feb','mar','apr','mei','jun','jul','aug','sep','okt','nov','dec'];
var dayarray = ['ma','di','wo','do','vr','za','zo'];
var weekstring = 'week';
var todaystring = 'vandaag';
break;
case "es": /* spanish */
var montharray = ['enero','febrero','marzo','april','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'];
var montharrayshort =['ene','feb','mar','abr','may','jun','jul','ago','sep','oct','nov','dic'];
var dayarray = ['lun','mar','mie','jue','vie','sab','dom'];
var weekstring = 'semana';
var todaystring = 'hoy es';
break;
case "pt-br": /* brazilian portuguese (pt-br) */
var montharray = ['janeiro','fevereiro','março','abril','maio','junho','julho','agosto','setembro','outubro','novembro','dezembro'];
var montharrayshort = ['jan','fev','mar','abr','mai','jun','jul','ago','set','out','nov','dez'];
var dayarray = ['seg','ter','qua','qui','sex','sáb','dom'];
var weekstring = 'sem.';
var todaystring = 'hoje é';
break;
case "fr": /* french */
var montharray = ['janvier','f関rier','mars','avril','mai','juin','juillet','ao鹴','septembre','octobre','novembre','d閏embre'];
var montharrayshort = ['jan','fev','mar','avr','mai','jun','jul','aou','sep','oct','nov','dec'];
var dayarray = ['lun','mar','mer','jeu','ven','sam','dim'];
var weekstring = 'sem';
var todaystring = "aujourd'hui";
break;
case "da": /*danish*/
var montharray = ['januar','februar','marts','april','maj','juni','juli','august','september','oktober','november','december'];
var montharrayshort = ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'];
var dayarray = ['man','tirs','ons','tors','fre','lør','søn'];
var weekstring = 'uge';
var todaystring = 'i dag er den';
break;
case "hu": /* hungarian - remember to use utf-8 encoding, i.e. the <meta> tag */
var montharray = ['janu谩r','febru谩r','m谩rcius','?prilis','m谩jus','j煤nius','j煤lius','augusztus','szeptember','okt贸ber','november','december'];
var montharrayshort = ['jan','feb','m谩rc','?pr','m谩j','j煤n','j煤l','aug','szep','okt','nov','dec'];
var dayarray = ['h茅','ke','sze','cs','p茅','szo','vas'];
var weekstring = 'h茅t';
var todaystring = 'mai nap';
break;
case "it": /* italian*/
var montharray = ['gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto','settembre','ottobre','novembre','dicembre'];
var montharrayshort = ['gen','feb','mar','apr','mag','giu','lugl','ago','set','ott','nov','dic'];
var dayarray = ['lun',';mar','mer','gio','ven','sab','dom'];
var weekstring = 'settimana';
var todaystring = 'oggi è il';
break;
case "sv": /* swedish */
var montharray = ['januari','februari','mars','april','maj','juni','juli','augusti','september','oktober','november','december'];
var montharrayshort = ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'];
var dayarray = ['mån','tis','ons','tor','fre','lör','sön'];
var weekstring = 'vecka';
var todaystring = 'idag är det den';
break;
}
var daysinmontharray = [31,28,31,30,31,30,31,31,30,31,30,31];
var currentmonth;
var currentyear;
var currenthour;
var currentminute;
var calendarcontentdiv;
var returndateto;
var returnformat;
var activeselectboxmonth;
var activeselectboxyear;
var activeselectboxhour;
var activeselectboxminute;
var iframeobj = false;
//// fix for ei frame problem on time dropdowns 09/30/2006
var iframeobj2 =false;
function eis_fix_ei1(where2fixit)
{
if(!iframeobj2)return;
iframeobj2.style.display = 'block';
iframeobj2.style.height =document.getelementbyid(where2fixit).offsetheight+1;
iframeobj2.style.width=document.getelementbyid(where2fixit).offsetwidth;
iframeobj2.style.left=getleftpos(document.getelementbyid(where2fixit))+1-calendar_offsetleft;
iframeobj2.style.top=gettoppos(document.getelementbyid(where2fixit))-document.getelementbyid(where2fixit).offsetheight-calendar_offsettop;
}
function eis_hide_frame()
{ if(iframeobj2)iframeobj2.style.display = 'none';}
//// fix for ei frame problem on time dropdowns 09/30/2006
var returndatetoyear;
var returndatetomonth;
var returndatetoday;
var returndatetohour;
var returndatetominute;
var inputyear;
var inputmonth;
var inputday;
var inputhour;
var inputminute;
var calendardisplaytime = false;
var selectboxhighlightcolor = '#d60808'; // highlight color of select boxes
var selectboxrolloverbgcolor = '#e2ebed'; // background color on drop down lists(rollover)
var selectboxmovementinprogress = false;
var activeselectbox = false;
function cancelcalendarevent()
{
return false;
}
function isleapyear(inputyear)
{
if(inputyear%400==0||(inputyear%4==0&&inputyear%100!=0)) return true;
return false;
}
var activeselectboxmonth = false;
var activeselectboxdirection = false;
function highlightmonthyear()
{
if(activeselectboxmonth)activeselectboxmonth.classname='';
activeselectbox = this;
if(this.classname=='monthyearactive'){
this.classname='';
}else{
this.classname = 'monthyearactive';
activeselectboxmonth = this;
}
if(this.innerhtml.indexof('-')>=0 || this.innerhtml.indexof('+')>=0){
if(this.classname=='monthyearactive')
selectboxmovementinprogress = true;
else
selectboxmovementinprogress = false;
if(this.innerhtml.indexof('-')>=0)activeselectboxdirection = -1; else activeselectboxdirection = 1;
}else selectboxmovementinprogress = false;
}
function showmonthdropdown()
{
if(document.getelementbyid('monthdropdown').style.display=='block'){
document.getelementbyid('monthdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('monthdropdown').style.display='block';
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
if (msie)
{ eis_fix_ei1('monthdropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function showyeardropdown()
{
if(document.getelementbyid('yeardropdown').style.display=='block'){
document.getelementbyid('yeardropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('yeardropdown').style.display='block';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
if (msie)
{ eis_fix_ei1('yeardropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function showhourdropdown()
{
if(document.getelementbyid('hourdropdown').style.display=='block'){
document.getelementbyid('hourdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('hourdropdown').style.display='block';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
if (msie)
{ eis_fix_ei1('hourdropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function showminutedropdown()
{
if(document.getelementbyid('minutedropdown').style.display=='block'){
document.getelementbyid('minutedropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
}else{
document.getelementbyid('minutedropdown').style.display='block';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
if (msie)
{ eis_fix_ei1('minutedropdown')}
//// fix for ei frame problem on time dropdowns 09/30/2006
}
}
function selectmonth()
{
document.getelementbyid('calendar_month_txt').innerhtml = this.innerhtml
currentmonth = this.id.replace(/[^\d]/g,'');
document.getelementbyid('monthdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
for(var no=0;no<montharray.length;no++){
document.getelementbyid('monthdiv_'+no).style.color='';
}
this.style.color = selectboxhighlightcolor;
activeselectboxmonth = this;
writecalendarcontent();
}
function selecthour()
{
document.getelementbyid('calendar_hour_txt').innerhtml = this.innerhtml
currenthour = this.innerhtml.replace(/[^\d]/g,'');
document.getelementbyid('hourdropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
if(activeselectboxhour){
activeselectboxhour.style.color='';
}
activeselectboxhour=this;
this.style.color = selectboxhighlightcolor;
}
function selectminute()
{
document.getelementbyid('calendar_minute_txt').innerhtml = this.innerhtml
currentminute = this.innerhtml.replace(/[^\d]/g,'');
document.getelementbyid('minutedropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
if(activeselectboxminute){
activeselectboxminute.style.color='';
}
activeselectboxminute=this;
this.style.color = selectboxhighlightcolor;
}
function selectyear()
{
document.getelementbyid('calendar_year_txt').innerhtml = this.innerhtml
currentyear = this.innerhtml.replace(/[^\d]/g,'');
document.getelementbyid('yeardropdown').style.display='none';
//// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();
if(activeselectboxyear){
activeselectboxyear.style.color='';
}
activeselectboxyear=this;
this.style.color = selectboxhighlightcolor;
writecalendarcontent();
}
function switchmonth()
{
if(this.src.indexof('left')>=0){
currentmonth=currentmonth-1;;
if(currentmonth<0){
currentmonth=11;
currentyear=currentyear-1;
}
}else{
currentmonth=currentmonth+1;;
if(currentmonth>11){
currentmonth=0;
currentyear=currentyear/1+1;
}
}
writecalendarcontent();
}
function createmonthdiv(){
var div = document.createelement('div');
div.classname='monthyearpicker';
div.id = 'monthpicker';
for(var no=0;no<montharray.length;no++){
var subdiv = document.createelement('div');
subdiv.innerhtml = montharray[no];
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selectmonth;
subdiv.id = 'monthdiv_' + no;
subdiv.style.width = '56px';
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentmonth && currentmonth==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxmonth = subdiv;
}
}
return div;
}
function changeselectboxyear(e,inputobj)
{
if(!inputobj)inputobj =this;
var yearitems = inputobj.parentnode.getelementsbytagname('div');
if(inputobj.innerhtml.indexof('-')>=0){
var startyear = yearitems[1].innerhtml/1 -1;
if(activeselectboxyear){
activeselectboxyear.style.color='';
}
}else{
var startyear = yearitems[1].innerhtml/1 +1;
if(activeselectboxyear){
activeselectboxyear.style.color='';
}
}
for(var no=1;no<yearitems.length-1;no++){
yearitems[no].innerhtml = startyear+no-1;
yearitems[no].id = 'yeardiv' + (startyear/1+no/1-1);
}
if(activeselectboxyear){
activeselectboxyear.style.color='';
if(document.getelementbyid('yeardiv'+currentyear)){
activeselectboxyear = document.getelementbyid('yeardiv'+currentyear);
activeselectboxyear.style.color=selectboxhighlightcolor;;
}
}
}
function changeselectboxhour(e,inputobj)
{
if(!inputobj)inputobj = this;
var houritems = inputobj.parentnode.getelementsbytagname('div');
if(inputobj.innerhtml.indexof('-')>=0){
var starthour = houritems[1].innerhtml/1 -1;
if(starthour<0)starthour=0;
if(activeselectboxhour){
activeselectboxhour.style.color='';
}
}else{
var starthour = houritems[1].innerhtml/1 +1;
if(starthour>14)starthour = 14;
if(activeselectboxhour){
activeselectboxhour.style.color='';
}
}
var prefix = '';
for(var no=1;no<houritems.length-1;no++){
if((starthour/1 + no/1) < 11)prefix = '0'; else prefix = '';
houritems[no].innerhtml = prefix + (starthour+no-1);
houritems[no].id = 'hourdiv' + (starthour/1+no/1-1);
}
if(activeselectboxhour){
activeselectboxhour.style.color='';
if(document.getelementbyid('hourdiv'+currenthour)){
activeselectboxhour = document.getelementbyid('hourdiv'+currenthour);
activeselectboxhour.style.color=selectboxhighlightcolor;;
}
}
}
function updateyeardiv()
{
var div = document.getelementbyid('yeardropdown');
var yearitems = div.getelementsbytagname('div');
for(var no=1;no<yearitems.length-1;no++){
yearitems[no].innerhtml = currentyear/1 -6 + no;
if(currentyear==(currentyear/1 -6 + no)){
yearitems[no].style.color = selectboxhighlightcolor;
activeselectboxyear = yearitems[no];
}else{
yearitems[no].style.color = '';
}
}
}
function updatemonthdiv()
{
for(no=0;no<12;no++){
document.getelementbyid('monthdiv_' + no).style.color = '';
}
document.getelementbyid('monthdiv_' + currentmonth).style.color = selectboxhighlightcolor;
activeselectboxmonth = document.getelementbyid('monthdiv_' + currentmonth);
}
function updatehourdiv()
{
var div = document.getelementbyid('hourdropdown');
var houritems = div.getelementsbytagname('div');
var addhours = 0;
if((currenthour/1 -6 + 1)<0){
addhours = (currenthour/1 -6 + 1)*-1;
}
for(var no=1;no<houritems.length-1;no++){
var prefix='';
if((currenthour/1 -6 + no + addhours) < 10)prefix='0';
houritems[no].innerhtml = prefix + (currenthour/1 -6 + no + addhours);
if(currenthour==(currenthour/1 -6 + no)){
houritems[no].style.color = selectboxhighlightcolor;
activeselectboxhour = houritems[no];
}else{
houritems[no].style.color = '';
}
}
}
function updateminutediv()
{
for(no=0;no<60;no+=intervalselectbox_minutes){
var prefix = '';
if(no<10)prefix = '0';
document.getelementbyid('minutediv_' + prefix + no).style.color = '';
}
if(document.getelementbyid('minutediv_' + currentminute)){
document.getelementbyid('minutediv_' + currentminute).style.color = selectboxhighlightcolor;
activeselectboxminute = document.getelementbyid('minutediv_' + currentminute);
}
}
function createyeardiv()
{
if(!document.getelementbyid('yeardropdown')){
var div = document.createelement('div');
div.classname='monthyearpicker';
}else{
var div = document.getelementbyid('yeardropdown');
var subdivs = div.getelementsbytagname('div');
for(var no=0;no<subdivs.length;no++){
subdivs[no].parentnode.removechild(subdivs[no]);
}
}
var d = new date();
if(currentyear){
d.setfullyear(currentyear);
}
var startyear = d.getfullyear()/1 - 5;
var subdiv = document.createelement('div');
subdiv.innerhtml = ' - ';
subdiv.onclick = changeselectboxyear;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
for(var no=startyear;no<(startyear+10);no++){
var subdiv = document.createelement('div');
subdiv.innerhtml = no;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selectyear;
subdiv.id = 'yeardiv' + no;
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentyear && currentyear==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxyear = subdiv;
}
}
var subdiv = document.createelement('div');
subdiv.innerhtml = ' + ';
subdiv.onclick = changeselectboxyear;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
return div;
}
/* this function creates the hour div at the bottom bar */
function slidecalendarselectbox()
{
if(selectboxmovementinprogress){
if(activeselectbox.parentnode.id=='hourdropdown'){
changeselectboxhour(false,activeselectbox);
}
if(activeselectbox.parentnode.id=='yeardropdown'){
changeselectboxyear(false,activeselectbox);
}
}
settimeout('slidecalendarselectbox()',speedofselectboxsliding);
}
function createhourdiv()
{
if(!document.getelementbyid('hourdropdown')){
var div = document.createelement('div');
div.classname='monthyearpicker';
}else{
var div = document.getelementbyid('hourdropdown');
var subdivs = div.getelementsbytagname('div');
for(var no=0;no<subdivs.length;no++){
subdivs[no].parentnode.removechild(subdivs[no]);
}
}
if(!currenthour)currenthour=0;
var starthour = currenthour/1;
if(starthour>14)starthour=14;
var subdiv = document.createelement('div');
subdiv.innerhtml = ' - ';
subdiv.onclick = changeselectboxhour;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
for(var no=starthour;no<starthour+10;no++){
var prefix = '';
if(no/1<10)prefix='0';
var subdiv = document.createelement('div');
subdiv.innerhtml = prefix + no;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selecthour;
subdiv.id = 'hourdiv' + no;
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentyear && currentyear==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxyear = subdiv;
}
}
var subdiv = document.createelement('div');
subdiv.innerhtml = ' + ';
subdiv.onclick = changeselectboxhour;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = function(){ selectboxmovementinprogress = false;};
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
return div;
}
/* this function creates the minute div at the bottom bar */
function createminutediv()
{
if(!document.getelementbyid('minutedropdown')){
var div = document.createelement('div');
div.classname='monthyearpicker';
}else{
var div = document.getelementbyid('minutedropdown');
var subdivs = div.getelementsbytagname('div');
for(var no=0;no<subdivs.length;no++){
subdivs[no].parentnode.removechild(subdivs[no]);
}
}
var startminute = 0;
var prefix = '';
for(var no=startminute;no<60;no+=intervalselectbox_minutes){
if(no<10)prefix='0'; else prefix = '';
var subdiv = document.createelement('div');
subdiv.innerhtml = prefix + no;
subdiv.onmouseover = highlightmonthyear;
subdiv.onmouseout = highlightmonthyear;
subdiv.onclick = selectminute;
subdiv.id = 'minutediv_' + prefix + no;
subdiv.onselectstart = cancelcalendarevent;
div.appendchild(subdiv);
if(currentyear && currentyear==no){
subdiv.style.color = selectboxhighlightcolor;
activeselectboxyear = subdiv;
}
}
return div;
}
function highlightselect()
{
if(this.classname=='selectboxtime'){
this.classname = 'selectboxtimeover';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down_time_over.gif';
}else if(this.classname=='selectboxtimeover'){
this.classname = 'selectboxtime';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down_time.gif';
}
if(this.classname=='selectbox'){
this.classname = 'selectboxover';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down_over.gif';
}else if(this.classname=='selectboxover'){
this.classname = 'selectbox';
this.getelementsbytagname('img')[0].src = pathtoimages + 'down.gif';
}
}
function highlightarrow()
{
if(this.src.indexof('over')>=0){
if(this.src.indexof('left')>=0)this.src = pathtoimages + 'left.gif';
if(this.src.indexof('right')>=0)this.src = pathtoimages + 'right.gif';
}else{
if(this.src.indexof('left')>=0)this.src = pathtoimages + 'left_over.gif';
if(this.src.indexof('right')>=0)this.src = pathtoimages + 'right_over.gif';
}
}
function highlightclose()
{
if(this.src.indexof('over')>=0){
this.src = pathtoimages + 'close.gif';
}else{
this.src = pathtoimages + 'close_over.gif';
}
}
function closecalendar(){
document.getelementbyid('yeardropdown').style.display='none';
document.getelementbyid('monthdropdown').style.display='none';
document.getelementbyid('hourdropdown').style.display='none';
document.getelementbyid('minutedropdown').style.display='none';
calendardiv.style.display='none';
if(iframeobj){
iframeobj.style.display='none';
//// //// fix for ei frame problem on time dropdowns 09/30/2006
eis_hide_frame();}
if(activeselectboxmonth)activeselectboxmonth.classname='';
if(activeselectboxyear)activeselectboxyear.classname='';
}
function writetopbar()
{
var topbar = document.createelement('div');
topbar.classname = 'topbar';
topbar.id = 'topbar';
calendardiv.appendchild(topbar);
// left arrow
var leftdiv = document.createelement('div');
leftdiv.style.marginright = '1px';
var img = document.createelement('img');
img.src = pathtoimages + 'left.gif';
img.onmouseover = highlightarrow;
img.onclick = switchmonth;
img.onmouseout = highlightarrow;
leftdiv.appendchild(img);
topbar.appendchild(leftdiv);
if(opera)leftdiv.style.width = '16px';
// right arrow
var rightdiv = document.createelement('div');
rightdiv.style.marginright = '1px';
var img = document.createelement('img');
img.src = pathtoimages + 'right.gif';
img.onclick = switchmonth;
img.onmouseover = highlightarrow;
img.onmouseout = highlightarrow;
rightdiv.appendchild(img);
if(opera)rightdiv.style.width = '16px';
topbar.appendchild(rightdiv);
// month selector
var monthdiv = document.createelement('div');
monthdiv.id = 'monthselect';
monthdiv.onmouseover = highlightselect;
monthdiv.onmouseout = highlightselect;
monthdiv.onclick = showmonthdropdown;
var span = document.createelement('span');
span.innerhtml = montharray[currentmonth];
span.id = 'calendar_month_txt';
monthdiv.appendchild(span);
var img = document.createelement('img');
img.src = pathtoimages + 'down.gif';
img.style.position = 'absolute';
img.style.right = '0px';
monthdiv.appendchild(img);
monthdiv.classname = 'selectbox';
if(opera){
img.style.csstext = 'float:right;position:relative';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
topbar.appendchild(monthdiv);
var monthpicker = createmonthdiv();
monthpicker.style.left = '37px';
monthpicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
monthpicker.style.width ='60px';
monthpicker.id = 'monthdropdown';
calendardiv.appendchild(monthpicker);
// year selector
var yeardiv = document.createelement('div');
yeardiv.onmouseover = highlightselect;
yeardiv.onmouseout = highlightselect;
yeardiv.onclick = showyeardropdown;
var span = document.createelement('span');
span.innerhtml = currentyear;
span.id = 'calendar_year_txt';
yeardiv.appendchild(span);
topbar.appendchild(yeardiv);
var img = document.createelement('img');
img.src = pathtoimages + 'down.gif';
yeardiv.appendchild(img);
yeardiv.classname = 'selectbox';
if(opera){
yeardiv.style.width = '50px';
img.style.csstext = 'float:right';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
var yearpicker = createyeardiv();
yearpicker.style.left = '113px';
yearpicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
yearpicker.style.width = '35px';
yearpicker.id = 'yeardropdown';
calendardiv.appendchild(yearpicker);
var img = document.createelement('img');
img.src = pathtoimages + 'close.gif';
img.style.stylefloat = 'right';
img.onmouseover = highlightclose;
img.onmouseout = highlightclose;
img.onclick = closecalendar;
topbar.appendchild(img);
if(!document.all){
img.style.position = 'absolute';
img.style.right = '2px';
}
}
function writecalendarcontent()
{
var calendarcontentdivexists = true;
if(!calendarcontentdiv){
calendarcontentdiv = document.createelement('div');
calendardiv.appendchild(calendarcontentdiv);
calendarcontentdivexists = false;
}
currentmonth = currentmonth/1;
var d = new date();
d.setfullyear(currentyear);
d.setdate(1);
d.setmonth(currentmonth);
var daystartofmonth = d.getday();
if(daystartofmonth==0)daystartofmonth=7;
daystartofmonth--;
document.getelementbyid('calendar_year_txt').innerhtml = currentyear;
document.getelementbyid('calendar_month_txt').innerhtml = montharray[currentmonth];
document.getelementbyid('calendar_hour_txt').innerhtml = currenthour;
document.getelementbyid('calendar_minute_txt').innerhtml = currentminute;
var existingtable = calendarcontentdiv.getelementsbytagname('table');
if(existingtable.length>0){
calendarcontentdiv.removechild(existingtable[0]);
}
var caltable = document.createelement('table');
caltable.width = '100%';
caltable.cellspacing = '0';
calendarcontentdiv.appendchild(caltable);
var caltbody = document.createelement('tbody');
caltable.appendchild(caltbody);
var row = caltbody.insertrow(-1);
row.classname = 'calendar_week_row';
var cell = row.insertcell(-1);
cell.innerhtml = weekstring;
cell.classname = 'calendar_week_column';
cell.style.backgroundcolor = selectboxrolloverbgcolor;
for(var no=0;no<dayarray.length;no++){
var cell = row.insertcell(-1);
cell.innerhtml = dayarray[no];
}
var row = caltbody.insertrow(-1);
var cell = row.insertcell(-1);
cell.classname = 'calendar_week_column';
cell.style.backgroundcolor = selectboxrolloverbgcolor;
var week = getweek(currentyear,currentmonth,1);
cell.innerhtml = week; // week
for(var no=0;no<daystartofmonth;no++){
var cell = row.insertcell(-1);
cell.innerhtml = ' ';
}
var colcounter = daystartofmonth;
var daysinmonth = daysinmontharray[currentmonth];
if(daysinmonth==28){
if(isleapyear(currentyear))daysinmonth=29;
}
for(var no=1;no<=daysinmonth;no++){
d.setdate(no-1);
if(colcounter>0 && colcounter%7==0){
var row = caltbody.insertrow(-1);
var cell = row.insertcell(-1);
cell.classname = 'calendar_week_column';
var week = getweek(currentyear,currentmonth,no);
cell.innerhtml = week; // week
cell.style.backgroundcolor = selectboxrolloverbgcolor;
}
var cell = row.insertcell(-1);
if(currentyear==inputyear && currentmonth == inputmonth && no==inputday){
cell.classname='activeday';
}
cell.innerhtml = no;
cell.onclick = pickdate;
colcounter++;
}
if(!document.all){
if(calendarcontentdiv.offsetheight)
document.getelementbyid('topbar').style.top = calendarcontentdiv.offsetheight + document.getelementbyid('timebar').offsetheight + document.getelementbyid('topbar').offsetheight -1 + 'px';
else{
document.getelementbyid('topbar').style.top = '';
document.getelementbyid('topbar').style.bottom = '0px';
}
}
if(iframeobj){
if(!calendarcontentdivexists)settimeout('resizeiframe()',350);else settimeout('resizeiframe()',10);
}
}
function resizeiframe()
{
iframeobj.style.width = calendardiv.offsetwidth + 'px';
iframeobj.style.height = calendardiv.offsetheight + 'px' ;
}
function picktodaysdate()
{
var d = new date();
currentmonth = d.getmonth();
currentyear = d.getfullyear();
pickdate(false,d.getdate());
}
function pickdate(e,inputday)
{
var month = currentmonth/1 +1;
if(month<10)month = '0' + month;
var day;
if(!inputday && this)day = this.innerhtml; else day = inputday;
if(day/1<10)day = '0' + day;
if(returnformat){
returnformat = returnformat.replace('dd',day);
returnformat = returnformat.replace('mm',month);
returnformat = returnformat.replace('yyyy',currentyear);
returnformat = returnformat.replace('hh',currenthour);
returnformat = returnformat.replace('ii',currentminute);
returnformat = returnformat.replace('d',day/1);
returnformat = returnformat.replace('m',month/1);
returndateto.value = returnformat;
try{
returndateto.onchange();
}catch(e){
}
}else{
for(var no=0;no<returndatetoyear.options.length;no++){
if(returndatetoyear.options[no].value==currentyear){
returndatetoyear.selectedindex=no;
break;
}
}
for(var no=0;no<returndatetomonth.options.length;no++){
if(returndatetomonth.options[no].value==month){
returndatetomonth.selectedindex=no;
break;
}
}
for(var no=0;no<returndatetoday.options.length;no++){
if(returndatetoday.options[no].value==day){
returndatetoday.selectedindex=no;
break;
}
}
if(calendardisplaytime){
for(var no=0;no<returndatetohour.options.length;no++){
if(returndatetohour.options[no].value==currenthour){
returndatetohour.selectedindex=no;
break;
}
}
for(var no=0;no<returndatetominute.options.length;no++){
if(returndatetominute.options[no].value==currentminute){
returndatetominute.selectedindex=no;
break;
}
}
}
}
closecalendar();
}
// this function is from http://www.codeproject.com/csharp/gregorianwknum.asp
// only changed the month add
function getweek(year,month,day){
day = day/1;
year = year /1;
month = month/1 + 1; //use 1-12
var a = math.floor((14-(month))/12);
var y = year+4800-a;
var m = (month)+(12*a)-3;
var jd = day + math.floor(((153*m)+2)/5) +
(365*y) + math.floor(y/4) - math.floor(y/100) +
math.floor(y/400) - 32045; // (gregorian calendar)
var d4 = (jd+31741-(jd%7))%146097%36524%1461;
var l = math.floor(d4/1460);
var d1 = ((d4-l)%365)+l;
numberofweek = math.floor(d1/7) + 1;
return numberofweek;
}
function writetimebar()
{
var timebar = document.createelement('div');
timebar.id = 'timebar';
timebar.classname = 'timebar';
var subdiv = document.createelement('div');
subdiv.innerhtml = 'time:';
//timebar.appendchild(subdiv);
// year selector
var hourdiv = document.createelement('div');
hourdiv.onmouseover = highlightselect;
hourdiv.onmouseout = highlightselect;
hourdiv.onclick = showhourdropdown;
hourdiv.style.width = '30px';
var span = document.createelement('span');
span.innerhtml = currenthour;
span.id = 'calendar_hour_txt';
hourdiv.appendchild(span);
timebar.appendchild(hourdiv);
var img = document.createelement('img');
img.src = pathtoimages + 'down_time.gif';
hourdiv.appendchild(img);
hourdiv.classname = 'selectboxtime';
if(opera){
hourdiv.style.width = '30px';
img.style.csstext = 'float:right';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
var hourpicker = createhourdiv();
hourpicker.style.left = '130px';
//hourpicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
hourpicker.style.width = '35px';
hourpicker.id = 'hourdropdown';
calendardiv.appendchild(hourpicker);
// add minute picker
// year selector
var minutediv = document.createelement('div');
minutediv.onmouseover = highlightselect;
minutediv.onmouseout = highlightselect;
minutediv.onclick = showminutedropdown;
minutediv.style.width = '30px';
var span = document.createelement('span');
span.innerhtml = currentminute;
span.id = 'calendar_minute_txt';
minutediv.appendchild(span);
timebar.appendchild(minutediv);
var img = document.createelement('img');
img.src = pathtoimages + 'down_time.gif';
minutediv.appendchild(img);
minutediv.classname = 'selectboxtime';
if(opera){
minutediv.style.width = '30px';
img.style.csstext = 'float:right';
img.style.position = 'relative';
img.style.stylefloat = 'right';
}
var minutepicker = createminutediv();
minutepicker.style.left = '167px';
//minutepicker.style.top = monthdiv.offsettop + monthdiv.offsetheight + 1 + 'px';
minutepicker.style.width = '35px';
minutepicker.id = 'minutedropdown';
calendardiv.appendchild(minutepicker);
return timebar;
}
function writebottombar()
{
var d = new date();
var bottombar = document.createelement('div');
bottombar.id = 'bottombar';
bottombar.style.cursor = 'pointer';
bottombar.classname = 'todaysdate';
// var todaystringformat = '[todaystring] [daystring] [day] [monthstring] [year]'; ;;
var subdiv = document.createelement('div');
subdiv.onclick = picktodaysdate;
subdiv.id = 'todaysdatestring';
subdiv.style.width = (calendardiv.offsetwidth - 95) + 'px';
var day = d.getday();
if(day==0)day = 7;
day--;
var bottomstring = todaystringformat;
bottomstring = bottomstring.replace('[monthstring]',montharrayshort[d.getmonth()]);
bottomstring = bottomstring.replace('[day]',d.getdate());
bottomstring = bottomstring.replace('[year]',d.getfullyear());
bottomstring = bottomstring.replace('[daystring]',dayarray[day].tolowercase());
bottomstring = bottomstring.replace('[ucfdaystring]',dayarray[day]);
bottomstring = bottomstring.replace('[todaystring]',todaystring);
subdiv.innerhtml = todaystring + ': ' + d.getdate() + '. ' + montharrayshort[d.getmonth()] + ', ' + d.getfullyear() ;
subdiv.innerhtml = bottomstring ;
bottombar.appendchild(subdiv);
var timediv = writetimebar();
bottombar.appendchild(timediv);
calendardiv.appendchild(bottombar);
}
function gettoppos(inputobj)
{
var returnvalue = inputobj.offsettop + inputobj.offsetheight;
while((inputobj = inputobj.offsetparent) != null)returnvalue += inputobj.offsettop;
return returnvalue + calendar_offsettop;
}
function getleftpos(inputobj)
{
var returnvalue = inputobj.offsetleft;
while((inputobj = inputobj.offsetparent) != null)returnvalue += inputobj.offsetleft;
return returnvalue + calendar_offsetleft;
}
function positioncalendar(inputobj)
{
calendardiv.style.left = getleftpos(inputobj) + 'px';
calendardiv.style.top = gettoppos(inputobj) + 'px';
if(iframeobj){
iframeobj.style.left = calendardiv.style.left;
iframeobj.style.top = calendardiv.style.top;
//// fix for ei frame problem on time dropdowns 09/30/2006
iframeobj2.style.left = calendardiv.style.left;
iframeobj2.style.top = calendardiv.style.top;
}
}
function initcalendar()
{
if(msie){
iframeobj = document.createelement('iframe');
iframeobj.style.filter = 'alpha(opacity=0)';
iframeobj.style.position = 'absolute';
iframeobj.border='0px';
iframeobj.style.border = '0px';
iframeobj.style.backgroundcolor = '#ff0000';
//// fix for ei frame problem on time dropdowns 09/30/2006
iframeobj2 = document.createelement('iframe');
iframeobj2.style.position = 'absolute';
iframeobj2.border='0px';
iframeobj2.style.border = '0px';
iframeobj2.style.height = '1px';
iframeobj2.style.width = '1px';
document.body.appendchild(iframeobj2);
//// fix for ei frame problem on time dropdowns 09/30/2006
// added fixed for https
iframeobj2.src = 'blank.html';
iframeobj.src = 'blank.html';
document.body.appendchild(iframeobj);
}
calendardiv = document.createelement('div');
calendardiv.id = 'calendardiv';
calendardiv.style.zindex = 1000;
slidecalendarselectbox();
document.body.appendchild(calendardiv);
writebottombar();
writetopbar();
if(!currentyear){
var d = new date();
currentmonth = d.getmonth();
currentyear = d.getfullyear();
}
writecalendarcontent();
}
function settimeproperties()
{
if(!calendardisplaytime){
document.getelementbyid('timebar').style.display='none';
document.getelementbyid('timebar').style.visibility='hidden';
document.getelementbyid('todaysdatestring').style.width = '100%';
}else{
document.getelementbyid('timebar').style.display='block';
document.getelementbyid('timebar').style.visibility='visible';
document.getelementbyid('hourdropdown').style.top = document.getelementbyid('calendar_minute_txt').parentnode.offsetheight + calendarcontentdiv.offsetheight + document.getelementbyid('topbar').offsetheight + 'px';
document.getelementbyid('minutedropdown').style.top = document.getelementbyid('calendar_minute_txt').parentnode.offsetheight + calendarcontentdiv.offsetheight + document.getelementbyid('topbar').offsetheight + 'px';
document.getelementbyid('minutedropdown').style.right = '50px';
document.getelementbyid('hourdropdown').style.right = '50px';
document.getelementbyid('todaysdatestring').style.width = '115px';
}
}
function calendarsortitems(a,b)
{
return a/1 - b/1;
}
function displaycalendar(inputfield,format,buttonobj,displaytime,timeinput)
{
if(displaytime)calendardisplaytime=true; else calendardisplaytime = false;
if(inputfield.value.length>0){
if(!format.match(/^[0-9]*?$/gi)){
var items = inputfield.value.split(/[^0-9]/gi);
var positionarray = new array();
positionarray['m'] = format.indexof('mm');
if(positionarray['m']==-1)positionarray['m'] = format.indexof('m');
positionarray['d'] = format.indexof('dd');
if(positionarray['d']==-1)positionarray['d'] = format.indexof('d');
positionarray['y'] = format.indexof('yyyy');
positionarray['h'] = format.indexof('hh');
positionarray['i'] = format.indexof('ii');
var positionarraynumeric = array();
positionarraynumeric[0] = positionarray['m'];
positionarraynumeric[1] = positionarray['d'];
positionarraynumeric[2] = positionarray['y'];
positionarraynumeric[3] = positionarray['h'];
positionarraynumeric[4] = positionarray['i'];
positionarraynumeric = positionarraynumeric.sort(calendarsortitems);
var itemindex = -1;
currenthour = '00';
currentminute = '00';
for(var no=0;no<positionarraynumeric.length;no++){
if(positionarraynumeric[no]==-1)continue;
itemindex++;
if(positionarraynumeric[no]==positionarray['m']){
currentmonth = items[itemindex]-1;
continue;
}
if(positionarraynumeric[no]==positionarray['y']){
currentyear = items[itemindex];
continue;
}
if(positionarraynumeric[no]==positionarray['d']){
tmpday = items[itemindex];
continue;
}
if(positionarraynumeric[no]==positionarray['h']){
currenthour = items[itemindex];
continue;
}
if(positionarraynumeric[no]==positionarray['i']){
currentminute = items[itemindex];
continue;
}
}
currentmonth = currentmonth / 1;
tmpday = tmpday / 1;
}else{
var monthpos = format.indexof('mm');
currentmonth = inputfield.value.substr(monthpos,2)/1 -1;
var yearpos = format.indexof('yyyy');
currentyear = inputfield.value.substr(yearpos,4);
var daypos = format.indexof('dd');
tmpday = inputfield.value.substr(daypos,2);
var hourpos = format.indexof('hh');
if(hourpos>=0){
tmphour = inputfield.value.substr(hourpos,2);
currenthour = tmphour;
}else{
currenthour = '00';
}
var minutepos = format.indexof('ii');
if(minutepos>=0){
tmpminute = inputfield.value.substr(minutepos,2);
currentminute = tmpminute;
}else{
currentminute = '00';
}
}
}else{
var d = new date();
currentmonth = d.getmonth();
currentyear = d.getfullyear();
currenthour = '08';
currentminute = '00';
tmpday = d.getdate();
}
inputyear = currentyear;
inputmonth = currentmonth;
inputday = tmpday/1;
if(!calendardiv){
initcalendar();
}else{
if(calendardiv.style.display=='block'){
closecalendar();
return false;
}
writecalendarcontent();
}
returnformat = format;
returndateto = inputfield;
positioncalendar(buttonobj);
calendardiv.style.visibility = 'visible';
calendardiv.style.display = 'block';
if(iframeobj){
iframeobj.style.display = '';
iframeobj.style.height = '140px';
iframeobj.style.width = '195px';
iframeobj2.style.display = '';
iframeobj2.style.height = '140px';
iframeobj2.style.width = '195px';
}
settimeproperties();
updateyeardiv();
updatemonthdiv();
updateminutediv();
updatehourdiv();
}
function displaycalendarselectbox(yearinput,monthinput,dayinput,hourinput,minuteinput,buttonobj)
{
if(!hourinput)calendardisplaytime=false; else calendardisplaytime = true;
currentmonth = monthinput.options[monthinput.selectedindex].value/1-1;
currentyear = yearinput.options[yearinput.selectedindex].value;
if(hourinput){
currenthour = hourinput.options[hourinput.selectedindex].value;
inputhour = currenthour/1;
}
if(minuteinput){
currentminute = minuteinput.options[minuteinput.selectedindex].value;
inputminute = currentminute/1;
}
inputyear = yearinput.options[yearinput.selectedindex].value;
inputmonth = monthinput.options[monthinput.selectedindex].value/1 - 1;
inputday = dayinput.options[dayinput.selectedindex].value/1;
if(!calendardiv){
initcalendar();
}else{
writecalendarcontent();
}
returndatetoyear = yearinput;
returndatetomonth = monthinput;
returndatetoday = dayinput;
returndatetohour = hourinput;
returndatetominute = minuteinput;
returnformat = false;
returndateto = false;
positioncalendar(buttonobj);
calendardiv.style.visibility = 'visible';
calendardiv.style.display = 'block';
if(iframeobj){
iframeobj.style.display = '';
iframeobj.style.height = calendardiv.offsetheight + 'px';
iframeobj.style.width = calendardiv.offsetwidth + 'px';
//// fix for ei frame problem on time dropdowns 09/30/2006
iframeobj2.style.display = '';
iframeobj2.style.height = calendardiv.offsetheight + 'px';
iframeobj2.style.width = calendardiv.offsetwidth + 'px'
}
settimeproperties();
updateyeardiv();
updatemonthdiv();
updatehourdiv();
updateminutediv();
}