<html>
<%@page info="minicalframe" language="java" pageEncoding="utf-8" contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/jato.tld" prefix="jato"%>
<%@include file="resourceBundleUtils.js"%>
<head>
<title></title>
<script src="../../uwc/js/browserVersion.js" type="text/javascript"> </script>
<script type="text/javascript">
<!--
  if (is_ie5up) // IE5
  {
   document.write("<LINK href=../<%= getLocalizedLabel(session, "skinModel", "Style-Sheet-IE", "../../uwc/css/css_ie5win.css") %> type=text/css rel=stylesheet>")
  }
  else if (is_gecko) // Netscape 6/7 or Mozilla
  {
   document.write("<LINK href=../<%= getLocalizedLabel(session, "skinModel", "Style-Sheet-NN", "../../uwc/css/css_ns6up.css") %> type=text/css rel=stylesheet>")
  }
  else  // All others
  {
   document.write("<LINK href=../<%= getLocalizedLabel(session, "skinModel", "Style-Sheet-NN", "../../uwc/css/css_ns6up.css") %> type=text/css rel=stylesheet>")
  }
//-->
</script>
<script>self.focus()</script>
</head>
<script>


var arr_months = [ "<%= getLocalizedLabel(session, "uwc-common-january", "Janurary") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-february", "February") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-march", "March") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-april", "April") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-may", "May") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-june", "June") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-july", "July") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-august", "August") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-september", "September") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-october", "October") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-november", "November") %>",
	               "<%= getLocalizedLabel(session, "uwc-common-december", "December") %>"]
	             
var week_days =  [ "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Sunday", "S") %>",
	               "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Monday", "M") %>",
	               "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Tuesday", "T") %>",
	               "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Wednesday", "W") %>",
	               "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Thursday", "T") %>",
	               "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Friday", "F") %>",
	               "<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-Saturday", "S") %>"]

var days = [ "0", "1", "2" , "3" , "4", "5", "6", "7", "8", "9",
              "10", "11", "12" , "13" , "14", "15", "16", "17", "18", "19",
              "20", "21", "22" , "23" , "24", "25", "26", "27", "28", "29",
              "30", "31"];

var i18n_close = "<%= getLocalizedLabel(session, "uwc-common-close","Close") %>"
var i18n_closewindow = "<%= getLocalizedLabel(session, "uwc-common-Close-title","Close Window") %>"
              
var n_weekstart = parent.weekstart;


function show_calendar(str_target, str_datetime) {
	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	
	var str_buffer = new String (
	            '<form name="myForm" method="post" action="">' +
	            '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
                '<tr>' +
                '<td class="McalOutline">' +
                '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="Mcal">' +
                '<tr align="center">' +
                '<td colspan="7" class="MonthHdr">' +
                '<span class="BlockHeaderText">'
        );
    str_buffer +=  '<a href="javascript: parent.previousMonthHref(' + '\'' + dt_datetime.toUTCString() + '\'' + ')"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-calclient-minicalendar-previousmonth","../../uwc/images/back.gif") %>" width="13" height="13" border="0" align="absmiddle" title="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-previousmonth", "Previous month") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-previousmonth", "Previous month") %>"></a>' +
                '&nbsp;&nbsp;' +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear() + '&nbsp;&nbsp;' +
                '<a href="javascript: parent.nextMonthHref(' + '\'' + dt_datetime.toUTCString() + '\'' + ')"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-calclient-minicalendar-nextmonth","../../uwc/images/forward.gif") %>" width="13" height="13" border="0" align="absmiddle" title="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-nextmonth", "next month") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-nextmonth", "next month") %>"></a>'
    str_buffer += '</span></td>' +
                       '</tr>' 
	
	var dt_current_day = new Date(dt_firstday);
        var openCol = '<th scope="col">'
        var closeCol = '</th>'

	// print weekdays titles
	str_buffer += "<tr>\n";

	for (var n=0; n<7; n++)
		str_buffer += openCol +
		week_days[(n_weekstart+n)%7] + closeCol;
	// print calendar table
	str_buffer += "</tr>\n";

	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row header
		str_buffer += "<tr>\n";
        for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
                                if(dt_current_day.getMonth() == dt_datetime.getMonth()) {
                                   if(dt_current_day.getDate() == dt_datetime.getDate())
                                       str_buffer += "<td class=\"Today\">";
                                   else {
                                   	   if(isWeekEnd((n_weekstart + n_current_wday)%7))
                                       	str_buffer += "	<td class=\"McalWkEnd\">";
                                       else
                                       	str_buffer += "	<td>";
                                   }
                                }
                                else {
                                      str_buffer += "	<td class=\"OtherMon\">";
                                }
                                str_buffer += '<a href="javascript: parent.selectedday(' + '\''  + dt_current_day.toUTCString() + '\'' + ')" class="Lnk" >'
                                str_buffer += days[dt_current_day.getDate()] + "</a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n"
	}
	// print calendar footer
	str_buffer +=
		"</table>\n" +
		"</td>\n</tr>\n" +
		"<tr>" + 
       "<td><img src=\"../../uwc/images/spacer.gif\" width=\"1\" height=\"10\"></td>" +
       "</tr>" +
       "<tr>" +
       "<td align=\"right\">" +
       "<input class=\"Btn2\" type=\"submit\" name=\"Button5\" id=\"button\" value=\"" +
        i18n_close + "\" onMouseOver=\"if (this.disabled==0) this.className='Btn2Hov'\" onFocus=\"if (this.disabled==0) this.className='Btn2Hov'\" onMouseOut=\"if (this.disabled==0) this.className='Btn2'\" onBlur=\"if (this.disabled==0) this.className='Btn2'\" onClick=\"parent.window.close()\" title=\"" + i18n_closewindow + "\">" +
       "</td>" +
       "</tr>" +
       "<tr>" +
      "<td>&nbsp;</td>" +
      "</tr>" +
	  "</table>\n" +
	  "</form>" +
	  "</body>\n"
        document.write(str_buffer)

}

// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
	return new Date(str_datetime);
}
function dt2dtstr (dt_datetime) {
	return (new String (
			dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" "));
}
function dt2tmstr (dt_datetime) {
	return (new String (
			dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

function isWeekEnd(day) {
   if(parent.weekends[day] == 0)
    return false;
   else
    return true;
}

show_calendar("",parent.today.toString())
</script>
</html>
