/* standard javascript library
 * written by henry rivera, 2001 */

/* setup of initial environment
 * see bottom of script for function initialization */

var retype = 0;

function BrowserCheck()  // thanks to Dan Steinman for the idea  (http://www.dansteinman.com/dynapi/) 
{
	var Browser = navigator.appName;
	if (Browser == "Netscape") {
		this.Browser = "ns";
	} else if (Browser == "Microsoft Internet Explorer") {
		this.Browser = "ie";
	} else {
		this.Browser = "b";
	}
	this.Version = parseInt(navigator.appVersion);
	this.ns = (this.Browser == "ns" && this.Version >= 4);
	this.ns4 = (this.Browser == "ns" && this.Version == 4);
	this.ns5 = (this.Browser == "ns" && this.Version == 5);
	this.ie = (this.Browser == "ie" && this.Version >= 4);
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4') > 0);
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5') > 0);
	if (this.ie5) {
		this.Version = 5;
	}
	this.min = (this.ns || this.ie);
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

/* 
 * image manipulation
 */
function preLoad(name, source)
{
	eval(name + ' = new Image()');
	eval(name + '.src = source + ".gif"');
	
	var keyOver = name + 'Over';
	eval(keyOver + ' = new Image()');
	eval(keyOver + ".src = source + 'over.gif'");
}

function batchLoad()
{
	for (i = 0; i < arguments.length; i++) {
		eval(arguments[i] + ' = new Image()');
		eval(arguments[i] + '.src = basepath + arguments[i] + ".gif"');

		var keyOver = arguments[i] + 'Over';
		eval(keyOver + ' = new Image()');
		eval(keyOver + ".src = basepath + arguments[i] + 'over.gif'");
	}
}

function preLoadArray(imageArray)
{
	for (key in imageArray) {
		eval(key + ' = new image()');
		eval(key + '.src = imageArray[Key] + ".gif"');
		
		var keyOver = key + 'Over';
		eval(keyOver + ' = new image()');
		eval(keyOver + '.src = imageArray[Key] + "over.gif"');
	} 
}

function rollMe(name, mode, layer)
{
	if (document.layers && layer != null) {
		var imageArray = eval('document.' + layer + '.document.images');
	} else {
		var imageArray = eval('document.images');
	}
	
	if (mode == "over") {
		imageArray[name].src = eval(name + 'Over.src');
	} else if (mode == "out") {
		imageArray[name].src = eval(name + '.src');
	} else {
		imageArray[name].src = eval(name + 'Down.src');
	}
}

function highlightRow(source)
{
	window.status = event.type;
	if (event.type == 'mouseover') {
		source.style.background = '3D8B70';
	} else if (event.type == 'mousedown') {
		source.style.background = '1F483A';
	} else {
		source.style.background = '31725C';
	}
}

/*
 * forms processing
 */
function focusForm(form,field)
{
	var target = eval("document." + form + "." + field);
	target.focus();	
}

/* onkeyup="nextField(this);" */
function nextField(source)
{
        var nextfield = source.tabIndex; /* no math is needed here, form starts at zero, the tab index starts at one (the next field) */
	//-> start debug
        //window.status = event.keyCode + ' ' + source.type;
	//-> end debug

        if (window.event.keyCode == 16 || event.keyCode == 9) { /* shift, tab */
                /* catches shift-tabs */
                        return;
        }
        /* this is annoying and doesn't work atm (bah)
        if (event.keyCode == 8 && source.value.length == 0) {
                var previous = source.tabIndex - 2;
                //if (previous >= 0 && source.type == 'text') { //-> catches empty backspaces
                if (previous >= 0) {
                        shiftTab(source.form[previous]);
                }
                return;
        }
         will fix later */

        if (source.value.length == source.maxLength) {
                //alert(i);
                source.form[nextfield].focus(); //focus();
                if (source.form[nextfield].type == 'text') {
                        source.form[nextfield].blur();
                        source.form[nextfield].select();
                }
        //} else if (source.type == 'checkbox' && source.checked) {
        } else if (source.type == 'checkbox') {
                if (event.keyCode == 32) {
                        if(!source.checked) {
                                //      alert('heh');
                                source.focus();
                                source.checked = true;
                                source.blur();
                                //source.click;
                                source.form[nextfield].focus();
                                if (source.form[nextfield].type == 'text') {
                                        source.form[nextfield].blur();
                                        source.form[nextfield].select();
                                }
                        }
                }
        } else if (source.type == 'select-one') {
                if (event.keyCode == 72 ||
                    event.keyCode == 79 || event.keyCode == 73 || event.keyCode == 69 || event.keyCode == 83 || event.keyCode == 65) {
                source.form[nextfield].focus();
                        if (source.form[nextfield].type == 'text') {
                                source.form[nextfield].blur();
                                source.form[nextfield].select();
                        }
                }
        }
}

function showTip(target,text)
{
	if (document.all && document.readyState == 'complete') {
		target.innerHTML = text;
		target.style.visibility = 'visible';
	}
}

function hideTip(target)
{
	if (document.all) {
		target.style.visibility = 'hidden';
	}
}

function showtip2(current,text)
{
	if (document.all&&document.readyState=="complete"){
		document.all.tooltip2.innerHTML=text;
		document.all.tooltip2.style.visibility="visible";
	} else if (document.layers){
		document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
		document.tooltip2.document.nstip.document.close()
		document.tooltip2.document.nstip.left=0
		currentscroll=setInterval("scrolltip()",100)
		document.tooltip2.left=e.pageX+10
		document.tooltip2.top=e.pageY+10
		document.tooltip2.visibility="show"
	}
}

function hidetip2()
{
	if (document.all)
		document.all.tooltip2.style.visibility="hidden"
		else if (document.layers){
		clearInterval(currentscroll)
		document.tooltip2.visibility="hidden"
	}
}
