<!-- Original:  Kedar R. Bhave (softricks@hotmail.com) -->
<!-- Web Site:  http://www.softricks.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

var weekend = [0,6];
var weekendColor = "#e0e0e0";
var fontface = "Verdana"; 
var fontsize = 2;

var gNow = new Date();
var ggWinCal;
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

Calendar.Months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];

// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
	if ((p_month == null) && (p_year == null))	return;

	if (p_WinCal == null)
		this.gWinCal = ggWinCal;
	else
		this.gWinCal = p_WinCal;
	
	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
	}

	this.gYear = p_year;
	this.gFormat = p_format;
	this.gBGColor = "white";
	this.gFGColor = "black";
	this.gTextColor = "black";
	this.gHeaderColor = "black";
	this.gReturnItem = p_item;
}

Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;

function Calendar_get_month(monthNo) {
	return Calendar.Months[monthNo];
}

function Calendar_get_daysofmonth(monthNo, p_year) {
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return Calendar.DOMonth[monthNo];
	
		return Calendar.lDOMonth[monthNo];
	} else
		return Calendar.DOMonth[monthNo];
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/* 
	Will return an 1-D array with 1st element being the calculated month 
	and second being the calculated year 
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();
	
	if (incr == -1) {
		// B A C K W A R D
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// F O R W A R D
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

function Calendar_print() {
	ggWinCal.print();
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/* 
	Will return an 1-D array with 1st element being the calculated month 
	and second being the calculated year 
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();
	
	if (incr == -1) {
		// B A C K W A R D
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// F O R W A R D
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
new Calendar();

Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";
	
	// Begin Table Drawing code here..
	vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";
	
	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode = vCode + vHeader_Code + vData_Code;
	
	vCode = vCode + "</TABLE>";
	
	return vCode;
}

Calendar.prototype.show = function() {
	var vCode = "";
	
	this.gWinCal.document.open();

	// Setup the page...
	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("</head>");

	this.wwrite("<body topmargin=0 onload=\"window.focus();\" onBlur=\"ensureFocus(10);\" bgcolor=\"#E6FDB0\" " + 
		"link=\"" + this.gLinkColor + "\" " + 
		"vlink=\"" + this.gLinkColor + "\" " +
		"alink=\"" + this.gLinkColor + "\" " +
		"text=\"" + this.gTextColor + "\">");

    this.wwrite("<div id=\"dek\" style=\"position:absolute;visibility:hidden;z-index:200;\"></div>");
    this.wwrite("<script language=\"JavaScript\" src=\"Browser/scripts/SksUtils.js\"> </script>");

	this.wwriteA("<FONT FACE='" + fontface + "' SIZE=1><B>");
	this.wwriteA("Select Month and Year first and then click on the day.");
	this.wwriteA("</B></FONT><br>");
	this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
	var astr = "";

	astr = astr + "  <select name='MonthBox' "
	astr = astr + "onChange=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', MonthBox.options[MonthBox.options.selectedIndex].value, YearBox.options[YearBox.options.selectedIndex].value, '" + this.gFormat + "'" +
		");\"";
	astr = astr + " >";
	for (var i=0;i<12;i++ )
	{
		astr = astr + "<option value='"+i+"' ";
		if (i == this.gMonth)
		{
			astr = astr + 'selected';
		}
		astr = astr + " >"+Calendar.Months[i]+"</option>";
	}
	astr = astr + "</select>";

	astr = astr + "  <select name='YearBox' "
	astr = astr + "onChange=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', MonthBox.options[MonthBox.options.selectedIndex].value, YearBox.options[YearBox.options.selectedIndex].value, '" + this.gFormat + "'" +
		");\"";
	astr = astr + " >";
	for (var i=1900;i<2100;i++ )
	{
		astr = astr + "<option value='"+i+"' ";
		if (i == this.gYear)
		{
			astr = astr + 'selected';
		}
		astr = astr + " >"+i+"</option>";
	}
	astr = astr + "</select>";
//	this.wwriteA(this.gMonthName + " " + this.gYear+"  "+astr);
	this.wwriteA(astr);
	this.wwriteA("</B><BR>");

	// Get the complete calendar code for the month..
	vCode = this.getMonthlyCalendarCode();
	this.wwrite(vCode);

	this.wwrite("</font></body></html>");
	this.gWinCal.document.close();
}

Calendar.prototype.showY = function() {
	var vCode = "";
	var i;
	var vr, vc, vx, vy;		// Row, Column, X-coord, Y-coord
	var vxf = 285;			// X-Factor
	var vyf = 200;			// Y-Factor
	var vxm = 10;			// X-margin
	var vym;				// Y-margin
	if (isIE)	vym = 75;
	else if (isNav)	vym = 25;
	
	this.gWinCal.document.open();

	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("<style type='text/css'>\n<!--");
	for (i=0; i<12; i++) {
		vc = i % 3;
		if (i>=0 && i<= 2)	vr = 0;
		if (i>=3 && i<= 5)	vr = 1;
		if (i>=6 && i<= 8)	vr = 2;
		if (i>=9 && i<= 11)	vr = 3;
		
		vx = parseInt(vxf * vc) + vxm;
		vy = parseInt(vyf * vr) + vym;

		this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
	}
	this.wwrite("-->\n</style>");
	this.wwrite("</head>");

	this.wwrite("<body onload=\"window.focus();ensureFocus();\" " + 
		"link=\"" + this.gLinkColor + "\" " + 
		"vlink=\"" + this.gLinkColor + "\" " +
		"alink=\"" + this.gLinkColor + "\" " +
		"text=\"" + this.gTextColor + "\">");
	this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
	this.wwrite("Year : " + this.gYear);
	this.wwrite("</B><BR>");

	// Show navigation buttons
	var prevYYYY = parseInt(this.gYear) - 1;
	var nextYYYY = parseInt(this.gYear) + 1;
	
	this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\">>><\/A>]</TD></TR></TABLE><BR>");

	// Get the complete calendar code for each month..
	var j;
	for (i=11; i>=0; i--) {
		if (isIE)
			this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
		else if (isNav)
			this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

		this.gMonth = i;
		this.gMonthName = Calendar.get_month(this.gMonth);
		vCode = this.getMonthlyCalendarCode();
		this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
		this.wwrite(vCode);

		if (isIE)
			this.wwrite("</DIV>");
		else if (isNav)
			this.wwrite("</LAYER>");
	}

	this.wwrite("</font><BR></body></html>");
	this.gWinCal.document.close();
}

Calendar.prototype.wwrite = function(wtext) {
	this.gWinCal.document.writeln(wtext);
}

Calendar.prototype.wwriteA = function(wtext) {
	this.gWinCal.document.write(wtext);
}

Calendar.prototype.cal_header = function() {
	var vCode = "";
	
	vCode = vCode + "<TR>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";
	vCode = vCode + "</TR>";
	
	return vCode;
}

Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);

	var vFirstDay=vDate.getDay();
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	var vOnLastDay=0;
	var vCode = "";

	/*
	Get day for the 1st of the requested month/year..
	Place as many blank cells before the 1st day of the month as necessary. 
	*/

	vCode = vCode + "<TR>";
	for (i=0; i<vFirstDay; i++) {
		vCode = vCode + "<TD WIDTH='14%' align=\"center\"" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'>&nbsp;</FONT></TD>";
	}

	// Write rest of the 1st week
	for (j=vFirstDay; j<7; j++) {
		vCode = vCode + "<TD WIDTH='14%' align=\"center\"" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
			"<A HREF='#' " + 
				"onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
				this.format_data(vDay) + 
				"';window.close();\">" + 
				this.format_day(vDay) + 
			"</A>" + 
			"</FONT></TD>";
		vDay=vDay + 1;
	}
	vCode = vCode + "</TR>";

	// Write the rest of the weeks
	for (k=2; k<7; k++) {
		vCode = vCode + "<TR>";

		for (j=0; j<7; j++) {
			vCode = vCode + "<TD WIDTH='14%' align=\"center\"" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
				"<A HREF='#' " + 
					"onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
					this.format_data(vDay) + 
					"';window.close();\">" + 
				this.format_day(vDay) + 
				"</A>" + 
				"</FONT></TD>";
			vDay=vDay + 1;

			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
			}
		}

		if (j == 6)
			vCode = vCode + "</TR>";
		if (vOnLastDay == 1)
			break;
	}
	
	// Fill up the rest of last week with proper blanks, so that we get proper square blocks
	for (m=1; m<(7-j); m++) {
		if (this.gYearly)
			vCode = vCode + "<TD WIDTH='14%' align=\"center\"" + this.write_weekend_string(j+m) + 
			"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
		else
			vCode = vCode + "<TD WIDTH='14%' align=\"center\"" + this.write_weekend_string(j+m) + 
			"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
	}
	
	return vCode;
}

