/* ----------------------------------------------------------------------------
File Name: global.js 
Application: 
Document Type: javascript include
Developer: rsymonds@infotree.com
Created: 01.08.2001
Last Modified: 01.08.2001 
Description:
	This is a global javascript include that should be included on EVERY page.
	It calls the correct standardized stylesheet for each browser and provides
	many useful methods/functions.
	
	If you are calling this file from a page in the root directory, then call 
	it like this:

		<script language="JavaScript" type="text/javascript" src="global/global.js"></script> 

	If you are calling the file from somewhere else, you must call the script using the relative path or
	absolute URL.  You must also specify the path variable before you call the script.  Example:

		<script language="JavaScript">path = "../";</script> 
		<script language="JavaScript" type="text/javascript" src="../global/global.js"></script> 

	OR

		<script language="JavaScript">path = "http://www.infotree.com/";</script> 
		<script language="JavaScript" type="text/javascript" src="http://www.infotree.com/global/global.js"></script>

	Note: you MUST have the final slash after the absolute URL in the path.

	For more information read: global_js_readme.txt
	
-- V2.0 --
---------------------------------------------------------------------------- */


// ------------------------------------------------------------------
// start: get generic browser type
NN = (navigator.appName == "Netscape" && navigator.appVersion.charAt(1) != "6")?true:false;
IE = (navigator.appName != "Netscape")?true:false;
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: select the appropriate stylesheet
if (!path) var path = ""; // if the path variable was set before the call to this (.js) file

if (NN)
	document.write("<LINK REL=stylesheet HREF=\""+path+"global/global_nn.css\" TYPE=\"text/css\">");
else
	document.write("<LINK REL=stylesheet HREF=\""+path+"global/global_ie.css\" TYPE=\"text/css\">");
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: drop down navigation
function jumpTo(URL) {
	if (URL.length > 0) {
		location.href = URL;
	}
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: confirm an action with a Javascript confirm box
function doConfirm(msg) {
	boolReturn = true;
	msg = (!msg)?"Are you sure you want to delete this item?":msg;
	if(!confirm(msg)) {
		boolReturn = false;
	}
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: checkForm()
function checkForm(form,strError) {
	boolReturn = true;
	strError = (strError)?strError:"You must supply information for all of the required fields.";
	if (form.required && form.required.value) {
		required = form.required.value;
	}
	else if (!form.required || !form.required.value) {
		required = "NONE";
	}

	if (required == "ALL") {
		arrControlsToValidate = new Array();
		for(i=0;i<form.elements.length;i++) {
			arrControlsToValidate[i] = form.elements[i];
		}
	}
	else if (required != "NONE") {
		arrRequiredFields = required.split(',');
		arrControlsToValidate = new Array();
		for(i=0;i<arrRequiredFields.length;i++) {
			objThisControl = new Object();
			objThisControl.constructor = eval("form."+arrRequiredFields[i]);
			objThisControl.name = eval("form."+arrRequiredFields[i]+".name");
			objThisControl.type = eval("form."+arrRequiredFields[i]+".type");
			objThisControl.value = eval("form."+arrRequiredFields[i]+".value");
			arrControlsToValidate[i] = eval(objThisControl);
		}
	}

	if (required != "NONE") {
		for(i=0;i<arrControlsToValidate.length;i++) {
			strCurrentControl = arrControlsToValidate[i];
			strCurrentName = arrControlsToValidate[i].name;
			strCurrentType = arrControlsToValidate[i].type.toUpperCase();
			strCurrentType = (strCurrentType == "PASSWORD" || strCurrentType == "TEXTAREA")?"TEXT":strCurrentType;
			strCurrentVal = arrControlsToValidate[i].value;

			if (strCurrentType == "TEXT") {
				boolReturn = validateTextInput(eval("form."+strCurrentName),strError);
				if (!boolReturn) break;				
			}
		}
	}
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
/* start: local, custom form validation
function checkFormLocal(form) {
	boolReturn = true;
	validate : {
		boolReturn = checkForm(form);
		if (!boolReturn) break validate;
		boolReturn = validateRadio(form.car,"You must specify a car.");
		if (!boolReturn) break validate;
		boolReturn = validateMultipleCheckbox(form.myNum,"You must specify a number.");
		if (!boolReturn) break validate;
	}
	return boolReturn;
}*/
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validate a radio button form input
function validateRadio(objFormInput,strError) { 
	boolReturn = false;
	strError = (strError)?strError:"You must supply information for all of the required fields.";
	for (i=0;i<objFormInput.length;i++) {
		if (objFormInput[i].checked) {
			boolReturn = true;
			break;
		}	
	}
	if (!boolReturn) alert(strError);
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validate a single checkbox
function validateSingleCheckbox(objFormInput,strError) { 
	boolReturn = false;
	strError = (strError)?strError:"You must supply information for all of the required fields.";
	boolReturn = objFormInput.checked;
	if (!boolReturn) alert(strError);
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validate a related group of checkboxes
function validateMultipleCheckbox(objFormInput,strError) { 
	boolReturn = false;
	strError = (strError)?strError:"You must supply information for all of the required fields.";
	for (i=0;i<objFormInput.length;i++) {
		if (objFormInput[i].checked) {
			boolReturn = true;
			break;
		}	
	}
	if (!boolReturn) alert(strError);
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validateTextInput()
function validateTextInput(objFormInput,strError) {
	boolReturn = true;
	strError = (strError)?strError:"You must supply information for all of the required fields.";
	if (!objFormInput.value) {
		boolReturn = false;
	}
	if (!boolReturn) {
		alert(strError);
		objFormInput.focus();
	}
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validateSelect()
function validateSelect(objFormInput,strError) {
	boolReturn = false;
	strError = (strError)?strError:"You must supply information for all of the required fields.";
	for (i=0;i<objFormInput.length;i++) {
		if (objFormInput[i].selected && objFormInput[i].value) {
			boolReturn = true;
			break;
		}
	}
	if (!boolReturn) {
		alert(strError);
		objFormInput.focus();
	}
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validateEmail()
function validateEmail(objFormInput,strError) {
	boolReturn = false;
	strError = (strError)?strError:"You must supply a valid email address.";
	strIn = trim(objFormInput.value);
	reA = new RegExp(/\./g);
	reB = new RegExp(/@/g);
	boolReturn = (reA.test(strIn) && reB.test(strIn) && strIn.length > 5 && strIn.indexOf(" ") == -1)?true:false;
	if (!boolReturn) {
		alert(strError);
		objFormInput.focus();
	}
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: validatePassword()
function validatePassword(form,strError) {
	boolReturn = false;
	strError = (strError)?strError:"Passwords do not match.  Please type your password again in the 'Confirm Password' box.";
	boolReturn = (form.password.value == form.confirmPassword.value)?true:false;
	if (!boolReturn) {
		alert(strError);
		form.confirmPassword.value = "";
		form.confirmPassword.focus();
	}
	return boolReturn;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: isEmail()
function isEmail(strIn) { 
	reA = new RegExp(/\./g);
	reB = new RegExp(/@/g);
	return (reA.test(strIn) && reB.test(strIn) && strIn.length > 5 && strIn.indexOf(" ") == -1)?true:false;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: isNameSafe()
function isNameSafe(strIn) { 
	re = new RegExp(/[\\\^\$\*\+\?~`!@#%&()-=|{}\[\]\s"';:<>,]/g);
	return (re.test(strIn))?false:true;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: isNumeric(num)
function isNumeric(num) {
	return (!isNaN(num))?true:false;
}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: misc string methods 
function lTrim(strIn) { 
	return strIn.replace(/^\s*/, ""); 
}

function rTrim(strIn) { 
	return strIn.replace(/\s*$/, ""); 
}

function trim(strIn) { 
	return lTrim(rTrim(strIn)); 
}
// ------------------------------------------------------------------



function tellFriend(URL) {
	window.open(URL,'','width=400,height=400,scrollbars=yes,resizeable=yes');
}

/*
CHANGE LOG:
	date author
		description

*/

// ------------------------------------------------------------------
// start:mouseover script
function msover(img,ref)
	{
			document.images[img].src = ref;
	}

function msout(img,ref)
	{
			document.images[img].src = ref;
	}


xx = new Image();
xx.src="images/find_button_on.gif";
// ------------------------------------------------------------------

