var compatabilityChecked = false; var localStorageAvailable = false; var cookiesAvailable = false; var compatable = false; function validateEmailAddress( emailAddress ) { var yepThisIsLong = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; return yepThisIsLong.test( emailAddress); } function removeBadEmailChars(str){ var newString = ""; for(var i = 0;i -1)){ newString += str.charAt( i ); } } return newString; } function checkCompatability(){ compatabilityChecked = true; compatable = false; localStorageAvailable = Modernizr.localstorage; var cookieTest = "sbzcheck" + new Date().getTime(); setCookie("sbzcheck", cookieTest); if (getCookie("sbzcheck") == cookieTest){ cookiesAvailable = true; } else { cookiesAvailable = false; } if (localStorageAvailable || cookiesAvailable) compatable = true; return compatable; } function getData(c_name){ if (!compatabilityChecked) checkCompatability(); if (localStorageAvailable){ return localStorage[c_name]; } else if (cookiesAvailable){ return getCookie(c_name); } } function getDataWithNullCheck(c_name){ if (!compatabilityChecked) checkCompatability(); if (localStorageAvailable){ if (localStorage.getItem(c_name) === null) { return {}; } else { return localStorage[c_name]; } } else if (cookiesAvailable){ return getCookie(c_name); } } function setData(c_name,value,exdays){ if (!compatabilityChecked) checkCompatability(); if (localStorageAvailable){ localStorage[c_name] = value; } else if (cookiesAvailable){ setCookie(c_name, value, exdays); } } function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i -1)){ newString += str.charAt( i ); } } return newString; } function numbersonly(myfield, e, dec){ var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==32) ) return true; // numbers else if ((("0123456789").indexOf(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")){ myfield.form.elements[dec].focus(); return false; } else return false; } function allowedcharsonly(myfield, e, dec){ var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==32) ) return true; // numbers else if ((("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@+-.!_(),").indexOf(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")){ myfield.form.elements[dec].focus(); return false; } else { $("#invalidCharacter").show(); return false; } } function isError( tag, xml ) { if( $(xml).attr( "status" ) == "failure" ) { return true; } if ($(xml).find(tag).attr("status") == "failure") return true; return false; } function convertFrom24(time){ // time will be a string. // find index of . and split the string at that point. var splitTime = time.split(":"); var hours = parseFloat(splitTime[0]); var ampm = "am"; if (hours > 11){ hours = hours - 12; if (hours == 0) hours = 12; ampm = "pm"; } return hours + ":" + splitTime[1] + ampm; } function convertFrom24TwoLines(time){ var splitTime = time.split(":"); var hours = parseFloat(splitTime[0]); var ampm = "am"; if (hours > 11){ hours = hours - 12; if (hours == 0) hours = 12; ampm = "pm"; } return hours + ":" + splitTime[1] + "
" + ampm; } function durationLabel(val){ var num = parseFloat(val); var hr = Math.floor(num); var min = num%1; if (min > 0){ min = Math.floor(min * 60); } if (min < 10) min = "0" + min; return hr + ":" + min + " hr"; } function priceLabel(val){ var num = parseFloat(val); var res = num.toFixed(2); return "$" + res; } function numbersonly(myfield, e, dec) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==32) ) return true; // numbers else if ((("0123456789").indexOf(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")) { myfield.form.elements[dec].focus(); return false; } else return false; }