Calendar.prototype.format_day = function(vday) {
	var vNowDay = gNow.getDate();
	var vNowMonth = gNow.getMonth();
	var vNowYear = gNow.getFullYear();

	if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
		return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
	else
		return (vday);
}

Calendar.prototype.write_weekend_string = function(vday) {
	var i;

	// Return special formatting for the weekend day.
	for (i=0; i<weekend.length; i++) {
		if (vday == weekend[i])
			return (" BGCOLOR=\"" + weekendColor + "\"");
	}
	
	return "";
}

Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vY2 = new String(this.gYear.substr(2,2));
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

	switch (this.gFormat) {
		case "MM\/DD\/YYYY" :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
			break;
		case "MM\/DD\/YY" :
			vData = vMonth + "\/" + vDD + "\/" + vY2;
			break;
		case "MM-DD-YYYY" :
			vData = vMonth + "-" + vDD + "-" + vY4;
			break;
		case "MM-DD-YY" :
			vData = vMonth + "-" + vDD + "-" + vY2;
			break;

		case "DD\/MON\/YYYY" :
			vData = vDD + "\/" + vMon + "\/" + vY4;
			break;
		case "DD\/MON\/YY" :
			vData = vDD + "\/" + vMon + "\/" + vY2;
			break;
		case "DD-MON-YYYY" :
			vData = vDD + "-" + vMon + "-" + vY4;
			break;
		case "DD-MON-YY" :
			vData = vDD + "-" + vMon + "-" + vY2;
			break;

		case "DD\/MONTH\/YYYY" :
			vData = vDD + "\/" + vFMon + "\/" + vY4;
			break;
		case "DD\/MONTH\/YY" :
			vData = vDD + "\/" + vFMon + "\/" + vY2;
			break;
		case "DD-MONTH-YYYY" :
			vData = vDD + "-" + vFMon + "-" + vY4;
			break;
		case "DD-MONTH-YY" :
			vData = vDD + "-" + vFMon + "-" + vY2;
			break;

		case "DD\/MM\/YYYY" :
			vData = vDD + "\/" + vMonth + "\/" + vY4;
			break;
		case "DD\/MM\/YY" :
			vData = vDD + "\/" + vMonth + "\/" + vY2;
			break;
		case "DD-MM-YYYY" :
			vData = vDD + "-" + vMonth + "-" + vY4;
			break;
		case "DD-MM-YY" :
			vData = vDD + "-" + vMonth + "-" + vY2;
			break;

		default :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
	}

	return vData;
}

