﻿function showImageZoomPopup(){var a=s.pageName+":[Modal]Image Zoom ";largeImagePathField=$get("largeImagePath");if(largeImagePathField!=null){$get("modelImageZoomContent").innerHTML="<img src='"+largeImagePathField.value+"'/>";a+=largeImagePathField.value}showModalPopup("modelImageZoomControl",a)}function SetMembershipFocus(b){var a=document.getElementById(b);if(typeof a=="object"){a.checked=true}}function MembershipKitClass(a,c,b){this.id=a;this.children=c;this.clearOnLostFocus=(b)?b:false}function SetMembershipSelectItemsFocus(c,a){var b=false;for(i=0,l=c.length;i<l;i++){b=(c[i].id==a);if(c[i].children!=null){for(ii=0,ll=c[i].children.length;ii<ll;ii++){if(c[i].children[ii].id==a){SetMembershipSelectValues(document.getElementById(c[i].id),true,false);ii=ll+1}else{SetMembershipSelectValues(document.getElementById(c[i].children[ii].id),b,c[i].children[ii].clearOnLostFocus)}}}}}function SetMembershipSelectValues(c,a,b){if(c!=null&&typeof c=="object"){if(c.tagName=="INPUT"){if(c.type=="text"){if(a){c.focus()}else{c.value=""}}else{if(c.type=="checkbox"||c.type=="radio"){if(a&&!b){c.checked=true}else{c.checked=false}}}}}};
var kitConfigurationArray;var currentSelectionGroupID=0;var selectionListScrollTween;var selectionListScrollTimer;var scrollDelayTimer;var scrollDelayInterval=200;var scrollInterval=16;var scrollAmount=8;var clickScrollAmount=100;var scrollDelayPassed=false;var selectionListMaskDiv=null;var selectionListItemsDiv=null;var slBtnUp=null;var slBtnDown=null;var externalAddToCartButtonID=null;function initializeKitSelectorUI(){currentSelectionGroupID=0;selectionListMaskDiv=$get("selectionListMask");selectionListItemsDiv=$get("selectionListItems");slBtnUp=$get("slBtnUp");slBtnDown=$get("slBtnDown");var a=$get("selectionListContent");var c=$get("selectionListFooter");var d=$get("selectionListFooterText");if(d.offsetHeight>20){var b=d.offsetHeight-10;a.style.height=(a.offsetHeight-b)+"px";selectionListMaskDiv.style.height=(selectionListMaskDiv.offsetHeight-b)+"px";c.style.height=(c.offsetHeight+b-2)+"px"}if(selectionListItemsDiv.offsetHeight>selectionListMaskDiv.offsetHeight){slBtnDown.className="btnDown"}resetPageItems()}function gotoSelectionGroup(h){$get("selectGroup"+currentSelectionGroupID).style.display="none";$get("selectionListItem"+currentSelectionGroupID).className="kitSelectionListItem";currentSelectionGroupID=h;$get("selectGroup"+h).style.display="block";var g=$get("selectionListItem"+h);g.className="kitSelectionListItem selected";$get("txtCurrentStep").innerHTML=h+1;var d=getListPosition();var e=getHeightDiff();if(e<0){var c=g.offsetTop;var a=g.offsetHeight;var b=selectionListMaskDiv.offsetHeight;var f;if((d+c+a)>b){f=c+a-b;tweenTo(0-f)}else{if((d+c+a)<0){f=c;tweenTo(0-f)}}}}function resetFeatureSelections(f){var a=document.getElementsByName("selectionItem"+f);var e;for(var d=0,c=a.length,b=(c-(c%3))-1;d<c;d++){e="selectionItemContainer";if(d%3==0){e+=" firstInRow"}if(d>b&&b>=5){e+=" lastRow"}if(d==c-1&&d%3!=2){e+=" lastItem"}a[d].className=e}}function selectItem(c,d,b,a){resetFeatureSelections(d);c.className+=" selected";kitConfigurationArray[d].Selection=b;$get("listName"+d).innerHTML=a;$get("listCheck"+d).style.visibility="visible";var e=d+1;if(kitConfigurationArray.length>e){gotoSelectionGroup(e)}updatePageItems()}function resetPageItems(){if(externalAddToCartButtonID!==null){var a=$get(externalAddToCartButtonID);if(a!==null){a.className="disabled"}}for(var b=0;b<kitConfigurationArray.length;b++){kitConfigurationArray[b].Selection=null;resetFeatureSelections(b);$get("listCheck"+b).style.visibility="hidden"}$get("txtCurrentStep").innerHTML=1;gotoSelectionGroup(0)}function updatePageItems(){var c=0;for(var b=0;b<kitConfigurationArray.length;b++){if(kitConfigurationArray[b].Selection!==null){c++}}if(c==kitConfigurationArray.length){if(externalAddToCartButtonID!==null){var a=$get(externalAddToCartButtonID);if(a!==null){a.className=""}}}}function scrollBtnMouseDown(a){clearTimeout(scrollDelayTimer);if(a==slBtnUp){scrollDelayPassed=false;scrollDelayTimer=setTimeout("startSelectionListScroll(0)",scrollDelayInterval)}else{if(a==slBtnDown){scrollDelayPassed=false;scrollDelayTimer=setTimeout("startSelectionListScroll(1)",scrollDelayInterval)}}}function scrollBtnMouseUp(d){clearTimeout(scrollDelayTimer);if(!scrollDelayPassed){var b=getListPosition();var c=getHeightDiff();if(c<0){if(d==slBtnUp){var a=b+clickScrollAmount;if(a>0){a=0}}else{if(d==slBtnDown){var a=b-clickScrollAmount;if(a<c){a=c}}}tweenTo(a)}}else{stopSelectionListScroll()}}function startSelectionListScroll(c){scrollDelayPassed=true;var a=getListPosition();var b=getHeightDiff();stopSelectionListScroll();switch(c){case 0:if(b<0&&a<0){slBtnDown.className="btnDown";selectionListScrollTimer=setInterval("scrollUp()",scrollInterval)}break;case 1:if(b<0&&a>b){slBtnUp.className="btnUp";selectionListScrollTimer=setInterval("scrollDown()",scrollInterval)}break}}function scrollUp(){var a=getListPosition();if(a<=(0-scrollAmount)){selectionListItemsDiv.style.top=(a+scrollAmount)+"px"}else{stopSelectionListScroll();selectionListItemsDiv.style.top="0px";slBtnUp.className="btnUp disabled"}}function scrollDown(){var a=getListPosition();var b=getHeightDiff();if(a>=(b+scrollAmount)){selectionListItemsDiv.style.top=(a-scrollAmount)+"px"}else{stopSelectionListScroll();selectionListItemsDiv.style.top=b+"px";slBtnDown.className="btnDown disabled"}}function getListPosition(){return new Number(selectionListItemsDiv.style.top.replace(/px/,""))}function getHeightDiff(){return selectionListMaskDiv.offsetHeight-selectionListItemsDiv.offsetHeight}function tweenTo(a){if(selectionListScrollTween!=null){selectionListScrollTween.stop()}selectionListScrollTween=new Tween(selectionListItemsDiv.style,"top",Tween.strongEaseOut,getListPosition(),a,0.5,"px");selectionListScrollTween.onMotionFinished=function(){updateButtonStates()};selectionListScrollTween.start()}function updateButtonStates(){var a=getListPosition();var b=getHeightDiff();if(a<0){slBtnUp.className="btnUp"}else{slBtnUp.className="btnUp disabled"}if(a>b){slBtnDown.className="btnDown"}else{slBtnDown.className="btnDown disabled"}}function kitScrollTo(a){selectionListItemsDiv.style.top=a+"px";updateButtonStates()}function stopSelectionListScroll(){clearInterval(selectionListScrollTimer)}function getKitConfiguration(){return kitConfigurationArray}function rtnAddKitToCart(rtn){try{closeModalPopup("kitConfigPopup");if(rtn.Omniture!=null){eval(rtn.Omniture)}if(rtn.Javascript!=null){eval(rtn.Javascript)}else{if(rtn.HtmlMessage!=null){alert(rtn.HtmlMessage)}}addToCartRefresh();if(rtn.Promotion!=null){eval(rtn.Promotion)}}catch(err){}}function populateModalKitConfig(rtn){if(rtn.Omniture!=null){eval(rtn.Omniture)}if(rtn.Javascript!=null){eval(rtn.Javascript)}else{if(rtn.HtmlMessage!=null){$get("kitConfigContainer").innerHTML="";showModalPopup("kitConfigPopup");resultArr=rtn.HtmlMessage.split("||KitConfigJavascript||");$get("kitConfigContainer").innerHTML=resultArr[0];eval(resultArr[1])}}}function showKitConfigPopup(d,a,c,b){if(!a||a==""||a==0){a=null}if(!c||c==""||c==0){c=null}if(!b||b==""){b="Unknown"}s.t({pageName:s.pageName+":[Modal]Kit "+d});Melaleuca.Web.AjaxManager.GetProductKitSelectorWithOmnitureSource(d,a,null,c,b,populateModalKitConfig)}function editKitConfig(e,b,a,d,c){if(!d||d==""||d==0){d=null}if(!c||c==""){c="Unknown"}Melaleuca.Web.AjaxManager.GetProductKitSelectorWithOmnitureSource(e,b,a,d,c,populateModalKitConfig)}function removeKitConfig(c,b,a){Melaleuca.Web.AjaxManager.RemoveKitConfigFromCart(c,b,a,rtnRemoveKitConfig)}function rtnRemoveKitConfig(rtn){if(rtn.Javascript!=null){eval(rtn.Javascript)}else{if(rtn.HtmlMessage!=null){alert(rtn.HtmlMessage)}}addToCartRefresh()};
function populateModalGroupSelector(a){$get("productGroupSelectorContainer").innerHTML=a}function populateLargeModalGroupSelector(a){$get("productGroupSelectorLargeContainer").innerHTML=a}function showProductGroupPopup(b,a){if(a==1){Melaleuca.Web.AjaxManager.GetProductGroupSelector(b,a,populateLargeModalGroupSelector);$get("productGroupSelectorLargeContainer").innerHTML="";showModalPopup("groupSelectorLargePopup",s.pageName+":[Modal]Large Product Group"+b)}else{Melaleuca.Web.AjaxManager.GetProductGroupSelector(b,a,populateModalGroupSelector);$get("productGroupSelectorContainer").innerHTML="";showModalPopup("groupSelectorPopup",s.pageName+":[Modal]Regular Product Group"+b)}}function selectGroupItem(d,g,m,k,l,h,o,c,b,q,p,n,a){g.className="categoryItem selected";$get("pgsProductName").innerHTML="<a href='javascript:;' onclick='gotoProductPage("+k+"); return false;'>"+m+"</a>";$get("pgsProductNumber").style.display="block";$get("pgsSku").innerHTML=k;$get("pgsSelectedImage").src="/ContentImages/"+l;$get("pgsSelectSku").value=k;$get(q).innerHTML=h;$get(p).innerHTML=o;$get(n).innerHTML=c;$get(a).innerHTML=b;d.className="";categoryItems=document.getElementsByName(g.name);for(var f=0,e=categoryItems.length;f<e;f++){categoryItems[f].className="categoryItem"}};
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();