var xe_utilities_js={"Version":3,"MinorVersion":0.100315};var XE=XE||{};XE.Utilities=(function(){var e={};e.in_array=function(a,b,c){var d=false,key,c=!!c;for(key in b){if((c&&b[key]===a)||(!c&&b[key]==a)){d=true;break}}return d};return e})();XE.Debug={"LogID":'',"SetupLog":function(a,b){$('<div />').attr('id',b).append('<h4>Debug Log</h4>').appendTo($('#'+a));XE.Debug.LogID=b},"Log":function(a){$('<span>'+a+'</span><br />').appendTo($('#'+XE.Debug.LogID))},"WriteConsole":function(a){var b=new Date;console.log(b.getMinutes()+':'+b.getSeconds()+'.'+b.getMilliseconds()+': '+a)},"Activities":{},"StartActivity":function(a){var b=new Date;XE.Debug.Activities[a]=b.getTime();XE.Debug.WriteConsole("Starting '"+a+"'.")},"StopActivity":function(a){var b,nDiff;b=new Date;if(XE.Debug.Activities[a]){nDiff=b.getTime()-XE.Debug.Activities[a];XE.Debug.WriteConsole("Stopping '"+a+"', elapsed time: "+(nDiff/1000)+" seconds.");delete XE.Debug.Activities[a]}else{XE.Debug.WriteConsole("No start time for activity '"+a+"' found.")}}};XE.Alert=function(a,b,c){if(arguments.length==1){b=a;a="Attention"}var d=XE.Panels.InitPanel('alert');XE.Panels.SetPanelTitle(d,a);XE.Panels.SetPanelContent(d,b);d.jqmShow();if(arguments.length==3){if(readCookie('devcookie')){alert('YOU ARE A DEVERLOPER!\nAn Alert has occurred, which is trying to contact the KDS Alerter service.\nNOTE: this type of event is supposed to be "recoverable".\n\nHere is the verbose error to report:\n'+c)}else{var e=window.location.href;XE.ReportError(a+':'+b,c)}}};XE.ReportError=function(d,e,f){function sendAlertFail(a,b,c){};function sendAlertSuccess(a){};function sendAlertComplete(a,b){if($.isFunction(f)){f()}};var g=window.location.href;var h=navigator.userAgent;var i='Error in CartXE StoreID '+XE.Settings.StoreID+', SessionID '+XE.Session.GetID();var j='\n\nFriendly Message:\n'+d;if(e){j+='\n\nDeveloper Message:\n'+e}var k='Url='+encodeURIComponent(g)+'&UA='+encodeURIComponent(h)+'&Context='+encodeURIComponent(i)+'&Details='+encodeURIComponent(j);$.ajax({url:XE.GetResourceUrl('service','Alerter'),type:'POST',dataType:'text',data:k,timeout:XE.Constants.SENDALERT_TIMEOUT,error:sendAlertFail,success:sendAlertSuccess,complete:sendAlertComplete})};XE.IsUserAbortedError=function(a,b,c,d){if(c&&c=="error"){if(!d){if(b&&b.readyState==4){if(!b.status&&!b.statusText){if(!b.responseText){return true}else{}}}}}return false};XE.GetAjaxFailureMessage=function(a,b,c,d){var e;var f;e='Error: '+(c||'null, zero, or undefined');if(d){if(d.name){e+='[E1:'+d.name+': '+d.message+']'}else{e+='[E2:'+(d+'')+']'}}if(b){if(b.readyState==4){e+='[C3]';if(b.status){e+='[S:'+b.status+']'}if(b.statusText){e+='[T:'+b.statusText+']'}}else{e+='[C4]'}}f='Request url: '+a.url;f=f+'\nRequest readyState: '+b.readyState;f=f+'\n'+e;if(b.readyState==4){if(!b.responseText){f=f+'\nUndefined or NULL responseText!'}else{f=f+'\nHere is the responseText: '+b.responseText}}return(f)};XE.Utilities.LoadJsCssFile=function(a,b){if(b=="js"){var c=document.createElement('script');c.setAttribute("type","text/javascript");c.setAttribute("src",a)}else if(b=="css"){var c=document.createElement("link");c.setAttribute("rel","stylesheet");c.setAttribute("type","text/css");c.setAttribute("href",a)}if(typeof c!="undefined"){document.getElementsByTagName("head")[0].appendChild(c)}};function jQueryFromHtml(a){a=$.trim(a);if(/^<[\w\W]+?>$/.test(a)){return($(a))}else{return($('<div />').html(a))}};function positionElement(a,b,c){switch(c){case XE.Constants.PLACEMENT_PREPENDTO:b.prepend(a);break;case XE.Constants.PLACEMENT_BEFORE:b.before(a);break;case XE.Constants.PLACEMENT_AFTER:b.after(a);break;default:b.append(a);break}};function Left(a,b){return a.substr(0,b)};function Right(a,b){return a.substr(a.length-b)};function Mid(a,b,c){return a.substr(b-1,c)};function moneyFormat(a){if(isNaN(a)){return null}var b=String(Math.round(Number(a)*100));var c=(Number(b)<0?'-':'');b=b.replace(/^\-/,'');while(b.length<3){b='0'+b}return c+b.substr(0,b.length-2)+'.'+b.substr(b.length-2)};function lookupFieldConfigByElement(a){var b=XE.Config.FormConfig;var c=null;for(var d in b){for(var i=0;!c&&(i<b[d].length);i++){if(b[d][i].element==a){c=b[d][i]}}if(c){break}}return c};function lookupFieldConfigByName(a){return XE.Config.FormConfig[a]};function lookupElementByConfig(a){};function setFieldRequired(a,b){var c=lookupFieldConfigByName(a);if(!c){return}c.isrequired=b;var d=null;if(c.inputtype=='group'){d=$('#'+a+'-fieldset .xe-asterisk')}else if(c.inputtype=='checkbox'){d=$('label[for="'+a+'"] .xe-asterisk')}else{d=$('#'+a).next().filter('.xe-asterisk')}if(b){d.show()}else{d.hide()}if(c.ut){c.ut.each(function(){clearFieldError(this)})}};function shipping_same_as_billing_toggle(){if(!XE.Application.IsInitComplete){return}var f=XE.Form;if(document.getElementById('shippingsameasbilling').checked){var a=document.getElementById('holdforpickup');if(a){f.shippingcompany.disabled=false;f.shippingdestinationtype.disabled=false;setFieldRequired('shippingmethodid',true);if(a.checked){a.checked=false;f.shippingcompany.value='';f.shippingdestinationtype.selectedIndex=0}}}billing_shipping_change()};function billing_shipping_change(){if(!XE.Application.IsInitComplete){return}var f=XE.Form;var a=new Array();a[0]=[f.billingfirstname,f.shippingfirstname];a[1]=[f.billinglastname,f.shippinglastname];a[2]=[f.billingaddress1,f.shippingaddress1];a[3]=[f.billingcity,f.shippingcity];a[4]=[f.billingstatecode,f.shippingstatecode];a[5]=[f.billingzip,f.shippingzip];a[6]=[f.billingphone,f.shippingphone];if(f.elements['shippingsameasbilling'].checked){var b=f.billingstatecode;var c=f.shippingstatecode;var d=$(c).val();if(!field_option_exists(c,b.options[b.selectedIndex].value)){alert('We are sorry, but due to restrictive state legislation, we currently '+'cannot ship to '+b.options[b.selectedIndex].value);clear_shipping_fields(f,a)}else{for(j=0;j<a.length;j++){a[j][1].disabled=true;copy_field(a[j][0],a[j][1])}}}else if(!f.elements['holdforpickup']||!f.elements['holdforpickup'].checked){for(j=0;j<a.length;j++){a[j][1].disabled=false}}if(d!=$(c).val()){XE.UpdateForm(f)}};function clear_shipping_fields(f,a){f.elements['shippingsameasbilling'].checked=false;for(j=0;j<a.length;j++){a[j][1].disabled=false;a[j][1].value=''}};function set_field_value(f,v){f.value=v;clearFieldError(f)};function copy_field(s,t){if(!s.options){t.value=s.value}else{var j;for(j=0;j<t.options.length;j++){if(t.options[j].value){if(t.options[j].value==s.options[s.selectedIndex].value){t.selectedIndex=j}}}}clearFieldError(t)};function clearFieldError(x){var a;if(typeof x=='string'){a=XE.Config.FormConfig[x]}else{a=XE.Config.FormConfig[$(x).get(0).name]}if(!a){alert('Script Error! clearFieldError');return}if(a.ht){a.ht.each(function(){$(this).removeClass('xe-fielderror')})}};function field_option_exists(e,v){var j;var a=false;for(j=0;j<e.options.length;j++){if(e.options[j].value==v){a=true}}return a};function hold_for_pickup(){var f=XE.Form;if(!f.holdforpickup){return}var a=[[f.shippingcompany,XE.Config.Store.HoldForPickupAddressCareOf],[f.shippingaddress1,XE.Config.Store.HoldForPickupAddressLine1],[f.shippingcity,XE.Config.Store.HoldForPickupAddressCity],[f.shippingstatecode,XE.Config.Store.HoldForPickupAddressState],[f.shippingzip,XE.Config.Store.HoldForPickupAddressZip],[f.shippingphone,XE.Config.Store.HoldForPickupAddressPhone],[f.shippingdestinationtype,XE.Config.Store.HoldForPickupAddressType]];if(f.shippingsameasbilling.checked){f.shippingsameasbilling.checked=false}if(f.holdforpickup.checked){for(var i=0;i<a.length;i++){set_field_value(a[i][0],a[i][1]);a[i][0].disabled=true}if(f.shippingfirstname.value==''){set_field_value(f.shippingfirstname,f.billingfirstname.value)}if(f.shippinglastname.value==''){set_field_value(f.shippinglastname,f.billinglastname.value)}f.shippingfirstname.disabled=false;f.shippinglastname.disabled=false;f.shippingdestinationtype.disabled=true;$("[name='shippingmethodid']").each(function(){this.disabled=true})}else{for(var i=0;i<a.length;i++){a[i][0].value='';a[i][0].disabled=false}f.shippingfirstname.disabled=false;f.shippinglastname.disabled=false;f.shippingdestinationtype.disabled=false}setFieldRequired('shippingmethodid',!f.holdforpickup.checked);itm_calc()};function billing_card_copy(){if(!XE.Application.IsInitComplete){return}var f=XE.Form;var a=[[f.billingfirstname,f.cardholderfirstname],[f.billinglastname,f.cardholderlastname],[f.billingzip,f.cardholderzip]];for(var i=0;i<a.length;i++){if(a[i][1].value=='')copy_field(a[i][0],a[i][1])}};function createCookie(a,b,c){if(c){var d=new Date();d.setTime(d.getTime()+(c*24*60*60*1000));var e="; expires="+d.toGMTString()}else var e="";document.cookie=a+"="+b+e+"; path=/"};function readCookie(a){var b=a+"=";var d=document.cookie.split(';');for(var i=0;i<d.length;i++){var c=d[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(b)==0)return c.substring(b.length,c.length)}return null};function eraseCookie(a){createCookie(a,"",-1)};function in_array(a,b,c){var d=false,key,c=!!c;for(key in b){if((c&&b[key]===a)||(!c&&b[key]==a)){d=true;break}}return d};