function Build(p_item, p_month, p_year, p_format) {
	var p_WinCal = ggWinCal;
	gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);

	// Customize your Calendar here..
	gCal.gBGColor="white";
	gCal.gLinkColor="black";
	gCal.gTextColor="black";
	gCal.gHeaderColor="darkgreen";

	// Choose appropriate show function
	if (gCal.gYearly)	gCal.showY();
	else	gCal.show();
}

function show_calendar() {
	/* 
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year	: 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_item	: Return Item.
	*/
	p_item = arguments[0];
	if (arguments[1] == null)
		p_month = new String(gNow.getMonth());
	else
	{
		p_month = arguments[1];
  	    if (p_month.length==0)
		   p_month = new String(gNow.getMonth()+1);
  	    if (p_month.substr(0,1)=='0')
		   p_month=p_month.substr(1,1);
		p_month=parseInt(p_month)-1;
		p_month=p_month.toString();
	}
	if (arguments[2] == "" || arguments[2] == null)
		p_year = new String(gNow.getFullYear().toString());
	else
	{
		p_year = arguments[2];
  	    if (p_year.length==0)
		   p_year = new String(gNow.getFullYear().toString());
	}
	if (arguments[3] == null)
		p_format = "DD/MM/YYYY";
	else
		p_format = arguments[3];
	var vWinCal = window.open("", "Calendar", "width=250,height=200,status=no,resizable=no,top=200,left=200");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, p_month, p_year, p_format);
}
/*
Yearly Calendar Code Starts here
*/
function show_yearly_calendar(p_item, p_year, p_format) {
	// Load the defaults..
	if (p_year == null || p_year == "")
		p_year = new String(gNow.getFullYear().toString());
	if (p_format == null || p_format == "")
		p_format = "DD/MM/YYYY";

	var vWinCal = window.open("", "Calendar", "scrollbars=yes");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, null, p_year, p_format);
}

