// ######################### Form Validation Functions #############################
// Validates any form to determine if required fields are empty
// This function checks for a hidden input field that has the required field name ending with '_required'
// located within the form. If found, false is returned and the message alert box displays the value of the
// hidden field as an error message.
// For Example: Required Input Field:
// Required hidden field with error message value:
function isValidRequired(myForm) {
var isValid=true;
var msg = "";
for (var j=0; j<(myForm.elements.length); j++) {
var indx = myForm.elements[j].name.indexOf('_required');
if (indx > 0) {
var fieldname=myForm.elements[j].name.substring(0,indx);
if ((myForm.elements[fieldname].type == 'text') || (myForm.elements[fieldname].type == 'textarea')) {
if (myForm.elements[fieldname].value.length == 0) {
if (msg == "") {
msg = myForm.elements[j].value;
} else {
msg = msg + '\n\n' + myForm.elements[j].value;
}
myForm.elements[fieldname].focus();
}
} else if (myForm.elements[fieldname].type == 'checkbox') {
if (isValidCheckBox(myForm.elements[fieldname]) == false) {
if (msg == "") {
msg = myForm.elements[j].value;
} else {
msg = msg + '\n\n' + myForm.elements[j].value;
}
}
myForm.elements[fieldname].focus();
} else if (myForm.elements[fieldname].type == 'radio') {
if (isValidRadioButton (myForm.elements[fieldname]) == false) {
if (msg == "") {
msg = myForm.elements[j].value;
} else {
msg = msg + '\n\n' + myForm.elements[j].value;
}
}
myForm.elements[fieldname].focus();
} else if (myForm.elements[fieldname].type == 'select') {
if (isValidSelect (myForm.elements[fieldname]) == false) {
if (msg == "") {
msg = myForm.elements[j].value;
} else {
msg = msg + '\n\n' + myForm.elements[j].value;
}
}
myForm.elements[fieldname].focus();
}
}
}
if (msg != "") {
alert(msg);
isValid = false;
}
return isValid;
}
// Checks whether a required checkbox has been checked
function isValidCheckBox(checkBoxName) {
var isValid = true;
if(checkBoxName.checked == false) {
isValid = false;
}
return isValid;
}
// Checks whether a required radio group button has been selected
function isValidRadioButton(radioGroup) {
var isValid = false;
for (var i=0; i < radioGroup.length; i++) {
if (radioGroup[i].checked) {
isValid = true;
}
}
return isValid;
}
// Checks whether a required select box has been selected
function isValidSelect(selectBox) {
var isValid = true;
if(selectBox.value == null || selectBox.value.length == 0) {
isValid = false;
}
return isValid;
}
// Validates an email address for proper form
function isValidEmail(s) {
var Count;
var s2;
var isValid=true;
// empty or blank email
if (s.value == "") isValid=false;
// email with whitespace
if (s.indexOf(' ') != -1) isValid=false;
// email without @
if (s.indexOf('@') == -1) isValid=false;
// email with @ as the 1st char
if (s.indexOf('@') == 0) isValid=false;
// email with @ as the last char
if ((s.indexOf('@')+1) == s.length) isValid=false;
// email without .
if (s.indexOf('.') == -1) isValid=false;
// email with . as the 1st char
if (s.indexOf('.') == 0) isValid=false;
// email with . as the last char
if ((s.indexOf('.')+1) == s.length) isValid=false;
// Now look for the first . after the first @
// s2 = string after the first @
s2=s.substring(s.indexOf('@')+1,s.length);
// email without a dot after the first @
if (s2.indexOf('.') == -1) isValid=false;
// email dot right after the first @
if (s2.indexOf('.') == 0) isValid=false;
return isValid;
}
function isPhoneNumber(s) {
if (s == "") {
return (true);
} else {
if (regExpSupported()) {
// var re = /^1?s*-?s*(?s*[0-9]{3}s*)?s*-?s*[0-9]{3}s*-?s*[0-9]{4}$/;
return re.test(s);
} else {
for (var i = 0; i < s.length; i++) {
if (((s.charAt(i) < '0') || (s.charAt(i) > '9')) && (s.charAt(i) != '-') && (s.charAt(i) != '(') && (s.charAt(i) != ')')) return (false);
}
return (true);
}
}
}
function isZipCode(s) {
if (EmptyString(s)) {
return (false);
} else {
if (isValidUSZipCode(s) || isValidCanadianPostalCode(s)) {
return (true);
} else {
return (false);
}
}
}
function isValidUSZipCode(s) {
if ((s.length != 5) && (s.length != 10)) {
return (false);
} else {
if (regExpSupported()) {
var re = /^[0-9]{5}(-[0-9]{4})?$/;
return re.test(s);
} else {
for (var i = 0; i < s.length; i++) {
if ((s.charAt(i) < '0') || (s.charAt(i) > '9')) {
if (s.charAt(i) == '-') {
if (i != 5)
return (false);
} else {
return (false);
}
}
}
return (true);
}
}
}
function isValidCanadianPostalCode(s) {
if ((s.length != 6) && (s.length != 7)) {
return (false);
} else {
if (regExpSupported()) {
var re = /^[a-z|A-Z]{1}\d{1}[a-z|A-Z]{1}\-?\d{1}[a-z|A-Z]{1}\d{1}$/;
return re.test(s);
} else {
for (var i = 0; i < s.length; i++) {
if ((s.charAt(i) < '0') || (s.charAt(i) > '9')) {
if (s.charAt(i) == '-') {
if (i != 3)
return (false);
} else {
if ((i != 0) && (i != 2)) {
if (s.charAt(3) == '-') {
if ((i != 5) || ((s.charAt(i) < 'A') || ((s.charAt(i) > 'Z') && ((s.charAt(i) < 'a') || (s.charAt(i) > 'z')))))
return (false);
} else {
if ((i != 4) || ((s.charAt(i) < 'A') || ((s.charAt(i) > 'Z') && ((s.charAt(i) < 'a') || (s.charAt(i) > 'z')))))
return (false);
}
} else {
if ((s.charAt(i) < 'A') || ((s.charAt(i) > 'Z') && ((s.charAt(i) < 'a') || (s.charAt(i) > 'z'))))
return (false);
}
}
} else {
if (s.charAt(3) == '-') {
if ((i != 1) && (i != 4) && (i != 6))
return (false);
} else {
if ((i != 1) && (i != 3) && (i != 5))
return (false);
}
}
}
return (true);
}
}
}
function noNumbers(s) {
if (s == "") {
return (true);
} else {
if (regExpSupported()) {
var re = /^[a-zA-Z]+[a-zA-Z\s]*$/;
//var re = /D/;
return re.test(s);
} else {
for (var i = 0; i < s.length; i++) {
if ((s.charAt(i) >= '0') && (s.charAt(i) <= '9')) return (false);
}
return (true);
}
}
}
// Uses isValidRequired function to check for required fields and isValidEmail function to check
// for valid email address format and returns result in massage box. Parameters passed are the form and
// the field name for email address fields
function validateNewsletterForm(myForm, emailFieldReq) {
var isValid = true;
if (isValidRequired(myForm) == false) {
isValid = false;
return isValid;
}
if (isValidEmail(myForm.elements[emailFieldReq].value) == false) {
alert ('Please provide a valid email address.');
myForm.elements[emailFieldReq].select();
myForm.elements[emailFieldReq].focus();
return false;
}
return isValid;
}
function clear_text(defaultValue, textField) {
if (textField.value == defaultValue) {
textField.value = "";
} else {
textField.value = defaultValue;
}
}/**
* FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
*/
if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="