function strpad(val) { return (!isNaN(val) && val.toString().length==1) ? "0"+val : val; } function generateCalendar( lang, none ) { var f = document.calendar_form; if (!none) { eval ( "var selected_month = f.m.options[f.m.selectedIndex].value;"); eval ( "var selected_year = f.y.options[f.y.selectedIndex].value;"); var js_month = selected_month - 1; } else { var today = new Date(); var selected_month = today.getMonth() + 1; selected_month = strpad(selected_month); var js_month = selected_month - 1; var selected_year = today.getFullYear(); } var thistime = new Date(); var thisyear = thistime.getFullYear(); var thismonth =thistime.getMonth() + 1; var js_thismonth = thismonth - 1; thismonth = strpad(thismonth); var thisday = thistime.getDate(); var years = new Array( thisyear, thisyear+1 ); var str_calendar_lt = "Renginių kalendorius"; var str_calendar_en = "Events calendar"; var months_lt = new Array( "Sausis", "Vasaris", "Kovas", "Balandis", "Gegužė", "Birželis", "Liepa", "Rugpjūtis", "Rugsėjis", "Spalis", "Lapkritis", "Gruodis" ); var months_en = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); eval( "var this_months = months_"+lang+";"); eval( "var this_str_calendar = str_calendar_"+lang+";"); var calendar = "
"; calendar += "

"+this_str_calendar+"

"; calendar += ""; calendar += "
"; calendar += ""; calendar += ""; var week_days_lt = new Array( "P", "A", "T", "K", "P", "Š", "S" ); var week_days_en = new Array( "M", "T", "W", "T", "F", "S", "S" ); eval( "var this_week = week_days_"+lang+";"); calendar += "
"; var thetime_ = new Date( selected_year, js_month ); var nexttime = thetime_.getTime() + (60 * 60 * 24 * 32 * 1000); var next_ = new Date( nexttime ); var next_year = next_.getFullYear(); var next_month = next_.getMonth(); var nexttime_ = new Date( next_year, next_month ); var weekday_ = thetime_.getDay(); if (weekday_ == 0) weekday_ = 7; var days_num = (nexttime_ - thetime_) / 24 / 60 / 60 / 1000; days_num = Math.round(days_num); calendar += ""; for ( var i =0; i"+this_week[i]+""; } calendar += ""; if (weekday_ > 1) { var colspan = weekday_ - 1; calendar += ""; } var link = "http://www.eb.lt/"+lang+".php3?vid=75&capital=9&date="; for ( var i = 1; i <= days_num; i++ ) { if ( weekday_ == 8 ) { calendar += ""; weekday_ = 1; } calendar += ""; weekday_++; } if ( weekday_ < 7 ) { colspan = 7 - weekday_; calendar += ""; } calendar += "
"; if (selected_year > thisyear || (selected_year == thisyear && (js_month > js_thismonth) || (js_month == js_thismonth && i >= thisday))) { var curDate = new Date( selected_year, js_month, i ); calendar += ""; } else { calendar += ""; } if (selected_year == thisyear && js_month == js_thismonth && i == thisday) calendar += ""; calendar +=i; if (selected_year == thisyear && js_month == js_thismonth && i == thisday) calendar += ""; if (selected_year > thisyear || (selected_year == thisyear && (js_month > js_thismonth) || (js_month == js_thismonth && i >= thisday))) calendar += "" else calendar += ""; calendar += "
"; document.getElementById('calendar').innerHTML = calendar; }