/*
Pop up information box II (Mike McGrath (mike_mcgrath@lineone.net,
http://website.lineone.net/~mike_mcgrath))
Permission granted to thewebmasterdirectory.com to display script
*/

Xoffset=10;    // modify these values to ...
Yoffset=-20;    // change the popup position.

var nav,old,iex=(document.all),yyy=-1000;xxx=-1000;
if(navigator.appName=="Netscape"){(document.layers)?nav=true:old=true;}

if(!old){
var skn=(nav)?document.dek:dek.style;
if(nav)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=get_mouse;
}

function popup(){
msg = new String ;
if (arguments[0] != null)
{
	msg = arguments[0]; 
}
awid = 250;
if (arguments[1] != null)
{
	awid = parseInt(arguments[1]);
}
var content="<Table><img height='40' width='40' src='Browser/images/duck.Gif'/></Table><TABLE  WIDTH="+awid+" BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
"BGCOLOR=#FFFF99><TD><FONT COLOR=black SIZE=1 face=arial>"+msg+"</FONT></TD></TABLE>";
if(old){alert(msg);return;} 
else{yyy=Yoffset;xxx=Xoffset;
 if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
 if(iex){document.all("dek").innerHTML=content;skn.visibility="visible"}
 }
}

function get_mouse(e){
var x=(nav)?e.pageX:event.x+document.body.scrollLeft;skn.left=x+xxx;
var y=(nav)?e.pageY:event.y+document.body.scrollTop;skn.top=y+yyy;
}

function kill(){
if(!old){xxx=-1000;yyy=-1000;skn.visibility="hidden";}
}

