
﻿
var is_running=false;var isButtonDisabled=false;function CallOnce(f){if(!is_running){is_running=true;eval(f);}}
function CallOnceCallback(){is_running=false;}
function disableButton(){var returnVal=true;if(!isButtonDisabled){isButtonDisabled=true;}else{alert("Processing please wait...");returnVal=false;}
return returnVal;}
function validateEmail(elementValue){var emailPattern=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;return emailPattern.test(elementValue);}
function getFriendlyTime(minutes){var hours=Math.floor(minutes/60);var minutesPast=minutes-(hours*60)
if(minutesPast<10)minutesPast='0'+minutesPast;if(hours>11)minutesPast+='pm';if(hours<=11)minutesPast+='am';if(hours>12)hours-=12;return hours+':'+minutesPast;}
function left(str,n){if(n<=0)
return"";else if(n>String(str).length)
return str;else
return String(str).substring(0,n);}
function right(str,n){if(n<=0)
return"";else if(n>String(str).length)
return str;else{var iLen=String(str).length;return String(str).substring(iLen,iLen-n);}}
function displayDateTime(d){alert(d);return d.format('MM/dd/yy')+' '+d.format('h:MMtt');}
function displayShortDateTime(d){return d.format('M/d')+' '+d.format('h:MMtt');}
function displayDate(d){return d.format('MM/dd/yy');}
function displayTime(d){return d.format('h:mmtt');}
var depMgr={load:function(url){$(document).append(unescape("%3Cscript src='"+url+"' type='text/javascript'%3E%3C/script%3E"));}}﻿
EventClass=function(){this.eventList=new Array();}
EventClass.prototype.eventObject=null;EventClass.prototype.add=function(triggerFunc){this.eventList.push(triggerFunc);return this.eventList.length-1;}
EventClass.prototype.remove=function(index){this.eventList[index]=null;}
EventClass.prototype.trigger=function(){for(var i=0;i<this.eventList.length;i++)if(!(this.eventList[i]==null))this.eventList[i].call(this);}
EventClass.prototype.triggerWithArg=function(e){for(var i=0;i<this.eventList.length;i++)if(!(this.eventList[i]==null))this.eventList[i].call(this,e);}
EventClass.prototype.triggerWithArgs=function(e1,e2){for(var i=0;i<this.eventList.length;i++)if(!(this.eventList[i]==null))this.eventList[i].call(this,e1,e2);}
function EventManagerClass(){this.onscroll=new EventClass();this.onresize=new EventClass();this.onkeydown=new EventClass();this.onaddtocart=new EventClass();this.onremovefromcart=new EventClass();this.onupdateqtyincart=new EventClass();this.onlogin=new EventClass();this.onlogout=new EventClass();this.onregister=new EventClass();this.onloadcart=new EventClass();this.onlocationchange=new EventClass();this.onselecteddatechange=new EventClass();this.onloaduser=new EventClass();this.onpopupopen=new EventClass();this.onpopupclose=new EventClass();}
EventManagerClass.prototype.setup=function(){window.onscroll=function(){eventMgr.onscroll.trigger();}
window.onresize=function(){eventMgr.onresize.trigger();}
document.body.onkeydown=function(e){eventMgr.onkeydown.triggerWithArg(e);}}
var eventMgr=new EventManagerClass();﻿
var gaMgr={pageTracker:null,initTracker:function(){try{if(gaMgr.pageTracker==null)gaMgr.pageTracker=_gat._getTracker(gAnalyticsKey);}catch(err){}},trackLink:function(link,category,action){try{gaMgr.initTracker();gaMgr.pageTracker._trackEvent(category,action);setTimeout('document.location = "'+link.href+'"',100)}catch(err){}},track:function(category,action){gaMgr.initTracker();try{gaMgr.pageTracker._trackEvent(category,action);}catch(err){}}}
﻿
AccordionMenu=function(rootDiv,speed,collapseOther){this.rootDiv=rootDiv;if(speed!=undefined)this.speed=speed;if(collapseOther!=undefined)this.collapsePrev=collapseOther;var me=this;$('#'+rootDiv+' .accordionMenuHeader a').click(function(){me.toggleElementClick(this);return false;});}
AccordionMenu.prototype.rootDiv=null;AccordionMenu.prototype.collapsePrev=true;AccordionMenu.prototype.speed='';AccordionMenu.prototype.unload=function(){$('#'+this.rootDiv+' .accordionMenuHeader a').unbind();}
AccordionMenu.prototype.toggleElementClick=function(ele){var ulId=$(ele).attr('target');if($(ele).parent('.accordionMenuHeader').hasClass('accordionOpenHeader')){$(ele).parent('.accordionMenuHeader').removeClass('accordionOpenHeader');if(this.speed==''){$('#'+ulId).toggle();}else{$('#'+ulId).slideToggle(this.speed);}}
else{if(this.collapsePrev){if(this.speed==''){$('#'+this.rootDiv).children('.accordionCategoryItem').hide();}else{$('#'+this.rootDiv).children('.accordionCategoryItem').slideUp(this.speed);}
$('#'+this.rootDiv).children('.accordionMenuHeader').removeClass('accordionOpenHeader');}
$(ele).parent('.accordionMenuHeader').addClass('accordionOpenHeader');if(this.speed==''){$('#'+ulId).show();}else{$('#'+ulId).slideDown(this.speed);}}}
AccordionMenu.prototype.toggleElement=function(ulId){if($('#'+this.rootDiv+' a[target='+ulId+']').parent('.accordionMenuHeader').hasClass('accordionOpenHeader')){this.collapseElement(ulId);}else{this.expandElement(ulId);}}
AccordionMenu.prototype.collapseElement=function(ulId){if($('#'+this.rootDiv+' a[target='+ulId+']').parent('.accordionMenuHeader').hasClass('accordionOpenHeader')){$('#'+this.rootDiv+' a[target='+ulId+']').parent('.accordionMenuHeader').removeClass('accordionOpenHeader');if(this.speed==''){$('#'+ulId).hide();}else{$('#'+ulId).slideUp(this.speed);}}}
AccordionMenu.prototype.expandElement=function(ulId){if(!$('#'+this.rootDiv+' a[target='+ulId+']').parent('.accordionMenuHeader').hasClass('accordionOpenHeader')){if(this.collapsePrev){if(this.speed==''){$('#'+this.rootDiv).children('.accordionCategoryItem').hide();}else{$('#'+this.rootDiv).children('.accordionCategoryItem').slideUp(this.speed);}
$('#'+this.rootDiv).children('.accordionMenuHeader').removeClass('accordionOpenHeader');}
$('#'+this.rootDiv+' a[target='+ulId+']').parent('.accordionMenuHeader').addClass('accordionOpenHeader');if(this.speed==''){$('#'+ulId).show();}else{$('#'+ulId).slideDown(this.speed);}}}﻿
var popupWindowMgr={popupContainerDivId:'',popupWindowDivId:'',popupContentDivId:'',smallCssMod:'',mediumCssMod:'',eventOnScroll:-1,eventOnResize:-1,eventOnKeyDown:-1,eventIndexCollection:Array(),setup:function(popupCt,popupWn,popupCnt,smallCssClass,medCssClass){this.popupContainerDivId='#'+popupCt;this.popupWindowDivId='#'+popupWn;this.popupContentDivId='#'+popupCnt;this.smallCssMod=smallCssClass;this.mediumCssMod=medCssClass;},clear:function(){$(this.popupContentDivId).html('');},showLargeWindow:function(){this.makeLarge();$(this.popupContainerDivId).height($(document).height());$(this.popupContainerDivId).show();$(this.popupWindowDivId).css('margin-top','0px');$(this.popupWindowDivId).show();this.center();if($(window).height()<568)$(window).scroll(0);this.addHandlers();},showMediumWindow:function(){this.makeMedium();$(this.popupContainerDivId).height($(document).height());$(this.popupContainerDivId).show();$(this.popupWindowDivId).css('margin-top','0px');$(this.popupWindowDivId).show();this.center();if($(window).height()<424)$(window).scroll(0);this.addHandlers();},showSmallWindow:function(){this.makeSmall();$(this.popupContainerDivId).height($(document).height());$(this.popupContainerDivId).show();$(this.popupWindowDivId).css('margin-top','0px');$(this.popupWindowDivId).show();this.center();if($(window).height()<340)$(window).scroll(0);this.addHandlers();},makeLarge:function(){$(this.popupWindowDivId).removeClass(this.smallCssMod);$(this.popupWindowDivId).removeClass(this.mediumCssMod);},makeMedium:function(){$(this.popupWindowDivId).addClass(this.mediumCssMod);$(this.popupWindowDivId).removeClass(this.smallCssMod);},makeSmall:function(){$(this.popupWindowDivId).removeClass(this.mediumCssMod);$(this.popupWindowDivId).addClass(this.smallCssMod);},escapeKeyDetector:function(e){var kC=(window.event)?event.keyCode:e.keyCode;var Esc=(window.event)?27:e.DOM_VK_ESCAPE;if(kC==Esc)popupWindowMgr.hide();},addHandlers:function(){this.eventOnScroll=eventMgr.onscroll.add(function(){popupWindowMgr.center();});eventMgr.onresize.add(function(){popupWindowMgr.center();});eventMgr.onkeydown.add(function(e){popupWindowMgr.escapeKeyDetector(e);});},remHandlers:function(){eventMgr.onscroll.remove(this.eventOnScroll);eventMgr.onscroll.remove(this.eventOnResize);eventMgr.onscroll.remove(this.eventOnKeyDown);},hide:function(){this.remHandlers();$(this.popupContainerDivId).hide();$(this.popupWindowDivId).hide();$(this.popupWindowDivId).css('margin-top','0px');$(this.popupWindowDivId).removeClass(this.smallCssMod);this.clear();eventMgr.onpopupclose.trigger();},content:function(text){$(this.popupContentDivId).html(text);},center:function(){var popupWn=$(this.popupWindowDivId);if(popupWn.is(':visible')){var popupHeight=popupWn.outerHeight();var windowHeight=$(window).height();var scrollPosition=0;var marginTop='0px';if(document.documentElement.scrollTop){scrollPosition=parseInt(document.documentElement.scrollTop);}else if(document.body.scrollTop){scrollPosition=parseInt(document.body.scrollTop);}
if(windowHeight<(popupHeight)){marginTop='0px';}else{marginTop=String(((windowHeight-popupHeight)/2)+scrollPosition)+'px';}
if(popupWn.css('margin-top')=='0px'){popupWn.css('margin-top',marginTop);}else{popupWn.stop();popupWn.animate({marginTop:marginTop},'fast','linear');}}}}
﻿
Type.registerNamespace('Specialtys.Core.SpecialtysDirect.AuthResponseType');Type.registerNamespace('Specialtys.Core.SpecialtysDirect.ChangePasswordResponse');Specialtys.Core.SpecialtysDirect.AuthResponseType={Failed:0,OK:1,FailedEmailVerificationRequired:2,OKPasswordChangeRequired:3,AlreadyRegistered:4};Specialtys.Core.SpecialtysDirect.ChangePasswordResponse={InvalidResponse:-1,OK:0,PasswordDoesNotMatch:1,PasswordBlank:2,PasswordIncorrect:3};var userMgr={authenticated:null,customerId:null,userName:null,firstName:null,skipUpsell:false,proposalFeatureEnabled:null,passwordChangeRequired:null,authResponse:null,authCount:0,lastAuthRequestUrl:null,isAuthRedirected:null,isAuthenticating:false,callback:null,onHideEventIndex:null,failCallback:null,sslFrame:null,init:function(callback){specialtys.com.SDProxy.GetUser(function(usr){userMgr.initCallback(usr,callback);});},initCallback:function(usr,callback){userMgr.authenticated=usr.Authenticated;userMgr.customerId=usr.CustomerId;userMgr.userName=usr.UserName;userMgr.proposalFeatureEnabled=usr.ProposalFeatureEnabled;userMgr.passwordChangeRequired=usr.PasswordChangeRequired;userMgr.authResponse=usr.AuthResponse;userMgr.lastAuthRequestUrl=usr.LastAuthRequestUrl;userMgr.isAuthRedirected=usr.IsAuthRedirected;eventMgr.onloaduser.trigger();if(callback!=undefined&&callback!=null)callback.call(this);},requireLogin:function(callback,failCallback){this.callback=callback;this.failCallback=failCallback;if(this.authenticated==true){this.triggerCallback();return;}
this.init(function(){userMgr.requireLoginCallback();});},requireLoginCallback:function(){if(userMgr.authenticated!=true){userMgr.login(this.callback,this.failCallback);return;}
this.failCallback=null;this.triggerCallback();},checkCustomerId:function(){this.initFromCookie();return(this.customerId>0);},requireCustomerId:function(callback,failCallback){this.callback=callback;this.failCallback=failCallback;if(this.userName==null||this.userName==undefined)this.initFromCookie();if(this.userName==null||this.userName==undefined){this.init(function(){userMgr.requireCustomerIdCallback();});return;}
userMgr.requireCustomerIdCallback();return;},requireCustomerIdCallback:function(){if(!(userMgr.customerId>0)){userMgr.login(this.callback,this.failCallback);return;}
this.failCallback=null;this.triggerCallback();},changePasswordCallback:function(){jQuery.get('Templates/userservices-change-password.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showSmallWindow();},'text');},changePasswordLogin:function(){jQuery.get('Templates/userservices-change-password.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showSmallWindow();$('#popupWindow_passwordchangePrompt_response').text("Your password has expired. Please change your password.");},'text');},register:function(callback,failCallback,userName,password){this.callback=callback;jQuery.get('Templates/userservices-register.htm','',function(data,textStatus){popupWindowMgr.showMediumWindow();popupWindowMgr.content(data);if(userName!=undefined)$('#popupWindow_registerPrompt_email').attr('value',userName);if(password!=undefined)$('#popupWindow_registerPrompt_password').attr('value',password);$('#popupWindow_registerPrompt_email').focus();if(userName!=undefined&&userName!=''){$('#popupWindow_registerPrompt_password').focus();if(password!=undefined){$('#popupWindow_registerPrompt_passwordconfirm').focus();}}},'text');},emailTemporaryPassword:function(){var em=$('#popupWindow_loginPrompt_username').val();jQuery.get('Templates/userservices-forgot-password.htm','',function(data,textStatus){productMgr.windowMgr.content(data);$('#popupWindow_loginPrompt_email_reminder').val(em);$('#popupWindow_loginPrompt_email_reminder').focus();productMgr.windowMgr.showSmallWindow();},'text');},login:function(callback,failCallback,userName){if(userMgr.userName==null||userMgr.userName==undefined)this.initFromCookie();if(userName!=undefined)userMgr.userName=userName;this.callback=callback;this.failCallback=failCallback;jQuery.get('Templates/userservices-login.htm','',function(data,textStatus){popupWindowMgr.showSmallWindow();popupWindowMgr.content(data);userMgr.setupOnHideEvent(function(){setTimeout('userMgr.triggerFailCallback()',250);});if(userMgr.userName==null||userMgr.userName==undefined||userMgr.userName==''){$('#popupWindow_loginPrompt_username').focus();}
else{$('#popupWindow_loginPrompt_username').val(userMgr.userName);$('#popupWindow_loginPrompt_password').focus().focus();}},'text');},initFromCookie:function(){this.customerId=this.readCookieKey('Customer','CustomerId');this.userName=this.readCookieKey('Customer','Email');this.firstName=this.readCookieKey('Customer','Firstname');this.proposalFeatureEnabled=false;if(this.readCookieKey('Customer','ProposalFeatureEnabled')=='True')this.proposalFeatureEnabled=true;},readCookie:function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;},readCookieKey:function(name,key){var cookie=this.readCookie(name);if(cookie==null||cookie==undefined)return null;var keys=cookie.split('&');for(var i=0;i<keys.length;i++){var thisKey=keys[i].split('=');if(thisKey[0]==key)return thisKey[1];}},tryLoginNonSecure:function(){var user=$('#popupWindow_loginPrompt_username').val();var pass=$('#popupWindow_loginPrompt_password').val();$('#popupWindow_loginPrompt_response').text("Verifying your identity, please wait...");specialtys.com.SDProxy.AuthenticateUser(user,pass,function(data){userMgr.tryLoginCallback(data);});},tryLoginSSL_IFrame:function(){userMgr.authCount++;var user=$('#popupWindow_loginPrompt_username').val();var pass=$('#popupWindow_loginPrompt_password').val();var url=sslUrl+'Wcf/SSLAuth.aspx';var qS='?user='+encodeURIComponent(user)+'&pass='+encodeURIComponent(String(pass));var iFrm=$get('iframeHelper');var iFrmResult=$get('iframeHelperResult');var frm=window.frames['iframeHelper'].document.getElementById('authForm');var frmUser=window.frames['iframeHelper'].document.getElementById('popupWindow_loginPrompt_username');var frmPass=window.frames['iframeHelper'].document.getElementById('popupWindow_loginPrompt_password');frmUser.value=user;frmPass.value=pass;$(iFrmResult).unbind('load');userMgr.isAuthenticating=true;$(iFrmResult).bind('load',function(){userMgr.isAuthenticating=false;specialtys.com.SDProxy.GetAuthResponse(function(data){userMgr.tryLoginCallback(data);});});setTimeout(function(){if(userMgr.isAuthenticating==true){specialtys.com.SDProxy.GetAuthResponse(function(data){userMgr.tryLoginCallback(data);});}},2500);frm.action=url;frm.submit();},tryBackgroundLogin:function(){},tryLoginSSL:function(){var user=$('#popupWindow_loginPrompt_username').val();var pass=$('#popupWindow_loginPrompt_password').val();var url=sslUrl+'Wcf/SSLAuth.aspx';$.ajax({dataType:'jsonp',data:'user='+encodeURIComponent(user)+'&pass='+encodeURIComponent(pass),jsonp:'callback',url:url,success:function(d,msg){userMgr.tryLoginCallback(d);},error:function(d,msg){$('#popupWindow_loginPrompt_response').text("SSL authentication failed, trying standard connection...");setTimeout('userMgr.tryLoginNonSecure()',1000)}});},sendEmailAuth:function(){var email=$('#popupWindow_loginPrompt_username').attr('value');specialtys.com.SDProxy.SendEmailVerification(email,function(){alert('A copy of the verification email has been sent to your email address. Please click the link shown in the email to complete registration.');popupWindowMgr.hide();});},tryLogin:function(){$('#popupWindow_loginPrompt_response').removeClass();$('#popupWindow_loginPrompt_response').addClass('toolTip');if(basePort=='80'||basePort=='443'){$('#popupWindow_loginPrompt_response').text("Verifying your identity using a secure connection, please wait...");userMgr.tryLoginSSL_IFrame();}
else{$('#popupWindow_loginPrompt_response').text("Verifying your identity in debug mode, please wait...");setTimeout('userMgr.tryLoginNonSecure()',500);}},tryLoginCallback:function(r){$('#popupWindow_loginPrompt_response').removeClass();$('#popupWindow_loginPrompt_response').addClass('toolTip');if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.OK){$('#popupWindow_loginPrompt_response').text("Login successful!");popupWindowMgr.hide();userMgr.triggerCallback();eventMgr.onlogin.triggerWithArg(r);if(typeof(ordersliderMgr)!="undefined")ordersliderMgr.proposalFeatureEnabled();}else if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.OKPasswordChangeRequired){if(typeof(ordersliderMgr)!="undefined")ordersliderMgr.proposalFeatureEnabled();userMgr.triggerCallback();eventMgr.onlogin.triggerWithArg(r);userMgr.changePasswordLogin();}else if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.Failed){if(userMgr.authCount>1){userMgr.authCount=0;$('#popupWindow_loginPrompt_response').text("Redirecting you to alternate login screen...");$('#popupWindow_loginPrompt_response').addClass('errorText');window.location=sslUrl+'Login.aspx';return;}
$('#popupWindow_loginPrompt_response').text("The details you provided were not correct. Please try again.");$('#popupWindow_loginPrompt_response').addClass('errorText');}else if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.FailedEmailVerificationRequired){$('#popupWindow_loginPrompt_response').text("Your email address had not been verified. Please verify your email address and try to login again.");$('#userServices-login-standardBtns').hide();$('#userServices-login-verifyBtns').show();$('#popupWindow_loginPrompt_username').attr('disabled',true);$('#popupWindow_loginPrompt_password').attr('disabled',true);$('#popupWindow_loginPrompt_response').addClass('errorText');}
$('#popupWindow_loginPrompt_password').val('');$('#popupWindow_loginPrompt_password').focus();},triggerCallback:function(){this.clearOnHideEvent();userMgr.failCallback=null;if(this.callback!=undefined&&this.callback!=null)this.callback.call(this);userMgr.callback=null;},triggerFailCallback:function(){this.clearOnHideEvent();userMgr.callback=null;if(this.failCallback!=undefined&&this.failCallback!=null)this.failCallback.call(this);userMgr.failCallback=null;},clearOnHideEvent:function(){if(this.onHideEventIndex!=null&&this.onHideEventIndex!=undefined)eventMgr.onpopupclose.remove(this.onHideEventIndex);},setupOnHideEvent:function(callback){if(this.onHideEventIndex!=null&&this.onHideEventIndex!=undefined)eventMgr.onpopupclose.remove(this.onHideEventIndex);this.onHideEventIndex=eventMgr.onpopupclose.add(callback);},tryRegister:function(){var email=$('#popupWindow_registerPrompt_email');var password=$('#popupWindow_registerPrompt_password');var passwordconfirm=$('#popupWindow_registerPrompt_passwordconfirm');var firstname=$('#popupWindow_registerPrompt_firstname');var lastname=$('#popupWindow_registerPrompt_lastname');var company=$('#popupWindow_registerPrompt_company');var phone=$('#popupWindow_registerPrompt_phone');var promocode=$('#popupWindow_registerPrompt_promocode');var errormessage=$('#popupWindow_registerPrompt_errormessage');errormessage.text('Please wait...');errormessage.removeClass('errorText')
if(email.val()==""){errormessage.text("Please ensure you entered a valid email address before continuing...");errormessage.addClass('errorText');email.focus();return;}
if(password.val()==""||password.val()!=passwordconfirm.val()){errormessage.text("Please ensure you provided a password and re-typed it correctly in the 'confirm' field before continuing...");errormessage.addClass('errorText');password.focus();return;}
if(firstname.val()==""){errormessage.text("Please enter a first name before continuing...");errormessage.addClass('errorText');firstname.focus();return;}
if(lastname.val()==""){errormessage.text("Please enter a last name before continuing...");errormessage.addClass('errorText');lastname.focus();return;}
if(phone.val()==""){errormessage.text("Please enter a phone number before continuing...");errormessage.addClass('errorText');lastname.focus();return;}
var url=sslUrl+'Wcf/SSLRegister.aspx';var qS='?email='+encodeURIComponent(email.val())
+'&password='+encodeURIComponent(password.val())
+'&firstname='+encodeURIComponent(firstname.val())
+'&lastname='+encodeURIComponent(lastname.val())
+'&company='+encodeURIComponent(company.val())
+'&phone='+encodeURIComponent(phone.val())
+'&promocode='+encodeURIComponent(promocode.val());var iFrm=$get('iframeHelperResult');$(iFrm).bind('load',function(){specialtys.com.SDProxy.GetAuthResponse(function(data){userMgr.tryRegisterCallback(data);});});iFrm.src=url+qS;},tryRegisterCallback:function(r){var errormessage=$('#popupWindow_registerPrompt_errormessage');if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.OK){eventMgr.onlogin.triggerWithArg(r);userMgr.triggerCallback();popupWindowMgr.hide();}else if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.AlreadyRegistered){errormessage.text("Oops! You have previously registered with our system using the email address entered.");errormessage.addClass('errorText');}else if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.Failed){errormessage.text("ERROR: Internal error, please try again shortly...");errormessage.addClass('errorText');}else if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.Failed){errormessage.text('ERROR: '+String(r.AuthResponseType));errormessage.addClass('errorText');}},requireHttp:function(onSuccess,onFailureUrl){if(sslEnabled!=true){if(onSuccess!=undefined&&onSuccess!=null)onSuccess.call(this);return true;}
else{if(onFailureUrl!=undefined&&onFailureUrl!=null){if(confirm('To follow this link this site we need to navigate away from the current page.  If you have not updated product quantities on this page, your changes may not be saved.  Are you sure you want to navigate away from this page?'))window.location.href=baseUrl+onFailureUrl;}
return false;}},requireHttps:function(onSuccess,onFailureUrl){if(sslEnabled==true){if(onSuccess!=undefined&&onSuccess!=null)onSuccess.call(this);return true;}
else{if(onFailureUrl!=undefined&&onFailureUrl!=null){if(confirm('To follow this link this site we need to navigate away from the current page.  If you have not updated product quantities on this page, your changes may not be saved.  Are you sure you want to navigate away from this page?'))window.location.href=sslUrl+onFailureUrl;}
return false;}},logout:function(){specialtys.com.SDProxy.Logout(function(){window.location='Default.aspx'});},checkout_checkcart:function(){lunchcartMgr.init(function(){if(lunchcartMgr.itemCount==0){jQuery.get('Templates/checkout-empty.htm','',function(data,textStatus){popupWindowMgr.showSmallWindow();popupWindowMgr.content(data);},'text');}else{setTimeout("window.location = 'Checkout.aspx'",100);}});},checkout:function(){if(userMgr.skipUpsell!=true){userMgr.skipUpsell=true;lunchcartMgr.showUpsellPage();}
else{userMgr.init(function(){if(userMgr.authenticated){userMgr.checkout_checkcart();}else{userMgr.login(function(){userMgr.checkout();});}});}},checkoutLite:function(){if(userMgr.skipUpsell!=true){userMgr.skipUpsell=true;lunchcartMgr.showUpsellPage();}
else{userMgr.init(function(){if(userMgr.authenticated){window.location='Checkout.aspx';}else{userMgr.login(function(){userMgr.checkoutLite();});}});}},checkoutproposal_checkcart:function(){lunchcartMgr.init(function(){if(lunchcartMgr.itemCount==0){jQuery.get('Templates/checkout-empty.htm','',function(data,textStatus){popupWindowMgr.showSmallWindow();popupWindowMgr.content(data);},'text');}else{window.location='CheckoutProposal.aspx';}});},checkoutproposal:function(){userMgr.init(function(){if(userMgr.authenticated&&userMgr.proposalFeatureEnabled){userMgr.checkoutproposal_checkcart();}else{userMgr.login(function(){userMgr.checkoutproposal();});}});},secure_page:function(fn){alert('secure_page(onSuccess) depreciated, use userMgr.requireLogin(onSuccess, onFailure) instead.');userMgr.init(function(){if(userMgr.authenticated){fn();}else{userMgr.login(function(){userMgr.secure_page(fn);});}});},tryChangePassword:function(){var responseMessage=$('#popupWindow_passwordchangePrompt_response');var oldpassword=$('#popupWindow_passwordchangePrompt_password');var newpassword=$('#popupWindow_passwordchangePrompt_new_password');var newpasswordconfirm=$('#popupWindow_passwordchangePrompt_new_password_confirm');if(oldpassword.val()==""){responseMessage.addClass('errorText');responseMessage.text('Oops! Your old password was not entered.');oldpassword.focus();return false;}
if(newpassword.val()==""||newpasswordconfirm.val()==""){responseMessage.addClass('errorText');responseMessage.text('Oops! Your new password cannot be blank.');newpassword.focus();return false;}
if(newpassword.val()!=newpasswordconfirm.val()){responseMessage.addClass('errorText');responseMessage.text('Oops! The "new password" and confirm fields did not match. Please re-enter your new password and confirm it.');newpassword.focus();return false;}
responseMessage.removeClass('errorText');responseMessage.text("Verifying, please wait...");specialtys.com.SDProxy.ChangeProfilePassword(oldpassword.val(),newpassword.val(),newpasswordconfirm.val(),userMgr.tryChangePasswordCallback,null,null);},clearcart:function(){jQuery.get('Templates/default-master-empty-cart.htm','',function(data,textStatus){$("#hdrLunchcartP").html(data);$('#lunchcart-header-checkoutBtn').removeClass('btnOrange');$('#lunchcart-header-checkoutBtn').addClass('btnDisabled');},'text');},changePassword:function(){userMgr.requireLogin(userMgr.changePasswordCallback,null);},tryChangePasswordCallback:function(r){var responseMessage=$('#popupWindow_passwordchangePrompt_response');switch(r){case Specialtys.Core.SpecialtysDirect.ChangePasswordResponse.InvalidResponse:responseMessage.addClass('errorText');responseMessage.text("An internal error occured, please try again.");break;case Specialtys.Core.SpecialtysDirect.ChangePasswordResponse.OK:responseMessage.removeClass('errorText');responseMessage.addClass('successText');responseMessage.text("Your password has been changed!");$('#userServicesChangePasswordOkBtn').show();$('#userServicesChangePasswordChangeBtn').hide();$('#userServicesChangePasswordCancelBtn').hide();break;case Specialtys.Core.SpecialtysDirect.ChangePasswordResponse.PasswordDoesNotMatch:responseMessage.addClass('errorText');responseMessage.text("Your new password must match the confirmed password.");break;case Specialtys.Core.SpecialtysDirect.ChangePasswordResponse.PasswordBlank:responseMessage.addClass('errorText');responseMessage.text("Your blank passwords are not allowed");break;case Specialtys.Core.SpecialtysDirect.ChangePasswordResponse.PasswordIncorrect:responseMessage.addClass('errorText');responseMessage.text("Your old password is incorrect");break;default:responseMessage.addClass('errorText');responseMessage.text("An internal error has occurred, please try again (invalid response).");break;}},addBillingAddress:function(){userMgr.secure_page(userMgr.addBillingAddressCallback);},updateBillingAddress:function(addressId){userMgr.secure_page(userMgr.updateBillingAddressCallback(addressId));},addBillingAddressCallback:function(){jQuery.get('Templates/userservices-bill-address.htm','',function(data,textStatus){data=data.replace("{header}","Add Billing Address");data=data.replace("{action-onsubmit}","userMgr.tryAddBillingAddress();");data=data.replace("{action-onclick}","userMgr.tryAddBillingAddress();");data=data.replace("{action-name}","Add");data=userMgr.clearBillAddressData(data)
popupWindowMgr.content(data);popupWindowMgr.showLargeWindow();},'text');},loadBillingAddressTemplate:function(addr){jQuery.get('Templates/userservices-bill-address.htm','',function(data,textStatus){data=data.replace("{header}","Edit Billing Address");data=data.replace("{action-onsubmit}","userMgr.tryUpdateBillingAddress();");data=data.replace("{action-onclick}","userMgr.tryUpdateBillingAddress();");data=data.replace("{action-name}","Edit");data=userMgr.bindBillAddressData(data,addr)
popupWindowMgr.content(data);popupWindowMgr.showLargeWindow();},'text');},updateBillingAddressCallback:function(addressId){specialtys.com.SDProxy.GetBillingAddress(addressId,userMgr.loadBillingAddressTemplate,null,null);},tryAddBillingAddress:function(){var ms=$("#popupWindow_billAddressPrompt_errormessage");var id=$("#popupWindow_billAddressPrompt_address_id");var fn=$("#popupWindow_billAddressPrompt_firstname");var ln=$("#popupWindow_billAddressPrompt_lastname");var em=$("#popupWindow_billAddressPrompt_email");var ph=$("#popupWindow_billAddressPrompt_phone");var px=$("#popupWindow_billAddressPrompt_phoneExt");var cm=$("#popupWindow_billAddressPrompt_company");var st=$("#popupWindow_billAddressPrompt_street_address");var su=$("#popupWindow_billAddressPrompt_suite");var fl=$("#popupWindow_billAddressPrompt_floor");var ci=$("#popupWindow_billAddressPrompt_city");var sta=$("#popupWindow_billAddressPrompt_state");var zi=$("#popupWindow_billAddressPrompt_zipcode");if(st.val()==""||ci.val()==""||st.val()==""||zi.val==""){ms.text("Street, city, state and zip code are required fields");ms.removeClass("hide");return false;}
if(em.val()!=""){if(!validateEmail(em.val())){ms.text("email address is an invalid format");ms.removeClass("hide");return false;}}
specialtys.com.SDProxy.AddBillingAddress(fn.val(),ln.val(),em.val(),ph.val(),px.val(),cm.val(),st.val(),fl.val(),su.val(),ci.val(),sta.val(),zi.val(),function(){window.location='profile.aspx?view=bill';},null,null);},tryUpdateBillingAddress:function(){var lc=$("#popupWindow_billAddressPrompt_linkedCC");var lt=$("#popupWindow_billAddressPrompt_linkedTA");var ms=$("#popupWindow_billAddressPrompt_errormessage");var id=$("#popupWindow_billAddressPrompt_address_id");var fn=$("#popupWindow_billAddressPrompt_firstname");var ln=$("#popupWindow_billAddressPrompt_lastname");var em=$("#popupWindow_billAddressPrompt_email");var ph=$("#popupWindow_billAddressPrompt_phone");var px=$("#popupWindow_billAddressPrompt_phoneExt");var cm=$("#popupWindow_billAddressPrompt_company");var st=$("#popupWindow_billAddressPrompt_street_address");var su=$("#popupWindow_billAddressPrompt_suite");var fl=$("#popupWindow_billAddressPrompt_floor");var ci=$("#popupWindow_billAddressPrompt_city");var sta=$("#popupWindow_billAddressPrompt_state");var zi=$("#popupWindow_billAddressPrompt_zipcode");if(st.val()==""||ci.val()==""||st.val()==""||zi.val==""){ms.text("Street, city, state and zip code are required fields");ms.removeClass("hide");return false;}
if(em.val()!=""){if(!validateEmail(em.val())){ms.text("email address is an invalid format");ms.removeClass("hide");return false;}}
if(lt.val()=="true"&&cm.val()==""){ms.text("Company is required since this bill address is linked to a term account");ms.removeClass("hide");return false;}
specialtys.com.SDProxy.UpdateBillingAddress(parseInt(id.val()),fn.val(),ln.val(),em.val(),ph.val(),px.val(),cm.val(),st.val(),fl.val(),su.val(),ci.val(),sta.val(),zi.val(),function(){window.location='profile.aspx?view=bill';},null,null);},clearBillAddressData:function(d){d=d.replace("{addressid}","");d=d.replace("{first-name}","");d=d.replace("{last-name}","");d=d.replace("{email}","");d=d.replace("{phone}","");d=d.replace("{phone-ext}","");d=d.replace("{company}","");d=d.replace("{street-address}","");d=d.replace("{suite}","");d=d.replace("{floor}","");d=d.replace("{city}","");d=d.replace("{state}","");d=d.replace("{zip}","");d=d.replace("{linkedCC}","");d=d.replace("{linkedTA}","");return d;},bindBillAddressData:function(d,o){d=d.replace("{addressid}",o.AddressId);d=d.replace("{first-name}",o.ContactFirstName);d=d.replace("{last-name}",o.ConactLastName);d=d.replace("{email}",o.ContactEmail);d=d.replace("{phone}",o.Telephone);d=d.replace("{phone-ext}",o.TelephoneExt);d=d.replace("{company}",o.ContactCompany);d=d.replace("{street-address}",o.StreetAddress);d=d.replace("{suite}",o.Suite);d=d.replace("{floor}",o.Floor);d=d.replace("{city}",o.City);d=d.replace("{state}",o.State);d=d.replace("{zip}",o.ZipCode);d=d.replace("{linkedCC}",o.LinkedCC);d=d.replace("{linkedTA}",o.LinkedTermAccount);return d;},trySendTermAccountCreditIncrease:function(id){specialtys.com.SDProxy.RequestTermAccountIncrease(id,function(){popupWindowMgr.hide();},null,null);},sendTermAccountCreditIncrease:function(id){jQuery.get('Templates/yesno-confirmation.htm','',function(data,textStatus){data=data.replace("{headerMessage}","Do you want to send a request to increase your limit");data=data.replace("{action-onclick}","userMgr.trySendTermAccountCreditIncrease("+id+");");popupWindowMgr.content(data);popupWindowMgr.showLargeWindow();},'text');},trySendTermAccountStatement:function(id){specialtys.com.SDProxy.SendTermAccountStatement(id,function(r){if(r==false){$("#popupWindow_ConfirmationPrompt_header").text("You do not have access to this account. Please try your request again");}else{popupWindowMgr.hide();}},null,null);},sendTermAccountStatment:function(id){jQuery.get('Templates/yesno-confirmation.htm','',function(data,textStatus){data=data.replace("{headerMessage}","Do you want request a statment");data=data.replace("{action-onclick}","userMgr.trySendTermAccountStatement("+id+");");popupWindowMgr.content(data);popupWindowMgr.showLargeWindow();},'text');},tryAccountAdd:function(sendToAdd){var ms=$("#popupWindow_addAccountPrompt_response");var nm=$("#popupWindow_addAccountPrompt_name");if(nm.val()==""){ms.addClass('toolTip errorText');ms.text("Account name is required");return false;}
specialtys.com.SDProxy.CreatePrepaidAccount(nm.val(),function(id){if(id==0){ms.addClass('toolTip errorText');ms.text("Your account was not created please try again");}
else{window.location=((sendToAdd==true)?'ProfileAccounts.aspx?command=reloadaccount&account_id='+id:'ProfileAccounts.aspx?view=Prepaid');}},null,null);},addAccount:function(){jQuery.get('Templates/userservices-add-account.htm','',function(data,textStatus){popupWindowMgr.showSmallWindow();popupWindowMgr.content(data);$('#popupWindow_addAccountPrompt_name').focus();},'text');},tryAddGiftCard:function(){var ms=$("#popupWindow_addGiftCardPrompt_response");var nu=$("#popupWindow_addGiftCardPrompt_number");var cd=$("#popupWindow_addGiftCardPrompt_code");var nm=$("#popupWindow_addGiftCardPrompt_name");if(nu.val()==""||cd.val()==""){ms.text("ERROR: Card number and security code required.");ms.addClass('toolTip');ms.addClass('errorText');return false;}
specialtys.com.SDProxy.CreateGiftCard(nu.val(),cd.val(),nm.val(),function(id){if(id<=0){ms.text("ERROR: Your gift card was not saved. Please check your card details entered and try again.");ms.addClass('toolTip');ms.addClass('errorText');}else{window.location='ProfileAccounts.aspx?view=GiftCards';}},null,null);},addGiftCard:function(){jQuery.get('Templates/userservices-add-giftcard.htm','',function(data,textStatus){popupWindowMgr.showMediumWindow();popupWindowMgr.content(data);$('#popupWindow_addAccountPrompt_name').focus();},'text');},tryAddLocation:function(){},addLocation:function(){alert("Comming soon");},tryEditLocation:function(){},editLocation:function(id){alert("Coming soon id:"+id.toString());},tryRequestInvoice:function(){var ms=$("#popupWindow_invoiceRequestPrompt_errormessage");var id=$("#popupWindow_invoiceRequestPrompt_lunchbox_id");var em=$("#popupWindow_invoiceRequestPrompt_email");if(id.val()==""){ms.text("An internal error has occurred prior to your request. Please close down this window and try it again.");ms.addClass("errorText");return false;}
if(em.val()==""){ms.text("Email address cannot be blank.");ms.addClass("errorText toolTip");return false;}else{if(!validateEmail(em.val())){ms.text("Email address is an invalid format.");ms.addClass("errorText toolTip");return false;}}
specialtys.com.SDProxy.RequestInvoice(id.val(),em.val(),function(success){if(success){popupWindowMgr.hide();}else{ms.text("An error has occurred, please check your email address and try again.");ms.addClass("errorText toolTip");}},null,null);},requestInvoice:function(id){jQuery.get('Templates/userservices-request-invoice.htm','',function(data,textStatus){data=data.replace("{lunchbox_id}",id);popupWindowMgr.content(data);popupWindowMgr.showSmallWindow();},'text');},changeRequestDateTimeCallBack:function(dtsel,id){$("#popupWindow_changeDatePrompt_DateSelector").append('<option value=""></option>');for(var i=0;i<dtsel.length;i++)if(dtsel[i].IsOpen)$("#popupWindow_changeDatePrompt_DateSelector").append('<option value="'+dtsel[i].DateValue+'">'+dtsel[i].FriendlyDateDescription+'</option>');$("#popupWindow_changeDatePrompt_TimeSelector").append('<option value="">-- no times available for this day --</option>');},changeRequestDateTime:function(id){jQuery.get('Templates/userservices-change-request-date.htm','',function(data,textStatus){data=data.replace("{lunchbox_id}",id);popupWindowMgr.content(data);popupWindowMgr.showSmallWindow();},'text');specialtys.com.SDProxy.LoadStoreOpenDatesByLunchbox(id,userMgr.changeRequestDateTimeCallBack,null,id);},changeRequestDateTime_DateSelectorCallBack:function(tm){$("#popupWindow_changeDatePrompt_TimeSelector").children("option").each(function(){$(this).remove();});for(var i=0;i<tm.length;i++){$("#popupWindow_changeDatePrompt_TimeSelector").append('<option value="'+tm[i].WindowStartMins+'">'+tm[i].FriendlyTimeSlotDescription+'</option>');}
if($("#popupWindow_changeDatePrompt_TimeSelector").children().length==0)$("#popupWindow_changeDatePrompt_TimeSelector").append('<option value="">-- no times available for this day --</option>');},changeRequestDateTime_DateSelector:function(){var id=$("#popupWindow_changeDatePrompt_lunchbox_id");var dt=$("#popupWindow_changeDatePrompt_DateSelector");if(dt.val()!=""){specialtys.com.SDProxy.LoadLunchboxTimes(id.val(),dt.val(),userMgr.changeRequestDateTime_DateSelectorCallBack,null,null);}},tryChangeRequestDateTimeCallBack:function(r){var ms=$("#popupWindow_changeDatePrompt_errormessage");switch(r){case-2:ms.text("You do not have access to this feature please login again");ms.removeClass("hide");break;case-1:ms.text("An internal error has occurred please try again");ms.removeClass("hide");break;case 0:popupWindowMgr.hide();window.location='ProfileOrders.aspx?view=Open';break;case 666:ms.text("Date and time not updated");break;case 667:ms.text("Your order has already printed in our store please contact customer service");break;}},tryEmailReminderCallback:function(r){var ms=$("#popupWindow_loginPrompt_response");if(r){ms.text("An email containing instructions on how to reset your password has been send to your email address.");$("#popupWindow_loginPrompt_email_reminder").attr('disabled','disabled');$('#resetPasswordBtn').addClass('hide');$('#okPasswordBtn').removeClass('hide');}else{ms.text("The email address you entered is not registered with SpecialtysDirect.com.");}},tryEmailReminder:function(){var em=$("#popupWindow_loginPrompt_email_reminder");if(em.val()!=""){specialtys.com.SDProxy.SendTemporaryPassword(em.val(),userMgr.tryEmailReminderCallback,null,null);}},tryChangeRequestDateTime:function(){var id=$("#popupWindow_changeDatePrompt_lunchbox_id");var dt=$("#popupWindow_changeDatePrompt_DateSelector");var tm=$("#popupWindow_changeDatePrompt_TimeSelector");if(dt.val()!=""&&tm.val()!=""&&id.val()!=""){specialtys.com.SDProxy.SetLunchboxTime(id.val(),dt.val(),tm.val(),userMgr.tryChangeRequestDateTimeCallBack,null,null);}},deleteLunchcart:function(lunchcartId,callback){specialtys.com.SDProxy.DeleteLunchcart(lunchcartId,function(){if(callback!=null&&callback!=undefined)callback.call(this);});},copyLunchbox:function(lunchboxId,callback){specialtys.com.SDProxy.CopyLunchbox(lunchboxId,function(){if(callback!=null&&callback!=undefined)callback.call(this);});},resumeLunchcart:function(lunchcartId,callback){specialtys.com.SDProxy.ResumeLunchcart(lunchcartId,function(){if(callback!=null&&callback!=undefined)callback.call(this);});},addProductToFavs:function(pId,callback){specialtys.com.SDProxy.AddFavoriteProduct(pId,function(){if(callback!=null&&callback!=undefined)callback.call(this);});},showBetaMsg:function(){jQuery.get('Templates/beta-intro.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showMediumWindow();},'text');},showFeedbackForm:function(){jQuery.get('Templates/userservices-feedback-0.1.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showLargeWindow();},'text');},sendFeedback:function(){var name=$('#userServices-feedback-name').attr('value');var email=$('#userServices-feedback-email').attr('value');var type=$('#userServices-feedback-type').attr('value');var subject=$('#userServices-feedback-subject').attr('value');var comments=$('#userServices-feedback-comments').attr('value');var dataOk=true;if(email==''){$('#intro').text('Oops! The "name" field is required for feedback.').addClass('errorText');dataOk=false;}
if(name==''){$('#intro').text('Oops! The "name" field is required for feedback.').addClass('errorText');dataOk=false;}
if(type==''){$('#intro').text('Oops! The "feedback type" option must be specified.').addClass('errorText');dataOk=false;}
if(subject==''){$('#intro').text('Oops! The "subject" field is required for feedback.').addClass('errorText');dataOk=false;}
if(comments==''){$('#intro').text('Oops! The "comments" field is required for feedback.').addClass('errorText');dataOk=false;}
if(dataOk){specialtys.com.SDProxy.SendFeedback(name,email,type,subject,comments,function(){$('#userServices-feedback-form').hide();$('#userServices-feedback-response').show();});}}}
﻿
var productMgr={windowMgr:null,productId:0,product:null,checkoutEventRef:null,setup:function(winMgr){this.windowMgr=winMgr;},getProductType:function(p){var pT=p.ProductTypeId;if(pT==100||pT==101)return'Sandwich';if(pT==110||pT==111)return'Salad';if(pT==115||pT==116)return'Salad';if(pT==152||pT==153)return'Breakfast Sandwich';return'Item';},getEmailSubject:function(p){return encodeURI('Specialty\'s '+productMgr.getProductType(p)+': "'+p.Name+'"');},getEmailBody:function(p){return encodeURI('I wanted to share this '+productMgr.getProductType(p).toLowerCase()+' with you: '+baseUrl+'Product.aspx?p='+p.ProductRelationHash+'\n\n--- \n\n"'+p.Name+'"\n'+p.Description);},showRename:function(pId){gaMgr.track('Rename Product Window','Open Window');jQuery.get('Templates/productservices-rename.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showSmallWindow();specialtys.com.SDProxy.LoadProduct(pId,function(data){productMgr.renderRename(data);});},'text');},renderRename:function(prod){this.product=prod;$('#productServices-rename-oldName').attr('value',prod.Name);$('#productServices-rename-newName').attr('value',prod.Name);$get('productServices-rename-newName').focus();},renameProduct:function(){var oldName=$('#productServices-rename-oldName').attr('value');var newName=$('#productServices-rename-newName').attr('value');if(oldName==newName){popupWindowMgr.hide();}else{this.product.Name=newName;specialtys.com.SDProxy.RenameProduct(this.product,function(){gaMgr.track('Rename Product Window','Success');popupWindowMgr.hide();eventMgr.onloadcart.trigger();});}},showFavorites:function(){gaMgr.track('My Favorites Window','Open Window');jQuery.get('Templates/productservices-favorites.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showLargeWindow();favMgr.initFavorites();},'text');},showFriendsFavorites:function(){gaMgr.track('Friend\'s Favorites Window','Open Window');fbMgr.isConnected(function(){jQuery.get('Templates/productservices-favorites.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showLargeWindow();favMgr.initFriendsFavorites();},'text');});},addFavoriteToCart:function(pid,qty){eventMgr.onaddtocart.add(function(){$("#favorite-checkoutBtn").removeClass();$("#favorite-checkoutBtn").addClass("btnTextLg btnOrangeLg ");});lunchcartMgr.addToCart(pid,qty);},showInfo:function(prodId){gaMgr.track('Product Info Window','Open Window');productMgr.productId=prodId;jQuery.get('Templates/productservices-info.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showMediumWindow();specialtys.com.SDProxy.LoadProduct(productMgr.productId,productMgr.renderInfo);},'text');},showEditor:function(prodId,sourceId){gaMgr.track('Product Editor Window','Open Window');depMgr.load('JScript/productservices-editor-0.0.js');productMgr.productId=prodId;jQuery.get('Templates/productservices-editor.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showLargeWindow();productMgr.paletteMenuMgr=new AccordionMenu('productServices-editor-palette');productEditorMgr.init(productMgr.productId,sourceId);},'text');},renderInfo:function(product){var p=product;productMgr.product=product;$('#productServices-info-bg').css('background-image','url(Images/ProdImg/'+p.ImageId+'_0215_c.jpg)');$('#productServices-info-name').text(p.Name);$('#productServices-info-link').attr('href','Product.aspx?p='+p.ProductRelationHash);$('#productServices-info-sublink').attr('href','Product.aspx?p='+p.ProductRelationHash);$('#productServices-info-sublink').text('http://www.specialtys.com/Product.aspx?p='+p.ProductRelationHash);$('#productServices-info-descHdr').html('Description');$('#productServices-info-desc').text(p.Description);if(p.FriendlyIngredientDescriptionHtml!=''){$('#productServices-info-descHdr').html('Ingredients');$('#productServices-info-desc').html(p.FriendlyIngredientDescriptionHtml);}
if(p.ShowNutrition==true){$('#productServices-info-fatGrams').text(p.FatGrams.toFixed(0)+'g');$('#productServices-info-fiberGrams').text(p.FiberGrams.toFixed(0)+'g');$('#productServices-info-calories').text(p.Calories.toFixed(0));$('#productServices-info-saturatedFatGrams').text(p.SaturatedFatGrams.toFixed(0)+'g');$('#productServices-info-transFatGrams').text(p.TransFatGrams.toFixed(0)+'g');$('#productServices-info-cholesterol').text(p.Cholesterol.toFixed(0)+'mg');$('#productServices-info-sodium').text(p.Sodium.toFixed(0)+'mg');$('#productServices-info-carbohydrates').text(p.Carbohydrates.toFixed(0)+'g');$('#productServices-info-sugarGrams').text(p.SugarGrams.toFixed(0)+'g');$('#productServices-info-proteinGrams').text(p.ProteinGrams.toFixed(0)+'g');if(productMgr.isSalad(p.ProductTypeId)==true){$('#productServices-info-nutritionSection-hdr').html('Nutritional Info*');$('#productServices-info-nutritionSection-footnote').html('* salad dressing is excluded from nutrition summary');$('#productServices-info-nutritionSection-footnote').show();}}else{$('#productServices-info-bg').css('background-image','url(Images/ProdImg/0_0215_c.jpg)');$('#productServices-info-nutritionSection').hide();$('#productServices-info-desc').removeClass('small');}
$('#productServices-info-btnShareEmail').attr('href','mailto:?subject='+productMgr.getEmailSubject(p)+'&body='+productMgr.getEmailBody(p));$('#productServices-info-btnShareEmail').click(function(){gaMgr.track('Product Info Window','Share via Email');});$('#productServices-info-btnShareFb').attr('href','javascript:userMgr.requireCustomerId(function() { fbMgr.isConnectedVerified(function() { fbMgr.shareProduct(\''+p.ProductRelationHash+'\'); }); })');$('#productServices-info-btnShareFb').click(function(){gaMgr.track('Product Info Window','Share via Facebook');});$('#productServices-info-btnShareTwitter').attr('href','javascript:userMgr.requireCustomerId(function() { twitMgr.isConnected(function() { twitMgr.shareProduct(\''+p.ProductRelationHash+'\'); }); })');$('#productServices-info-btnShareTwitter').click(function(){gaMgr.track('Product Info Window','Share via Twitter');});$('#productServices-info-inputShareUrl').attr('value',baseUrl+'Product.aspx?p='+p.ProductRelationHash);$get('productServices-info-btnFavorite').onclick=function(){userMgr.initFromCookie();if(userMgr.customerId>0){specialtys.com.SDProxy.AddFavoriteProduct(productMgr.productId,function(){alert('Item added to my favorites.');productMgr.showFavorites();});}else{userMgr.requireCustomerId(function(){specialtys.com.SDProxy.AddFavoriteProduct(productMgr.productId,function(){productMgr.showInfo(productMgr.productId);setTimeout('alert(\'Item was successfully saved to my favorites.\')',250);});},function(){productMgr.showInfo(productMgr.productId);});}}
if(product.IsReadOnly!=true){$get('productServices-info-btnEdit').onclick=function(){productMgr.showEditor(productMgr.productId);};$('#productServices-info-btnEditDiv').addClass('btnLModLg');$('#productServices-info-btnAddToOrderDiv').addClass('btnRModLg');}
else{$('#productServices-info-btnEditDiv').hide();}
$get('productServices-info-btnAddToOrder').onclick=function(){lunchcartMgr.addToCart(productMgr.productId,1);};},deleteFavorite:function(productId){specialtys.com.SDProxy.DeleteFavoriteProduct(productId);$('#listGalleryFavoritesItem_'+productId).fadeOut('fast');},addFavorite:function(productId,callback){specialtys.com.SDProxy.AddFavoriteProduct(productId,function(){if(callback!=undefined&&callback!=null)callback.call(this);});},isSalad:function(p){if(p==110||p==111||p==115||p==116)return true;return false;}}
var favMgr={favList:null,fbList:null,setButtonSelected:function(index){var a=['#productServices-favorites-tabList-favorites','#productServices-favorites-tabList-friendsFavorites'];$(a[0]).removeClass('selected');$(a[1]).removeClass('selected');$(a[index]).addClass('selected');$('#productServices-favorites-connect').hide();$('#productServices-favorites-ul').show();},filterFavList:function(uid){var fL=new Array();for(var i=0;i<favMgr.favList.length;i++){if(favMgr.favList[i].FacebookUid==uid)fL.push(favMgr.favList[i]);}
return fL;},showLoading:function(){var html='<p class="toolTip successText">loading, please wait...</p>';$('#productServices-favorites-ul').html('<li class="blank">'+html+'</li>');$('#productServices-friendsFavorites-wrapper').html(html);},initFriendsFavorites:function(){this.setButtonSelected(1);$('#productServices-favorites-wrapper').hide();$('#productServices-friendsFavorites-wrapper').show();this.showLoading();specialtys.com.SDProxy.LoadFacebookFriends(function(data){if(data!=null){favMgr.fbList=data;favMgr.initFriendsFavoritesB();}});},initFriendsFavoritesB:function(){this.showLoading();specialtys.com.SDProxy.LoadFriendsFavorites(function(data){favMgr.favList=data;favMgr.renderFriendsFavorites();});},initFavorites:function(){this.setButtonSelected(0);$('#productServices-friendsFavorites-wrapper').hide();$('#productServices-favorites-wrapper').show();this.showLoading();specialtys.com.SDProxy.LoadFavorites(function(data){favMgr.favList=data;favMgr.renderFavorites();});},renderFriendsFavorites:function(){var divFF=$('#productServices-friendsFavorites-wrapper');var html='';divFF.html(html);html+='<div id="ffAccordion" class="accordionMenu">';var pList;for(var j=0;j<this.fbList.length;j++){var u=this.fbList[j];html+='<h3 class="accordionMenuHeader accordionExpandable accordionFbUserHeader"><a target="ffav_'+u.Uid+'" href="#"><img src="'+((u.PicSquareUrl=='')?'Images/q_silhouette.gif':u.PicSquareUrl)+'" alt="" /><span class="text">'+u.Name+'</span> <span class="arrow">&nbsp;</span></a></h3>';html+='<ul class="accordionCategoryItem" id="ffav_'+u.Uid+'"><li>';html+='<ul class="favoritesList">';pList=this.filterFavList(u.Uid);for(var i=0;i<pList.length;i++){var p=pList[i];html+='<li id="listGalleryFavoritesItem_'+p.ProductId+'">';html+='<div class="leftCol">';html+='<span class="btnText btnGreen"><a href="#" onclick="gaMgr.track(\'Friend\\\'s Favorites Window\', \'Add To Order\'); productMgr.addFavoriteToCart('+p.ProductId+', 1); return false;"><span>add to order</span></a></span>';html+='</div>';html+='<div class="leftCol"></div>';html+='<div class="midCol"><h4>';if(p.IsReadOnly==false)html+='<a title="click for more detailed info about this item" href="'+baseUrl+'Favorite.aspx?f='+p.FavoriteHash+'" onclick="gaMgr.track(\'Friend\\\'s Favorites Window\', \'More Info\');">';html+=p.Name;if(p.IsReadOnly==false)html+='</a>';html+='<small> - $'+p.Price.toFixed(2)+'</small>';if(p.IsReadOnly==false)html+='&nbsp;&nbsp;<span class="btnTextSml btnDkGreenSml"><a href="#" onclick="gaMgr.track(\'Friend\\\'s Favorites Window\', \'Open in Editor\'); productMgr.showEditor('+p.ProductId+'); return false;"><span>edit / customize</span></a></span>';html+='</h4><p class="productDescription">'+p.FriendlyIngredientDescriptionHtml+'</p>';html+='</div>';html+='<div class="rightCol">';if(p.IsReadOnly==false)html+='<span class="btnTextSml"><a href="'+baseUrl+'Favorite.aspx?f='+p.FavoriteHash+'" onclick="gaMgr.track(\'Friend\\\'s Favorites Window\', \'More Info\');"><span>more info</span></a></span>';html+='</div>'
html+='</li>';}
html+='</ul>';html+='</li></ul>';}
html+='</div>';divFF.html(html);var ffA=new AccordionMenu('ffAccordion');},getEmailSubject:function(p){return encodeURI('Specialty\'s Favorite '+productMgr.getProductType(p)+': "'+p.Name+'"');},getEmailBody:function(p){return encodeURI('I wanted to share this '+productMgr.getProductType(p).toLowerCase()+' with you: '+baseUrl+'Favorite.aspx?f='+p.FavoriteHash+'\n\n--- \n\n"'+p.Name+'"\n'+p.FriendlyIngredientDescription);},renderFavorites:function(){var pList=favMgr.favList;var ul=$('#productServices-favorites-ul');var html='';ul.html(html);for(var i=0;i<pList.length;i++){var p=pList[i];html+='<li id="listGalleryFavoritesItem_'+p.ProductId+'">';html+='<div class="leftCol">';html+='<span class="btnText btnGreen"><a href="#" onclick="productMgr.addFavoriteToCart('+p.ProductId+', 1); gaMgr.track(\'My Favorites Window\', \'Add To Order\'); return false;"><span>add to order</span></a></span>';html+='</div>';html+='<div class="midCol"><h4>';if(p.IsReadOnly==false)html+='<a title="click for more detailed info about this item" href="'+baseUrl+'Favorite.aspx?f='+p.FavoriteHash+'">';html+=p.Name;if(p.IsReadOnly==false)html+='</a>';html+='<small> - $'+p.Price.toFixed(2)+'</small>';if(p.IsReadOnly==false)html+='&nbsp;&nbsp;<span class="btnTextSml btnDkGreenSml"><a href="#" onclick="productMgr.showEditor('+p.ProductId+'); return false;"><span>edit / customize</span></a></span>';html+='&nbsp;<span class="btnTextSml btnDeleteSmlAlt"><a href="#" onclick="productMgr.deleteFavorite('+p.ProductId+'); return false;"><span>delete</span></a></span>';html+='</h4><p class="productDescription">'+p.FriendlyIngredientDescriptionHtml+'</p>';html+='</div>'
html+='<div class="rightCol">';if(p.IsReadOnly==false){html+='<div class="shareButtons">';html+='<span class="btnShareEmail"><a title="share via email" href="mailto:?subject='+favMgr.getEmailSubject(p)+'&body='+favMgr.getEmailBody(p)+'" onclick="gaMgr.track(\'My Favorites Window\', \'Share via Email\');"><span>&nbsp;</span></a></span>';html+='<span class="btnShareFb"><a title="share via facebook" href="javascript:void(0)" onclick="gaMgr.track(\'My Favorites Window\', \'Share via Facebook\'); fbMgr.isConnectedVerified(function() { fbMgr.shareFavorite(\''+p.FavoriteHash+'\'); });"><span>&nbsp;</span></a></span>';html+='<span class="btnShareTwitter"><a title="share via twitter" href="javascript:void(0)" onclick="gaMgr.track(\'My Favorites Window\', \'Share via Twitter\'); twitMgr.isConnected(function() {  twitMgr.shareFavorite(\''+p.FavoriteHash+'\'); });"><span>&nbsp;</span></a></span>';html+='<div><input type="text" onclick="this.select();" size="10" id="" value="'+baseUrl+'Favorite.aspx?f='+p.FavoriteHash+'" /></div>'
html+='</div>';}
html+='</div>'
html+='</li>';}
ul.html(html);}}﻿
var lunchcartMgr={customerId:0,lunchcartId:null,cellId:null,dateRequested:null,pickupFlag:null,itemCount:0,itemList:new Array(),isGroupLunchcart:false,isGrouplunchcartObject:false,dateDeadline:null,budget:null,init:function(callback){specialtys.com.SDProxy.LoadLunchcart(function(lc){lunchcartMgr.initCallback(lc,callback);},null,null);},initCallback:function(lc,callback){lunchcartMgr.customerId=lc.CustomerId;lunchcartMgr.lunchcartId=lc.LunchcartId;lunchcartMgr.cellId=lc.CellId;lunchcartMgr.dateRequested=lc.DateRequested;lunchcartMgr.pickupFlag=lc.PickupFlag;lunchcartMgr.itemCount=lc.ItemCount;lunchcartMgr.isGroupLunchcart=lc.IsGroupLunchcart;lunchcartMgr.isGrouplunchcartObject=lc.IsGroupLunchcartObject;lunchcartMgr.dateDeadline=lc.DateDeadline;lunchcartMgr.budget=lc.Budget;eventMgr.onloadcart.trigger();if(callback!=undefined&&callback!=null)callback.call(this);},showExpressCheckout:function(){userMgr.requireLogin(function(){lunchcartMgr.init(function(){if(lunchcartMgr.itemCount>0){if(confirm('Warning: Upon opening the Express Checkout, your current order will be moved to your list of unfinished orders. Are you sure you want to continue?'))window.location='ExpressCheckout.aspx';}else{window.location='ExpressCheckout.aspx';}});});},addToCart:function(pId,qtyToAdd,callback){var cb=callback;specialtys.com.SDProxy.AddProductToLunchcart(pId,qtyToAdd,function(p,q){eventMgr.onaddtocart.triggerWithArgs(p,q);if(cb!=undefined&&cb!=null)cb.call(this);},null,{Quantity:qtyToAdd});},removeFromCart:function(pid,productPrice){specialtys.com.SDProxy.DeleteProductFromLunchcart(pid,function(q,p){eventMgr.onremovefromcart.triggerWithArgs(q,p)},null,{ProductId:pid,Price:productPrice});},updateCart:function(items){specialtys.com.SDProxy.UpdateProductsInLunchcart(items,function(s,p){eventMgr.onupdateqtyincart.triggerWithArgs(s,p)},null,items);},updateCartEdit:function(items){specialtys.com.SDProxy.UpdateProductsInLunchcartEdit(items,function(s,p){eventMgr.onupdateqtyincart.triggerWithArgs(s,p)},null,items);},setPickupLocation:function(bId){specialtys.com.SDProxy.SetPickupLocation(bId,function(){eventMgr.onlocationchange.trigger();},null,null);},setDeliveryLocation:function(aId){specialtys.com.SDProxy.SetDeliveryLocation(aId,function(){eventMgr.onlocationchange.trigger();},null,null);},confirmLocation:function(){specialtys.com.SDProxy.ConfirmLocation();},setDateRequested:function(dtSel,offset){specialtys.com.SDProxy.SetDateRequested(new Date(dtSel),parseInt(offset),function(){eventMgr.onselecteddatechange.trigger();},null,null);},showUpsellPage:function(){depMgr.load('JScript/lunchcartservices-upsell-0.0.js');jQuery.get('Templates/lunchcartservices-upsell.htm','',function(data,textStatus){popupWindowMgr.showLargeWindow();popupWindowMgr.content(data);upsellMgr.init();},'text');},showDateRequestedPage:function(callback){jQuery.get('Templates/lunchcartservices-date-selector.htm','',function(data,textStatus){popupWindowMgr.showSmallWindow();popupWindowMgr.content(data);dateTimeMgr.init(callback);},'text');},setProposalLocation:function(){specialtys.com.SDProxy.LoadLunchcartLocationFormated(function(r){$("#aProposalLocation").html(r)},null,null)},setProposalDateRequested:function(){specialtys.com.SDProxy.LoadLunchcartDateRequestedFormated(function(r){$("#aProposalDateRequest").html(r)},null,null)}};var grpLunchboxMgr={showDateRequestedPage:function(callback){jQuery.get('Templates/group-lunchbox-date-selector.htm','',function(data,textStatus){popupWindowMgr.showSmallWindow();popupWindowMgr.content(data);dateTimeGLBMgr.init(callback);},'text');},setLocation:function(){specialtys.com.SDProxy.LoadLunchcartLocationFormated(function(r){$("#aLocation").html(r)},null,null);specialtys.com.SDProxy.LoadLunchcartDateRequestedFormated(function(r){$("#aDateRequested").html(r)},null,null);},setDateRequested:function(){specialtys.com.SDProxy.LoadLunchcartDateRequestedFormated(function(r){$("#aDateRequested").html(r)},null,null);}};﻿
eventMgr.onlogin.add(function(r){if(r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.OK||r.AuthResponseType==Specialtys.Core.SpecialtysDirect.AuthResponseType.OKPasswordChangeRequired){jQuery.get('Templates/default-master-login.htm','',function(data,textStatus){var today=new Date();var greeting=today.getHours()<12?"Good Morning, ":today.getHours()<17?"Good Afternoon, ":"Good Evening, ";greeting=greeting+" "+r.FirstName+'.';data=data.replace("{greeting}",greeting);$("#hdrLogin").html(data);},'text');}});eventMgr.onaddtocart.add(function(p,q){var totalItems=$("#header_items");var totalPrice=$("#header_total");if(totalItems.length==0){jQuery.get('Templates/default-master-nonempty-cart.htm','',function(data,textStatus){data=data.replace("{items}",q.Quantity);data=data.replace("{total}",'$'+(parseFloat(q.Quantity)*p.Price).toFixed(2));$("#hdrLunchcartP").html(data);$('#lunchcart-header-checkoutBtn').removeClass('btnDisabled');$('#lunchcart-header-checkoutBtn').addClass('btnOrange');},'text');}
else{totalItems.text(parseInt(totalItems.text())+parseInt(q.Quantity));totalPrice.text('$'+(parseFloat(String(totalPrice.text()).replace('$',''))+(parseFloat(q.Quantity)*p.Price)).toFixed(2));}});eventMgr.onremovefromcart.add(function(q,p){var totalItems=$("#header_items");var totalPrice=$("#header_total");totalItems.text(parseInt(totalItems.text())-parseInt(q));totalPrice.text('$'+(parseFloat(String(totalPrice.text()).replace('$',''))-(parseFloat(q)*p.Price)).toFixed(2));if(parseInt(totalItems.text())==0)userMgr.clearcart();});eventMgr.onupdateqtyincart.add(function(s,items){var totalItems=$("#header_items");var totalPrice=$("#header_total");totalItems.text("0");totalPrice.text("0.00");for(var i=0;i<items.length;i++){totalItems.text(parseInt(totalItems.text())+parseInt(items[i].Quantity));totalPrice.text((parseFloat(totalPrice.text())+(parseFloat(items[i].Quantity)*items[i].Price)).toFixed(2));}});﻿
var twitMgr={callback:null,isConnected:function(callback){specialtys.com.SDProxy.IsTwitterConnected(function(data){if(data==true){callback.call(this);}else{twitMgr.connect();}});},connect:function(callback){gaMgr.track('Twitter Connect Window','Open Window');twitMgr.callback=callback;jQuery.get('Templates/socialservices-connect-twitter.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showSmallWindow();twitMgr.connectInit();},'text');},connectInit:function(){specialtys.com.SDProxy.GetTwitterConnectUrl(function(data){$('#popupWindow_twitConnectBtn').click(function(){window.open(data,'twitConnectWindow','width=800,height=420,noresize,scrollbars=no');});});},connectCallback:function(){gaMgr.track('Twitter Connect Window','Success');twitMgr.close();if(twitMgr.callback!=null&&this.callback!=undefined)twitMgr.callback.call(this);},renderShareProduct:function(p){$('#twitShare_userTxt').attr('value','Wanted to share the '+productMgr.getProductType(p).toLowerCase()+' "'+p.Name+'" available from Specialtys.com.');$('#popupWindow_twitShareBtn').attr('href','javascript:twitMgr.shareProductToStream(\''+p.ProductRelationHash+'\')');$('#popupWindow_twitShareBtn_text').html('share via twitter');},initShareProduct:function(pRId){specialtys.com.SDProxy.LoadProductUsingRelation(pRId,function(data){twitMgr.renderShareProduct(data);});},shareProduct:function(pRId){gaMgr.track('Twitter Share Product Window','Open Window');jQuery.get('Templates/twitter-share.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showSmallWindow();twitMgr.initShareProduct(pRId);},'text');},shareProductToStream:function(pRId){var c=$('#twitShare_userTxt').val();$('#popupWindow_twitShareBtn').attr('href','javascript:void(0)');$('#popupWindow_twitShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareProductViaTwitter(pRId,c,function(){gaMgr.track('Twitter Share Product Window','Success');twitMgr.close();},function(){gaMgr.track('Twitter Share Product Window','Failed');alert('ERROR: Something went wrong.')
twitMgr.initShareProduct(pRId);});},renderShareGroupLunchbox:function(glb){$('#twitShare_userTxt').attr('value','Let\'s get together at specialtys ');$('#popupWindow_twitShareBtn').attr('href','javascript:twitMgr.shareGrouplunchboxToStream(\''+glb.GroupLunchboxHash+'\')');$('#popupWindow_twitShareBtn_text').html('share via twitter');},initShareGroupLunchbox:function(glbId){specialtys.com.SDProxy.LoadGroupLunchbox(glbId,function(data){twitMgr.renderShareGroupLunchbox(data);});},shareGroupLunchbox:function(glbId){gaMgr.track('Twitter Share Group Lunchbox Window','Open Window');jQuery.get('Templates/twitter-share.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showSmallWindow();twitMgr.initShareGroupLunchbox(glbId);},'text');},shareGrouplunchboxToStream:function(glbId){var c=$('#twitShare_userTxt').val();$('#popupWindow_twitShareBtn').attr('href','javascript:void(0)');$('#popupWindow_twitShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareGroupLunchboxViaTwitter(glbId,c,function(){gaMgr.track('Twitter Share Group Lunchbox Window','Success');twitMgr.close();},function(){gaMgr.track('Twitter Share Group Lunchbox Window','Failed');alert('ERROR: Something went wrong.')
twitMgr.initShareProduct(glbId);});},renderShareFavorite:function(p){$('#twitShare_userTxt').attr('value','Wanted to share a '+productMgr.getProductType(p).toLowerCase()+' masterpiece "'+p.Name+'" created at Specialtys.com.');$('#popupWindow_twitShareBtn').attr('href','javascript:twitMgr.shareFavoriteToStream(\''+p.FavoriteHash+'\')');},shareFavorite:function(fId){gaMgr.track('Twitter Share Favorite Window','Open Window');jQuery.get('Templates/twitter-share.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showSmallWindow();twitMgr.initShareFavorite(fId);},'text');},initShareFavorite:function(fId){specialtys.com.SDProxy.LoadFavorite(fId,function(data){twitMgr.renderShareFavorite(data);});},shareFavoriteToStream:function(fId){var c=$('#twitShare_userTxt').val();$('#popupWindow_twitShareBtn').attr('href','javascript:void(0)');$('#popupWindow_twitShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareFavoriteViaTwitter(fId,c,function(){gaMgr.track('Twitter Share Favorite Window','Success');twitMgr.close();},function(){gaMgr.track('Twitter Share Favorite Window','Failed');alert('ERROR: Something went wrong.')
twitMgr.initShareFavorite(fId);});},close:function(){popupWindowMgr.hide();}}
var fbMgr={callback:null,isConnected:function(callback){specialtys.com.SDProxy.IsFacebookConnected(function(data){if(data==true){callback.call(this);}else{fbMgr.connect(callback);}});},isConnectedVerified:function(callback){specialtys.com.SDProxy.IsFacebookConnectedVerified(function(data){if(data==true){callback.call(this);}else{fbMgr.connect(callback);}});},connect:function(callback){gaMgr.track('Facebook Connect Window','Open Window');fbMgr.callback=callback;jQuery.get('Templates/socialservices-connect-facebook.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showSmallWindow();fbMgr.connectInit();},'text');},connectInit:function(){specialtys.com.SDProxy.GetFacebookConnectUrl(function(data){$('#popupWindow_fbConnectBtn').click(function(){window.open(data,'fbConnectWindow','width=500,height=450,noresize,scrollbars=no');});});},connectCallback:function(){gaMgr.track('Facebook Connect Window','Success');fbMgr.close();if(fbMgr.callback!=null&&this.callback!=undefined)fbMgr.callback.call(this);},renderShareProduct:function(p){$('#fbShare_streamTitle').html('Specialty\'s '+productMgr.getProductType(p)+': "'+p.Name+'"');$('#fbShare_streamCaption').html(userMgr.firstName+' wanted to share a '+productMgr.getProductType(p).toLowerCase()+' available from Specialtys.com');$('#fbShare_streamDesc').html(p.Description);$('#fbShare_streamExtraTxt').hide();$('#fbShare_streamImg').attr('src','Images/ProdImg/80x80/'+p.ImageId+'.jpg');$('#popupWindow_fbShareBtn').attr('href','javascript:fbMgr.shareProductToStream(\''+p.ProductRelationId+'\')');$('#popupWindow_fbShareBtn_text').html('share via facebook');},initShareProduct:function(pRId){specialtys.com.SDProxy.LoadProductUsingRelation(pRId,function(data){fbMgr.renderShareProduct(data);});},shareProduct:function(pRId){gaMgr.track('Facebook Share Product Window','Open Window');jQuery.get('Templates/facebook-share.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showMediumWindow();fbMgr.initShareProduct(pRId);},'text');},shareProductToStream:function(pRId){var c=$('#fbShare_userTxt').val();$('#popupWindow_fbShareBtn').attr('href','javascript:void(0)');$('#popupWindow_fbShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareProductViaFacebook(pRId,c,function(){gaMgr.track('Facebook Share Product Window','Success');fbMgr.close();},function(){gaMgr.track('Facebook Share Product Window','Failed');alert('ERROR: Something went wrong.')
fbMgr.initShareProduct(pRId);});},renderShareFavorite:function(p){$('#fbShare_streamTitle').html('Favorite '+productMgr.getProductType(p)+': "'+p.Name+'"');$('#fbShare_streamCaption').html(userMgr.firstName+' wanted to share a '+productMgr.getProductType(p).toLowerCase()+' masterpiece created at Specialtys.com');$('#fbShare_streamDesc').html('"'+(p.IsReadOnly?p.Description:p.FriendlyIngredientDescription)+'"');$('#fbShare_streamExtraTxt').hide();$('#fbShare_streamImg').attr('src','ProdImg.ashx?w=80&f='+p.FavoriteHash);$('#popupWindow_fbShareBtn').attr('href','javascript:fbMgr.shareFavoriteToStream(\''+p.FavoriteHash+'\')');},shareFavorite:function(fId){gaMgr.track('Facebook Share Favorite Window','Open Window');jQuery.get('Templates/facebook-share.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showMediumWindow();fbMgr.initShareFavorite(fId);},'text');},initShareFavorite:function(fId){specialtys.com.SDProxy.LoadFavorite(fId,function(data){fbMgr.renderShareFavorite(data);});},shareFavoriteToStream:function(fId){var c=$('#fbShare_userTxt').val();$('#popupWindow_fbShareBtn').attr('href','javascript:void(0)');$('#popupWindow_fbShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareFavoriteViaFacebook(fId,c,function(){gaMgr.track('Facebook Share Favorite Window','Success');fbMgr.close();},function(){gaMgr.track('Facebook Share Favorite Window','Failed');alert('ERROR: Something went wrong.')
fbMgr.initShareFavorite(fId);});},renderShareGroupLunchbox:function(glb){$('#fbShare_streamTitle').html('Let\'s get togther at Specialtys');$('#fbShare_streamCaption').html('"'+userMgr.firstName+' would like to arange a get together"');$('#fbShare_streamDesc').html('on:'+glb.DateRequested+'at '+glb.Location);if(glb.descritption!=null)
$('#fbShare_streamExtraTxt').html(glb.descritption);else
$('#fbShare_streamExtraTxt').hide();$('#popupWindow_fbShareBtn').attr('href','javascript:fbMgr.shareGrouplunchboxToStream(\''+glb.GroupLunchboxHash+'\')');},shareGroupLunchbox:function(glbId){gaMgr.track('Facebook Share Group Lunchbox Window','Open Window');jQuery.get('Templates/facebook-share-group-lunchbox.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showMediumWindow();fbMgr.initShareGroupLunchbox(glbId);},'text');},initShareGroupLunchbox:function(glbId){specialtys.com.SDProxy.LoadGroupLunchbox(glbId,function(data){fbMgr.renderShareGroupLunchbox(data);});},shareGrouplunchboxToStream:function(glbId){var c=$('#fbShare_userTxt').val();$('#popupWindow_fbShareBtn').attr('href','javascript:void(0)');$('#popupWindow_fbShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareGroupLunchboxViaFacebook(glbId,c,function(){gaMgr.track('Facebook Share Group Lunchbox  Window','Success');fbMgr.close();},function(){gaMgr.track('Facebook Share Group Lunchbox Window','Failed');alert('ERROR: Something went wrong.')
fbMgr.initShareGroupLunchbox(glbId);});},lbName:function(lbId){if(lbId==0)return'Overall';if(lbId==1)return'Sandwich';if(lbId==2)return'Salad';if(lbId==3)return'Soup';if(lbId==4)return'Cookie';},lbTitle:function(lbId){if(lbId==0)return'Overall Specialty\'s Best Fan';if(lbId==1)return'Specialty\'s Best Sandwich Fan';if(lbId==2)return'Specialty\'s Best Salad Fan';if(lbId==3)return'Specialty\'s Best Soup Fan';if(lbId==4)return'Specialty\'s Best Cookie Fan';},renderShareBestFanScore:function(lbId,scoreType,lb){userMgr.initFromCookie();var d=new Date();var month=new Array(12);month[0]="January";month[1]="February";month[2]="March";month[3]="April";month[4]="May";month[5]="June";month[6]="July";month[7]="August";month[8]="September";month[9]="October";month[10]="November";month[11]="December";$('#fbShare_streamTitle').html(fbMgr.lbTitle(lbId));$('#fbShare_streamCaption').html(userMgr.firstName+' wanted to share (brag) about their Specialty\'s Fan Score...');if(scoreType=='lifetime'){$('#fbShare_streamDesc').html(fbMgr.lbTitle(lbId)+' Score: '+lb.Score+' lifetime points');}else{$('#fbShare_streamDesc').html(fbMgr.lbTitle(lbId)+' Score: '+lb.CurrentPeriodScore+' points accumulated so far for the month of '+month[d.getMonth()]+', '+d.getFullYear()+'.');}
$('#fbShare_streamExtraTxt').hide();$('#fbShare_streamImg').attr('src','Images/BestFan/position_'+lb.LeaderboardPosition+'.jpg');$('#popupWindow_fbShareBtn').attr('href','javascript:fbMgr.shareBestFanScoreToStream('+lbId+', \''+scoreType+'\')');$('#fbShare_linkTitle').html('Calculate & Compare Your Score');$('#popupWindow_fbShareBtn_text').html('share via facebook');},shareBestFanScore:function(lbId,scoreType){gaMgr.track('Facebook Share Fan Score Window','Open Window');jQuery.get('Templates/facebook-share.htm','',function(data,textStatus){popupWindowMgr.content(data);popupWindowMgr.showMediumWindow();fbMgr.initShareBestFanScore(lbId,scoreType);},'text');},initShareBestFanScore:function(lbId,scoreType){specialtys.com.SDProxy.LoadBestFanScore(lbId,function(data){fbMgr.renderShareBestFanScore(lbId,scoreType,data);});},shareBestFanScoreToStream:function(lbId,scoreType){var c=$('#fbShare_userTxt').val();$('#popupWindow_fbShareBtn').attr('href','javascript:void(0)');$('#popupWindow_fbShareBtn_text').html('please wait...');specialtys.com.SDProxy.ShareBestFanScoreViaFacebook(lbId,scoreType,c,function(){gaMgr.track('Facebook Share Fan Score Window','Success');fbMgr.close();},function(){gaMgr.track('Facebook Share Fan Score Window','Failed');alert('ERROR: Something went wrong.')
fbMgr.shareBestFanScore();});},close:function(){popupWindowMgr.hide();}}﻿
var beetMgr={windowMgr:popupWindowMgr,map:null,cellId:null,mapDivId:null,pageMapDivId:null,setup:function(winMgr){this.windowMgr=winMgr;},showSSLError:function(source){alert('Sorry, this function is not available in SSL mode.'+((source==undefined)?'':' '+source));},showDeliveryZoneMap:function(){depMgr.load('JScript/beetservices-gmap-0.0.js');if(!GBrowserIsCompatible()){this.showSSLError('showDeliveryZoneMap()');return;}
beetMgr.windowMgr.showLargeWindow();jQuery.get('Templates/beetservices-delivery-zones.htm','',function(data,textStatus){beetMgr.windowMgr.content(data);beetMgr.initGMap('beetServices-delivery-zones-gMap');beetMgr.map.setSize('medium');beetMgr.initDeliveryZoneMap();beetMgr.map.map.setCenter(new GLatLng(37.583766,-121.959229),9);},'text');},initDeliveryZoneMap:function(){specialtys.com.SDProxy.LoadDeliveryRegionCoordStream(function(data){var deliveryRegionList=new Array();var deliveryRegion=null;var cI=0;deliveryRegionList.push(new BeetDeliveryRegion());for(var i=0;i<data.length;i++){if(deliveryRegionList[cI].id!=data[i].DeliveryRegionId&&i>0){deliveryRegionList.push(new BeetDeliveryRegion());cI++;}
deliveryRegionList[cI].id=data[i].DeliveryRegionId;deliveryRegionList[cI].deliveryFeeModelId=data[i].DeliveryFeeModelId;deliveryRegionList[cI].pointArr.push([data[i].GpsLat,data[i].GpsLong]);deliveryRegionList[cI].active=true;}
beetMgr.map.addDeliveryRegionArrayToMap(deliveryRegionList,true);});},showLocationSelector:function(selectedView,callback){depMgr.load('JScript/beetservices-location-selector-0.0.js');jQuery.get('Templates/beetservices-location-selector.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showMediumWindow();beetLocMgr.init(selectedView,callback);},'text');},showAddDeliveryLocation:function(callback,callbackFail){depMgr.load('JScript/beetservices-add-delivery-location-0.2.js');jQuery.get('Templates/beetservices-add-delivery-location-0.2.htm','',function(data,textStatus){productMgr.windowMgr.content(data);productMgr.windowMgr.showMediumWindow();beetAddDelLocMgr.init(callback,callbackFail);},'text');},showCookieAlert:function(){depMgr.load('JScript/beetservices-cookiealert-0.0.js');productMgr.windowMgr.showLargeWindow();jQuery.get('Templates/beetservices-cookiealert.htm','',function(data,textStatus){beetMgr.windowMgr.content(data);cookieAlertMgr.init();},'text');},showCookieRadar:function(){depMgr.load('JScript/beetservices-cookieradar-0.0.js');depMgr.load('JScript/beetservices-gmap-0.0.js');if(!userMgr.requireHttp(null,'CookieRadar.aspx'))return;if(!GBrowserIsCompatible()){this.showSSLError('showCookieRadar()');return;}
beetMgr.windowMgr.showLargeWindow();jQuery.get('Templates/beetservices-cookieradar.htm','',function(data,textStatus){beetMgr.windowMgr.content(data);cookieRadarMgr.init();},'text');},showStore:function(cellId){depMgr.load('JScript/beetservices-gmap-0.0.js');if(!userMgr.requireHttp(null,'Stores.aspx'))return;if(!GBrowserIsCompatible()){this.showSSLError('showStore()');return;}
this.cellId=cellId;beetMgr.windowMgr.showLargeWindow();jQuery.get('Templates/beetservices-gmap.htm','',function(data,textStatus){beetMgr.windowMgr.content(data);beetMgr.initGMap('beetServices-gMap-window');beetMgr.map.setSize('medium');specialtys.com.SDProxy.LoadStores(beetMgr.renderStores,null,{highlightedCellId:cellId,autoOpenHighlightedWindow:true});},'text');},renderStores:function(data,args){for(var i=0;i<data.length;i++){var store=new BeetStore();store.id=data[i].CellId;store.buildingId=data[i].BuildingId;store.streetName=data[i].StreetName;store.streetNumber=data[i].StreetNumber;store.latitude=data[i].GpsLat;store.longitude=data[i].GpsLong;store.city=data[i].City;store.state=data[i].State;store.zip=data[i].Zip;store.openTimesHTML=data[i].FriendlyOpenTimesHtml;store.pickupFlag=data[i].PickupFlag;store.priorityPickupStatus=data[i].PriorityPickupStatus;store.highlighted=false;if(data[i].CellId==beetMgr.cellId){store.active=false;store.highlighted=true;}
beetMgr.map.addStoreToMap(store);}
for(var i=0;i<beetMgr.map.storeArr.length;i++){if(beetMgr.map.storeArr[i].highlighted==true){beetMgr.map.storeArr[i].centerOnMap(beetMgr.map);var store=beetMgr.map.storeArr[i];}}},initGMap:function(gMapInstanceId){this.mapDivId=gMapInstanceId;this.map=new BeetGMap(document.getElementById(this.mapDivId));},renderStore:function(data,args){var store=new BeetStore();store.id=data.CellId;store.streetName=data.StreetName;store.streetNumber=data.StreetNumber;store.latitude=data.GpsLat;store.longitude=data.GpsLong;store.city=data.City;store.state=data.State;store.zip=data.Zip;store.highlighted=false;beetMgr.map.addStoreToMap(store);beetMgr.map.zoomToFit();},addFavoritePickupLocation:function(buildingId,callback){specialtys.com.SDProxy.AddFavoritePickupLocation(buildingId,function(){callback.call(this);});},selectPickupLocation:function(bId,callback){specialtys.com.SDProxy.SetPickupLocation(bId,function(){if(callback!=undefined)callback.call(this);});},addFavoritePickupLocation:function(bId,callback){specialtys.com.SDProxy.AddFavoritePickupLocation(bId,function(){if(callback!=undefined)callback.call(this);});}}