var loaded=false;
var run="";

function start(){
	loaded=true;
	if (run != ""){setTimeout(run,0);}
}

function showDate(){
	var correctDate, d
	var d = new Date();
	theDate = d.getDate();
	theMonth = d.getMonth();
	theYear = d.getFullYear();

	if ( theMonth == 0 ) { theMonth = "January"; }
	if ( theMonth == 1 ) { theMonth = "February"; }
	if ( theMonth == 2 ) { theMonth = "March"; }
	if ( theMonth == 3 ) { theMonth = "April"; }
	if ( theMonth == 4 ) { theMonth = "May"; }
	if ( theMonth == 5 ) { theMonth = "June"; }
	if ( theMonth == 6 ) { theMonth = "July"; }
	if ( theMonth == 7 ) { theMonth = "August"; }
	if ( theMonth == 8 ) { theMonth = "September"; }
	if ( theMonth == 9 ) { theMonth = "October"; }
	if ( theMonth == 10 ) { theMonth = "November"; }
	if ( theMonth == 11 ) { theMonth = "December"; }

	correctDate = theDate + " " + theMonth + " " + theYear;
	document.write('<font size="1" face="Verdana">' + correctDate + '</font>');
}


function populatedropdown(adayfield, amonthfield, ayearfield, ldayfield, lmonthfield, lyearfield){

	var monthtext = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
	var mdays = [31, 28, 31, 30, 30, 31, 31, 31, 31, 31, 30, 31];

     var today=new Date();
     var adayfield = document.getElementById(adayfield);
     var amonthfield = document.getElementById(amonthfield);
     var ayearfield = document.getElementById(ayearfield);

     var ldayfield = document.getElementById(ldayfield);
     var lmonthfield = document.getElementById(lmonthfield);
     var lyearfield = document.getElementById(lyearfield);
     
     var thisyear = today.getFullYear();
     
	if ( (isLeapYear(thisyear)) && (monthtext[today.getMonth()] == 'Feb') ) {
		nday = 29;
	 }
     else {
		nday = mdays[today.getMonth()];
	 }
	
//	document.write('<font size="1" face="Verdana">' + 'The month is: ' + monthtext[today.getMonth()] + '</font>');
	
     for (var i=0; i<nday; i++) {
          adayfield.options[i]=new Option(i+1, i+1);
          ldayfield.options[i]=new Option(i+1, i+1);
          }

     adayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true); //select today's day
     ldayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true); //select today's day
     
     for (var m=0; m<12; m++) {
          amonthfield.options[m]=new Option(monthtext[m], monthtext[m]);
          lmonthfield.options[m]=new Option(monthtext[m], monthtext[m]);
          }
               
     amonthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true); //select today's month
     lmonthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true); //select today's month
          
     for (var y=0; y<20; y++) {
          ayearfield.options[y]=new Option(thisyear, thisyear);
          lyearfield.options[y]=new Option(thisyear, thisyear);
          thisyear+=1;
     }
     
     ayearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true); //select today's year
     lyearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true); //select today's year
}


function isLeapYear(y) {
        return ( ((y % 400) == 0) || ( ((y % 4) == 0) && ((y % 100) != 0) ) );
    }