/* Tabs and Menus */

	isMac = (navigator.appVersion.indexOf("Macintosh") != -1);

	tabsEventList = new Array(1);
	tabsEventList[0] = 0;

	uniqueEventIdentifiertabs = 1;

	function tabsEvent (secs, exeStatement) {
		canceltabsEvent ();

		this.tabstime = secs;
		this.tabsexeStatement = exeStatement;
		this.tabsidentifier = uniqueEventIdentifiertabs++;
		
		tabsEventList[0] = this;

		window.setTimeout ( "executetabsEvent(" + tabsEventList[0].tabsidentifier + ");", secs*1000 );  					
		}

	function executetabsEvent (eventIdentifier) {
		if ( typeof ( tabsEventList[0] ) == "object" )
			if ( typeof ( tabsEventList[0].tabsexeStatement ) == "string" )
				if ( tabsEventList[0].tabsidentifier == eventIdentifier ) {
					eval ( tabsEventList[0].tabsexeStatement );
					tabsEventList[0] = void 0;
					}
		}

	function canceltabsEvent () {
		tabsEventList[0] = void 0;
		}

	function tabsBarMouseOut () {
		if (isMac) {
			tempEvent = new tabsEvent (3, 'if (document.tabsIsActive) { document.currenttabs.style.display=\'none\'; document.currentTBarOpt.style.border=\'1px solid lightgrey\'; document.currentTBarOpt.style.backgroundColor=\'lightgrey\'; document.currentTBarOpt.style.color=\'black\'; document.tabsIsActive=false; }')
			}
		}
	function tabsBarBlur () {
		document.currentTBarOpt.style.border='3px buttonface outset';
	   	document.currentTBarOpt.style.backgroundColor='teal';
		document.currentTBarOpt.style.color='white';
		}

	function tabsBarOptionMouseOver (tabsBarOptionId, tabsId) {
		if (isMac) {
			tabsId.style.top=16;
			if (document.tabsIsActive) {
				tabsBarOptionId.style.border='1px solid darkblue';
				tabsBarOptionId.style.backgroundColor='darkblue';
				tabsBarOptionId.style.color='white';
				tabsId.style.display = 'block';
				}
			}
		else {  if (tabsBarOptionId != document.currentTBarOpt) {
				tabsBarOptionId.style.cursor='default';
				tabsBarOptionId.style.border='3px solid lightblue';
				tabsBarOptionId.style.backgroundColor='lightblue';
				tabsBarOptionId.style.color='black';
				}
			}
		}
	function tabsBarOptionMouseOut (tabsBarOptionId) {
		tabsBarOptionId.style.border='3px solid brown';
		tabsBarOptionId.style.backgroundColor='brown';
		tabsBarOptionId.style.color='white';
		if (document.tabsIsActive) {
		document.currentTBarOpt.style.border='3px buttonface outset';
		document.currentTBarOpt.style.backgroundColor='teal';
		document.currentTBarOpt.style.color='white';
		}
		}
	function tabsBarOptionMouseDown (tabsBarOptionId, tabsId) {
		if (document.tabsIsActive) {
		document.currenttabs.style.display = 'none';
		document.currentTBarOpt.style.border='3px solid brown';
		document.currentTBarOpt.style.backgroundColor='brown';
		document.currentTBarOpt.style.color='white';
		}
		if (isMac) {
			tabsBarOptionId.style.border='1px solid darkblue';
			tabsBarOptionId.style.backgroundColor='darkblue';
			tabsBarOptionId.style.color='white';
			}
		else {
			tabsBarOptionId.style.border='3px buttonface outset';
			tabsBarOptionId.style.backgroundColor='teal';
			tabsBarOptionId.style.color='white';
			}
		tabsId.style.display = 'block';
		tabsBarOptionId.style.cursor='default';
		tabsBarOptionId.parentElement.style.height=tabsId.offsetHeight + 28;
		document.tabsIsActive=true;
		document.currenttabs = tabsId;
		document.currentTBarOpt = tabsBarOptionId;
		}

	function tabsClick () {
		if (isMac) {
			document.currenttabs.style.display='none';
			document.currentTBarOpt.style.border='1px solid lightgrey';
			document.currentTBarOpt.style.backgroundColor='yellow';
			document.currentTBarOpt.style.color='black';
			}
		}



	menuEventList = new Array(1);
	menuEventList[0] = 0;

	uniqueEventIdentifier = 1;


	function menuEvent (secs, exeStatement) {
		cancelMenuEvent ();

		this.time = secs;
		this.exeStatement = exeStatement;
		this.identifier = uniqueEventIdentifier++;

		menuEventList[0] = this;
		
		window.setTimeout ( "executemenuEvent(" + menuEventList[0].identifier + ");", secs*1000 );  					
		}
	function executemenuEvent (eventIdentifier) {
		if ( typeof ( menuEventList[0] ) == "object" )
			if ( typeof ( menuEventList[0].exeStatement ) == "string" )
				if ( menuEventList[0].identifier == eventIdentifier ) {
					eval ( menuEventList[0].exeStatement );
					menuEventList[0] = void 0;
					}
		}
	function cancelMenuEvent () {
		menuEventList[0] = void 0;
		}

	function menuBarMouseOut () {
		if (isMac) {
			tempEvent = new menuEvent (3, 'if (document.menuIsActive) { document.currentMenu.style.display=\'none\'; document.currentMBarOpt.style.border=\'1px solid lightgrey\'; document.currentMBarOpt.style.backgroundColor=\'lightgrey\'; document.currentMBarOpt.style.color=\'black\'; document.menuIsActive=false; }')
			}
		}
	function menuBarBlur () {
		document.currentMenu.style.display='none';
		document.currentMBarOpt.style.border='1px solid lightyellow';
	   	document.currentMBarOpt.style.backgroundColor='lightyellow';
		document.currentMBarOpt.style.color='black';
		document.menuIsActive = false;
		}

	function menuBarOptionMouseOver (menuBarOptionId, menuId) {
		if (document.menuIsActive) {
			document.currentMenu.style.display = 'none';
			document.currentMBarOpt.style.border='1px solid lightyellow';
			document.currentMBarOpt.style.backgroundColor='lightyellow';
			document.currentMBarOpt.style.color='black';
			}
		if (isMac) {
			menuId.style.top=16;
			if (document.menuIsActive) {
				menuBarOptionId.style.border='1px solid darkblue';
				menuBarOptionId.style.backgroundColor='darkblue';
				menuBarOptionId.style.color='white';
				menuId.style.display = 'block';
				}
			}
		else {
			if (document.menuIsActive) {
				menuBarOptionId.style.border='1px buttonface inset';
				menuId.style.display = 'block';
				menuBarOptionId.style.backgroundColor='lightblue';
				menuBarOptionId.style.color='black';
				}
			else {
				if (typeof (document.currentMBarOpt) == 'object') {
					document.currentMBarOpt.style.border='1px solid lightyellow';
					}
				menuBarOptionId.style.border='1px buttonface outset';
				menuBarOptionId.style.backgroundColor='lightblue';
				menuBarOptionId.style.color='black';
				}
			}
		menuBarOptionId.style.cursor='default';
		document.currentMenu=menuId;
		document.currentMBarOpt=menuBarOptionId;
		}
	function menuBarOptionMouseOut (menuBarOptionId) {
		if (!document.menuIsActive) {
			menuBarOptionId.style.border='1px solid lightyellow';
			menuBarOptionId.style.backgroundColor='lightyellow';
			menuBarOptionId.style.color='black';
			}
		}
	function menuBarOptionMouseDown (menuBarOptionId, menuId) {
		menubar.focus ();
		if (isMac) {
			menuBarOptionId.style.border='1px solid darkblue';
			menuBarOptionId.style.backgroundColor='darkblue';
			menuBarOptionId.style.color='white';
			}
		else {
			menuBarOptionId.style.border='1px buttonface inset';
			menuBarOptionId.style.backgroundColor='lightblue';
			menuBarOptionId.style.color='black';
			}
		menuId.style.display = 'block';
		document.menuIsActive=true;
		}

	function menuClick () {
		if (isMac) {
			document.currentMenu.style.display='none';
			document.currentMBarOpt.style.border='1px solid lightgrey';
			document.currentMBarOpt.style.backgroundColor='yellow';
			document.currentMBarOpt.style.color='black';
			}
		}

	function menuOptionCellMouseOver (cell) {
		cell.style.cursor='default';
		cell.style.color='black';
		cell.style.backgroundColor='lightblue';
		}
	function menuOptionCellMouseOut (cell) {
		cell.style.backgroundColor='lightyellow';
		cell.style.color='black';
		}

	function menuOptionDivMouseDown (url) {
		if (! isMac) {
			document.currentMenu.style.display='none';
			document.currentMBarOpt.style.border='1px solid lightgrey';
			document.menuIsActive = false;
			window.location=url;
			}
		}
	function menuOptionDivClick (url) {
		if (isMac) {
			document.currentMenu.style.display='none';
			document.currentMBarOpt.style.border='1px solid lightgrey';
			document.menuIsActive = false;
			window.location=url;
			}
		}

  function getElement (aname){
  var ans = null;
  for (var i = 0; i < document.forms[0].elements.length; i++)
  {
	  var aItem = document.forms[0].elements[i];
	  if(aItem.name == aname){
		  ans = aItem;
	  };
  } 
  return ans;
  }

