function popupWin(myPage, myWindowName, w, h, Scroll, Resize) { 
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	WinProps = "height=" + h + ", width=" + w + ", top=" + wint + ", left=" + winl + ", scrollbars=" + Scroll + ", resizable=" + Resize + ", toolbar=no, location=no, directories=no, status=no, menubar=no, poppedWin=yes";
	var win = window.open(myPage, myWindowName, WinProps);
	win.focus();
}

function firstFocus() {
	var bFound = false;
	for (f=0; f < document.forms.length; f++) {
		for(i=0; i < document.forms[f].length; i++) {
			if (document.forms[f][i].type != "hidden") {
				if (document.forms[f][i].disabled != true) {
					document.forms[f][i].focus();
					var bFound = true;
				}
			}
			if (bFound == true) break;
		}
		if (bFound == true) break;
	}
}

function compareOptionText(a,b) { 
	return a.text!=b.text ? a.text<b.text ? -1 : 1 : 0; 
} 

function sortOptions(list) { 
	var items = list.options.length; 
	var tmpArray = new Array(items); 
	for ( i=0; i<items; i++ )
		tmpArray[i] = new 
	Option(list.options[i].text,list.options[i].value); 
	tmpArray.sort(compareOptionText); 
	for ( i=0; i<items; i++ ) 
		list.options[i] = new Option(tmpArray[i].text,tmpArray[i].value); 
} 

function showHide(obj) {
	if (document.getElementById(obj).className == "layerHide") {
		document.getElementById(obj).className = "layerShow";		
	}
	else {
		document.getElementById(obj).className = "layerHide";
	}
}

function resetddlColors(list) {
	for (var i=0; i < list.options.length; i++) {
		if (i % 2) list.options[i].style.backgroundColor = "E1E1E1";
		else list.options[i].style.backgroundColor = "F4F4F4";
	}
}

function disableButton() {
	for (j = 0; j < document.forms.length; j++) {
		var TForm = document.forms[j];
		for (i = 0; i < TForm.length; i++) {
			var tempObj = TForm.elements[i];
			if (tempObj.type.toLowerCase() == "submit" || tempObj.type.toLowerCase() == "reset" || tempObj.type.toLowerCase() == "button" ||tempObj.name.toLowerCase() == "cmdsubmit" || tempObj.name.toLowerCase() == "cmdreset") tempObj.disabled = true;
		}
	}
}

function openTable(f) {
	if(!f.ddlTable.value) {
		alert("Please select a table.");
		f.ddlTable.focus();
		return false;
	}
	else {
		popupWin("/admin/" + f.ddlTable.options[f.ddlTable.selectedIndex].value, "tableWindow", 700, 400, "yes", "yes");
	}
}
