sfHover = function() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("mainCats")) return false;

	var sfEls = document.getElementById("mainCats").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



function openGenericPopup(theURL, theWidth, theHeight){
	win = window.open(theURL,"winPopUpGeneric" , 'menubar=no,status=no,resizable=yes,scrollbars=1,width='+theWidth+',height='+theHeight);
}


function clearField(theForm, theField, theDefault) {
		if (document [theForm] [theField].value == theDefault){
			document [theForm] [theField].value = "";
		}
}


function formImageOn(imgName, formImg) {
	if (cached==1) {
	lineOn = eval("the_" + imgName + "_on.src");
	formImg.src= lineOn;
	}
}

function formImageOff(imgName, formImg) {
	if (cached==1) {
	lineOff = eval("the_" + imgName + "_off.src");
	formImg.src= lineOff;
	}
}

function checkForm(theForm, theFields, theTitles){
	var hasError = 0;
	var missingFields = "";

	highlightColor = "#ffffff";
	defaultColor = "#D9D9D9";
	thisForm = theForm;

	var arrFields = theFields;
	var arrTitles = theTitles;

	for(i=0; i<arrFields.length; i++){
		theField = arrFields[i];
		theTitle = arrTitles[i];

		if(isNaN(thisForm[theField].length) || ! isNaN(thisForm[theField].selectedIndex)){
			if(thisForm[theField].value == ""){
				missingFields += theTitle + "\n";
				thisForm[theField].style.background = highlightColor;
				if(hasError == 0){thisForm[theField].focus()}
				hasError = 1;
			}else{
				thisForm[theField].style.background = defaultColor;
			}
		}else{
			var hasNodeSelected = 0;
			for(j=0; j<thisForm[theField].length; j++){
				if(thisForm[theField][j].checked){
					hasNodeSelected++;
				}
			}
			if(hasNodeSelected == 0){
				hasError = 1;
				missingFields += theTitle + "\n";
			}
		}
		
		if(theTitle == 'Email'){
			if(thisForm[theField].value.indexOf("@") == -1){
				hasError = 2;
			}
		}

	}

	if(hasError > 0 && hasError < 2){
		alert('Please complete the following fields:\n' + missingFields);
		return false;
	}else if(hasError == 2){
		alert('Please enter a valid email address.\n');
		return false;
	}else{
		return true;
	}

}