function CheckRequired(List){
  var ListArr =List.split(",");
  var AllOk = true;
  var aitem ;
  for (var i = 0; i < ListArr.length; i++)
  {
	  if (ListArr[i] != "")
	  {
		  aitem = getElement(ListArr[i]);
		  if (aitem != null)
			if (aitem.value == "")
			{
			  AllOk = false;
			  if (aitem.DISPLAYNAME != null)
				  alert("No value for "+aitem.DISPLAYNAME+". Must enter value for all required (* marked) fields !");
			  else 
				  alert("No value for "+aitem.name+". Must enter value for all required (* marked) fields !");
			  aitem.focus();
			  break;
			}
	  }
  } 
  return AllOk;
}


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Original:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Changes:
/* 1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters
international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two
letters (interpreted to be a country code) or one of the known
TLDs (com, net, org, edu, int, mil, gov, arpa), including the
new ones (biz, aero, name, coop, info, pro, museum).  One can
easily update the list (if ICANN adds even more TLDs in the
future) by updating the knownDomsPat variable near the
top of the function.  Also, I added a variable at the top
of the function that determines whether or not TLDs should be
checked at all.  This is good if you are using this function
internally (i.e. intranet site) where hostnames don't have to 
conform to W3C standards and thus internal organization e-mail
addresses don't have to either.
Changed some of the logic so that the function will work properly
with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing
(the bug is actually in the weak regexp engine of the browser; I
simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain,
so abc@host.uk is now legal.  However, there's still the 
restriction that an address must end in a two or three letter
word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  */
// -->

