window.defaultStatus = document.title; // set the status bar same as page's title

//var arrIOInvalidChars = new Array(\","<", ">", "|", "\", "/", "?", "*", ":");
var arrIOInvalidChars = new Array(escape('"'), "<", ">", "|", "/", escape("\\"), "?", "*", ":");
var sCharsLN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var sCharsLNS = sCharsLN + ' ';

function removeInvalidChars(sValidChars, str) { var sNew = '';
	for (var i = 0; i < str.length; i++) { if (sValidChars.indexOf(str.substring(i, (i+1))) > -1) { sNew += str.substring(i, (i+1)); } } return sNew; }

function hasIOInvalidChars(s) { var flag = false;
	for (var i = 0; i < arrIOInvalidChars.length; i++) { if (s.indexOf(unescape(arrIOInvalidChars[i])) > -1) { flag = true; } } return flag; }
	
function void1() { }
function refreshPage() { location.href = location.href.split('#')[0] + ' '; }

function addOption(oSel, text, value) {
	var oOption = document.createElement("OPTION");
	oSel.options.add(oOption);
	if (!text) { text = value; }
	if (!value) { value = text; }
	oOption.innerText = text;
	oOption.value = value;
	oSel.selectedIndex = -1;
	oOption.selected = 'selected';
}

function getAllOptions(oSel, separator) { var s = '';
	for (var i = 0; i < oSel.options.length; i++) { if (i > 0) { s += separator; } s += oSel.options[i].value; } return s; }

function showWaitMessage() { cs("spanMainContents").display = 'none'; cs("divWaitMessage").display = "block"; }
function hideWaitMessage() {  }

function cancelEnterKey(enterScript) { if (event.keyCode == 13) { 
	event.cancelBubble = true;
	event.returnValue = false;
	if (enterScript) {setTimeout(enterScript, 1);}
	if (typeof(doThisOnEnter) == 'function') { doThisOnEnter();}  
} }
//function doThisOnEnter() { }

function parseBoolean(value) { if (value.toLowerCase() == 'true' || value == '-1' || value == '1' || value.toLowerCase() == 'yes') { return true; } else { return false; } }

function c(id) { return document.all[id]; } // control
function cv(id) { // control value
	if (typeof(c(id)) != "undefined") {
		if (c(id).type == 'select-one') { if (c(id).selectedIndex != -1) { return c(id).options[c(id).selectedIndex].value; } else { return ""; } }
		else { return c(id).value; }
	} else { alert("Error: control with id \"" + id + "\" does not exist on this page."); }
} 
function cs(id) { return c(id).style; } // control style
function ct(id) { // control text or drop-down-list selected text
	if (typeof(c(id)) != "undefined") {
		if (c(id).type == 'select-one') { if (c(id).selectedIndex != -1) { return c(id).options[c(id).selectedIndex].innerText; } else { return ""; } }
		else { return c(id).value; }
	} else { alert("Error: control with id \"" + id + "\" does not exist on this page."); }
} 

function printPreview(title, style, html, onlyHtml) { 
	var p = window.open(); 
	if (!onlyHtml) { p.document.write("<html><head><title>" + title + "</title><style>body {text-align:center;}" + style + "</style></head><body>"); }
	p.document.write(html);
	if (!onlyHtml) { p.document.write("</body></html>"); }
	p.focus(); } // open a new browser window and show print contents

function showInfoWindow(title, html, width, height) {
	var pre1 = "<html><head><title>" + title + "</title></head><body>";
	var p = window.open("", "", "WIDTH=" + width + ",HEIGHT=" + height + ",resizable=no,menubar=no,toolbar=no,status=no,scrollbars=no", false);
	p.document.write(pre1);
	p.document.write(html);
	p.document.write("</body></html>");
	p.focus(); }

function showMsgBox(url, title, mWidth, mHeight) {
	var sFeatures = 'scroll:no; status:no; resizable:no; help:no; edge:raised;';

	if (!mWidth) { mWidth = '1'; } // temporary set to 1 pixel, if not specified
	if (!mHeight) {mHeight = '1'; } // -- || --
	
	if (mWidth) { sFeatures += ' dialogWidth:' + mWidth + 'px;' }
	if (mHeight) { sFeatures += ' dialogHeight:' + mHeight + 'px;' }
	
	var result = window.showModalDialog('/msgbox.aspx?title=' + escape(title) + '&src=' + escape(url), '', sFeatures);
	return result; }
function showTFDialog(url, title, trueAction, mWidth, mHeight) { var dres = showMsgBox(url, title, mWidth, mHeight); if (dres && trueAction) { eval(trueAction); } } // True/False Dialog
function showTFDialogRefresh(url, title, mWidth, mHeight) { showTFDialog(url, title, "location.href = location.href.split('#')[0];", mWidth, mHeight); }

function imgBtnToggle(img, action) { if (img) { if (action == 'down') { img.className = 'imgBtnDown'; } else if (action == 'up') { img.className = 'imgBtnUp'; } } }
function preloadImg(arr1) {
	var arr2 = new Array();
	for (var i = 0; i < arr1.length; i++) { arr2[i] = new Image(); arr2[i].src = arr1[i]; } }

function replace(str,searchFor,replaceWith) {
	var i = str.indexOf(searchFor);
	while ( i!=-1 ) {
		var j = i+searchFor.length;
		str = str.substring(0,i)+replaceWith+str.substring(j,str.length);
		i = str.indexOf(searchFor,i+replaceWith.length);
	} return str; }

function FormsTweak(state) { //Used to hide every listbox (or combo) element on a page.	for(var f = 0; f <= (document.forms.length - 1); f++)		for(var e = 0; e <= (document.forms[f].elements.length - 1); e++)			if(document.forms[f].elements[e].type=="select-one")				document.forms[f].elements[e].style.visibility = state;}
