
function setInset(pagecode, pageparm) {
	var sURL = pagecode;
	if (pageparm) 
		sURL += "?" + pageparm;
	document.getElementById('inset').src = sURL;
}

function textLimit(infield,limit,dochandle) {
	var result = true;
	if (infield.value.length >= limit)
		result = false;
	dochandle.onkeypress = new Function('return ' + result + ';');
	return result;
}

function textTrim(infield,limit) {
	infield.value = infield.value.substring(0,limit);
}

function trimField(source_fld) {
	var a = source_fld.value.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
}

function verifyPhone(source_fld) {
	// convert phone alphas to corresponding numbers
	re = /[abc]/gi;
	source_fld.value = source_fld.value.replace(re, "2");
	re = /[def]/gi;
	source_fld.value = source_fld.value.replace(re, "3");
	re = /[ghi]/gi;
	source_fld.value = source_fld.value.replace(re, "4");
	re = /[jkl]/gi;
	source_fld.value = source_fld.value.replace(re, "5");
	re = /[mno]/gi;
	source_fld.value = source_fld.value.replace(re, "6");
	re = /[prs]/gi;
	source_fld.value = source_fld.value.replace(re, "7");
	re = /[tuv]/gi;
	source_fld.value = source_fld.value.replace(re, "8");
	re = /[wxy]/gi;
	source_fld.value = source_fld.value.replace(re, "9");
	// get rid of other non-numerics
	re = /[^0-9]/gi;
	source_fld.value = source_fld.value.replace(re, "");
	// only verify if present
	if (!source_fld.value) {
		return true;
	}
	// append area code if required
	if (source_fld.value.length == 7) {
		source_fld.value = "908" + source_fld.value;
	}
	// drop the long distance 1
	if (source_fld.value.length == 11 && source_fld.value.substring(0,1) == "1") {
		source_fld.value = source_fld.value.substring(1,12);
	}
	// if not a full number, alert and set focus
	if (source_fld.value.length != 10) {
		alert("Improper phone number format, please correct.");
		source_fld.focus();
	}
	else {
		source_fld.value = source_fld.value.substring(0,3) + "-" + source_fld.value.substring(3,6) + "-" + source_fld.value.substring(6,10);
	}
}

function wDelete(TARGET) {
	if (window.confirm("Are you sure you want to delete this entry?")) {
		window.location.href = TARGET;
	}
}

function navShow2(target, navurl) {
	var http = null;
	var nav = navurl
	
	if(window.XMLHttpRequest)
		http = new XMLHttpRequest();
	else if (window.ActiveXObject)
		http = new ActiveXObject('Microsoft.XMLHTTP');
  
	http.onreadystatechange = function()
	{
			if (nav == '')
				return;
			else
				window.location.href = nav;
	};

	http.open('POST', 'navtrack.php', true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	if (document.getElementById("ntb_" + target)) {
		if (document.getElementById("ntb_" + target).style.display == '') {
			document.getElementById("ntb_" + target).style.display = 'none';
			http.send('DATA=0' + target);
		}
		else {
			document.getElementById("ntb_" + target).style.display = '';
			http.send('DATA=1' + target);
		}
	}
	return true;
		
}

// function used to open the link selector window			
function openFileSelect(fileType, formName, fieldName){
	// open the selector window
	window.open('link_manager.php?reqtype=' + fileType + '&form=' + formName + '&cntrl=' + fieldName, 'FileSelect', 'status=yes,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=650,height=425');
}
