/** * Copyright 2017. Demandforce, Inc. The copyright for all material * provided on this site ("Site") is held by Demandforce, Inc. Except as * stated herein, none of the material may be copied, reproduced, * distributed, republished, downloaded, displayed, posted or transmitted * in any form or by any means, including, but not limited to, * electronic, mechanical, photocopying, recording, or otherwise, without * the prior written permission of Demandforce, Inc. and all materials * are provided as-is without expressed or implied warranty. Permission * is granted to use, display, copy, distribute and download the * materials on this Site for provided you do not modify the materials * and that you retain all copyright and other proprietary notices * contained in the materials. You also may not, without Demandforce, * Inc. permission, "mirror" any material contained on this Site on any * other server. This permission terminates automatically if you breach * any of these terms or conditions. Upon termination, you will * immediately destroy any downloaded and printed materials. Any * unauthorized use of any material contained on this Site may violate * copyright laws, trademark laws, the laws of privacy and publicity, and * communications regulations and statutes. */ //=0) { var year_arr2 = v_year1.split('-'); var yr1 = year_arr2[0]; var yr2 = year_arr2[1]; var y1 = parseInt(yr1,10) + 1900; var y2 = parseInt(yr2,10) + 1900; if(y1 < 1970) y1 += 100; if(y2 < 1970) y2 += 100; if((y1 <= year && year<=y2)) { find = true; break; } }else{ var v_year = parseInt(v_year1,10) + 1900; if(v_year < 1970) v_year += 100; if(v_year == year) { find = true; break; } } } return find; } /* Common functions */ function d3cp_validateZipCode(inputZip) { if(inputZip.trim() == '') { return false; } return true; } function d3cp_validateEmail(emailAddress) { var regExpObj = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})$/; if(regExpObj.exec(emailAddress) == null) { return false; //Invalid } else { return true; //Valid } } function d3cp_validatePhone(phoneNum) { //US phone var regUSphone = /^((\+?1[-. ]?)?\(?\d{3}\)?)?[-. ]?\d{3}[-. ]?\d{4}$/; if(regUSphone.exec(phoneNum) != null) { return true; // Valid } else { //UK phone var regUK1 = /^((\+?44[-. ]?)?\(?\d{3}\)?)?[-. ]?\d{4}[-. ]?\d{4}$/; var regUK2 = /^((\+?44[-. ]?)?\(?\d{4}\)?)?[-. ]?\d{3}[-. ]?\d{4}$/; var regUK3 = /^((\+?44[-. ]?)?\(?\d{5}\)?)?[-. ]?\d{5,6}$/; var regUK4 = /^((\+?44[-. ]?)?\(?\d{6}\)?)?[-. ]?\d{4,5}$/; if(regUK1.exec(phoneNum) != null) { return true; } else if(regUK2.exec(phoneNum) != null) { return true; } else if(regUK3.exec(phoneNum) != null) { return true; } else if(regUK4.exec(phoneNum) != null) { return true; } return false; // Invalid } } //dateStr should be format as 'mm/dd/yyyy' function d3cp_validateDate(dateStr) { dateStr = dateStr.trim(); var regExpObj = /^((0?[1-9])|(1[0|1|2]))\/((0?[1-9])|([1|2][0-9])|(3[0|1]))\/(2\d{3})$/; if(regExpObj.exec(dateStr) == null) { return false; // Invalid } if(isNaN(Date.parse(dateStr))) { return false; // Invalid } var trueDate = new Date(dateStr); var dateSplit = dateStr.split("/"); var inputMonth = parseInt(dateSplit[0], 10) - 1; var inputDate = parseInt(dateSplit[1], 10); var inputYear = parseInt(dateSplit[2], 10); if(trueDate.getMonth() != inputMonth || trueDate.getDate() != inputDate || trueDate.getFullYear() != inputYear) { return false; // Invalid, since the input date is not exist } return true; } // timeStr should be format as 'hh:mm am' function d3cp_validateTime(timeStr) { var regExpObj = /^(0?[0-9]|1[0-9]|2[0-4]):(0?[0-9]|[0-5][0-9])(\s(am|pm|AM|PM))?$/; if(regExpObj.exec(timeStr) == null) { return false; // Invalid } else { return true; // Valid } } // dateStr should be format as 'mm/dd/yyyy', and timeStr should be format as 'hh:mm am' function d3cp_validateDateTime(dateStr, timeStr) { var fDateTime = ''; dateStr = dateStr.trim(); timeStr = timeStr.trim(); if(dateStr != '' && !validateDate(dateStr)) { return false; } if(timeStr != '' && !validateTime(timeStr)) { return false; } if(dateStr != '' && timeStr != '') fDateTime = dateStr + " " + timeStr; if(fDateTime != '' && isNaN(Date.parse(fDateTime)) ) { return false; } return true; } function d3cp_validateDateSimple(date, month) { if(month <= 0 || month > 12) { return false; }else if(date <= 0 || date > 31) { return false; } else if( (month == 4 || month == 6 || month == 9 || month == 11) && date > 30) { return false; } else if(month == 2 && date > 29) { return false; } return true; } function d3cp_countWords(text) { var tmp = text.replace(/\r\n|\n\r|\n/g, " "); var tmpArr = tmp.split(" "); var arr = new Array(); for(i = 0; i < tmpArr.length; i++) { if(tmpArr[i] > '') { arr.push(tmpArr[i]); } } return arr.length; } /* END Common functions */ String.prototype.replaceAll = function(s1,s2){ return this.replace(new RegExp(s1,"gm"),s2); } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } //IE 7.0 and previous if ( !window.Element ) { Element = function(){} var __createElement = document.createElement; document.createElement = function(tagName) { var element = __createElement(tagName); for(var key in Element.prototype) element[key] = Element.prototype[key]; return element; } } function d3cpAppendChildTextNode(obj, txt_str){ if(obj.appendChild) { if(txt_str && txt_str.trim() != '') { var tmp = txt_str; tmp = tmp.replace(/\r\n|\n\r|\n/g, "[br]"); tmp = tmp.replace('
', '[br]'); tmp = tmp.replace('
', '[br]'); tmp = tmp.replace('
', '[br]'); tmp = tmp.replace('
', '[br]'); var txts = tmp.split('[br]'); for(var i = 0; i < txts.length; i++) { if(i != 0) obj.appendChild(document.createElement("br")); obj.appendChild(document.createTextNode(txts[i])); } } } } /* Compat IE and FireFox */ //IE 10 and previous version -- createElement document.d3cpCreateElementByName = function(tag, name, type, checked) { var el; var ie_version = /MSIE/;//IE var ie_version_7 = /MSIE 7/; //IE7 var trident_7 = new RegExp("Trident/3.0"); //IE7 Compatibility View var ie_version_8 = /MSIE 8/; //IE8 var trident_8 = new RegExp("Trident/4.0"); //IE8 Compatibility View var ie_version_9 = /MSIE 9/; //IE9 var trident_9 = new RegExp("Trident/5.0"); //IE9 Compatibility View var ie_version_10 = /MSIE 10/; //IE10 var trident_10 = new RegExp("Trident/6.0"); //IE10 Compatibility View if (ie_version.exec(navigator.appVersion) != null && ie_version_7.exec(navigator.appVersion) == null && trident_7.exec(navigator.appVersion) == null && ie_version_8.exec(navigator.appVersion) == null && trident_8.exec(navigator.appVersion) == null && ie_version_9.exec(navigator.appVersion) == null && trident_9.exec(navigator.appVersion) == null && ie_version_10.exec(navigator.appVersion) == null && trident_10.exec(navigator.appVersion) == null) //IE 10 and before { var str = "<" + tag + " name=\"" + name + "\" "; if(type) { str += " type = \"" + type + "\" "; } if(checked) { str += " checked = \"" + checked + "\" "; } str += " />"; el = document.createElement(str); }else{ try{ var str = "<" + tag + " name=\"" + name + "\" />"; el = document.createElement(str); if(type) { el.setAttribute("type",type); } if(checked) { el.setAttribute("checked",checked); } }catch(error) { el = document.createElement(tag); el.setAttribute("name", name); if(type) { el.setAttribute("type",type); } if(checked) { el.setAttribute("checked",checked); } } } return el; } function d3cp_formatIntToTimeDisplay(timeKey) { var timeShow = ""; if(timeKey == -1) timeShow = "CLOSED"; else { var m = timeKey%60; var h = (timeKey-m)/60; var a = " AM"; /*begin modified by Rebecca for BP-6323*/ if (h == 0 || h == 24){ h = 12; a = " AM"; }else if (h == 12){ a = " PM"; }else if (h > 12 && h < 24) { h = h - 12; a = " PM"; } /*end modified by Rebecca for BP-6323*/ if(m <= 9) timeShow = h + ":" + "0"+m; else timeShow = h + ":" + m; timeShow = timeShow + a; } return timeShow; } function d3cp_formatIntToTimeValue(timeKey) { var timeValue = ""; if(timeKey == -1) timeValue = "CLOSED"; else { var m = timeKey%60; var h = (timeKey-m)/60; if(m <= 9) timeValue = h + ":" + "0"+m; else timeValue = h + ":" + m; } return timeValue; } /* END Compat IE and FireFox */ /* * ------ * END D3CP functions and parameters - http://www.demandforce.com * ------ */ //]]> d3cp_exid='brakemax-12'; //"); } else { d3cp_reviews_loadUrl = d3cp_serverURL + "/1.0/js/review/reviews.content.jsp?"+d3cp_queryString; document.write(""); } //]]>