function MiniCalendar(name, targetWin, displayDate, currDate, selectedDate, dayURL, dayMessage, monthURL, monthMessage, mainBg, todayStyle, todayBg, selectedStyle, selectedBg, selectedTodayStyle, selectedTodayBg, dayStyle, dayBg, weekStyle, weekBg, monthStyle, monthBg, borderWidth, colsize, firstDayOfWeek) { this.name=name; this.targetWin = (targetWin?targetWin:self); this.outDoc = this.targetWin.document; this.displayDate = (displayDate?displayDate:new Date()); this.displayDate.setDate(15); if(this.displayDate.getFullYear() < 1970) this.displayDate = new Date(1970,0,15,0,0,0,0); else if(this.displayDate.getFullYear() > 2039) this.displayDate = new Date(2039,11,15,0,0,0,0); this.currDate = (currDate?currDate:new Date()); this.selectedDate = (selectedDate?selectedDate:new Date(1960,0,1,0,0,0,0)); this.dayURL = (dayURL?dayURL:"JavaScript://"); this.dayMessage = (dayMessage?dayMessage:""); this.monthURL = (monthURL?monthURL:"JavaScript://"); this.monthMessage = (monthMessage?monthMessage:""); this.mainBg = (mainBg?mainBg:"#C0C0C0"); this.todayStyle = (todayStyle?todayStyle:"font-size:9pt;color:black;font-weight:bold;text-decoration:none;font-family:arial,helvetica,sans-serif;"); this.todayBg = (todayBg?todayBg:"#CCCC00"); this.dayStyle = (dayStyle?dayStyle:"font-size:9pt;color:black;text-decoration:none;font-family:arial,helvetica,sans-serif;"); this.dayBg = (dayBg?dayBg:"#CCCCCC"); this.selectedStyle = (selectedStyle?selectedStyle:"font-size:9pt;color:white;text-decoration:none;font-family:arial,helvetica,sans-serif;"); this.selectedBg = (selectedBg?selectedBg:"#000080"); this.bothStyle = (selectedTodayStyle?selectedTodayStyle:"font-size:9pt;color:white;font-weight:bold;text-decoration:none;font-family:arial,helvetica,sans-serif;"); this.bothBg = (selectedTodayBg?selectedTodayBg:"#008000"); this.weekStyle = (weekStyle?weekStyle:"font-size:9pt;color:white;font-family:arial,helvetica,sans-serif;"); this.weekBg = (weekBg?weekBg:"#666666"); this.monthStyle = (monthStyle?monthStyle:"font-size:13pt;color:black;text-decoration:none;font-family:arial,helvetica,sans-serif;"); this.monthBg = (monthBg?monthBg:"#999999"); this.borderWidth = (isNaN(parseInt(borderWidth))?"0":Math.abs(parseInt(borderWidth))); this.colsize = (isNaN(parseInt(colsize))?20:Math.abs(parseInt(colsize))); this.firstDayOfWeek = (isNaN(parseInt(firstDayOfWeek))?0:parseInt(firstDayOfWeek)%7); this.container = null; this.width=7*this.colsize; this.styleString = ""; if(this.name != "initialize")document.write(this.styleString); this.location = new Array(0,0); } new MiniCalendar("initialize"); MiniCalendar.prototype.write = function() { var adjWidth = "width=" + (this.width + 2*this.borderWidth) + " "; var adjHeight = "height=" + (165 + 2*this.borderWidth) + " "; this.outDoc.write("
"); this.container = this.outDoc.links[this.outDoc.links.length-1]; }; MiniCalendar.prototype.show = function() { this.location = new Array((this.container.x-1),(this.container.y-1)) this.container = new Layer(this.width,this.targetWin); this.writeContainer(); }; MiniCalendar.prototype.writeContainer = function() { this.container.visibility = "hide"; this.container.document.open(); this.container.document.write("" + this.makeContents() + ""); this.container.document.close(); this.container.resizeTo(this.width,165); this.container.moveTo(this.location[0],this.location[1]); this.container.visibility = "show"; }; MiniCalendar.prototype.makeContents = function() { var firstDay = new Date(this.displayDate.getTime()); firstDay.setDate(1); firstDay = firstDay.getDay(); var lastDay = this.getLastDayInMonth(this.displayDate.getMonth(),this.displayDate.getFullYear()); var currDate = 1 - (firstDay - this.firstDayOfWeek); if(currDate>0)currDate-=7; var today = ((this.currDate.getMonth() == this.displayDate.getMonth())&&(this.currDate.getFullYear() == this.displayDate.getFullYear()))?this.currDate.getDate():40; var selected = ((this.selectedDate.getMonth() == this.displayDate.getMonth())&&(this.selectedDate.getFullYear() == this.displayDate.getFullYear()))?this.selectedDate.getDate():40; var dateString = "" + this.displayDate.getFullYear() + this.format((this.displayDate.getMonth()+1),2); var outString ="
"; if(this.displayDate.getFullYear() > 1970 || this.displayDate.getMonth() > 0) outString += "\"Previous"; else outString += ""; outString += "" + srcwin.shortMonths[this.displayDate.getMonth()] + " " + this.displayDate.getFullYear() + ""; if(this.displayDate.getFullYear() < 2039 || this.displayDate.getMonth() < 11) outString += "\"Next"; else outString += ""; outString += "
"; for(var day=this.firstDayOfWeek; day<(this.firstDayOfWeek + 7); day++) outString += ""; outString += ""; while(currDate <= lastDay) { outString += "" for(day=this.firstDayOfWeek; day<(this.firstDayOfWeek + 7); day++) { outString += ""; currDate++; } outString += ""; } outString += "
" + srcwin.weekDayInitials[day%7] + "
"; if(currDate < 1 || currDate > lastDay) outString += ""; else { outString += "" + currDate + ""; } outString += "
"; return outString; }; MiniCalendar.prototype.changeMonth = function(direction) { this.displayDate.setMonth(this.displayDate.getMonth() + direction); if(this.onMonthChange(direction)) this.writeContainer(); else this.displayDate.setMonth(this.displayDate.getMonth() - direction); }; MiniCalendar.prototype.format = function(str,len) { while(str.toString().length < (len?len:2)) str = "0" + str; return str; }; MiniCalendar.prototype.getLastDayInMonth = function(month,year) { month = (!isNaN(parseInt(month))?parseInt(month):(new Date()).getMonth()); year = (!isNaN(parseInt(year))?parseInt(year):(new Date()).getFullYear()); if((month%2==0&&month<7)||(month%2==1&&month>6)) return 31; else if(month==1&&(year%400==0||(year%4==0&&year%100!=0))) return 29; else if(month==1) return 28 else return 30; }; MiniCalendar.prototype.onMonthClick = function(){return (this.monthURL.toUpperCase()=="JAVSCRIPT://"?false:true);}; MiniCalendar.prototype.onMonthChange = function(direction){return true;} MiniCalendar.prototype.onDayClick = function(day){return (this.dayURL.toUpperCase()=="JAVASCRIPT://"?false:true);};