function cal(){
	n='calendar';
	c=xGetElementById(n);
	c.style.display='block';
	xLeft(n, xPageX('cbutton')+30);
	xTop(n, xPageY('cbutton')-xHeight(n)-40);
	xGetElementById('cform').dd.value='';
	c.innerHTML=createCal();
	xGetElementById('cform').dd.style.textAlign='left';
	return false;
	}

function createCal(y,m,d){
	str='';
	linkdays=new Array();
	monthdays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	if (y){
		todayDate=new Date(y,m,d);
		}else{
		todayDate=new Date();
		}
	realDate=new Date();
	realmonth=realDate.getMonth();
	thisday=todayDate.getDay();
	thismonth=todayDate.getMonth();
	thisdate=todayDate.getDate();
	thisyear=todayDate.getYear();
	thisyear=thisyear%100;
	thisyear=((thisyear<50)?(2000+thisyear):(1900+thisyear));
	if (((thisyear%4==0)&&!(thisyear%100==0))||(thisyear%400==0))monthdays[1]++;
	startspaces=thisdate;
	while (startspaces>7) startspaces-=7;
	startspaces=thisday-startspaces;
	if (startspaces<0) startspaces+=7;
	//alert(startspaces);
	str+="<table>";
	str+="<tr><td colspan=7 align=center>";
	if (thismonth>=(realmonth+1)){
		str+="<a href=\"#\" onClick=\"c.innerHTML=createCal((thismonth!=1)?thisyear:thisyear-1,(thismonth!=1)?thismonth-1:12,1)\">&lt;</a>";
		}
	str+="&nbsp;&nbsp;<b>"+monthnames[thismonth]+" "+thisyear+"</b>&nbsp;&nbsp;";
	if (thismonth<=(realmonth+1)){
		str+="<a href=\"#\" onClick=\"c.innerHTML=createCal((thismonth!=12)?thisyear:thisyear+1,(thismonth!=12)?thismonth+1:1,1)\">&gt;</a>";
		}
	str+="</td></tr>";
	str+=strDays;
	str+="<tr>";
	for (s=0; s<startspaces; s++){
		str+="<td> </td>";
		}
	count=1;
	while (count<=monthdays[thismonth]){
		for (b=startspaces; b<7; b++){
			linktrue=false;
			str+="<td>";
			if (count>thisdate||y){
				str+=(monthnames[0]=='Jan')?"<a href=# onClick=\"xGetElementById('cform').dd.value='"+monthnames1[thismonth]+" "+count+"'; c.style.display='none'; return false;\">" : "<a href=# onClick=\"xGetElementById('cform').dd.value='"+count+" "+monthnames1[thismonth]+"'; c.style.display='none'; return false;\">";
				}
			if (count==thisdate&&!y){
				str+="<font color='FF0000'><b>";
				}
			if (count<=monthdays[thismonth]){
				str+=count;
				}else{
				str+=" ";
				}
			if (count==thisdate&&!y){
				str+="</b></font>";
				}
			if (count>thisdate||y){
				str+="</a>";
				}
	str+="</td>";
	count++;
	}
	str+="</tr>";
	str+="<tr>";
	startspaces=0;
	}
	str+="</table>";
	return str;
	}