//this is a black box JS file not intended for modification. its purpose is to segregate some gnarly code
//that supports the calendar widget. the user-friendly, easily customized interface to the calendar widget 
//uses the functions getCalendarHTML() and getCalendarValue()

function getCalendarGridHTML(nam,tp,lf,wd,ht,tab,cap,def,mod){
	if(!def||def=="0")var now=new Date();
	else var now=new Date(parseInt(def));
	var yrNum=now.getFullYear();
	var moNum=now.getMonth();
	var moNam=months[moNum];
	var daNum=now.getDate();
	var nextMon=moNum+1;
	if(nextMon>11)nextMon=0;
	nextMon=new Date(yrNum,nextMon,1);
	nextMon=nextMon.getTime();
	nextMon=nextMon-(72000000);
	nextMon=new Date(nextMon);
	var mLen=nextMon.getDate();
	var moStart=new Date(yrNum,moNum,1);
	moStartDay=moStart.getDay();
	var sPos=moStartDay;
	var celWd=Math.round(wd/7);
	var celHt=Math.round(ht/6);
	wd=7*celWd;
	ht=6*celHt;
	var titleHt=Math.round(.6*celHt);
	var txt="<table cellpadding=0 cellspacing=0 border=0 width="+wd+" height="+titleHt+"><tr><td class=caltitle valign=middle align=center width="+celWd+" height="+titleHt+" onclick=newCalView(-1,'"+nam+"')>&lt;</td><td class=caltitle width="+(5*celWd)+" align=center><b>";
	txt+=moNam+" "+yrNum;
	txt+="</b></td><td class=caltitle valign=middle align=center width="+celWd+" height="+titleHt+" onclick=newCalView(1,'"+nam+"')>&gt;</td></tr></table>";
	var dayHt=Math.round(.4*celHt);
	txt+="<table cellpadding=0 cellspacing=0 border=0 width="+wd+" height="+dayHt+" class=titlebox><tr><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">S</td><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">M</td><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">T</td><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">W</td><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">T</td><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">F</td><td class=calday valign=middle align=center width="+celWd+" height="+dayHt+">S</td></tr></table>";
	txt+="<table cellpadding=0 cellspacing=0 border=0 width="+wd+" height="+ht+" class=calbox><tr>";
	for(d=0;d<sPos;d++){
		txt+="<td class=calnum><img src=../images/blank.gif width="+(celWd-1)+" height="+(celHt-1)+" border=0 /></td>";
	}
	for(var d=sPos;d<(mLen+sPos);d++){
		var dNum=d-sPos+1;
		if(dNum!=daNum)txt+="<td id=calCel"+nam+dNum+" class=calnum valign=middle align=center width="+celWd+" height="+celHt+" onclick=dayClick("+dNum+",'"+nam+"')>"+dNum+"</td>";
		else txt+="<td id=calCel"+nam+dNum+" class=calnum valign=middle align=center width="+celWd+" height="+celHt+" style=background-color:999999; onclick=dayClick("+dNum+","+nam+")>"+dNum+"</td>";
		if(d%7==6)txt+="</tr><tr>";
	}
	for(var e=d;e<42;e++){
		txt+="<td class=calnum><img src=../images/blank.gif width="+(celWd-2)+" height="+(celHt-2)+" border=0 /></td>";
		if(e%7==6)txt+="</tr><tr>";
	}
	txt+="</table>";
	return txt;
}

//accepts time in milliseconds
function getCalendarFormHTML(nam,tp,lf,wd,ht,tab,cap,def,mod){
	if(!def||def=="0")var now=new Date();
	else var now=new Date(1000*parseInt(def));
	var moNum=parseInt(now.getMonth())+1;
	var daNum=parseInt(now.getDate());
	var yrNum=now.getFullYear();
	if(moNum<10)moNum="0"+moNum;
	if(daNum<10)daNum="0"+daNum;
	var txt="<input id="+nam+"Form0 name="+nam+"Form0 type=text tabindex="+tab+" style=width:22px class=single value="+(moNum)+" /> &nbsp;/ &nbsp;";
	txt+="<input id="+nam+"Form1 name="+nam+"Form1 type=text tabindex="+tab+" style=width:22px class=single value="+daNum+" /> &nbsp;/ &nbsp;";
	txt+="<input id="+nam+"Form2 name="+nam+"Form2 type=text tabindex="+tab+" style=width:36px class=single value="+yrNum+" /> ";
	return txt;
}

