function doShowHide(fSpn) {
	if (fSpn.style.display == "none") {
		fSpn.style.display = "inline";
	} else {
		fSpn.style.display = "none";
	}
}
function changeText(idName) {
	if (idName.innerText == 'Show Page Tracking') {
		idName.innerText = 'Hide Page Tracking';
	} else {
		idName.innerText = 'Show Page Tracking';
	}
}

/*****************************************************************************************************************/
/* CHANGES THE CLASS NAME OF A SPECIFIC ID
 * Parameters:
 *		classpassed		name of the class file
 *		idname			id of the TD going to be changes
 */
/******************************************************************************************************************/
function changeClass(classpassed, idname) {
	document.getElementById(idname).className=classpassed;
}
/******************************************************************************************************************/
/* CHANGES THE WINDOW LOCATION (URL)
 * Parameters:
 *		goToPage		Page to redirect visitor to
 */
/******************************************************************************************************************/ 
function changePage(goToPage) {
	window.location = goToPage;
}
/******************************************************************************************************************/
/* ADD A NEW ERROR THE ERROR ARRAY LIST
 *	Paramenters:
 *		e2Add	The error name
 */
/******************************************************************************************************************/
function addErr(e2add){
	nextIndex = aryErrors.length;
	aryErrors[nextIndex] = e2add;
}
/******************************************************************************************************************/
/* DISPLAY AN ALERT TO THE USER IF THERE ARE ANY ERRORS
 *	Paramenters:
 *		none
 */
/******************************************************************************************************************/
function hasErrors(){
	if(aryErrors.length < 1) {
		return false;
	} else {
		errString = "This form contains the following error(s):\n\n";
		for(i = 0; i < aryErrors.length; i++) {
			errString = errString + "- " + aryErrors[i] + "\n";
		}
		alert(errString);
		return true;
	}
}

function hasSpecChar(fld) {
	arySpecChars = "<>%*#";
	for(i = 0; i < fld.length; i++) {
		for(j = 0; j < arySpecChars.length; j++) {
			if(fld.indexOf(arySpecChars.charAt(j)) != -1) {
				return true;
				break;
			}
		}
	}
	return false;
}

function isEmail(eml) {
	// make sure search function is available
	if(eml.search) {
		if (eml.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}

/******************************************************************************************************************/
/* CONVERTS A STRING TO A SPECIFIC DISPLAY OUTPUT
 *	Paramenters:
 *		theField	what input field this applies to	
 *		mask		how to display the string
 *		domestic	
 *		type		is this alpha or numeric
 */
/******************************************************************************************************************/
function applyMask(theField, mask, domestic, type) {
	var mi;
	var si = 0;
	var returnString = "";
	if (type != "alphamask") {
		var string = stripNonNumeric(theField.value);
	} else {
		var string = theField.value;
	}
	for (mi = 0; mi < mask.length && si < string.length; mi++) 	{
		var mc = mask.charAt(mi)
		var sc = string.charAt(si)
		if (mc != "#") {
			returnString += mc;
		} else {
			returnString += sc;
			si+=1 
		}
	}
	theField.value = returnString
}


function LaunchExternalWin(fUrl,fWidth,fHeight,fParams,fName){
	if(fWidth == "") {
		fWidth = 600;
	}
	if(fHeight == "") {
		fHeight = 400;
	}
	if(fParams == '') {
		fParams = ',scrollbars=1';
	}
	if(fName == "") {
		fName = "winLoad" + Math.round(Math.random()*1000);
	}
	
	fWinL = (screen.width - fWidth) / 2;
	fWinT = (screen.height - fHeight) / 2;
	fParams += ",top="+fWinT+",left="+fWinL;
	
	window.open(fUrl, fName, 'width='+fWidth+',height='+fHeight+fParams);
}
