function validateForm(_1){wError=_1.getAttribute("lastError");formItems=_1.length;for(i=1;i<=formItems;i++){wElement=_1.elements[i-1];setValType="";setValType=wElement.getAttribute("valtype");if(wError!=null&&wError!=""){rsetObj=eval("_1."+wError);if(rsetObj.length>1&&rsetObj[0].value!=""){rsetObj=eval("_1."+wError+"[0]");}rsetObj.style.color="#000000";rsetObj.style.backgroundColor="#FFFFFF";}switch(setValType){case "valText":if(validateText(wElement,_1)==false){return (false);}break;case "valNumber":if(validateNumber(wElement,_1)==false){return (false);}break;case "valPrice":if(wElement.value.indexOf(".")!=-1){if(validatePrice(wElement,_1)==false){return (false);}}else{if(validateNumber(wElement,_1)==false){return (false);}}break;case "valPhone":if(validatePhone(wElement,_1)==false){return (false);}break;case "valEmail":if(validateEmail(wElement,_1)==false){return (false);}break;case "valEmail2":if(validateEmail2(wElement,_1)==false){return (false);}break;case "valSelect":if(validateSelect(wElement,_1)==false){return (false);}break;case "valChkBox":if(validateChkBox(wElement,_1)==false){return (false);}break;case "valRadio":if(validateRadio(wElement,_1)==false){return (false);}break;case "compareText":if(compareText(wElement,_1)==false){return (false);}break;}}return (true);}function validateText(_2,_3){if((_2.getAttribute("allowotherchk")&&chkOther(_2,_3)==true)||(_2.getAttribute("allowvalchk")&&chkAllowType(_2,_3)==true)||(!_2.getAttribute("allowvalchk")&&_2.getAttribute("valrequired")==1)){var _4=_2.value;var ch=_4.substring(0,1);while(ch==" "){_4=_4.substring(1,_4.length);ch=_4.substring(0,1);}if(_4==""){alert("Please complete all the required fields before submitting");_2.style.color="#FFFFFF";_2.style.backgroundColor="#CC0000";_2.focus();_3.setAttribute("lastError",_2.name);return (false);}}}function validateNumber(_6,_7){if((_6.getAttribute("allowotherchk")&&chkOther(_6,_7)==true)||(_6.getAttribute("allowvalchk")&&chkAllowType(_6,_7)==true)||(!_6.getAttribute("allowvalchk")&&_6.getAttribute("valrequired")==1)){if(validateText(_6,_7)==false){return (false);}}var _8=/(^\d+$)/;if(_6.value!=""){if((!_8.test(_6.value)&&_6.getAttribute("allowvalchk")&&chkAllowType(_6,_7)==true)||(!_8.test(_6.value)&&!_6.getAttribute("allowvalchk"))){alert("Please input only numeric characters");_6.style.color="#FFFFFF";_6.style.backgroundColor="#CC0000";_6.focus();_7.setAttribute("lastError",_6.name);return (false);}}}function validatePrice(_9,_a){if((_9.getAttribute("allowotherchk")&&chkOther(_9,_a)==true)||(_9.getAttribute("allowvalchk")&&chkAllowType(_9,_a)==true)||(!_9.getAttribute("allowvalchk")&&_9.getAttribute("valrequired")==1)){if(validateText(_9,_a)==false){return (false);}}var _b=/(^\d+$)/;if(_9.value!=""){var _c=new Array();_c=_9.value.split(".");if(_c.length!=2||((!_b.test(_c[0])||!_b.test(_c[1])||_c[1].length>2)&&_9.getAttribute("allowvalchk")&&chkAllowType(_9,_a)==true)||((!_b.test(_c[0])||!_b.test(_c[1])||_c[1].length>2)&&!_9.getAttribute("allowvalchk"))){alert("Please input a valid price");_9.style.color="#FFFFFF";_9.style.backgroundColor="#CC0000";_9.focus();_a.setAttribute("lastError",_9.name);return (false);}}}function validatePhone(_d,_e){numFull=eval("_e."+_d.getAttribute("hiddenname")+"3.value");numArea=eval("_e."+_d.getAttribute("hiddenname")+"2.value");numInt=eval("_e."+_d.getAttribute("hiddenname")+"1.value");if(numFull==""&&numArea.length<=3&&numInt.length<=3){_d.value="";}else{_d.value=numInt+""+numArea+""+numFull;if(_d.value.length<7){alert("Please input a valid contact number");wCnum=eval("_e."+_d.getAttribute("hiddenname")+"3");wCnum.style.color="#FFFFFF";wCnum.style.backgroundColor="#CC0000";wCnum.focus();_e.setAttribute("lastError",wCnum.name);return (false);}else{_d.value=numInt+" "+numArea+" "+numFull;}}}function validateEmail(_f,_10){if((_f.getAttribute("allowvalchk")&&chkAllowType(_f,_10)==true)||(!_f.getAttribute("allowvalchk")&&_f.getAttribute("valrequired")==1)){if(validateText(_f,_10)==false){return (false);}}if((_f.value&&_f.getAttribute("allowvalchk")&&chkAllowType(_f,_10)==true)||(_f.value&&!_f.getAttribute("allowvalchk"))){var _11=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(!_11.test(_f.value)){alert("Please input a valid email address");_f.style.color="#FFFFFF";_f.style.backgroundColor="#CC0000";_f.focus();_10.setAttribute("lastError",_f.name);return (false);}}}function validateEmail2(_12,_13){if((_12.getAttribute("allowvalchk")&&chkAllowType(_12,_13)==true)||(!_12.getAttribute("allowvalchk")&&_12.getAttribute("valrequired")==1)){if(validateText(_12,_13)==false){return (false);}}if((_12.value&&_12.getAttribute("allowvalchk")&&chkAllowType(_12,_13)==true)||(_12.value&&!_12.getAttribute("allowvalchk"))){var _14=/^(([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})([,;]\W?(?!$))?)+$/;if(!_14.test(_12.value)){alert("Please input valid email addresses and ensure each address is separated by either a comma or semi-colon");_12.style.color="#FFFFFF";_12.style.backgroundColor="#CC0000";_12.focus();_13.setAttribute("lastError",_12.name);return (false);}}}function validateSelect(_15,_16){if((_15.getAttribute("allowvalchk")&&chkAllowType(_15,_16)==true)||(!_15.getAttribute("allowvalchk")&&_15.getAttribute("valrequired")==1)){if((_15.getAttribute("nselect")==1&&_15.selectedIndex==-1)||(!_15.multiple&&_15.options[_15.selectedIndex].value=="")||(_15.multiple&&_15.options.length==0)){alert("Please complete all the required fields before submitting");_15.style.color="#FFFFFF";_15.style.backgroundColor="#CC0000";_15.focus();_16.setAttribute("lastError",_15.name);return (false);}}}function validateChkBox(_17,_18){chkVal=0;if((_17.getAttribute("allowvalchk")&&chkAllowType(_17,_18)==true)||!_17.getAttribute("allowvalchk")){if(_17.getAttribute("chkboxlength")!=0){for(j=1;j<=_17.getAttribute("chkboxlength");j++){if(eval("_18."+_17.getAttribute("chkboxname")+j)){if(eval("_18."+_17.getAttribute("chkboxname")+j+".checked")){chkVal=1;}}else{if(eval("_18."+_17.getAttribute("chkboxname")+"_"+j)){if(eval("_18."+_17.getAttribute("chkboxname")+"_"+j+".checked")){chkVal=1;}}}}}else{if(eval("_18."+_17.getAttribute("chkboxname")+".checked")){chkVal=1;}}}else{chkVal=1;}if(chkVal==0){alert("Please complete all the required fields before submitting");_17.style.color="#FFFFFF";_17.style.backgroundColor="#CC0000";_17.focus();_18.setAttribute("lastError",_17.name);return (false);}}function validateRadio(_19,_1a){chkVal=0;if((_19.getAttribute("allowvalchk")&&chkAllowType(_19,_1a)==true)||!_19.getAttribute("allowvalchk")){for(j=0;j<_19.getAttribute("radiolength");j++){if(eval("_1a."+_19.getAttribute("radioname")+"["+j+"].checked")){chkVal=1;}}}else{chkVal=1;}if(chkVal==0){alert("Please complete all the required fields before submitting");_19.style.color="#FFFFFF";_19.style.backgroundColor="#CC0000";_19.focus();_1a.setAttribute("lastError",_19.name);return (false);}}function compareText(_1b,_1c){if((_1b.getAttribute("allowvalchk")&&chkAllowType(_1b,_1c)==true)||(!_1b.getAttribute("allowvalchk")&&_1b.getAttribute("valrequired")==1)){if(validateText(_1b,_1c)==false){return (false);}}if((_1b.value&&_1b.getAttribute("allowvalchk")&&chkAllowType(_1b,_1c)==true)||(_1b.value&&!_1b.getAttribute("allowvalchk"))){if(_1b.value!=eval("_1c."+_1b.getAttribute("compareto")+".value")){alert("Please make sure both the "+_1b.getAttribute("errortext")+" and Confirm "+_1b.getAttribute("errortext")+" fields match before submitting");_1b.style.color="#FFFFFF";_1b.style.backgroundColor="#CC0000";_1b.focus();_1c.setAttribute("lastError",_1b.name);return (false);}}}function chkAllowType(_1d,_1e){wType=eval("_1c."+_1d.getAttribute("allowvalchk"));if(wType.length>1){if(wType[0].checked){return (true);}}else{if(!wType.checked&&wType.getAttribute("valsetting")=="off"){return (true);}else{if(wType.checked&&wType.getAttribute("valsetting")=="on"){return (true);}}}return (false);}function chkOther(_1f,_20){wType=eval("_20."+_1f.getAttribute("allowotherchk"));if(wType.length>1){if(wType[_1f.getAttribute("otherfieldpos")].checked){return (true);}}else{if(!wType.checked&&wType.getAttribute("valsetting")=="off"){return (true);}else{if(wType.checked&&wType.getAttribute("valsetting")=="on"){return (true);}}}return (false);}function checkSearchWords(id){var _22=document.getElementById(id);srchwrds=_22.value.replace(/^\s+|\s+$/g,"");var _23=new Array();if(srchwrds.length<=2){alert("Search keywords must be 3 characters long or more");return false;}return true;}
