var exit=true; function showTabCom(objComDivId) { var imgPath = "http://content.onestepahead.com/assets/images/shopping/" var objComDivArr = new Array("tab-more-info","tab-files","tab-email-friend","tab-products"); for (i = 0; i < objComDivArr.length; i++) { if (document.getElementById(objComDivArr[i] + "-img")) { document.getElementById(objComDivArr[i] + "-img").src = imgPath + objComDivArr[i] + "-off.gif"; document.getElementById(objComDivArr[i]).style.display = "none"; } } document.getElementById(objComDivId + "-img").src = imgPath + objComDivId + ".gif"; document.getElementById(objComDivId).style.display = "block"; } utilityBrowserVer = parseInt(navigator.appVersion); function imgOn(imgName) { if (utilityBrowserVer >= 3) { imgOnString = eval(imgName + "_on.src"); document.images[imgName].src = imgOnString; } } function imgOff(imgName) { if (utilityBrowserVer >= 3) { imgOffString = eval(imgName + "_off.src"); document.images[imgName].src = imgOffString; } } function goToLink(address) { var linkURL = address.options[address.selectedIndex].value; window.top.location.href = linkURL; address.selectedIndex=0; } function goTo(address) { window.top.location.href = address; } // opens a url in the parent window, currently used on popups function openInParent(url) { if (window.opener && !window.opener.closed) window.opener.location.href = url; else window.open(url); window.close(); } function getUrlParameter(name) { var regexS = "[\\?&]"+name+"=([^]*)"; var regex = new RegExp( regexS ); var tmpURL = window.location.href; var results = regex.exec( tmpURL ); if( results == null ) return ""; else return results[1]; } /* * This function launches a new web browser window to a specified width, height and features. * Features string is a comma separated window's feature needed for this new window. For Instance * If a new window needs a toolbar the feature string must be "toolbar" like needs scroll bar and * and toolbar then it must be "toolbar,scrollbars". Note that the order of the feature is not required. * Also it's case insensitive. Therefore, "scrollbars,toolbar" is identical to "Toolbar,ScrollBars". * * NOTE: By default window will be shown at center of screen, if you'd like to display it at a specific coordinates * pass the left and top properties as a feature string. For instance, to display a window at 100px on X and 100px on Y * set feature string as "left=100,top=100" * * If the features string is ommitted then all the features are turned off. To turn all the features on * use the word "all" for features instead of specifying each feature. * * @address URL to open in new window * @width width of new window in pixel. Defaults to 400 pixels. * @height height of new window in pixel. Default to 350 pixels. * @features feature string to have window features enable. Such as scrollbars,toolbars,menubars etc. * @name string if new window to be named window. * @retrun opened Window Instance. */ function openWindow(address, width, height,features, name) { if(typeof(features) != 'undefined') features = features.toLowerCase(); else features = "scrollbars,resizeable"; //set default treatment to scrollbars and resizeable if no features are passed if(typeof(name) == 'undefined') name = "_blank"; var toolbar = (features == "all" ? 1 : 0); var menubar = (features == "all" ? 1 : 0); var location = (features == "all" ? 1 : 0); var directories = (features == "all" ? 1 : 0); var status = (features == "all" ? 1 : 0); var scrollbars = (features == "all" ? 1 : 0); var resizable = (features == "all" ? 1 : 0); if(typeof(width) != "number") width=500; if(typeof(height) != "number") height=600; var left = ("left=" + ((screen.width-width)/2)); var top = ("top=" + ((screen.height-height)/2)); if(features != "all") { //split features var feature = features.split(","); for(i = 0; i < feature.length; i++) { if(feature[i] == "toolbar") toolbar = 1; else if(feature[i] == "menubar") menubar = 1; else if(feature[i] == "location") location = 1; else if(feature[i] == "directories") directories = 1; else if(feature[i] == "status") status = 1; else if(feature[i] == "scrollbars") scrollbars = 1; else if(feature[i] == "resizable") resizable = 1; else if(feature[i].indexOf("left=") != -1) left = feature[i]; else if(feature[i].indexOf("top=") != -1) top = feature[i]; } } features = "toolbar=" + toolbar + ","; features += "menubar=" + menubar + ","; features += "location=" + location + ","; features += "directories=" + directories + ","; features += "status=" + status + ","; features += "scrollbars=" + scrollbars + ","; features += "resizable=" + resizable + ","; features += left + "," + top; var thisWindow = window.open(address, removeNonAlphaNumericChars(name), 'width=' + width + ',height=' + height + ',"' + features + '"'); thisWindow.focus(); return thisWindow; } /** * Function to remove all non alpha numeric character except ('_' underscore since it could be use to give predefined window names[_blabk, _top, _self,_media]) from a given string * and return the modified string. If there are errors return the given string as is */ function removeNonAlphaNumericChars(string) { if(typeof(string) != 'string') return string; var modifiedString = ""; var tempChar; for(i = 0; i < string.length; i++) { var tempChar = string.charAt(i); if((tempChar >= '0' && tempChar <= '9') || (tempChar >= 'a' && tempChar <= 'z') || (tempChar >= 'A' && tempChar <= 'Z') || (tempChar == '_') ) { modifiedString += tempChar; } } if(modifiedString != "") return modifiedString; else return string; } function confirmWindow(url, text) { if (confirm(text)) { window.go = url; window.location = url; } } function setOperation(opType,needSubmit,addressIndex) { document.addUpdateDeleteAddressForm.operation.value = opType; if(addressIndex) document.addUpdateDeleteAddressForm.selectedAddressIndex.value = addressIndex; if(needSubmit) { if(opType == "EDIT") window.location="/user/address_book.jsp?addressIndex=" + addressIndex; else document.addUpdateDeleteAddressForm.submit(); } } function setEditOperation(opType,needSubmit) { document.editAddressForm.operation.value = opType; } function setAddTo(addToType, my_form_name) { my_form = document.forms[my_form_name]; my_form.addTo.value = addToType; my_form.submit(); } // This is an example of sending product data from the server // to the client, then formatting the variants on the client-side // based on certain criteria. function cbFormatter(list, attribute, opt) { // Get the price for this variant.. If this is the primary list, get all related // variants from the group and get their prices as well so we can build a range. var pvds = list.productVariantDropdownSupport; // Get all of the product variants for this attribute var variantGroup = attribute.getVariant().getProductVariantGroup(); var groupVariants = variantGroup.getAllVariants() // Are all of the prices the same within the group? var lowGroupPrice = 999999.00; var highGroupPrice = -1.00; for (var idx = 0; idx < groupVariants.length; idx++) { lowGroupPrice = groupVariants[idx].numericPrice < lowGroupPrice ? groupVariants[idx].numericPrice : lowGroupPrice; highGroupPrice = groupVariants[idx].numericPrice > highGroupPrice ? groupVariants[idx].numericPrice : highGroupPrice; } // Are all of the prices the same within the variant? var variants = variantGroup.getVariantsMatching(attribute.name, attribute.value); var lowVariantPrice = 999999.00; var highVariantPrice = -1.00; var lowVariantDisplay = variants[0].displayPrice; var highVariantDisplay = variants[0].displayPrice; for (var idx = 0; idx < variants.length; idx++) { // Display really needs to be done before the re-assignment... lowVariantDisplay = variants[idx].numericPrice < lowVariantPrice ? variants[idx].displayPrice : lowVariantDisplay; lowVariantPrice = variants[idx].numericPrice < lowVariantPrice ? variants[idx].numericPrice : lowVariantPrice; highVariantDisplay = variants[idx].numericPrice > highVariantPrice ? variants[idx].displayPrice : highVariantDisplay; highVariantPrice = variants[idx].numericPrice > highVariantPrice ? variants[idx].numericPrice : highVariantPrice; } if (lowGroupPrice != highGroupPrice) { // Primary list should display a range if (pvds.isPrimary) if (lowVariantPrice != highVariantPrice) opt.text = opt.text + " " + lowVariantDisplay + " - " + highVariantDisplay; else opt.text = opt.text + " " + attribute.getVariant().displayPrice; else // Secondary lists should show exact price opt.text = opt.text + " " + attribute.getVariant().displayPrice; } return opt; } /* This function is called when a subject is changed so that actual subject text can be * stored in to a hidden subject field. Since value of the subject list is a keyword define * in the command configuration file to identify it's email address. */ function setSubject(thisRef) { var formRef = document.forms["contactUsForm"]; //set subject value formRef.elements["subject"].value = (thisRef.options[thisRef.selectedIndex]).text; } /* * This function is used to get DHTML object reference. */ function getElement(id) { if(document.getElementById) { return document.getElementById(id); } else if(document.layers) { return document.layers[id]; } else if(document.all) { return document.all[id]; } else return null; } var defaultSearchValue = "Product, Keyword or #"; function clearDefaultText(field, defaultText) { if (field.value == defaultSearchValue) field.value = ""; } function repopulateDefaultText(field, defaultText) { if (trim(field.value) == "") field.value = defaultSearchValue; else field.value = trim(field.value); } function trim(s) { var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/); return (m == null) ? "" : m[1]; } function search(field) { var keywords = field.value; if (keywords == defaultSearchValue) keywords = ""; keywords = escape(keywords); var url = "http://www.leapsandbounds.com/?PIPELINE_SESSION_ID=fa36c9787f00000154eb057786ab7451catalog/search.jsp?N=0&Nty=1&Ntk=Def&Ntx=mode matchpartialmax&Ntt=" + keywords; location.href = url; return false; } function validateEmail(str, errorId) { var invalidEmailMessage = "Invalid email address. Please enter a valid email address."; if (!isEmail(str)) { document.getElementById(errorId).innerHTML= invalidEmailMessage; return false; } return true; } function isEmail(email) { email = trim(email); if (email.indexOf(" ") >= 0) { return false; } var index = email.indexOf("@"); if (index > 0) { var dot = email.indexOf(".", index); if ((dot > index + 1) && (email.length > dot + 1)) return true; } return false; } function trim(s) { var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/); return (m == null) ? "" : m[1]; } /* ** This function loads a popup page given a user's email address. ** The idea is to popup a dialog box that loads a predetermined page from CheetahMail ** so that the user can select which newsletters they want to receive. ** ** emailAddress: the user's email address ** returns nothing. */ function emailSignUp(emailAddress ) { var signUpURL = 'https://www.leapsandbounds.com/user/email_sign_up.jsp?PIPELINE_SESSION_ID=fa36c9787f00000154eb057786ab7451'; var signUpURLWithParams = signUpURL + '?userEmail=' + emailAddress; window.top.location.href = signUpURLWithParams; } /** * Utility method to build the breadcrumbs. */ function buildBreadCrumb(siteName, breadCrumbName1, breadCrumbURL1, breadCrumbName2, breadCrumbURL2, breadCrumbName3) { // Open the breadcrumb container. var breadCrumb = "
"; document.write(breadCrumb); } /** * Redirects the user based on the path specified while checking the context * and if the site should go into or out of SSL. */ function redirectPage(path, sendSecure) { var secureBase = "https://www.leapsandbounds.com"; var unsecureBase = "http://www.leapsandbounds.com"; var baseURL; if (sendSecure) baseURL = secureBase; else baseURL = unsecureBase; // Make sure there is exactly one '/' character between the two parts if (endsWith(baseURL, "/") && startsWith(path, "/")) { url = baseURL + path.substring(1); } else if (!endsWith(baseURL, "/") && !startsWith(path, "/")) { url = baseURL + "/" + path; } else { url = baseURL + path; } window.location = url; } /** * Tests if the string begins with the specified prefix. */ function startsWith(str, value) { if (str == null || str == "") return false; if (value == null || value == "") return false; var length = value.length; if (str.substring(0, length) == value) return true; else return false; } /** * Tests if the string ends with the specified suffix. */ function endsWith(str, value) { if (str == null || str == "") return false; if (value == null || value == "") return false; var length = (value.length); if (str.substring(str.length-length, str.length) == value) return true; else return false; } function openMe_nourl(winName,urlPath,width,height,top,left) { winName = winName; BrowserName = navigator.appName; BrowserVersion = parseFloat(navigator.appVersion); // the adjusts the window for Netscape's lack of a phantom scroll bar if (BrowserName == "Netscape"){ width -= 15; } eval(winName + '= eval(\'window.open(urlPath,"\' + winName + \'","resizable=yes,scrollbars=yes,location=no,width=\' + width + \',height=\' + height + \',top=' + top + ',left=' + left + '")\')') //flyout = window.open(urlPath,"flyout","resizable=yes,scrollbars=yes,width=645,height=410,top=5,left=225"); eval('window.' + winName + '.focus()'); // eval('window.' + winName + '.onblur = window.' + winName + '.close'); } function openMe_nourl_1(winName,urlPath,width,height,top,left) { winName = winName; BrowserName = navigator.appName; BrowserVersion = parseFloat(navigator.appVersion); // the adjusts the window for Netscape's lack of a phantom scroll bar if (BrowserName == "Netscape"){ width -= 15; } eval(winName + '= eval(\'window.open(urlPath,"\' + winName + \'","resizable=yes,titlebar=no,scrollbars=yes,location=no,width=\' + width + \',height=\' + height + \',top=' + top + ',left=' + left + '")\')') //flyout = window.open(urlPath,"flyout","resizable=yes,scrollbars=yes,width=645,height=410,top=5,left=225"); eval('window.' + winName + '.focus()'); // eval('window.' + winName + '.onblur = window.' + winName + '.close'); } /* This function replaces all instances of a value in a string with the following parms. NOTE: Special characters such as ' and / will need to be passed in as \' and \/. string = The value to be searched on. (required) match = The value to find in the string. (required) replacement = The to replace the match with. (required) */ function stringReplace(string, match, replacement) { var result = ''; var index = 0; var lastIndex = index; while (string.length > lastIndex) { index = string.indexOf(match, lastIndex); if (index == -1) { break } result += string.substring(lastIndex, index) + replacement; lastIndex = index + match.length; } result += string.substring(lastIndex, string.length); return result; } /* ** Functions to popup Bill Me Later Terms & Conditions overview window using openWindow function */ function showBMLInfoPopup(url) { var bmlInfoWnd = openWindow(url, 620 ,400,"scrollbars", "BMLInfoWnd"); } function showBMLTnCPopup(url) { var bmlTnCWnd = openWindow(url, 503 ,480,"scrollbars", "BMLTnCWnd"); } function showBMLTnCPrintPopup(url) { var bmlTnCPWnd = openWindow(url, 503 ,480,"scrollbars", "BMLTnCPWnd"); } /* ** Function to display or hide Canada duties/taxes message if Canadian Province is selected */ function selectChange(control) { var arrCanadaProvinces = new Array(); arrCanadaProvinces[0] = "AB"; //Alberta arrCanadaProvinces[1] = "BC"; //British Columbia arrCanadaProvinces[2] = "MB"; //Manitoba arrCanadaProvinces[3] = "NB"; //New Brunswick arrCanadaProvinces[4] = "NL"; //Newfoundland arrCanadaProvinces[5] = "NT"; //Northwest Territories arrCanadaProvinces[6] = "NS"; //Nova Scotia arrCanadaProvinces[7] = "NU"; //Nunavut arrCanadaProvinces[8] = "ON"; //Ontario arrCanadaProvinces[9] = "PE"; //Prince Edward Island arrCanadaProvinces[10] = "QC"; //Quebec arrCanadaProvinces[11] = "SK"; //Saskatchewan arrCanadaProvinces[12] = "YT"; //Yukon Territory var x ; var notFound = true; for ( x = 0 ; x < arrCanadaProvinces.length ; x++ ) { if ( arrCanadaProvinces[x] == control.value ) { document.getElementById("canadaMsg").style.display = "block"; notFound = false; break; } } if(notFound == true) { document.getElementById("canadaMsg").style.display = "none"; } } /* ** Function to submit a form on enter */ function submitEnter(myfield,e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { myfield.form.submit(); return false; } else return true; }