function clearFields(){document.getElementById("address").value="";document.getElementById("city").value="";document.getElementById("zipcode").value="";}function bindtextFieldsWithFormSubmit(){document.getElementById("address").onkeypress=submitForm;document.getElementById("city").onkeypress=submitForm;document.getElementById("zipcode").onkeypress=submitForm;}function isNumberKey(c){var d=(c.which)?c.which:event.keyCode;if(d>31&&(d<48||d>57)){return false;}return true;}String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");};function fnToValidateCheck(){var j=(document.getElementById("address").value).trim();var n=(document.getElementById("city").value).trim();var k=(document.getElementById("zipcode").value).trim();j=new String(j.value);n=new String(n.value);$(".error-msg").remove();var l=$("#city"),h=$("#address"),m=$("#zipcode");changeMode(l,"normal");changeMode(m,"normal");l.val(l.val().trim());h.val(h.val().trim());if(l.val()!=""){var o=/^[0-9]+$/;if(l.val().match(o)){$(".java_script_errors").append('<div class="error-msg"><div class="wrap"><p>Oops. City name should contain only characters.</p></div></div>');changeMode(l,"error");location.hash="wrapperId";l.focus();return false;}}if((document.getElementById("city").value).trim()==""&&(document.getElementById("zipcode").value).trim()==""){$(".java_script_errors").append('<div class="error-msg"><div class="wrap"><p>Oops. Please enter a valid zip code or city.</p></div></div>');document.getElementById("city").value=(document.getElementById("city").value).trim();document.getElementById("address").value=(document.getElementById("address").value).trim();window.location.hash="wrapperId";document.getElementById("city").focus();changeMode(l,"error");changeMode(m,"error");return false;}if((document.getElementById("city").value).trim()==""&&(document.getElementById("zipcode").value.length!="5"||document.getElementById("zipcode").value=="00000"||!IsNumeric(document.getElementById("zipcode").value))){$(".java_script_errors").append('<div class="error-msg"><div class="wrap"><p>Oops. Please enter a valid zip code or city.</p></div></div>');document.getElementById("city").value=(document.getElementById("city").value).trim();document.getElementById("address").value=(document.getElementById("address").value).trim();window.location.hash="wrapperId";document.getElementById("zipcode").focus();changeMode(l,"error");changeMode(m,"error");return false;}else{return true;}}function fnToSearchStore(){var m=fnToValidateCheck();if(m){var h=(document.getElementById("address").value).trim();var g=(document.getElementById("city").value).trim();var j=document.getElementById("findState").value;var k=(document.getElementById("zipcode").value).trim();var l="";if(h){l=l+h+",";}if(g){l=l+g+",";}if(j){l=l+j+",";}if(k){l=l+k;}heb.maps.getCoordinatesForAddress(l,coordinatesReceived);}return false;}function coordinatesReceived(b){if(b.status==heb.maps.OK_STATUS){document.getElementById("searchLat").value=b.latitude;document.getElementById("searchLong").value=b.longitude;document.getElementById("frmSubmit").form.onsubmit="return true";document.getElementById("frmSubmit").click();}else{$(".java_script_errors").append('<div class="error-msg"><div class="wrap"><p>Oops. Please enter a valid zip code or city.</p></div></div>');changeMode($("#city"),"error");changeMode($("#zipcode"),"error");}}function addAddressForFlyweight(e){if(!e||e.Status.code!=200){document.findaStoreForm1.action="../find-a-store/find-a-store.jsp?errorMsg=Please enter a valid zip code or city.";document.getElementById("loginSuccessURL").value="../find-a-store/find-a-store.jsp?errorMsg=Please enter a valid zip code or city.";}else{place=e.Placemark[0];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);var f=place.Point.coordinates[1];var d=place.Point.coordinates[0];document.getElementById("searchLat1").value=f;document.getElementById("searchLong1").value=d;document.getElementById("cityOrZip").value="";}document.findaStoreForm1.submit();}function addAddressToMapStore(e){if(!e||e.Status.code!=200){$(".error-msg").remove();$(".java_script_errors").append('<div class="error-msg"><div class="wrap"><p>Oops. Please enter a valid zip code or city.</p></div></div>');changeMode($("#city"),"error");changeMode($("#zipcode"),"error");document.getElementById("city").value=(document.getElementById("city").value).trim();document.getElementById("findState").value.selected=document.getElementById("findState").value;document.getElementById("address").value=(document.getElementById("address").value).trim();}else{place=e.Placemark[0];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);var f=place.Point.coordinates[1];var d=place.Point.coordinates[0];document.getElementById("searchLat").value=f;document.getElementById("searchLong").value=d;document.findaStoreForm.submit();}}function validateString(g,f){var e=(f.which)?f.which:event.keyCode;if(e==8){return true;}var h=/^[a-zA-Z\s]*$/i;if(!h.test(g.value)){g.value=g.value.replace(/[^a-zA-Z\s]/g,"");}return h.test(String.fromCharCode(e));}function validateCityZip(g,f){var e=(f.which)?f.which:event.keyCode;if(e==8){return true;}var h=/^[0-9a-zA-Z\s]+/;return h.test(String.fromCharCode(e));}function IsNumeric(e){var g="0123456789";var h=true;var f;for(i=0;i<e.length&&h==true;i++){f=e.charAt(i);if(g.indexOf(f)==-1){h=false;}}return h;}function submitForm(d){var d=(d)?d:((event)?event:null);var c=(d.target)?d.target:((d.srcElement)?d.srcElement:null);if((d.keyCode==13)&&(c.type=="text")){fnToSearchStore();return false;}}function changeMode(d,c){if(d){if(c=="error"){d.addClass("error");d.siblings(".input-left-rounded-corners").addClass("error");d.siblings(".input-right-rounded-corners").addClass("error");}else{if(c=="normal"){d.removeClass("error");d.siblings(".input-left-rounded-corners").removeClass("error");d.siblings(".input-right-rounded-corners").removeClass("error");}}}}function fnSubmenuToSearchStore(e){if("undefined"!==typeof e.passThrough&&e.passThrough===true){e.passThrough=false;return true;}var d=jQuery("#cityOrZip");if(d.val()&&d.val().trim()!==""){var f=d.val().trim();heb.maps.getCoordinatesForAddress(f,function(a){if(heb.maps.OK_STATUS===a.status){jQuery("#searchLat1").val(a.latitude);jQuery("#searchLong1").val(a.longitude);e.passThrough=true;jQuery("#frmSubmit1").click();}});}return false;}
