var xmlreq=false;var redirectUrl=null;var flowType=null;var isParentSSL=null;var popupLoginURL=null;var dontContinueLoginFlag=false;var url="";var homePageUrl;var implicitLoginPollCount=30;var pollTime=1000;var clearPollT;var clearT;var countdownLogoutCount=2;var permissionDeniedError=false;var isBVUser=null;var adirect;var loginHolderUrl;var sterlingRedirectUrl;var redirectPost;var isPostPage;var isSterlingFailed;var isInB2BFrame=false;function jSecuritySubmit(a){rememberMe(a,document.forms.login["j_username"].value);document.forms.login.submit();}function validateUser(b,d,f){hideAllErrors();$("#loginContentLoading").show();var e=$("#login");var c=e.serialize();var a={loginname:document.login.loginname.value,loginpass:document.login.loginpass.value};rememberMe(f,document.login.loginname.value);$.ajax({type:"POST",url:stripUrl(b),async:false,data:c,success:validate,error:alertError});return false;}function rememberMe(b,a){if($("#remember")[0].checked){addUserCookie(b,a);}else{eraseCookie(b);}}function alertError(a,c,b){}function implicitLogin(a){$(document.body).append('<iframe id="implicitLoginIFrame" src="'+a+'" name="implicitLoginIFrame" frameborder="0" width="1" height="1"></iframe>');$("iframe#implicitLoginIFrame").attr("src",a);clearPollT=setTimeout(checkImplicitLogin,pollTime);clearT=setTimeout(timedOut,pollTime*(implicitLoginPollCount));}function timedOut(){clearTimeout(clearPollT);continueLogin("success");}function getContentFromIframe(c){var a=document.getElementById(c);var b=a.contentWindow.document.body.innerHTML;if($.trim(b)!="success"){isSterlingFailed=true;}}function checkImplicitLogin(){clearPollT=setTimeout(checkImplicitLogin,pollTime);try{if(frames.implicitLoginIFrame&&frames.implicitLoginIFrame.location&&frames.implicitLoginIFrame.location.href&&(frames.implicitLoginIFrame.location.href.indexOf("directLogin")>=0)){getContentFromIframe("implicitLoginIFrame");continueLogin("success");clearTimeout(clearT);clearTimeout(clearPollT);}}catch(a){permissionDeniedError=true;}}function redirectWithImplicitLogin(b,a){dontContinueLoginFlag=true;redirectUrl=b;if(a!=null){implicitLoginUrl+=a;}implicitLogin(implicitLoginUrl);}function checkRedirect(b){if(b.status.toString()[0]=="3"){implicitLogin(b.getResponseHeader("Location"));}else{var f={};var a="<div>"+b.responseText+"</div>";$("input",a).each(function(){f[$(this).attr("name")]=$(this).attr("value");});var e;var c=/ACTION="(.*?)"/i;var d=c.exec(b.responseText);if(d&&d.length&&d.length>=2){e=d[1];}if(e){$.ajax({type:"POST",url:stripUrl(e),async:false,data:f,complete:checkRedirect,error:continueLoginError});}else{continueLogin("success");}}}function redirectToRegister(c){var e=new Date();var b=c;var a="";if(redirectUrl!=undefined&&redirectUrl!=""){a+="&redirectUrl="+doEscapeUrl(redirectUrl);}if(flowType!=undefined&&flowType!=""){a+="&flowType="+flowType;}var d=popupLoginURL+a+"&reloadUrl="+b;if(isParentSSL!=undefined&&isParentSSL=="true"){register(b);}else{redirectCurrent(d);}}function redirectParent(a){a=replace(a,"&amp;","&");if(isBVUser){a=a+"&parentBVURL="+doEscapeUrl(parent.location.href);}if(a.indexOf(".pdf")!=-1||a.indexOf(".PDF")!=-1){if(a.indexOf(".pdf")!=-1){a=a.substring(0,a.indexOf(".pdf")+4);}else{if(a.indexOf(".PDF")!=-1){a=a.substring(0,a.indexOf(".PDF")+4);}}}if(isInB2BFrame){self.location.href=a;}else{parent.location.href=a;}closeOverlays();return;}function checkAndRedirect(a){if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(a);}else{redirectCurrent(popupLoginURL+"&refreshParent="+doEscapeUrl(a));}}function checkAndCall(a){if(isParentSSL!=undefined&&isParentSSL=="true"){parent.openscriptOverlay(a);}else{redirectCurrent(popupLoginURL+"&callParent="+a);}}function refreshParent(){window.location.href=replace(window.location.href,"reloadParent=true","reloadParent=false");parent.location.reload();}function redirectCurrent(a){a=replace(a,"&amp;","&");window.location.href=a;}function validate(a){a=jQuery.trim(a);p=a.split(" ");if(p[0]=="punchout"){redirectWithImplicitLogin(p[1],p[2]);}else{if(a=="success"){implicitLogin(implicitLoginUrl);}else{$("#loginContentLoading").hide();if(a=="bvusercustservice"||a=="bvuserecomm"){isBVUser=true;if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(loginPage+"&forward="+a);}else{redirectCurrent(popupLoginURL+"&redirectParent="+a+"&ts="+new Date().getTime());}}else{if(a.indexOf("bvredirect")!=-1){document.getElementById("unSupportedUserName").style.display="block";document.getElementById("forgotpoploginforgotusername").style.display="none";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="none";}else{if(a=="failure"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="block";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="none";}else{if(a=="suppressb2c"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("suppressb2c").style.display="block";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="none";}else{if(a=="inactiveuser"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="none";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="block";}else{if(a=="locked"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernamelocked").style.display="block";document.getElementById("inactivechilduser").style.display="none";}else{if(a=="errormsg"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="block";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="none";}else{if(a=="punchouterr"){document.getElementById("punchouterr").style.display="block";}else{if(a=="sixattempts"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="none";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="block";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="none";}else{if(a=="twelveattempts"){document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="none";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="block";document.getElementById("inactivechilduser").style.display="none";}else{document.getElementById("unSupportedUserName").style.display="none";document.getElementById("forgotpoploginforgotusername").style.display="block";document.getElementById("forgotpoploginforgotusernamelocked").style.display="none";document.getElementById("forgotpoploginforgotusernamesixattemptswarning").style.display="none";document.getElementById("forgotpoploginforgotusernametwelveattemptswarning").style.display="none";document.getElementById("inactivechilduser").style.display="none";}}}}}}}}}}}}}function hideAllErrors(){$("#unSupportedUserName").hide();$("#forgotpoploginforgotusername").hide();$("#forgotpoploginforgotusernamelocked").hide();$("#forgotpoploginforgotusernamesixattemptswarning").hide();$("#forgotpoploginforgotusernametwelveattemptswarning").hide();}function continueLogin(d){if(isSterlingFailed){popupLoginURL=popupLoginURL+"&isSterlingFailed=true";}if(adirect){popupLoginURL=loginHolderUrl+"&isSterlingFailed=true";}if(dontContinueLoginFlag){dontContinueLoginFlag=false;if(redirectUrl!=undefined&&redirectUrl!=""){if((isInB2BFrame)||(isParentSSL!=undefined&&isParentSSL=="true")){redirectParent(getHotListUrl(redirectUrl));}else{if(popupLoginURL!=null){redirectCurrent(popupLoginURL+"&redirectSterling="+doEscapeUrl(redirectUrl));}else{redirectCurrent(redirectUrl);}}}}else{var b="&";$("#poplogin,#popsearchpredict,#popprevviewed,#shadow").hide();$("#findprodinfotable,.selecthider").show();if(redirectUrl!=null&&redirectUrl!=undefined&&redirectUrl!=""){if(!(redirectUrl.indexOf("?")>=0)){b="?";}var a=redirectUrl;if(flowType!="undefined"&&flowType!="null"){a=a+b+"FlowType="+flowType;}if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(getHotListUrl(a));}else{if(popupLoginURL!=null){redirectCurrent(popupLoginURL+"&redirectSterling="+doEscapeUrl(a));}else{redirectCurrent(a);}}}else{if(isParentSSL!=undefined&&isParentSSL=="true"){refreshParent();}else{var c=popupLoginURL+"&reloadParent=true";redirectCurrent(c);}}}}function continueLoginError(a,c,b){continueLogin("error");}function createCookie(c,d,e){if(e){var b=new Date();b.setTime(b.getTime()+(e*24*60*60*1000));var a="; expires="+b.toGMTString();}else{var a="";}document.cookie=c+"="+d+a+"; path=/";}function readCookie(b){var e=b+"=";var a=document.cookie.split(";");for(var d=0;d<a.length;d++){var f=a[d];while(f.charAt(0)==" "){f=f.substring(1,f.length);}if(f.indexOf(e)==0){return f.substring(e.length,f.length);}}return null;}function eraseCookie(a){createCookie(a,"",-1);}function addUserCookie(a,b){if(b){createCookie(a,b,30);}}function redirectLogin(a,b){redirectUrl=a;flowType=b;if(!(url&&!a&&!b)){if(adirect){url=loginHolderUrl;}else{url=loginUrl;}if(redirectUrl){url=url+"&redirectUrl="+doEscapeUrl(redirectUrl);}if(flowType){url=url+"&flowType="+flowType;}}url=replace(url,"&amp;","&");if(document.getElementById("portalloginlink")&&document.getElementById("portalloginlink").click){document.getElementById("portalloginlink").click();}else{showLoginOverlay();}}function register(d){var b=parent.location.href;var f=getQueryParameter("vertical");var e=getQueryParameter("catID");var c="&";if(!(d.indexOf("?")>=0)){c="?";}if(redirectUrl){redirectUrl=doEscapeUrl(redirectUrl);var a=d+c+"RedirectURL="+redirectUrl;if(flowType){a=a+"&FlowType="+flowType;}a=a+"&verticalParam="+f+"&catIdParam="+e;redirectParent(a);}else{b=doEscapeUrl(b);b=b+"&verticalParam="+f+"&catIdParam="+e;redirectParent(d+c+"redirectToPrevLoc="+b);}}function doEscapeUrl(a){if(a){a=a.replace(/&/g,"%26");a=a.replace(/\?/g,"%3f");a=a.replace(/\s/g,"%20");return a;}}function openWin(b,h){var e=450;var a=270;var d=(screen.width-e)/2;var g=(screen.height-a)/2;var f=window.location.href;var c=(f.indexOf("https")==0);b+="&isParentSSL="+c;b=replace(b,"&amp;","&");childWindow=window.open(b,"Login","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=no,top="+g+",left="+d+", resizable=1,width="+e+",height="+a);childWindow.focus();}function replace(b,a,e){if(b){if((a==e)||(parseInt(e.indexOf(a))>-1)){return false;}while(b.indexOf(a)!=-1){var d=b.substring(0,b.indexOf(a));var c=b.substring(b.indexOf(a)+a.length,b.length);b=d+e+c;}return b;}}function getQueryParameter(a){var b=window.parent.location.search.substring(1);var a=a+"=";if(b.length>0){begin=b.indexOf(a);if(begin!=-1){begin+=a.length;end=b.indexOf("&",begin);if(end==-1){end=b.length;}return unescape(b.substring(begin,end));}}return"none";}function stripUrl(b){var d=/^https?:\/\/.*?(\/.*)/i;var a=b;var c=d.exec(b);if(c&&c.length&&c.length>=2){a=c[1];}return a;}function notYou(a){implicitLogout();}function logoutSterling(){$.ajax({type:"GET",url:implicitLogoutUrl,complete:logoutMsg});}function logoutMsg(a){if(sterlingRedirectUrl){redirectParent(redirectPost);}else{if(isPostPage){goHome();}else{refreshParent();}}}function implicitLogout(a){$.ajax({type:"GET",url:portalLogoutUrl,complete:countdownLogout});$.ajax({type:"GET",url:implicitLogoutUrl,complete:countdownLogout});}function countdownLogout(a){countdownLogoutCount=countdownLogoutCount-1;if(countdownLogoutCount<=0){window.location.href=homePageLoginUrl;}}function updateRetryCount(a){$.ajax({type:"GET",url:a,success:function(b){}});return true;}function getHotListUrl(a){if(a.indexOf("ReturnURL")>=0){var c=a.substring(0,(a.indexOf("ReturnURL")+("ReturnURL".length)+1));var b=doEscapeUrl(a.substring(a.indexOf("ReturnURL")+("ReturnURL".length)+1));var d=c+doEscapeUrl(b);return d;}else{return a;}}
