// Copyright (C) 2003 JVolution Ltd.
var testundefined ;
var datePanels = new Array() ;
var isNav4, isIE4, isNav6;

if (parseInt(navigator.appVersion.charAt(0)) >= 4) 
{
  isNav6 = navigator.userAgent.indexOf("Gecko")!=-1?true:false;
  isNav4 = (navigator.appName == "Netscape") ? true && !isNav6: false;
  isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}

function JVDatePanel()
{
	this.id = datePanels.length ;
	datePanels[this.id] = this ;

	this.jvCaption = "Caption" ;
	this.jvCaptionClass = null ;
	this.jvCaptionBackground = null ;
	this.jvCaptionForeground = null ;
	this.jvCaptionWidth = null ;
	this.jvCaptionHeight = null ;
	this.jvCalendarWidth = null ;
	this.showObject = null ;
	this.showMethod = null ;
	this.iconimage = null ;

	this.createJVDatePanel = createJVDatePanel ;
	this.endJVDatePanel = endJVDatePanel ;
	this.showJVDatePanel = showJVDatePanel ;
	this.hideJVDatePanel = hideJVDatePanel ;
	this.registerShowMethod = registerShowMethod ;
}
function createJVDatePanel(caption, captionclass, background, foreground, width, height, calendarwidth, iconimage)
{
	if (typeof caption != typeof testundefined)
		this.jvCaption = caption ;
	if (typeof captionclass != typeof testundefined)
		this.jvCaptionClass = captionclass ;
	if (typeof background != typeof testundefined)
		this.jvCaptionBackground = background ;
	if (typeof foreground != typeof testundefined)
		this.jvCaptionForeground = foreground ;
	if (typeof width != typeof testundefined)
		this.jvCaptionWidth = width ;
	if (typeof height != typeof testundefined)
		this.jvCaptionHeight = height ;
	if (typeof calendarwidth != typeof testundefined)
		this.jvCalendarWidth = calendarwidth ;
	if (typeof iconimage != typeof testundefined)
		this.iconimage = iconimage ;

	if (this.iconimage != null)
	{
		document.write('<IMG src="' + this.iconimage + '" onClick="showJVDatePanel(' + this.id + ')" border="0">') ;
	}
	else
	{
		document.write('<div name="jvcalendardiv' + this.id + '" id="jvcalendardiv' + this.id + '" style="cursor:hand;position:relative;border-left: 1px white solid;border-top: 1px white solid;border-right: 1px black solid;border-bottom: 1px black solid;') ;
		if (this.jvCaptionBackground != null)
			document.write('background:' + this.jvCaptionBackground + ';');
		if (this.jvCaptionWidth != null)
			document.write('width:' + this.jvCaptionWidth + ';');
		if (this.jvCaptionHeight != null)
			document.write('height:' + this.jvCaptionHeight + ';');
		document.write('" onClick="showJVDatePanel(' + this.id + ')"');
		if (this.jvCaptionClass != null)
			document.write(' class="' + this.jvCaptionClass + '"') ;
		document.write('>') ;
		if (this.jvCaptionForeground != null)
			document.write('<FONT color="' + this.jvCaptionForeground + '">');
 		document.write(this.jvCaption);
		if (this.jvCaptionForeground != null)
			document.write('</FONT>');
		document.write('</div>');
	}
	document.write('<div name="jvcalendarpanel' + this.id + '" id="jvcalendarpanel' + this.id + '" style="position:absolute;visibility:hidden;border-left: 1px white solid;border-top: 1px white solid;border-right: 1px black solid;border-bottom: 1px black solid;');
	if (this.jvCaptionBackground != null)
		document.write('background:' + this.jvCaptionBackground + ';');
	if (this.jvCalendarWidth != null)
		document.write('width:' + this.jvCalendarWidth + ';');
	document.write('">') ;
}
function endJVDatePanel()
{
	document.write('</div>');
}
function registerShowMethod(showobject, eventmethod)
{
	this.showObject = showobject ;
	this.showMethod = eventmethod ;
}
function showJVDatePanel(id)
{
	thisid = datePanels[id] ;
	var jvcalendarpanel = (isIE4) ? eval("document.all.jvcalendarpanel" + id) : document.getElementById("jvcalendarpanel" + id) ;
	if (jvcalendarpanel.style.visibility == "visible")
		jvcalendarpanel.style.visibility = "hidden" ;
	else
		jvcalendarpanel.style.visibility = "visible" ;
	if (thisid.showMethod != null)
        {
		if (thisid.showObject == null)
			thisid.showMethod() ;
		else
 			thisid.showObject.showMethod() ;
        }
}
function hideJVDatePanel()
{
	var jvcalendarpanel = (isIE4) ? eval("document.all.jvcalendarpanel" + this.id) : document.getElementById("jvcalendarpanel" + this.id) ;
	jvcalendarpanel.style.visibility = "hidden" ; 
}