<!-- Begin
function emailCheck (emailStr) {

if (emailStr == '')
{
	return true;
}

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//  End -->

function DisplayFormat(aValue, aFormat){
	if ((aFormat == null) | (aFormat == '')) return aValue ;
	if (aFormat.toUpperCase() == 'ALLLOWER') return aValue.toLowerCase();
	if (aFormat.toUpperCase() == 'ALLUPPER') return aValue.toUpperCase();
	if (aFormat.toUpperCase() == 'TOLOWER') return aValue.toLowerCase();
	if (aFormat.toUpperCase() == 'TOUPPER') return aValue.toUpperCase();
	if (aFormat.toUpperCase() == 'FIRSTCAPS'){
		var result = '';
		var ToCaps = true ;
		for (var i = 0; i < aValue.length; i++ )
		  if ((aValue.charAt(i) >= 'A') & (aValue.charAt(i) <= 'z')) {
  			if (ToCaps){
			result = result + (aValue.charAt(i)).toUpperCase();
			ToCaps = false;
  			}
			else
  			  result = result + aValue.charAt(i);
		  }
		  else {
			result = result + aValue.charAt(i);
			ToCaps = true;
		  }
		return result;
	}
	return aValue;
}

function ValidateField(aValue, aFormat){
	if ((aFormat == null) | (aFormat == '')) return True ;
	if (aFormat.toUpperCase() == 'ISNUMBER'){
			var i = parseInt(aValue);
			if (aValue != i.toString()) 
			{
				alert(aValue + " is not a valid number.")
				return false;
			}
			else
				return true;
	}
	if (aFormat.toUpperCase() == 'ISDATE'){
	    var aday = aValue.substr(0,2);
	    var amonth = aValue.substr(3,2);
	    var ayear = aValue.substr(6,4);
	    var aDate = new Date(ayear,amonth-1,aday);
  	    if ((aDate.getMonth() != (amonth-1)) | (aDate.getFullYear() != ayear) | (aDate.getDate() != aday))
			{
				alert(aValue + " is not a valid date.")
				return false;
			}
		else
			return true;
	}
	return true;
}

function SetPrinting(value){
  var aObj ;
  var aDivArray ;
  aDivArray = document.all.tags("DIV");
  for (var i = 0; i < aDivArray.length; i++){
    if ((aDivArray[i].name == "NoPrint")|(aDivArray[i].name == "NavigatorTab")|(aDivArray[i].id == "NoPrint")|(aDivArray[i].id == "NavigatorTab")){
      aObj = aDivArray[i];
	  if (value == true)
        aObj.style.visibility='hidden';
	  else
        aObj.style.visibility='visible';
    }
  }
}


function GridFieldExit(aField, aHFTField)
	{
	  var ret_val = true;
	  var i, j, k, l ;
      if ((aField.name.substr(0,3)=="ROW"))
   	     {
            var astr = aHFTField.value;
			var rowno, fldname;
			fldname = aField.name;
			i = fldname.search('__');
			rowno = fldname.substr(3,i-1);
			rowno = parseInt(rowno);
			fldname = fldname.substr(i+2);
			i = fldname.search('__');
			fldname = fldname.substr(0,i);
			i = 0 ;
			j = 0 ;
	        while (true)
	        {
				j = astr.substr(i);
				j = j.search("-");
   			    k = astr.substr(i,j+1);
			    k = parseInt(k);
                if (k < rowno)
                {
  				   j = astr.substr(i).search(":;");
				   i = i + j + 2 ;
                } 
				else
				{
    	 		    j = astr.substr(i).search(":;");

					var bstr = astr.substr(i,j+2);
					k = bstr.search(fldname);
					k = k + bstr.substr(k).search("::");
					l = bstr.substr(k).search(":,");
					if (l == -1)
					{
						l = bstr.substr(k).search(":;");
					}
					var cstr = aField.value;
					if (aField.type == "checkbox")
						cstr = aField.checked;
					bstr = bstr.substr(0,k+2)+cstr+bstr.substr(k+l);
					astr = astr.substr(0,i)+bstr+astr.substr(i+j+2);
                    aHFTField.value = astr;
					break;
				}
	        }
	     }
  return ret_val;
}

function getElement(name){
//    var i, str ;
//	var aElement ;
//	for (i=0; i<document.forms[0].length;i++)
//	{
//		if (document.forms[0].elements[i].name == name)
//		{
//			return document.forms[0].elements[i];
//		}
//    }
//	return null;
  return document.all.item(name);
}

function stuffString(opn, Ele, str){
    var i;
	if (Ele.value != '')
  	  Ele.value = Ele.value + ',';
	if (opn == true)
	{
        if (Ele.value.indexOf(str+',')==-1)
  		    Ele.value = Ele.value + str+',';
	}
	else
	{
	    str = str+',';
		i = Ele.value.indexOf(str);
		if (i!=-1)
	  	    Ele.value = Ele.value.substr(0,i) + Ele.value.substr(i+str.length);
	}
	Ele.value = Ele.value.substr(0,Ele.value.length-1);
}

function removeQuotes(astr){
  astr = astr.substr(1,astr.length-2);
  return astr;
}
function updateMultiSearch(val, code, astr){
    var i, str, bstr, estr ;
	var aElement ;
	aElement = getElement("SearchRecord");
	stuffString(val, aElement,code);
	while (astr.length > 0)
	{
		i = astr.indexOf(';');
		bstr = astr.substr(0,i);
		astr = astr.substr(i+1);
		i = bstr.indexOf('=');
		estr = bstr.substr(0,i);
		bstr = bstr.substr(i+1);
		i = estr.indexOf('.value');
		estr = estr.substr(0,i);
		stuffString(val,getElement(estr),removeQuotes(bstr));
	}
}

function SelectAllBoxes(cnt){
    var i;
	var aElement ;
	for (i=1;i<=cnt;i++ )
	{
		aElement = getElement("selectcheck__"+i);
		aElement.click();
	}
}

function handlePress(){
  if (event.keyCode == 13){
  		event.cancelBubble = true;
		event.returnValue = false;
  }
  return true;
}

function Last_Date(aY, aM){
	return 28; 
}

function Check_Date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!");
	  DateField.value = "01/"+DateField.value.substr(3);
	  var aBox = getElement(DateField.name+'_D');
      aBox.options.selectedIndex = Last_Date(year,month);
	  aBox.focus();
	  aBox.select(); 
   }
}

var interval
var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 10
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
		window.focus();
    }
    self.status = secs
    secs = secs - 1
    timerRunning = true
    timerID = self.setTimeout("StartTheTimer()", delay)
}
  
function ensureFocus(i)
{
  InitializeTimer();
  if (i != null)
    secs = i;
  interval = secs;
}

function cheboxCheck(obj,v)
{
alert(obj.value);
alert(v.value);
}


function validate_num(field) { 
 var valid = "1234567890" 
 var ok = "yes"; 
 var temp; 
 for (var i=0; i<field.value.length; i++) { 
   temp = "" + field.value.substring(i, i+1); 
   if (valid.indexOf(temp) == "-1") ok = "no"; 
 } 
 if (ok == "no") { 
   alert("Invalid entry!  Only numbers 0-9 are accepted!"); 
   field.focus(); 
   field.select(); 
 }
 return true;
}
