/*
 * contactForm.js
 * (C)2007 U.S. Bank
 */

function displayCompanyBox(selectElement) {
	//alert("selectedElement is : " + selectElement.selectedIndex);
	var selectValue = selectElement.options[selectElement.selectedIndex].value;
	if ( selectValue == "ISO" || selectValue == "Financial Institution") {
		toggleElementVisibility("companyNameSection", true);
	} else {
		toggleElementVisibility("companyNameSection", false);
	}
}

function toggleElementVisibility(elementName, visible) {
	//FIXME netscape layers don't work right
	if ( document.layers ) { //is ns4 or below
		if ( ! visible && document.layers[elementName].display == "block" ) {
			document.layers[elementName].display = "none";
		} else if ( visible ) {
			document.layers[elementName].display = "block";
		}
	} else {
		var nza = null;
		if ( document.all ) { //is ie4 or 5 (or 6 beta)
			nza = eval("document.all." + elementName)
		} else if ( document.getElementById && ! document.all ) {
			nza = document.getElementById(elementName);
		}
		if ( ! visible && nza.style.display == "block" ) {
			nza.style.display = "none";
		} else if ( visible ) {
			nza.style.display = "block";
		}

	}
}

function validField(element, type, length) {
	//check length first
	if ( element.value.length > length || element.value.length < 0 ) return false;
	
	if ( type == "text" ) {
		return true;
	} else if ( type == "phone" ) {
		return true;
	} else if ( type == "numeric" ) {
		return true;
	}
	return false;
}
