
                
        document.write("<div id='calendar_month1' style='background-color:#FFFFFF;width:271px;height:200px''>");
        document.write("<div class='form-format'>");
        document.write("<div class='form-content' style='height:200px;'>");
        document.write("<table width=275 height=200>");
        document.write("<tr><td colspan=7 align=center><nobr><small><b><span id='1calendar_title' style='float:left'></span></b>&nbsp;&nbsp;&nbsp;<span id='1month'></span>&nbsp;&nbsp;<span id='1year'></span></nobr></td></tr>");
        document.write("<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><tr>");
        document.write("<tr><td><span id='1day1'></span></td>");
        document.write("<td><span id='1day2'></span></td>");
        document.write("<td><span id='1day3'></span></td>");
        document.write("<td><span id='1day4'></span></td>");
        document.write("<td><span id='1day5'></span></td>");
        document.write("<td><span id='1day6'></span></td>");
        document.write("<td><span id='1day7'></span></td></tr>");
        document.write("<tr><td><span id='1day8'></span></td>");
        document.write("<td><span id='1day9'></span></td>");
        document.write("<td><span id='1day10'></span></td>");
        document.write("<td><span id='1day11'></span></td>");
        document.write("<td><span id='1day12'></span></td>");
        document.write("<td><span id='1day13'></span></td>");
        document.write("<td><span id='1day14'></span></td></tr>");
        document.write("<tr><td><span id='1day15'></span></td>");
        document.write("<td><span id='1day16'></span></td>");
        document.write("<td><span id='1day17'></span></td>");
        document.write("<td><span id='1day18'></span></td>");
        document.write("<td><span id='1day19'></span></td>");
        document.write("<td><span id='1day20'></span></td>");
        document.write("<td><span id='1day21'></span></td></tr>");
        document.write("<tr><td><span id='1day22'></span></td>");
        document.write("<td><span id='1day23'></span></td>");
        document.write("<td><span id='1day24'></span></td>");
        document.write("<td><span id='1day25'></span></td>");
        document.write("<td><span id='1day26'></span></td>");
        document.write("<td><span id='1day27'></span></td>");
        document.write("<td><span id='1day28'></span></td></tr>");
        document.write("<tr><td><span id='1day29'></span></td>");
        document.write("<td><span id='1day30'></span></td>");
        document.write("<td><span id='1day31'></span></td>");
        document.write("<td><span id='1day32'></span></td>");
        document.write("<td><span id='1day33'></span></td>");
        document.write("<td><span id='1day34'></span></td>");
        document.write("<td><span id='1day35'></span></td></tr>");
        document.write("<tr><td><span id='1day36'></span></td>");
        document.write("<td><span id='1day37'></span></td></tr>");
        document.write("</table>");
        document.write("</div>");
        document.write("</div>");
        document.write("</div>");
    
        // Prepare the display
        function showmonth(value,month,year) {
            emptycalendar(value);               // erase the existing month
            document.getElementById("calendar_month" + value).style.visibility = "visible";
            outputdisplay(value,month,year);    // populate it with the new month
        }
        
        // erase the calendar
        function emptycalendar(value) {
            for (var x=1; x<=37; x++) {
                document.getElementById(value + "day" + x).innerHTML = "&nbsp";
            }            
            document.getElementById(value + "month").innerHTML = "";
            document.getElementById(value + "year").innerHTML = "";        
        }

        // populate the calendar
        function outputdisplay (value, indexmonth, indexyear) {
            if (indexyear < 2000) indexyear = indexyear + 1900;
            var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];    
            var lengths = [31,28,31,30,31,30,31,31,30,31,30,31];
            var theday;
            var theid;
            var previousMonth; 
            var previousYear; 
            var nextMonth;
            var nextYear;
            var max = lengths[indexmonth];
            var dontShowDaysBeforeToday=0;
            if (indexmonth == 1) max = february(indexyear); // leap year calculation
    
            // get first day of the month (Mon,Tue,Wed, ...)
            var now = new Date();
            now.setDate(1);
            now.setMonth(indexmonth);
            now.setYear(indexyear);
            var first=now.getDay();
                        
            // used by the previous and next links
            previousMonth = indexmonth - 1;
            previousYear = indexyear;
            if (previousMonth == -1) {
                previousMonth = 11;
                previousYear = indexyear-1;
            }
            nextMonth = indexmonth + 1;
            nextYear = indexyear;
            if (nextMonth == 12) {
                nextMonth = 0;
                nextYear = indexyear+1;
            }

            var dontShowDaysAfterToday=0;
	    var dontShowDaysBeforeToday=0;
	    var dontShowMonthBeforeToday=0;

            // if current month, then don't allow them to click on
            // days that are before today.
            now = new Date();
            var currentyear = now.getYear();
            if (currentyear < 2000) currentyear = currentyear + 1900;

            if ((indexmonth == now.getMonth()) && (indexyear == currentyear))
                dontShowDaysAfterToday=1;                

	    // don't allow clicks on days before a certain day in a specific month
	    // (to do archive start date)
	    if ((indexmonth <= 10 && indexyear == 2007) || indexyear < 2007)
                dontShowDaysBeforeToday=1;

	    // don't allow clicks on an entire month before a certain date
	    // (to do archive start date)
	    if ((indexmonth < 10 && indexyear == 2007) || indexyear < 2007)
                dontShowMonthBeforeToday=1;
            
            // should start to populate at the correct first day (Mon,Tue,Wed,...)
            for (var x=first; x<=max+first-1; x++) {
                theday = x-first+1; // to be displayed (adjusted)
                theid = x+1;        // span id's begin at 1, not 0, oops.
                if (dontShowMonthBeforeToday==1) {		    
                    document.getElementById(value + "day" + theid).innerHTML = theday;
                } else if ((dontShowDaysBeforeToday==1) && (theday < 10)) {		    
                    document.getElementById(value + "day" + theid).innerHTML = theday;
		} else if ((dontShowDaysAfterToday==1) && (theday >= now.getDate())) {
                    document.getElementById(value + "day" + theid).innerHTML = theday;
                } else {
                    displaymonth = parseInt(indexmonth) + 1;
                    document.getElementById(value + "day" + theid).innerHTML = "<a href=javascript:setdropdown(" + value + "," + displaymonth + "," + theday + "," + indexyear + ")>" + theday + "</a>";
                }
            }

            if(indexyear < 2000) indexyear = indexyear + 1900;
            document.getElementById(value +"calendar_title").innerHTML = " " + months[indexmonth] + " " + indexyear;
            var now = new Date();
            var currentyear = now.getYear();
            if (currentyear < 2000) currentyear = currentyear + 1900;
	    // next and previous months
            var monthLinks = "<a href=javascript:showmonth(" + value + "," + previousMonth + "," + previousYear + ")><< </a> month";
            if ((nextYear < currentyear) || ((nextYear == currentyear) && (nextMonth <= now.getMonth())))
		monthLinks = monthLinks + "<a href=javascript:showmonth(" + value + "," + nextMonth + "," + nextYear + ")> >></a>";
	    document.getElementById(value + "month").innerHTML = monthLinks;
	    // next and previous year
	    var displayPreviousYear = indexyear - 1;
	    var displayNextYear = indexyear + 1;
            var yearLinks = "<a href=javascript:showmonth(" + value + "," + indexmonth + "," + displayPreviousYear + ")><< </a> year";
            if ((nextYear < currentyear) || (nextYear == currentyear && indexmonth == 11))
		yearLinks = yearLinks + "<a href=javascript:showmonth(" + value + "," + indexmonth + "," + displayNextYear + ")> >></a>";
	    document.getElementById(value + "year").innerHTML = yearLinks;

        }
        
        // hide the calendar
        function hideall(value) {
            document.getElementById("calendar_month" + value).style.visibility = "hidden";
        }
        
        // the action performed when a day is clicked. 
        function setdropdown(value, month, day, year) {
		window.location.href = 'http://www.middleeast.org/mereport/frame.cgi?a=' + year + '_' + month + '_' + day + '.html';
        }
        
        // How many days are there in February? (trick Question)
        function february(year) {
            if (year % 4 != 0) {
                 return 28;
            } else if  (year % 400 == 0) {
                 return 29;
            } else if (year % 100 == 0) {
                 return 28;
            } else {
                return 29;
            }
        }
