function trim(str) {
return( ("" + str).replace(/^\s+/,'').replace(/\s+$/,'') );
}

function checkFields(fArray, sButton) {
var missinginfo = "";
	for (var i=0; i < fArray.length; i++) {
		if ( trim(fArray[i].value) == null || trim(fArray[i].value) == "" ) {
			missinginfo += "- " + document.getElementById(fArray[i].name).getAttribute('title') + "\n";
			fArray[i].value = "";
			fArray[i].style.backgroundColor = '#ffcccc';
		} else {
			fArray[i].style.backgroundColor = '#ffffff';
		}
	}
	
	if (missinginfo != "") {
		alert("Please complete the required fields before submitting!\n\n" + missinginfo);
		return false;
	} else {
		sButton.disabled = true;
		return true;
	}
}



function selectChange ( url, formName ) {
	var queryName = formName.name;
	var queryValue = formName.options[formName.selectedIndex].value;
		if ( queryValue == "ALL" ) {
			queryString = '?' + queryName + '=';
		}
		else if ( queryValue != "" ) {
			queryString = '?' + queryName + '=' + queryValue;
		}
	location.href =  url + queryString;
}


var startList = function() {
	if ( document.all && document.getElementById ) {
		var navRoot = document.getElementById("navlist");
		for ( var i=0; i < navRoot.childNodes.length; i++) {
			var node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover = function() {
					this.className+= " over";
				}
				node.onmouseout = function() {
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}
}


function popupWin(link,attribs) {
    var popupWin = null;
    popupWin = window.open(link,'winPopup',attribs);  
}

function popupWindows() {
    if( !document.getElementsByTagName ) {
         return;
    }
    var scrW = screen.availWidth;
    var scrH = screen.availHeight;
    var anchors = document.getElementsByTagName("a");
    for ( var i = 0; i < anchors.length; i++ ) {
         var anchor = anchors[i];
         var linkDest = anchor.getAttribute("href");
         var relIndex = anchor.getAttribute("rel");
         var relSplit = relIndex.split("|");
         var windowAttributes = "";
         if( relSplit[0] == "popup" ) {
			if (relSplit[1] > scrW) {
				var pW = scrW - 10;
			} else {
				var pW = relSplit[1];
			}
			
			if (relSplit[2] > scrH) {
				var pH = scrH - 40;
			} else {
				var pH = relSplit[2];
			}
			var scrX = (scrW - pW - 10) * .5;
			var scrY = (scrH - pH - 30) * .5;
			windowAttributes = "width=" + pW + ",height=" + pH + ",left=" + scrX + ",top=" + scrY + ",screenX=" + scrX + ",screenY=" + scrY;
			windowAttributes += ",location=" + relSplit[3] + ",resizable=" + relSplit[4] + ",scrollbars=" + relSplit[5] + ",status=1,menubar=1";
			anchor.setAttribute("href", "javascript:popupWin('" + linkDest + "','" + windowAttributes + "')");
         } else if ( relSplit[0] == "external" ) {
			anchor = anchors[i];
			linkDest = anchor.getAttribute("href");
			anchor.setAttribute("href", "javascript:popupWin('" + linkDest + "','');");
		 }
    }
}

function startMultipleOnload() {
	//startList();
	popupWindows();
}

window.onload = startMultipleOnload;