var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;
var isMinIE5_5=(isMinIE5&&navigator.appVersion.indexOf("5.5")>=0)?1:0;
var IMAGEDIR ='images/';
var IMAGETYPE ='gif';
var preloaded = false;

// Global defines

// ------------------------------------------------------------------------------
// General functions
//-------------------------------------------------------------------------------

// Button RollOver routine
// action can be _r, _g, or null
// type could be gif or jpg
function bro(thisimage, theaction, type)
{
	if (thisimage.src.indexOf("_g")!=-1) return false;
	if (arguments.length < 3) type = "gif";
	if (arguments.length < 2) theaction = "";
	thisimage.src = "images//buttons//" + thisimage.name + theaction + "." + type;
	return true;
}

function showwindowstatus(text)
{
	text = text.replace("\'", "\\\'")
	window.setTimeout("window.status=\'" + text + "\'", 10);
}

function getURLArgs()
{
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for (var i = 0; i < pairs.length; i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos==-1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname] = unescape(value);
	}
return args;
}

function isblank(s)
{
	for(var i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

function verify(f, msg)
{
	//var msg;
	var empty_fields = "";
	var errors = "";

	// Loop through the elements of the form, looking for all 
	// text and textarea elements that don't have an "optional" property
	// defined. Then, check for fields that are empty and make a list of them.
	// Also, if any of these elements have a "min" or a "max" property defined,
	// then verify that they are numbers and that they are in the right range.
	// Put together error messages for fields that are wrong.
	for(var i = 0; i < f.length; i++)
	{
		var e = f.elements[i];
		if (((e.type == "text") || (e.type == "textarea")) && !e.optional)
		{
			// first check if the field is empty
			if ((e.value == null) || (e.value == "") || isblank(e.value))
			{
				empty_fields += "\n          " + e.name;
				continue;
			}

		// Now check for fields that are supposed to be numeric.
			if (e.numeric || (e.min != null) || (e.max != null))
			{
				var v = parseFloat(e.value);
				if (isNaN(v) || ((e.min != null) && (v < e.min)) || ((e.max != null) && (v > e.max)))
				{
					errors += "- The field " + e.name + " must be a number";
					if (e.min != null)
						errors += " that is greater than " + e.min;
					if (e.max != null && e.min != null)
						errors += " and less than " + e.max;
					else if (e.max != null)
						errors += " that is less than " + e.max;
					errors += ".\n";
				}
			}
		}
	}

	// Now, if there were any errors, display the messages, and
	// return false to prevent the form from being submitted. 
	// Otherwise return true.
	if (!empty_fields && !errors) return true;
	alert(msg);
	return false;
}

function reloadPage(init)
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function OpenNewWindow(fyle, action)
{
	var wf = "";
	var w = (arguments[2] ? arguments[2] : 610);
	var h = (arguments[3] ? arguments[3] : 400);
	
	wf = wf + "width=" + w;
	wf = wf + ",height=" + h;
	wf = wf + ",resizable=no";
	wf = wf + ",scrollbars=no";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	window.open("popup.asp?showing=" + fyle,action,wf);
	return true;
}

function OpenEditor(fyle, action)
{
	var wf = "";
	var w = (arguments[2] ? arguments[2] : 610);
	var h = (arguments[3] ? arguments[3] : 400);
	
	wf = wf + "width=" + w;
	wf = wf + ",height=" + h;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=no";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	window.open(fyle,action,wf);
	return true;
}
function OpenHelper(fyle)
{
	var wf = "";
	var w = (arguments[1] ? arguments[1] : 300);
	var h = (arguments[2] ? arguments[2] : 200);
	
	wf = wf + "width=" + w;
	wf = wf + ",height=" + h;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";
	window.open(fyle,'_blank',wf);
	return true;
}

function PageTurner()
{
	var tl = (arguments[1] ? arguments[1] : 15000);
	var thepage = (arguments[0] ? "location.href='" + arguments[0] + "'" : "history.back()");
	setTimeout(thepage,tl);
	return true;
}

