window.onload = function() { // grab all select boxes arrSelectBoxes = document.getElementsByTagName("SELECT"); // home page png if (navigator.appName.indexOf("Microsoft") != -1 && document.getElementById("home_column_right")) { arrBestBuys = document.getElementById("home_column_right").getElementsByTagName("DIV"); for (i = 0; i < arrBestBuys.length; i++) { if (arrBestBuys[i].className == "starburst") { arrBestBuys[i].getElementsByTagName("img")[0].style.display = "none"; } } } // free floating global menu freeFloatingArr = document.getElementById("pe_nav") ? document.getElementById("pe_nav").getElementsByTagName("DIV") : []; freeFloatingMenu(); // tool tips var toolTipsArr = { "myReorderLists":"A summary of items you have ordered in the past so you can reorder in one easy step","myWishList":"Add items to your Wish List and use it to place orders at any time in one easy step","mySavedItemsList":"Add items to your Saved Items List and use it to place orders at any time in one easy step","catalogItemNumber":"A Quick Order Form that makes ordering items from the catalog fast and easy","whatIsThis":"Select variants and add the items to your Wish List for a later purchase.","exclusive":"Look for the symbol to identify PetEdge Exclusive products" }; for (var tip in toolTipsArr) { objId = document.getElementById(tip); if (objId) { objId.onmouseover = function(evtObj) { var newEventObject = new BrowserUtil.getEvent(evtObj); toolTip('create',toolTipsArr[this.id],newEventObject); } objId.onmouseout = function() { toolTip('destroy','',''); } } } var toolTipsImgArr = document.getElementsByTagName("A"); // prevents the collection of objects unless on the product detail page with product options if(document.getElementById("pd_product_opt")) { var priceDetailPopup = getElementsByClass('pe-price-info'); } for (var i = 0; i < toolTipsImgArr.length; i++) { if (toolTipsImgArr[i].className == "peBrandFlag") { toolTipsImgArr[i].onmouseover = function(evtObj) { var newEventObject = new BrowserUtil.getEvent(evtObj); toolTip('create',"Exclusive PetEdge Brands Are Your Best Value.",newEventObject); } toolTipsImgArr[i].onmouseout = function(evtObj) { toolTip('destroy','',''); } } else if(toolTipsImgArr[i].className == "pePrice") { var boxId = toolTipsImgArr[i].id; var theLinkId; var indxNum; toolTipsImgArr[i].onmouseover = function(evtObj) { // used for determining the position of the anchor tag var newEventObject = new BrowserUtil.getEvent(evtObj); theLinkId = this.id.split("_"); indxNum = theLinkId[1]; priceDetailPopup[indxNum].style.top = (((indxNum * 26) - priceDetailPopup[indxNum].offsetHeight) + 30) + "px"; priceDetailPopup[indxNum].style.left = (((priceDetailPopup[indxNum].offsetWidth/2) * -1) - 50) + "px"; priceDetailPopup[indxNum].style.visibility = "visible"; } toolTipsImgArr[i].onmouseout = function(evtObj, num) { theLinkId = this.id.split("_"); indxNum = theLinkId[1]; priceDetailPopup[indxNum].style.visibility = "hidden"; } } } /* These methods support setting focus on a control when the page is loaded. To focus on a field, use: beginSetFocus("myFormName", myFieldName"); */ if (focusedFields.length > 0 && document.forms[focusedFields[0][0]]) { if (document.forms[focusedFields[0][0]][focusedFields[0][1]]){ document.forms[focusedFields[0][0]][focusedFields[0][1]].focus(); } else { var fieldRef = eval("document.forms[\"" + focusedFields[0][0] + "\"]."+focusedFields[0][1]); if (fieldRef) { fieldRef.focus(); } } } /* end form focus control */ } var focusedFields = new Array(); function beginSetFocus(formName, fieldName) { focusedFields.push(new Array(formName, fieldName)); } /* BrowserUtil.getEvent is the event object with cross-browser properties assigned. */ var BrowserUtil = {}; BrowserUtil.getEvent = function(evtObj) { var navAgent = navigator.userAgent.toLowerCase(); var evt = null; if ((window.event != null) && (navAgent.indexOf("mac") == -1)) { // Internet Explorer evt = window.event; // * IE 6 standards-compliant mode document.documentElement reassignment if (document.documentElement && document.documentElement.clientWidth) { evt.getViewportAxisX = document.documentElement.clientWidth; evt.getViewportAxisY = document.documentElement.clientHeight; } else if (document.body) { evt.getViewportAxisX = document.body.clientWidth; evt.getViewportAxisY = document.body.clientHeight; } evt.getViewportOffsetX = document.documentElement.scrollLeft; evt.getViewportOffsetY = document.documentElement.scrollTop; evt.getPageCoordX = evt.clientX + document.documentElement.scrollLeft; evt.getPageCoordY = evt.clientY + document.documentElement.scrollTop; evt.getRelatedTarget = evt.toElement ? evt.toElement : evt.fromElement; } else if (evtObj != null) { // EOMB evt = evtObj; evt.getViewportAxisX = self.innerWidth; evt.getViewportAxisY = self.innerHeight; evt.getViewportOffsetX = self.pageXOffset; evt.getViewportOffsetY = self.pageYOffset; evt.getPageCoordX = evt.pageX; evt.getPageCoordY = evt.pageY; evt.getRelatedTarget = evt.relatedTarget; evt.getTarget = evt.target; } return evt; } // visit URL through onclick function goToUrl(aUrl) { location.href = aUrl; } // global dropdown menus function freeFloatingMenu() { for (i = 0; i < freeFloatingArr.length; i++) { if (freeFloatingArr[i].className == "ffm_drop_wrapper") { freeFloatingArr[i].onmouseover = function() { if (typeof hideMenuTimeout != "undefined") { window.clearTimeout(hideMenuTimeout); menuHide.objRef = prevMenu; if (prevMenu != this.getElementsByTagName("li")[0]) { menuHide(); } } menuShow.objRef = this.getElementsByTagName("li")[0]; showMenuTimeout = window.setTimeout("menuShow()",500); } freeFloatingArr[i].onmouseout = function() { if (typeof showMenuTimeout != "undefined") { window.clearTimeout(showMenuTimeout); } menuHide.objRef = this.getElementsByTagName("li")[0]; hideMenuTimeout = window.setTimeout("menuHide()",1000); prevMenu = this.getElementsByTagName("li")[0]; } } } } var menuShow = function() { menuShow.objRef.style.visibility = "visible"; switchOnOffElements(arrSelectBoxes,"select","off"); } var menuHide = function() { menuHide.objRef.style.visibility = "hidden"; switchOnOffElements(arrSelectBoxes,"select","on"); } // function for getting elements by class function getElementsByClass(searchClass,node,tag) { // this array will hold the nodes that have the desired class var classElements = []; // if we did not pass the node parameter, assume document if (node == null) {node = document;} // if we did not pass the tag parameter, grab every node if (tag == null) {tag = '*';} // gather all the element nodes to look through; by default is everything in document var els = node.getElementsByTagName(tag); // to improve loop performance, determine the length ahead of time var elsLen = els.length; // establish the pattern to search for within className var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); // look through all the class properties to see if there is a match // the j variable is the counter variable that increments each time a // match is found and becomes the next item in classElements for (var i = 0, j = 0; i < elsLen; i++) { if (pattern.test(els[i].className)) { classElements[j] = els[i]; j++; } } // send back the array of elements to whatever variable called this function return classElements; } function switchOnOffElements(elArray,elType,elStatus) { if (elStatus == "off") { for (i = 0; i < elArray.length; i++) { eval("document.getElementsByTagName('" + elType + "')[" + i + "].style.visibility = 'hidden'"); } } else { for (i = 0; i < elArray.length; i++) { eval("document.getElementsByTagName('" + elType + "')[" + i + "].style.visibility = 'visible'"); } } } // tool tip creator (accessed from window.onload event above) var toolTip = function(elemState,elemMsg,newEventObject) { if (elemState == "create") { elemDiv = document.createElement("div"); elemDiv.setAttribute("id", "toolTip"); elemDiv.className = "tool_tip"; elemDivInner = document.createElement("div"); elemDiv.appendChild(elemDivInner); elemDivInner.className = "tool_tip_inner"; elemTxt = document.createTextNode(elemMsg); elemDivInner.innerHTML = elemMsg; //elemDivInner.appendChild(elemTxt); elemDivArrow = document.createElement("div"); elemDivArrow.className = "tool_tip_arrow"; elemDiv.appendChild(elemDivArrow); document.body.appendChild(elemDiv); objId = document.getElementById("toolTip"); objId.style.top = (newEventObject.getPageCoordY - objId.offsetHeight - 10) + "px"; objId.style.left = (newEventObject.getPageCoordX - objId.offsetWidth + 20) + "px"; objId.style.visibility = "visible"; } else { if (document.getElementById("toolTip")) { elemDiv = document.getElementById("toolTip"); document.body.removeChild(elemDiv); } } } function productDetailsTabs(objId) { var tabArr = new Array("safety","description1","shipping","specifications", "instructions", "testimonials", "sizing", "associates"); var imgPath = "/assets/images/catalog/product_details/" for (i = 0; i < tabArr.length; i++) { if (document.getElementById(tabArr[i])) { document.getElementById("tab_" + tabArr[i]).src = imgPath + "tab_" + tabArr[i] + "_off.gif"; document.getElementById(tabArr[i]).style.display = "none"; } } document.getElementById("tab_" + objId).src = imgPath + "tab_" + objId + "_on.gif"; document.getElementById(objId).style.display = "block"; } function viewHideProductGrid(objId,imgId) { if (document.getElementById(imgId).src.indexOf("btn_view_options_on") != -1) { document.getElementById(imgId).src = '/assets/images/catalog/product_details/btn_view_options.gif'; document.getElementById(objId).style.display = "none"; } else { document.getElementById(imgId).src = '/assets/images/catalog/product_details/btn_view_options_on.gif'; document.getElementById(objId).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; } /* * 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,scrollbar". Note that the order of the feature is not required. * Also it's case insensitive. Therefore, "scrollbar,toolbar" is identical to "Toolbar,ScrollBar". * * 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. */ function openWindow(address, width, height,features) { /* Find out what features need to be enable * */ if(features) features = features.toLowerCase(); else features = ""; 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(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; } } features = "toolbar=" + toolbar + ","; features += "menubar=" + menubar + ","; features += "location=" + location + ","; features += "directories=" + directories + ","; features += "status=" + status + ","; features += "scrollbars=" + scrollbars + ","; features += "resizable=" + resizable; var newWindow = window.open(address, 'Popup_Window', 'width=' + width + ',height=' + height + ',"' + features + '"'); newWindow.focus(); } 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 setAddTo(addToType) { document.productForm.addTo.value = addToType; } // 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 called by updateCountry javascript */ function arrayContains(arr, value) { var result = false; for (var i = 0; i < arr.length; i++) { if (arr[i] == value) { result = true; break; } } return result; } /* This function is called on pages contain address form, e.g., user registration, user address book * checkout billing/shipping address forms. It will automatically populate country name when state * province value is filled in the form. */ function updateCountry(state, country) { var state = state.options[state.selectedIndex].value; if (state != "") { var CanadaProvinces = ["AB", "BC", "MB", "NB", "NF", "NT", "NS", "NU", "ON", "PEI", "QC", "SK", "YT"]; var countryCode = ""; if (state == "FN") countryCode = "1072"; else if (arrayContains(CanadaProvinces, state)) countryCode = "0001"; else countryCode = "0000"; var countries = country.options; var countryIndex = 0; for (var i = 0; i < countries.length; i++) { if (countries[i].value == countryCode) { countryIndex = i; break; } } country.selectedIndex = countryIndex; } } /* * This function is called on certain pages where some functions need to be executed after loading the page */ function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } }