function getObj(id) {
	var obj = document.getElementById(id);
	if (obj) {
		return obj;
	}
}

function showProofType(isChecked) {
	if (isChecked) {
		getObj("proofTypeWrap").style.visibility = "visible";
	} else {
		getObj("proofTypeWrap").style.visibility = "hidden";
	}
}

function openFileWindow() {
	var look="width=600,height=600,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0";
		url = "files.php";
		fileWin = window.open(url,"fw",look);
		fileWin.focus();
}

function requiredFields( formName ) {
//this function requires a div on the page with the id of errorDiv
//each form element that is required gets a required attribute that should be set to required
//each form element should have a label with a for attribute with a value that is the same as the form element id that it applies to
//Included using shellError display module if errorDiv is not found

//Call on the form tag with - onsubmit="return requiredFields(this.name);"


	labels = new Array();
	//var errorDivObj = document.getElementById("errorDiv");
	var errorText = "";
	//errorDivObj.innerHTML = "";
	
	var labelList = document.getElementsByTagName("label");
	for(var i=0; i<labelList.length; i++) {
		labels[labelList[i].htmlFor] = labelList[i];
	}
	
	for(var i=0; i < document.forms[formName].elements.length; i++) {
		var thisElement = document.forms[formName].elements[i];
		
		if (labels[thisElement.id]!= undefined) {
			labels[thisElement.id].style.color = "black";
			thisElement.style.backgroundColor="#e5e5e5";
			thisElement.style.borderColor="black";
			//errorDivObj.style.display="";			
		}		
		
		if ( ( thisElement.getAttribute("required") != null ) && (thisElement.value.length == 0 || thisElement.value == "-SELECT-" || thisElement.value == "" || thisElement.value == "SHOW MORE PRODUCTS...") ) {
			if(labels[thisElement.id] == undefined) {
				errorText += "Element ID: "+thisElement.id+" is required to save.<br />";
				//errorDivObj.style.display="";
			} else {
				errorText += "<strong>"+labels[thisElement.id].innerHTML+"</strong> is required to save.<br />";
				labels[thisElement.id].style.color = "red";
				thisElement.style.backgroundColor="#FFCCCC";
				thisElement.style.borderColor="red";
				//errorDivObj.style.display="";
			}
		}
	}
	var errorDivObj = document.getElementById("errorDiv");
	if(errorText == "") { 		// no errors
		if(errorDivObj) { 		// errorDiv exists on the page
			errorDivObj.style.display = "none"; 	// I changed this from "" to "none"
		}
		return true;
	} else { 					// required field was missing
		if(!errorDivObj) { 		// errorDiv does not exist on page
			errorShow(errorText,false);	// use the shellError module
		} else { 				// errorDiv exists on the page
			errorDivObj.style.display = ""; 	// show the div
			errorDivObj.innerHTML = errorText; 	// populate the div with the error message
		}
		return false;
	}
}