//************************************************
// KorscientGeneric.js                           *
//                                               *
// Copyright 2001: Korscient Ltd                 *
// Web Address: http://www.korscient.com         *
//                                               *
// Generic Javascript used throughout the        *
// Korscient web site                            *
//***********************************************/


var docObj="document.all.";
var styleObj = ".style";

var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var NS6 = (document.getElementById && !document.all) ? true : false;


// Randomly chhose a banner add for the front page
function kchoose_banner()
{
// three possible texts and three primary colours
// so permute 0 from 8

	var iIndex = Math.min( Math.round(Math.random() * 9 ), 8) ;

	document.write("<IMG SRC=\"Images/SP_Banner" + iIndex + ".gif\" WIDTH=468 HEIGHT=60 BORDER=0 ALT=\"Goto Standard Platform Home Page\">");

	return;

} // end kchoose_banner


function kinit()
{
	if (NS4) {
		docObj = "document.layers.";
		styleObj ="";

		document.captureEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT);
	} else {
		if (IE4) {
			docObj="document.all.";
			styleObj = ".style";
		}
	}

	return;

} // end kinit


function ktooltip(evt, target, possibleTargets)
{
	var tooltip;

	if ((NS6 || NS4 || IE5|| IE4)) {
		if ( evt.x < 0 && evt.y < 0 ) {
			// If the user presses a button and then moves away from the map zone
			// You get a spurious event. In this case hide all the windows
			
			for ( var i = 0; i < possibleTargets.length; i++ ) {

				if (NS6 || IE5) {
					tooltip = document.getElementById(possibleTargets[i]).style;
				} else {
					tooltip = eval(docObj+possibleTargets[i]+styleObj);
				}

				tooltip.visibility = "hidden";
			}
		} else {
			if (NS6 || IE5) {
				tooltip = document.getElementById(target).style;
			} else {
				tooltip = eval(docObj+target+styleObj);
			}

			if (tooltip.visibility == "visible" || tooltip.visibility == "show" ) {
				tooltip.visibility = "hidden";
			} else {
				if (IE4 || IE5) {
					requiredTop = evt.y + document.body.scrollTop + 2;
					requiredLeft = Math.max(2, evt.x + document.body.scrollLeft - 125);
					tooltip.border="1 solid";
				} else {
					if (NS4 || NS6) {
						requiredTop = parseInt(evt.pageY)+2;
						requiredLeft = Math.max(2, parseInt(evt.pageX)-125);

						if (NS6) {
							tooltip.border="1px solid";
						}
					}
				}

				tooltip.top = requiredTop;
				tooltip.left = requiredLeft;
				tooltip.visibility = "visible";
			}

			window.status="";
		}
	}

	return true;

} // end ktooltip


function kset_date()
{
	var now = new Date();
	var month = now.getMonth();
	var date = now.getDate();
	var year = now.getYear();
	var dow = now.getDay()
	var monthname;
	var arrDOW = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

	monthname = arrMonths[month];

	var yearname;

	if (year < 1900) year = year + 1900;

	yearname = year;

	var output_text="<P CLASS=\"Date\">"+arrDOW[dow]+" "+date+" "+monthname+" "+yearname+"</P>";

	document.write(output_text);

	return;

} //end kset_date
