function initDatePicker() {
}
function showCalendar(field) {
datePickerField = getElementObj(field);
if(!datePickerField.validate()) datePickerField.set("");
var d = datePickerField.get();
if(d <= "") d = null;
$(frames.__datePickerFrame.document.body).html(buildCalendar(d));
var p = findPosition(document.getElementById("_"+field+"PickerA"));
var br = getScrollBottomRightPosition();
x=p.left-1;
y=p.top-1;
if(x+194>br.right) x-=174;
if(y+120>br.bottom) y-=98;
$("#__datePickerDiv").css({left:x,top:y,visibility:"visible"});
}
function goNavMonth(y, m) {
$(frames.__datePickerFrame.document.body).html(buildCalendar(m+"/1/"+y));
}
function doDay(y,m,d) {
$("#__datePickerDiv").css("visibility","hidden");
if(datePickerField!=null) {
datePickerField.set(m+"/"+d+"/"+y);
datePickerField.executeEvent("change");
datePickerField.focus();
datePickerField = null;
}
}
function buildCalendar(dateParam,styles) {
var doStyles = (styles == null || (styles != null && styles));
var today = currentDateTime();
var displayDate;
if (dateParam != null) {
if(typeof MyDateTime == "function") {
displayDate = (new MyDateTime()).setFromString(dateParam).getAsDate();
} else if (typeof MyDate == "function") {
displayDate = (new MyDate()).setFromString(dateParam).getAsDate();
} else {
displayDate = new Date(dateParam);
}
} else {
displayDate = currentDateTime();
}
var firstDay = displayDate;
firstDay.setDate(1);
var y = displayDate.getFullYear();
var m = displayDate.getMonth();
var isLeapYear = ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0);
var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var numDays = new Array(31, isLeapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var dayInits = new Array("S","M","T","W","T","F","S");
var c = "<table width=\"190\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
c += "<tr><td colspan=\"7\"";
if(doStyles) c += " class=\"calMiniHeader\"";
c += "><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
c += "<tr><td";
if(doStyles) c += " class=\"calMiniHeader\"";
var tDate = new Date(displayDate.toString());
tDate.setYear(tDate.getFullYear()-1);
c += " width=\"1%\"><a href=\"javaScript:goNavMonth(" + tDate.getFullYear() + ", " + (tDate.getMonth()+1) + ")\">";
c += "<img src=\"" + IMG_ROOT + "calendar/ico_prev_ext.gif\" style=\"vertical-align:middle;border:0;margin:0\" alt=\"Previous Year\"></a></td>";

c += "<td";
if(doStyles) c += " class=\"calMiniHeader\"";
tDate = new Date(displayDate.toString());
tDate.setMonth((tDate.getMonth()-1)%12);
if(tDate.getMonth()==12) tDate.setYear(tDate.getFullYear()-1);
c += " width=\"1%\"><a href=\"javaScript:goNavMonth(" + tDate.getFullYear() + ", " + (tDate.getMonth()+1) + ")\">";
c += "<img src=\"" + IMG_ROOT + "calendar/ico_prev.gif\" style=\"vertical-align:middle;border:0;margin:0\" alt=\"Previous Month\"></a></td>";

c += "<td";
if(doStyles) c += " class=\"calMiniHeader\"";
c += " width=\"98%\" align=\"center\"><b>" + monthNames[displayDate.getMonth()] + "&nbsp;" + y + "</b></td>";

c += "<td";
if(doStyles) c += " class=\"calMiniHeader\"";
tDate = new Date(displayDate.toString());
tDate.setMonth((tDate.getMonth()+1)%12);
if(tDate.getMonth()<1) tDate.setYear(tDate.getFullYear()+1);
c += " width=\"1%\" align=\"right\"><a href=\"javaScript:goNavMonth(" + tDate.getFullYear() + ", " + (tDate.getMonth()+1) + ")\">";
c += "<img src=\"" + IMG_ROOT + "calendar/ico_next.gif\" style=\"vertical-align:middle;border:0;margin:0\" alt=\"Next Month\"></a></td>";

c += "<td";
if(doStyles) c += " class=\"calMiniHeader\"";
tDate = new Date(displayDate.toString());
tDate.setYear(tDate.getFullYear()+1);
c += " width=\"1%\" align=\"right\"><a href=\"javaScript:goNavMonth(" + tDate.getFullYear() + ", " + (tDate.getMonth()+1) + ")\">";
c += "<img src=\"" + IMG_ROOT + "calendar/ico_next_ext.gif\" style=\"vertical-align:middle;border:0;margin:0\" alt=\"Next Year\"></a></td></tr>";
c += "</table></td></tr><tr>";
for(var i = 0; i < 7; i++) c += "<td" + (doStyles ? " class=\"calMiniDayOfWeek\"" : "") + " width=\"14%\" align=\"center\"><b>" + dayInits[i] + "</b></td>";
c += "</tr>";
var dayOfMonth = 1 - firstDay.getDay();
var dayOfWeek = 0;
while(dayOfMonth <= numDays[m] || dayOfWeek != 0) {
if(dayOfWeek % 7 == 0) c += "<tr>";
if(dayOfMonth == today.getDate() && m == today.getMonth() && y == today.getFullYear()) {
c += "<td" + (doStyles ? " class=\"calMiniToday\"" : "" ) + " align=\"center\">" + (doStyles ? "" : "<b>");
} else {
c += "<td" + (doStyles ? " class=\"calMiniDay\"" : "") + " align=\"center\">";
}
if(dayOfMonth > 0 && dayOfMonth <= numDays[m]) c += "<a href=\"javaScript:doDay(" + y + "," + (m+1) + "," + dayOfMonth + ")\">" + dayOfMonth + "</a>";
else c += "&nbsp;";
if(dayOfMonth == today.getDate() && m == today.getMonth() && y == today.getFullYear() && !doStyles) c += "</b>";
c += "</td>";
if(dayOfWeek % 7 == 6) c += "</tr>";
dayOfWeek = (dayOfWeek + 1) % 7;
dayOfMonth++;
}
c += "</table>";
return c;
}
var _SR_;
if(_SR_ != null) _SR_.notify("minicalendar.js");