Listing 1 calendar.js

var currow = 0;
var day = 0;
var month = 0;
var orig_month = 0;
var year = 0;
var orig_year = 0;
var date_field = "";
var mywindow;

function padout(number) { return (number < 10) ? '0' + 
number : number; }

function setDate() {
var value = '' + padout(month - 0 + 1) + '/' + 
padout(day) + '/' + year;
obj.SetItem( currow, date_field, value );
mywindow.close();
}

function openCalendar(fieldname,evnt,row) {
var dt = obj.GetItem(row,fieldname); 
if (dt == null){
date = new Date();
} else {
var dtstr = dt.toString();
var pos = dtstr.search(" ");
if (pos > 0) {
dtstr = dtstr.substr(0,pos);


date = new Date(dtstr);
}
currow = row ; 
day = date.getDate(); 
month = date.getMonth();
orig_month = month;
year = date.getFullYear();
orig_year = year;
date_field = fieldname; 
var properties = "left=" + (evnt.screenX + 20);
properties += ",top=" + (evnt.screenY + 1);
properties += ",titlebar=0,resizable=no,width=170,height=195";
if (!mywindow || mywindow.closed) { 
mywindow=open('calendar.html','Demo',properties); 
}
mywindow.location.href = 'calendar.html';
if (mywindow.opener == null) mywindow.opener = self;
mywindow.focus();

}


Listing 2 calendar.html

<HTML>
<HEAD>
<TITLE>Demo - Calendar</TITLE>
<style type="text/css">
<!--
font {font-family: Arial; font-size: 12px}
.bold {font-family: Arial; font-size: 14px; text-style: bold; color: #DC143C}
A {text-decoration: none;}
-->
</style>

<SCRIPT LANGUAGE="JavaScript"><!--
function Calendar(Month,Year) {
var output = '';
curr_year = opener.orig_year;
curr_day = opener.day;
curr_month = opener.orig_month;

output += '<FORM NAME="Cal">

<TABLE BGCOLOR="#EEEEEE" BORDER=0 width="100%"><TR>';
output += '<TD width="30%" ALIGN="CENTER">

<A HREF="javascript:previousYear()">

<img src="images/move_left.gif" height="16" width="13" alt="" name="leftarrowY" border="0"></a><\/TD>';
output += '<TD width="20%" align="center">

<B><SPAN CLASS="bold">' + Year + '</SPAN></B></TD>';
output += '<TD width="30%" align="center">

<A HREF="javascript:nextYear()">

<img src="images/move.gif" height="16" width="13" alt="" name="rightarrowY" border="0"></a><\/TD></TR>';
output += '<TR><TD width="30%" ALIGN="CENTER">

<A HREF="javascript:previousMonth()">

<img src="images/move_left.gif" height="16" width="13" alt="" name="leftarrowM" border="0"></a><\/TD>';
output += '<TD width="20%" align="center">

<B><SPAN CLASS="bold">' + names[Month] + '</SPAN></B></TD>';
output += '<TD width="30%" align="center">

<A HREF="javascript:nextMonth()">

<img src="images/move.gif" height="16" width="13" alt="" name="rightarrowM" border="0"></a><\/TD></TR>';

firstDay = new Date(Year,Month,1);
startDay = firstDay.getDay();

if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
days[1] = 29;
else
days[1] = 28;

output += '<TABLE CALLSPACING=0 CELLPADDING=0 BORDER=1 BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#C0C0C0"><TR>';

for (i=0; i<7; i++)
output += '<TD WIDTH=15 ALIGN=CENTER VALIGN=MIDDLE>

<FONT SIZE=2 COLOR="#000000" FACE="ARIAL"><B>' + dow[i] +'<\/B><\/FONT><\/TD>';

output += '<\/TR><TR ALIGN=CENTER VALIGN=MIDDLE>';

var column = 0;
var lastMonth = Month - 1;
if (lastMonth == -1) lastMonth = 11;

for (i=0; i<startDay; i++, column++)
output += '<TD WIDTH=15 HEIGHT=5>

<FONT SIZE=2 COLOR="#336699" FACE="ARIAL">' + (days[lastMonth]-startDay+i+1) + '<\/FONT><\/TD>';

for (i=1; i<=days[Month]; i++, column++) {
if ((curr_month == Month) && (curr_year == Year) && (i == curr_day)) {
output += '<TD WIDTH=15 HEIGHT=5>' +

 '<A HREF="javascript:changeDay(' + i + ')">

<B><SPAN CLASS="bold">' + i + '<\/SPAN></B><\/A>' +'<\/TD>';
}
else {
output += '<TD WIDTH=15 HEIGHT=5>' +

 '<A HREF="javascript:changeDay(' + i + ')">

<FONT SIZE=2 FACE="ARIAL" COLOR="#000000">' + i + '<\/FONT><\/A>' +'<\/TD>';
}
if (column == 6) {
output += '<\/TR><TR ALIGN=CENTER VALIGN=MIDDLE>';
column = -1;
}
}

if (column > 0) {
for (i=1; column<7; i++, column++)
output += '<TD WIDTH=15 HEIGHT=5>

<FONT SIZE=2 COLOR="#336699" FACE="ARIAL">' + i + '<\/FONT><\/TD>';
}

output += '<\/TR><\/TABLE><\/FORM><\/TD><\/TR><\/TABLE>';

return output;
}

function changeDay(day) {
opener.day = day + '';
opener.restart();
self.close;
}

function nextMonth(action) {
if (opener.month < 11){
opener.month = opener.month + 1;
}else{
opener.month = 0;
nextYear();
}
location.href = 'calendar.html';
}

function previousMonth() {
if (opener.month >= 1){
opener.month = opener.month - 1;
}else{
opener.month = 11;
previousYear();
}
location.href = 'calendar.html';
}

function nextYear() {
opener.year = opener.year + 1;
location.href = "calendar.html";
}

function previousYear() {
opener.year = opener.year - 1;
location.href = "calendar.html";
}

function makeArray0() {
for (i = 0; i<makeArray0.arguments.length; i++)
this[i] = makeArray0.arguments[i];
}

var names = new makeArray0('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var days = new makeArray0(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var dow = new makeArray0('S','M','T','W','T','F','S');
//--></SCRIPT>
</HEAD>

<BODY BGCOLOR="#EEEEEE" topmargin="2" leftmargin="2">
<CENTER>

<SCRIPT LANGUAGE="JavaScript"><!--
document.write(Calendar(opener.month,opener.year));
//--></SCRIPT>

</CENTER>
</BODY>
</HTML>

Listing 3 calendar.jsp


<%@ page import="org.omg.CORBA.ORB" %>
<%@ page import="org.omg.CosNaming.NamingContext" %>
<%@ page import="org.omg.CosNaming.NamingContextHelper" %>
<%@ page import="org.omg.CosNaming.NameComponent" %>
<%@ page import="powerobjects.*" %>

<%
String sz_action ;
String sz_context ;
String sz_browser ;

sz_action = (String)request.getParameter( "obj_action" ) ;
if ( sz_action == null ) 
{
sz_action = "" ;
}

sz_context = (String)request.getParameter( "obj_context" ) ;
if ( sz_context == null ) 
{
sz_context = "" ;
}

sz_browser = (String)request.getHeader( "User-Agent" );
if ( sz_browser == null ) 
{
sz_browser = "" ;
}

n_calendar iJagComponent = null;
String sz = new String("");

java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBClass","com.sybase.CORBA.ORB");
props.put("com.sybase.CORBA.NameServiceURL", "iiop://jones-dean:9000" );

ORB orb = ORB.init((String[]) null, props);

try {
NamingContext context = NamingContextHelper.narrow( orb.resolve_initial_references("NameService"));
NameComponent[] name = { new NameComponent("powerobjects/n_calendar","") };
SessionManager.Factory factory = SessionManager.FactoryHelper.narrow(context.resolve(name));
iJagComponent = n_calendarHelper.narrow(factory.create("jagadmin","sarah"));
}

catch (org.omg.CORBA.ORBPackage.InvalidName aException) {}
catch (org.omg.CosNaming.NamingContextPackage.NotFound aException) {}
catch (org.omg.CosNaming.NamingContextPackage.CannotProceed aException) {}
catch (org.omg.CosNaming.NamingContextPackage.InvalidName aException) {}

try {
sz = iJagComponent.of_html( );
}

catch (CTS.PBUserException aException) {}

%>

<html>
<head><title>Calendar Popup</title>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<meta HTTP-EQUIV="Expires" CONTENT="0">
</head>
<script language="JavaScript" src='calendar.js'></script>
<body>
<p align="center"><font color="#FF0000" size="5"><i><b>Demo Calendar Popup</b></i></font>
<p align="center">&nbsp;
<%= sz %>
</body>
</html>