<script language="javascript" src="/iwnewsletter/ScriptLibrary/FormControls.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
function WAtrimIt(theString,leaveLeft,leaveRight) {
if (!leaveLeft) {
while (theString.charAt(0) == " ")
theString = theString.substring(1);
}
if (!leaveRight) {
while (theString.charAt(theString.length-1) == " ")
theString = theString.substring(0,theString.length-1);
}
return theString;
}
function WAAddError(formElement,errorMsg,focusIt,stopIt) {
if (document.WAFV_Error) {
document.WAFV_Error += "\n" + errorMsg;
}
else {
document.WAFV_Error = errorMsg;
}
if (!document.WAFV_InvalidArray) {
document.WAFV_InvalidArray = new Array();
}
document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
if (focusIt && !document.WAFV_Focus) {
document.WAFV_Focus = focusIt;
}
if (stopIt == 1) {
document.WAFV_Stop = true;
}
else if (stopIt == 2) {
formElement.WAFV_Continue = true;
}
else if (stopIt == 3) {
formElement.WAFV_Stop = true;
formElement.WAFV_Continue = false;
}
}
function WAValidateRQ(formElement,errorMsg,focusIt,stopIt,t rimWhite,inputType) {
var isValid = true;
if (!document.WAFV_Stop && !formElement.WAFV_Stop) {
if (inputType == "select") {
if (formElement.selectedIndex == -1) {
isValid = false;
}
else if (!formElement.options[formElement.selectedIndex].value || formElement.options[formElement.selectedIndex].value == "") {
isValid = false;
}
}
else if (inputType == "checkbox") {
if (formElement.length) {
isValid = false;
for (var x=0; x<formElement.length ; x++) {
if (formElement[x].checked && formElement[x].value!="") {
isValid = true;
break;
}
}
}
else if (!formElement.checked)
isValid = false;
}
else if (inputType == "radio") {
isValid = false;
if (formElement.checked)
isValid = true;
}
else if (inputType == "radiogroup") {
isValid = false;
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
isValid = true;
break;
}
}
formElement = formElement[0];
}
else {
var value = formElement.value;
if (trimWhite) {
value = WAtrimIt(value);
}
if (value == "") {
isValid = false;
}
}
}
if (!isValid) {
WAAddError(formElement,errorMsg,focusIt,stopIt);
}
}
function WAAlertErrors(errorHead,errorFoot,setFocus,submitF orm) {
if (!document.WAFV_StopAlert) {
document.WAFV_StopAlert = true;
if (document.WAFV_InvalidArray) {
document.WAFV_Stop = true;
var errorMsg = document.WAFV_Error;
if (errorHead!="")
errorMsg = errorHead + "\n" + errorMsg;
if (errorFoot!="")
errorMsg += "\n" + errorFoot;
document.MM_returnValue = false;
if (document.WAFV_Error!="")
alert(errorMsg.replace(/"/g,'"'));
else if (submitForm)
submitForm.submit();
if (setFocus && document.WAFV_Focus) {
document.tempFocus = document.WAFV_Focus;
setTimeout("document.tempFocus.focus();setTimeout( 'document.WAFV_Stop = false;document.WAFV_StopAlert = false;',1)",1);
}
else {
document.WAFV_Stop = false;
document.WAFV_StopAlert = false;
}
for (var x=0; x<document.WAFV_InvalidArray.length; x++) {
document.WAFV_InvalidArray[x].WAFV_Stop = false;
}
}
else {
document.WAFV_Stop = false;
document.WAFV_StopAlert = false;
if (submitForm) {
submitForm.submit();
}
document.MM_returnValue = true;
}
document.WAFV_Focus = false;
document.WAFV_Error = false;
document.WAFV_InvalidArray = false;
}
}
//-->
</script>