var siteBaseURL=window.location.pathname.substr(0,window.location.pathname.lastIndexOf("/")+1);$(document).ready(function(){$(".homeBannerSlideshow").cycle({fx:"scrollUp",speed:600,timeout:4e3}).show()});$.fn.fixBrokenImage=function(options){var settings={onBrokenImage:null,onSuccess:null};options=options||{};$.extend(settings,options);return this.each(function(){var $this=$(this);if(!this.complete||!$.browser.msie&&(typeof this.naturalWidth==="undefined"||this.naturalWidth===0))settings.onBrokenImage&&settings.onBrokenImage($this);else settings.onSuccess&&settings.onSuccess($this)})};function hideModalTitle(){$("div.ui-dialog-titlebar").hide()}function genericDialog(html,options){if(!options)options={modal:true,closeOnEscape:true,draggable:false,resizable:false,position:"center"};html.dialog(options).show()}function RefreshPage(loadfromserver){loadfromserver=loadfromserver===undefined?true:loadfromserver;window.location.reload(loadfromserver)}function callWCFModel(calltype,endpoint,jsondata,successmethod,asyncValue,failuremethod,datatype,contenttype){asyncValue=asyncValue===undefined?true:asyncValue;failuremethod=failuremethod===undefined?AjaxErrorHandler:failuremethod;var wcfServiceURL=siteBaseURL+endpoint;datatype=datatype===undefined?"json":datatype;contenttype=contenttype===undefined?"application/json;":contenttype;$.ajax({type:calltype,url:wcfServiceURL,data:jsondata,dataFilter:function(response){var jsonObject=JSON.parse(response);if(jsonObject.d||typeof jsonObject.d==="boolean")jsonObject=jsonObject.d;return JSON.stringify(jsonObject)},dataType:datatype,contentType:contenttype,async:asyncValue,success:successmethod,error:failuremethod})}function isEmailAddress(value){if(value.match(/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i))return true;return false}function getCookie(name){var result="",myCookie=" "+document.cookie+";",searchName=" "+name+"=",startOfCookie=myCookie.indexOf(searchName),endOfCookie;if(startOfCookie!=-1){startOfCookie+=searchName.length;endOfCookie=myCookie.indexOf(";",startOfCookie);result=unescape(myCookie.substring(startOfCookie,endOfCookie))}return result}function getCookieMultiValue(cookiename,cookiekey){var cookievalue=getCookie(cookiename);if(cookievalue==="")return "";cookievaluesep=cookievalue.split("&");for(c=0;c<cookievaluesep.length;c++){cookienamevalue=cookievaluesep[c].split("=");if(cookienamevalue.length>1){if(cookienamevalue[0]==cookiekey)return cookienamevalue[1].toString()}else return ""}return ""}function SetImageRatio(image,height){if(image.height==image.width)image.width=height;else image.width=image.width/(image.height/height);image.height=height}function SetDefaultImage(image,defaultImageSrc){image.src=defaultImageSrc;image.width=63;image.height=60}function FundRaisingAddToBag(){var qtydropdown=document.getElementById("IDqty"),sku=document.getElementById("IDsku"),destination=document.getElementById("IDdestination"),list_price=document.getElementById("IDlist_price"),sale_price=document.getElementById("IDsale_price"),name=document.getElementById("IDname"),short_name=document.getElementById("IDshort_name"),prod_url=document.getElementById("IDprod_url"),from=document.getElementById("IDfrom"),fulfilment=document.getElementById("IDfulfilment"),fulfilment_name=document.getElementById("IDfulfilment_name"),url="/shop/xt_orderform_additem.asp?";url+="qty="+qtydropdown[qtydropdown.selectedIndex].value;url+="&sku="+sku.value;url+="&destination="+escape(destination.value);url+="&list_price="+list_price.value;url+="&sale_price="+sale_price.value;url+="&name="+name.value;url+="&short_name="+short_name.value;url+="&prod_url="+escape(prod_url.value);url+="&from="+from.value;url+="&fulfilment="+fulfilment.value;url+="&fulfilment_name="+fulfilment_name.value;document.location.href=url}function ChangeLoadingMessage(choice){$("#AddedLoadingMessageText").hide();$("#CouponLoadingMessageText").hide();$("#DefaultLoadingMessageText").hide();$("#RemovingLoadingMessageText").hide();$("#SortingMessageText").hide();switch(choice){case "add":$("#AddedLoadingMessageText").show();break;case "coupon":$("#CouponLoadingMessageText").show();break;case "remove":$("#RemovingLoadingMessageText").show();break;case "sort":$("#SortingMessageText").show();break;default:$("#DefaultLoadingMessageText").show();break}}function DoClear(theText){if(theText.value=="Qty")theText.value=""}function RedirectTo(RedirectURL){top.location.href=RedirectURL}function scrollWindowToShades(){document.getElementById("shadesBookMark").focus()}function LaunchPopupWindow(url,windowName){var win_chk=null;win_chk=window.open("",windowName,"width=550,height=500,resizable,scrollbars");if(typeof win_chk!="undefined"){win_chk.location.href=url;if(typeof win_chk.opener!="undefined")win_chk.opener=self}return false}function LaunchPopupWindowWithoutReturn(url,windowName){var win_chk=null;win_chk=window.open("",windowName,"width=550,height=500,resizable,scrollbars");if(typeof win_chk!="undefined"){win_chk.location.href=url;if(typeof win_chk.opener!="undefined")win_chk.opener=self}}function LaunchPopupWindowNotifyMe(url){var win_chk=null;win_chk=window.open("","NotifyMe","width=360,height=260,resizable=no,scrollbars=no,top=170,left=220");if(typeof win_chk!="undefined"){win_chk.location.href=url;if(typeof win_chk.opener!="undefined")win_chk.opener=self}}function LaunchSmallPopupWindow(url,windowName){var win_chk=null;win_chk=window.open("",windowName,"width=360,height=260,resizable,scrollbars");if(typeof win_chk!="undefined"){win_chk.location.href=url;if(typeof win_chk.opener!="undefined")win_chk.opener=self}return false}var closeTimer,basketIsOpen=false;function ShowBasketAfterAddingToBag(){OpenBasket();closeTimer=setTimeout("CloseBasket();",6e3)}function OpenBasket(){if(parseInt($("#basketItemCountHiddenField").val())<1){HideLinksWhenNoItemsInCart();return}ToggleCartHeader(true);ToggleCartSpecialOffers(true);ToggleCartItems(true);basketIsOpen=true}function CloseBasket(){ToggleCartHeader(false);ToggleCartSpecialOffers(false);ToggleCartItems(false);basketIsOpen=false}function StopBasketCloser(){if(closeTimer)closeTimer=clearTimeout(closeTimer)}function HideLinksWhenNoItemsInCart(){$("#CheckOutLink").css("display","none");$("#CloseLink").css("display","none")}function ShoppingBasketHeaderClick(){StopBasketCloser();if(basketIsOpen)CloseBasket();else OpenBasket()}function ToggleCartHeader(openCart){if(parseInt($("#basketItemCountHiddenField").value)<1){HideLinksWhenNoItemsInCart();return}$("#CheckOutLink").css("display",openCart?"none":"inline");$("#CloseLink").css("display",openCart?"inline":"none")}function ToggleCartSpecialOffers(openCart){if(document.getElementById("showBasketSpecialOffersPanelFlag")===null)return;var specialOffersPresent=document.getElementById("showBasketSpecialOffersPanelFlag").value=="1";if(specialOffersPresent){var specialOffersPanel=$("#basketSpecialOffersPanel");(openCart&&!specialOffersPanel.is(":visible")||!openCart&&specialOffersPanel.is(":visible"))&&specialOffersPanel.slideToggle(600)}}function ToggleCartItems(openCart){var basketContentsPanel=$("#basketContentsPanel");(openCart&&!basketContentsPanel.is(":visible")||!openCart&&basketContentsPanel.is(":visible"))&&basketContentsPanel.slideToggle(600)}function mOvrProduct(productName){self.status=productName;document.body.style.cursor="hand"}function mOutProduct(){self.status="";document.body.style.cursor="default"}function mOvrXtraLink(label,text){self.status=text;label.className=swapXtraLabelClass(label.className)}function mOutXtraLink(label){self.status="";label.className=swapXtraLabelClass(label.className)}function swapXtraLabelClass(className){return className=="xtraLink"?"xtraLinkOvr":"xtraLink"}function mOvr(label){$(label).css("cursor","hand")}function mOut(label){$(label).css("cursor","default")}function ShowImg(src,width,height){$("#imagePopupImg").attr("src",src);showModal("imagePopup",width,height)}function ShowLrgrImg(src,profileNumber){ShowImg(src,"525","550");Omniture_ProductView(profileNumber)}function ShowLargerImage(imageSrc,profileNumber,sourcepage){document.getElementById("modalPopupLargeImage").src=imageSrc;showModal("ModalPopuplargerImageDiv","525","550");Omniture_ProductView(profileNumber)}function changeCursor(cursor){document.body.style.cursor=cursor}function OpenChatWindow(url){window.open(url,"chat","width=407,height=487,left=150,top=150,toolbar=no,menubar=no,location=no,status=no,resizable=no,scrollbars=no,directories=no,personalbar=no,channelmode=no,dialog=no,minimizable=yes")}function VariantAction(variantdd,disabledindexreset,qtytext,productaddtobag,notifyMsgDiv,notifylnk){var variantobj=document.getElementById(variantdd),qtytextobj=document.getElementById(qtytext),productaddtobagobj=document.getElementById(productaddtobag),notifyMsgDivobj=document.getElementById(notifyMsgDiv),notifylnkobj=document.getElementById(notifylnk),ddindex=variantobj.selectedIndex;if(variantobj.options[ddindex].style.color=="DarkGray"||variantobj.options[ddindex].style.color=="darkgray"){variantobj.selectedIndex=disabledindexreset;qtytextobj.style.display="inline";productaddtobagobj.style.display="inline";notifyMsgDivobj.style.display="none";notifylnkobj.style.display="none"}else{if(variantobj.options[ddindex].text.lastIndexOf("*")!=-1){var placeholder="{1}",searchtxt,nextindex,variantpf_id,variantprod_name,variantfsc_id,paramfields;searchtxt=variantobj.options[ddindex].value;nextindex=searchtxt.indexOf(";");searchtxt=searchtxt.substring(nextindex+1,searchtxt.length);nextindex=searchtxt.indexOf(";");if(nextindex>0){variantpf_id=searchtxt.substring(0,nextindex);searchtxt=searchtxt.substring(nextindex+1,searchtxt.length)}nextindex=searchtxt.indexOf(";");if(nextindex>0){variantprod_name=searchtxt.substring(0,nextindex);searchtxt=searchtxt.substring(nextindex+1,searchtxt.length)}nextindex=searchtxt.indexOf(";");if(nextindex==-1)variantfsc_id=searchtxt;if(variantpf_id>""){paramfields="pf_id={0}&prod_name={1}&fsc_id={2}";paramfields=paramfields.replace("{0}",variantpf_id);paramfields=paramfields.replace("{1}",variantprod_name);paramfields=paramfields.replace("{2}",variantfsc_id)}notifylnkobj.href=notifylnkobj.href.replace(placeholder,paramfields);qtytextobj.style.display="none";notifyMsgDivobj.style.display="inline";notifylnkobj.style.display="inline";productaddtobagobj.style.display="none"}else{qtytextobj.style.display="inline";productaddtobagobj.style.display="inline";notifyMsgDivobj.style.display="none";notifylnkobj.style.display="none"}return false}}function VariantNotify(variantdd,notifylnk){var notifylnkobj=document.getElementById(notifylnk),variantobj=document.getElementById(variantdd),ddindex=variantobj.selectedIndex;if(variantobj.options[ddindex].text.lastIndexOf("*")!=-1){var placeholder="{1}",searchtxt,nextindex,variantpf_id,variantprod_name,variantfsc_id,paramfields;searchtxt=variantobj.options[ddindex].value;nextindex=searchtxt.indexOf(";");searchtxt=searchtxt.substring(nextindex+1,searchtxt.length);nextindex=searchtxt.indexOf(";");if(nextindex>0){variantpf_id=searchtxt.substring(0,nextindex);searchtxt=searchtxt.substring(nextindex+1,searchtxt.length)}nextindex=searchtxt.indexOf(";");if(nextindex>0){variantprod_name=searchtxt.substring(0,nextindex);searchtxt=searchtxt.substring(nextindex+1,searchtxt.length)}nextindex=searchtxt.indexOf(";");if(nextindex==-1)variantfsc_id=searchtxt;if(variantpf_id>""){paramfields="pf_id={0}&prod_name={1}&fsc_id={2}";paramfields=paramfields.replace("{0}",variantpf_id);paramfields=paramfields.replace("{1}",variantprod_name);paramfields=paramfields.replace("{2}",variantfsc_id)}LaunchPopupWindowNotifyMe("notifyme.asp?"+paramfields)}}function GoToSearch(url){location.href=url+"?department=search&find_spec="+$("#srchTxt").val()}function showModal(popupId,width,height){var popupBackground=$("#popupBackground");if(popupBackground.length===0){$("body").append('<div id="popupBackground"></div>');popupBackground=$("#popupBackground")}popupBackground.show();var widthString=width.toString()+"px",marginLeftString="-"+(width/2).toString()+"px",heightString=height.toString()+"px",topString=(posTop()+(pageHeight()-height)/2).toString()+"px",popup=$("#"+popupId);popup.show();popup.css("width",widthString);popup.css("margin-left",marginLeftString);popup.css("height",heightString);popup.css("top",topString)}function hideModal(popupId){if(popupId!==""){$("#popupBackground").hide();$("#"+popupId).hide()}}function ShowLoading(message){$("#loadingDivMsgHolder").text($("#"+message+"Msg").text());var height=35;if(message=="removing"||message=="loadingVmo"||message=="coupon")height=55;showModal("loadingDiv",120,height)}function AjaxErrorHandler(request,status,error){document.location.href="error.aspx"}function ServiceFailed(result){if(result.ServiceFailed){hideModal("loadingDiv");showModal("errorPopup",350,80);$("#errorPopup").find("#msg").html(result.FailureMessage);return true}return false}function ShowProductChartPopup(width,height){height=height+40;showModal("ProdChartModalPopupDiv",width,height)}function ShowIngFaqModalPopup(source){if(source=="faq"){$("#ModalHeading").html($("#HeadingFaq").html());$("#ModalDetails").html($("#ProdFaq").html())}else{$("#ModalHeading").html($("#HeadingIngredients").html());$("#ModalDetails").html($("#ProdIndgredients").html())}showModal("IngFaqModalPopupDiv","525","550")}function CloseIngFaqModalPopup(source){$("#ModalHeading").html("");$("#ModalDetails").html("");hideModal("IngFaqModalPopupDiv")}function HideModalImagePopup(){document.getElementById("modalPopupLargeImage").src="";hideModal("ModalPopuplargerImageDiv")}function ShowModalImagePopup(imgUrl){document.getElementById("modalPopupLargeImage").src=imgUrl;showModal("ModalPopuplargerImageDiv","550","525")}function HandleEnterKeyPress(controlIdToClick,e){if((typeof e.keyCode=="undefined"?e.which:e.keyCode)==13){$("#"+controlIdToClick).click();typeof e.keyCode=="undefined"?e.preventDefault():(e.keyCode=null)}}function pageWidth(){return window.innerWidth!=null?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body!=null?document.body.clientWidth:null}function pageHeight(){return window.innerHeight!=null?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body!=null?document.body.clientHeight:null}function posLeft(){return typeof window.pageXOffset!="undefined"?window.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft?document.body.scrollLeft:0}function posTop(){return typeof window.pageYOffset!="undefined"?window.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0}function posRight(){return posLeft()+pageWidth()}function posBottom(){return posTop()+pageHeight()}function SetModalPopUpImageValues(src){document.getElementById("modalPopupLargeImage").src=src;showModal("ModalPopuplargerImageDiv","250","250")}function ShowVMO(id,omnProp17Value,caption,url,width,height){var vmoIframe=$("#VMO_frame");vmoIframe.css("width",width);vmoIframe.css("height",height);vmoIframe.attr("src",url);$("#VMO_caption").html(caption);showModal(id,width,height+14);Omniture_DoVmoClick(omnProp17Value)}function HideVMO(id){var vmoIframe=$("#VMO_frame");vmoIframe.attr("src","");hideModal(id)}function HndlEnter4BagAdd(container){if(window.event.keyCode==13){window.event.keyCode=null;$(container).find("img#addButton").click()}}function AddBtnClick(productIndex){var productCtrl,msgContainer,qty,sku;productCtrl=$("#product"+productIndex);msgContainer=productCtrl.find("#msg");msgContainer.text("");qty=parseInt(productCtrl.find("input:text#qty").val(),10);if(isNaN(qty))qty=1;if(productCtrl.find("#sku").length==1)sku=productCtrl.find("#sku").text();else{var selected=productCtrl.find("select option:selected");sku=selected.val();if(sku.length===0){msgContainer.text($("#mustSpecifyVersionMsg").text());return}}var bagItem={Id:productIndex,Quantity:qty,Sku:sku,OrderType:"PL"};Bag_ListPageAddToBagServiceCall(bagItem,GetConditionalProducts())}function GetConditionalProducts(){var conditionalItems=[];$("div[id='conditionalProductInfo']").each(function(){var productInfo=$(this).text(),splitResult=productInfo.split(":"),conditionalProduct={ProductControlIndex:splitResult[0],PfId:splitResult[1]};conditionalItems.push(conditionalProduct)});return conditionalItems}function VariantChanged(productIndex){var productCtrl=$("#product"+productIndex),selected=productCtrl.find("select option:selected"),showNotifyMeButton=selected.text().charAt(0)=="*";productCtrl.find(showNotifyMeButton?"#notifyPanel":"#addButton").show();productCtrl.find(showNotifyMeButton?"#addButton":"#notifyPanel").hide();showNotifyMeButton&&productCtrl.find("#notifyPanel img").click(function(){var splitResult=selected.val().split(";"),url="notifyme.asp?pf_id={0}&fsc_id={1}&prod_name={2}".replace("{0}",splitResult[1]).replace("{1}",splitResult[2]).replace("{2}",productCtrl.find("#name").html());LaunchPopupWindowNotifyMe(url)});if(selected.val()==="")productCtrl.find("select").each(function(){this.selectedIndex=0});else productCtrl.find("#msg").text("")}function BagPage_Update(){if(!BagPage_FormChanged()){$("#noChangesToUpdateMsg").show();$("#youMustUpdateMsg").hide();showModal("bagMsgPopup",420,50);return false}return true}function BagPage_GoTo(url){if(BagPage_FormChanged()){$("#youMustUpdateMsg").show();$("#noChangesToUpdateMsg").hide();showModal("bagMsgPopup",420,50)}else location.href=url}function BagPage_FormChanged(){var isDirty=false;if($(":checked").length>0)isDirty=true;!isDirty&&$("div .qtyCol").each(function(){var hdnQty=$(this).find("input[type=hidden]").val(),qty=$(this).find("input[type=text]").val();if(hdnQty!=qty){isDirty=true;return false}});if(!isDirty)if($("#couponCodeHdn").val()!=$("#couponCode").val())isDirty=true;return isDirty}
