// JavaScript Document //browser detection var userBrowser,userPlat; if (navigator.userAgent.indexOf("MSIE") >= 0) userBrowser = "ie"; if (navigator.userAgent.indexOf("Firefox") >= 0 ) userBrowser = "ff"; if (navigator.userAgent.indexOf("Safari") >= 0) userBrowser = "sf"; userPlat = (navigator.userAgent.indexOf("Mac") >= 0) ? "mac" : "pc"; function validQnty(qntTxtField) { if(/[0-9]/.test(qntTxtField.value)) qntTxtField.value=qntTxtField.value.replace(/[a-z]/gi, ""); var val = qntTxtField.value; if (val != null) { val = qntTxtField.value.replace(/^\s+|\s+$/g,""); if (isNaN(val)){ val = '1'; }else{ if (val < 1){ val = '1'; } } } if ( val == null || val == ''){ val = '1'; } qntTxtField.value = val; } //to find x,y of elements (object needs to be passed as variable) function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do{ curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); } return [curleft,curtop]; } function jsPaus(ms){ var date = new Date(); var curDate = null; do{ curDate = new Date(); } while(curDate - date < ms); } //show the persistent cart function showPersistCart(){ var gotoPage = "/include/ajax/top_nav_persist.jsp"; divTagId="topNavDiv"; var callBack = "function callBackFunc(t) {if (t != null) {showBag(); } }"; sendAjaxRequest(false, gotoPage, document.forms['add_to_cart','dont_add_to_cart'], divTagId, false, null, true, callBack); } //add item to persistent cart function addToCart() { document.getElementById("shoppingBagBttn").src = imgShoppingBagOpenPath; var gotoPage = "/include/ajax/top_nav_add_to_cart.jsp"; divTagIds=new Array(4); divTagIds[0]="searchbox"; divTagIds[1]="topNavDiv"; divTagIds[2]="product_details_form"; divTagIds[3]="inventory_error_0"; var callBack = "function callBackFunc(t) { if (t[1] != null) { showBag(); parent.scrollTo(0,0); setTimeout('closeBag()', 5000);getProductDetail();}else{location.reload(true);} }"; sendAjaxRequest(false, gotoPage, document.forms['add_to_cart'], divTagIds, true, "add_to_cart", true, callBack); } //remove an item from the persistent cart function removeFromCart(url, noItems, prod) { var gotoPage = url; var items = noItems; divTagIds=new Array(2); divTagIds[0]="searchbox"; divTagIds[1]="topNavDiv"; if (items > 1) { var callBack = "function callBackFunc(t) {if (t[1] != null) {showBag(); } }"; } else { var callBack = "function callBackFunc(t) {if (t[1] != null) {document.getElementById('persistShoppingBag').style.display = 'block'; isBagOpen(); } }"; } //omniture var s=s_gi(s_account); s.linkTrackVars='channel,prop1,prop11,products,events'; s.linkTrackEvents='scRemove'; s.channel='Shopping Bag:Remove'; s.events='scRemove'; s.prop1=s.channel; s.prop11=s.channel; //s.prop12=s.channel; s.products = ";"+prod; s.tl(this,'o','Remove from Shopping Bag'); sendAjaxRequest(false, gotoPage, document.forms['persistent_shopping_cart'], divTagIds, true, "remove_from_cart", true, callBack); } //check is persistent cart is open/close & do appropriate actions function isBagOpen() { var shoppingBag = document.getElementById("persistShoppingBag"); if(shoppingBag && shoppingBag.style.display == 'block') { shoppingBag.style.display = 'none'; document.getElementById("shoppingBagBttn").src = imgShoppingBagClosePath; var iframe = document.getElementById("if_persistShoppingBag"); if(iframe != null) { iframe.style.display = 'none'; iframe.style.width = 0; iframe.style.height = 0; iframe.style.left = 0; iframe.style.top = 0; } } else { showPersistCart(); document.getElementById("shoppingBagBttn").src = imgShoppingBagOpenPath; } } //close the bag if it is open function closeBag() { var shoppingBag = document.getElementById("persistShoppingBag"); if(shoppingBag && shoppingBag.style.display == 'block') { shoppingBag.style.display = 'none'; document.getElementById("shoppingBagBttn").src = imgShoppingBagClosePath; var iframe = document.getElementById("if_persistShoppingBag"); if(iframe != null) { iframe.style.display = 'none'; iframe.style.width = 0; iframe.style.height = 0; iframe.style.left = 0; iframe.style.top = 0; } } } //open & adjust persistent cart position function showBag() { var shoppingBag = document.getElementById("persistShoppingBag"); if(shoppingBag && shoppingBag.style.display == 'none') { document.getElementById("shoppingBagBttn").src = imgShoppingBagOpenPath; var shpnBagX = findPos(document.getElementById("shoppingBagBttn")); ajustX = (userBrowser == "ie" ? 1 : 0); ajustY = (userBrowser == "ie" ? -2 : 12); shoppingBag.style.display = 'block'; shoppingBag.style.left = shpnBagX[0] - ajustX; shoppingBag.style.top = shpnBagX[1] + ajustY; document.getElementById("shoppingBagBttn").src = imgShoppingBagOpenPath; var iframe = document.getElementById("if_persistShoppingBag"); if(iframe != null) { var layer = document.getElementById("persistShoppingBag"); iframe.style.zIndex = layer.style.zIndex - 1; iframe.style.display = 'block'; iframe.style.width = layer.offsetWidth; iframe.style.height = layer.offsetHeight; iframe.style.left = layer.offsetLeft; iframe.style.top = layer.offsetTop; } } } function openPopupGeneral(p_url,p_width,p_height,p_scroll,p_resize){ var p_arguments=""; if(p_width!=null)p_arguments+="width="+p_width+","; if(p_height!=null)p_arguments+="height="+p_height+","; if(p_scroll!=null)p_arguments+="scrollbars="+p_scroll+","; if(p_resize!=null)p_arguments+="resizable="+p_resize; window.open(p_url,'JCpopUp',p_arguments); } function togglePromoDetails(obj, toggle){ var newY = findPos(obj); var descDiv = document.getElementById('promoDetailsDiv'); if (toggle == 'open') { descDiv.style.display='block'; var divHeight = descDiv.offsetHeight; ajustY = (userBrowser == "ie" ? -5 : 10); descDiv.style.left = newY[0]-105; descDiv.style.top = newY[1]-ajustY; } if (toggle == 'close') { descDiv.style.display='none'; } }