// ------------------------------------------------------------------
// start: get generic browser type
browser = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) <= 4)?"NN":"DEFAULT";
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// start: select the appropriate stylesheet
if (!path) var path = ""; // if the path variable was set before the call to this (.js) file

if (browser == "NN"){
	document.write("<LINK REL=stylesheet HREF=\""+path+"css/nn4.css\" TYPE=\"text/css\">");
	NN = true;
	}
else{
	document.write("<LINK REL=stylesheet HREF=\""+path+"css/default.css\" TYPE=\"text/css\">");
	NN = false;
	}
// ------------------------------------------------------------------


// ------------------------------------------------------------------
// 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');
}

// ------------------------------------------------------------------
// start: open wizard dialog
function openWizard(wizardURL,w,h) {
	window.open(wizardURL,'','width='+w+',height='+h+',scrollbars=yes,resizeable=yes,status=yes');
}

// ------------------------------------------------------------------


function menubar( tableCellRef, hoverFlag ) {
	if ( hoverFlag ) {
		tableCellRef.style.backgroundImage = 'url(' + path + '"images/menubar_on.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#ff6600';
		}
	} else {
		tableCellRef.style.backgroundImage = 'url(' + path + '"images/menubar_off.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#333';
		}
	}
}

function menubarClick( tableCellRef, url ) {
	menubar( tableCellRef, 0 );
	location.href = url;
}