function drawDateInput(n){
	var i;
	var oDate = new Date();
	if(n=="") return;
	document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td>");
	var strHTML = "<select name=\""+n+"\" id=\""+n+"\" style='width:50px' onChange=\"chkDate('"+n+"')\">\n";
	for(i=oDate.getYear()+3;i>1999;i--)
		strHTML += "<option value=\""+i+"\" "+(i==oDate.getYear()?"selected":"")+">"+i+"</option>\n";
	strHTML += "</select>";
	SS_write(strHTML);
	document.write("</td><td style='padding-left:4px'>");
	strHTML = "<select name=\""+n+"\" id=\""+n+"\" style='width:38px' onChange=\"chkDate('"+n+"')\">\n";
	for(i=1;i<13;i++)
		strHTML += "<option value=\""+i+"\" "+(i==oDate.getMonth()+1?"selected":"")+">"+i+"</option>\n";
	strHTML += "</select>";
	SS_write(strHTML);
	document.write("</td><td style='padding-left:4px'>");
	strHTML = "<select name=\""+n+"\" id=\""+n+"\" style='width:38px' onLoad=\"chkDate('"+n+"')\">\n";
	for(i=1;i<32;i++)
		strHTML += "<option value=\""+i+"\" "+(i==oDate.getDate()?"selected":"")+">"+i+"</option>\n";
	strHTML += "</select>";
	strHTML += "<script language=javascript>chkDate('"+n+"')</script>";
	SS_write(strHTML,10);
	document.write("</td></tr></table>");
}

function chkDate(n){
	var oDateInput = document.all[n]
	if(!oDateInput) return;
	var nYear = parseInt(document.all[n][0].value);
	var nMonth = parseInt(document.all[n][1].value);
	var nDate = parseInt(document.all[n][2].value);
	var oDate2 = new Date(nYear,nMonth-1,1);
	var oDate1 = new Date(nYear,nMonth-1,1);
	oDate2.setMonth(oDate2.getMonth()+1);
	var iDayOfMonth = (oDate2-oDate1)/24/3600000;
	oDateInput[2].length=0;
	for(var i=1;i<iDayOfMonth+1;i++){
		oDateInput[2].length++;
		oDateInput[2].options[i-1].text=i;
		oDateInput[2].options[i-1].value=i;
		if(nDate==i) oDateInput[2].options[i-1].selected=true;
	}
}

String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, '');
}


function doUpload(o,n){
	var oForm = o.form;
	window.UploadField = o;
	oWinUpload = window.open('/Upload.asp?type='+n,'winUpload','width=520px,height=310px');
	oWinUpload.focus();
}
