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;function jSecuritySubmit(cookieName){rememberMe(cookieName,document.forms.login["j_username"].value);document.forms.login.submit();}function validateUser(url,redirectUrl,cookieName){hideAllErrors();$("#loginContentLoading").show();var loginForm=$("#login");var serializedForm=loginForm.serialize();var loginData={loginname:document.login.loginname.value,loginpass:document.login.loginpass.value};rememberMe(cookieName,document.login.loginname.value);$.ajax({type:"POST",url:stripUrl(url),data:serializedForm,success:validate,error:alertError});return false;}function rememberMe(cookieName,userName){if($("#remember")[0].checked){addUserCookie(cookieName,userName);}else{eraseCookie(cookieName);}}function alertError(XMLHttpRequest,textStatus,errorThrown){}function implicitLogin(targetUrl){$(document.body).append('<iframe id="implicitLoginIFrame" src="'+targetUrl+'" name="implicitLoginIFrame" frameborder="0" width="1" height="1"></iframe>');$("iframe#implicitLoginIFrame").attr("src",targetUrl);clearPollT=setTimeout(checkImplicitLogin,pollTime);clearT=setTimeout(timedOut,pollTime*(implicitLoginPollCount));}function timedOut(){clearTimeout(clearPollT);continueLogin("success");}function getContentFromIframe(iFrameName){var myIFrame=document.getElementById(iFrameName);var content=myIFrame.contentWindow.document.body.innerHTML;if($.trim(content)!="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(err){permissionDeniedError=true;}}function redirectWithImplicitLogin(targetUrl){dontContinueLoginFlag=true;redirectUrl=targetUrl;implicitLogin(implicitLoginUrl);}function checkRedirect(xmlHttp){if(xmlHttp.status.toString()[0]=="3"){implicitLogin(xmlHttp.getResponseHeader("Location"));}else{var params={};var txt="<div>"+xmlHttp.responseText+"</div>";$("input",txt).each(function(){params[$(this).attr("name")]=$(this).attr("value");});var action;var acRegex=/ACTION="(.*?)"/i;var match=acRegex.exec(xmlHttp.responseText);if(match&&match.length&&match.length>=2){action=match[1];}if(action){$.ajax({type:"POST",url:stripUrl(action),data:params,complete:checkRedirect,error:continueLoginError});}else{continueLogin("success");}}}function redirectToRegister(anchor){var start=new Date();var url=anchor;var temp="";if(redirectUrl!=undefined&&redirectUrl!=""){temp+="&redirectUrl="+doEscapeUrl(redirectUrl);}if(flowType!=undefined&&flowType!=""){temp+="&flowType="+flowType;}var pass=popupLoginURL+temp+"&reloadUrl="+url;if(isParentSSL!=undefined&&isParentSSL=="true"){register(url);}else{redirectCurrent(pass);}}function redirectParent(url){url=replace(url,"&amp;","&");if(isBVUser){url=url+"&parentBVURL="+doEscapeUrl(parent.location.href);}if(url.indexOf(".pdf")!=-1||url.indexOf(".PDF")!=-1){if(url.indexOf(".pdf")!=-1){url=url.substring(0,url.indexOf(".pdf")+4);}else{if(url.indexOf(".PDF")!=-1){url=url.substring(0,url.indexOf(".PDF")+4);}}}parent.location.href=url;closeOverlays();return;}function checkAndRedirect(url){if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(url);}else{redirectCurrent(popupLoginURL+"&refreshParent="+doEscapeUrl(url));}}function checkAndCall(overlayId){if(isParentSSL!=undefined&&isParentSSL=="true"){parent.openscriptOverlay(overlayId);}else{redirectCurrent(popupLoginURL+"&callParent="+overlayId);}}function refreshParent(){window.location.href=replace(window.location.href,"reloadParent=true","reloadParent=false");parent.location.reload();}function redirectCurrent(url){url=replace(url,"&amp;","&");window.location.href=url;}function validate(msg){if(msg=="success"){implicitLogin(implicitLoginUrl);}else{$("#loginContentLoading").hide();if(msg=="bvusercustservice"||msg=="bvuserecomm"){isBVUser=true;if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(loginPage+"&forward="+msg);}else{redirectCurrent(popupLoginURL+"&redirectParent="+msg+"&ts="+new Date().getTime());}}else{if(msg.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(msg=="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(msg=="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(msg=="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(msg=="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(msg=="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(msg=="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(data){if(isSterlingFailed){popupLoginURL=popupLoginURL+"&isSterlingFailed=true";}if(adirect){popupLoginURL=loginHolderUrl+"&isSterlingFailed=true";}if(dontContinueLoginFlag){dontContinueLoginFlag=false;if(redirectUrl!=undefined&&redirectUrl!=""){if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(getHotListUrl(redirectUrl));}else{if(popupLoginURL!=null){redirectCurrent(popupLoginURL+"&redirectSterling="+doEscapeUrl(redirectUrl));}else{redirectCurrent(redirectUrl);}}}}else{var delimiter="&";$("#poplogin,#popsearchpredict,#popprevviewed,#shadow").hide();$("#findprodinfotable,.selecthider").show();if(redirectUrl!=null&&redirectUrl!=undefined&&redirectUrl!=""){if(!(redirectUrl.indexOf("?")>=0)){delimiter="?";}var finalUrl=redirectUrl;if(flowType!="undefined"&&flowType!="null"){finalUrl=finalUrl+delimiter+"FlowType="+flowType;}if(isParentSSL!=undefined&&isParentSSL=="true"){redirectParent(getHotListUrl(finalUrl));}else{if(popupLoginURL!=null){redirectCurrent(popupLoginURL+"&redirectSterling="+doEscapeUrl(finalUrl));}else{redirectCurrent(finalUrl);}}}else{if(isParentSSL!=undefined&&isParentSSL=="true"){refreshParent();}else{var pass=popupLoginURL+"&reloadParent=true";redirectCurrent(pass);}}}}function continueLoginError(XMLHttpRequest,textStatus,errorThrown){continueLogin("error");}function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{var expires="";}document.cookie=name+"="+value+expires+"; path=/";}function readCookie(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;}function eraseCookie(name){createCookie(name,"",-1);}function addUserCookie(name,userName){if(userName){createCookie(name,userName,30);}}function redirectLogin(redirectUrlParam,flowTypeParam){redirectUrl=redirectUrlParam;flowType=flowTypeParam;if(!(url&&!redirectUrlParam&&!flowTypeParam)){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(anchor){var redirectToPrevLoc=parent.location.href;var verticalParam=getQueryParameter("vertical");var catIdParam=getQueryParameter("catID");var delimiter="&";if(!(anchor.indexOf("?")>=0)){delimiter="?";}if(redirectUrl){redirectUrl=doEscapeUrl(redirectUrl);var finalUrl=anchor+delimiter+"RedirectURL="+redirectUrl;if(flowType){finalUrl=finalUrl+"&FlowType="+flowType;}finalUrl=finalUrl+"&verticalParam="+verticalParam+"&catIdParam="+catIdParam;redirectParent(finalUrl);}else{redirectToPrevLoc=doEscapeUrl(redirectToPrevLoc);redirectToPrevLoc=redirectToPrevLoc+"&verticalParam="+verticalParam+"&catIdParam="+catIdParam;redirectParent(anchor+delimiter+"redirectToPrevLoc="+redirectToPrevLoc);}}function doEscapeUrl(url){if(url){url=url.replace(/&/g,"%26");url=url.replace(/\?/g,"%3f");url=url.replace(/\s/g,"%20");return url;}}function openWin(url,title){var width=450;var height=270;var winl=(screen.width-width)/2;var wint=(screen.height-height)/2;var currLoc=window.location.href;var isCurrentSSL=(currLoc.indexOf("https")==0);url+="&isParentSSL="+isCurrentSSL;url=replace(url,"&amp;","&");childWindow=window.open(url,"Login","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=no,top="+wint+",left="+winl+", resizable=1,width="+width+",height="+height);childWindow.focus();}function replace(argvalue,x,y){if(argvalue){if((x==y)||(parseInt(y.indexOf(x))>-1)){return false;}while(argvalue.indexOf(x)!=-1){var leading=argvalue.substring(0,argvalue.indexOf(x));var trailing=argvalue.substring(argvalue.indexOf(x)+x.length,argvalue.length);argvalue=leading+y+trailing;}return argvalue;}}function getQueryParameter(parameterName){var queryString=window.top.location.search.substring(1);var parameterName=parameterName+"=";if(queryString.length>0){begin=queryString.indexOf(parameterName);if(begin!=-1){begin+=parameterName.length;end=queryString.indexOf("&",begin);if(end==-1){end=queryString.length;}return unescape(queryString.substring(begin,end));}}return"none";}function stripUrl(input){var regex=/^https?:\/\/.*?(\/.*)/i;var output=input;var match=regex.exec(input);if(match&&match.length&&match.length>=2){output=match[1];}return output;}function notYou(msg){implicitLogout();}function logoutSterling(){$.ajax({type:"GET",url:implicitLogoutUrl,complete:logoutMsg});}function logoutMsg(xmlHttp){if(sterlingRedirectUrl){redirectParent(redirectPost);}else{if(isPostPage){goHome();}else{refreshParent();}}}function implicitLogout(func){$.ajax({type:"GET",url:portalLogoutUrl,complete:countdownLogout});$.ajax({type:"GET",url:implicitLogoutUrl,complete:countdownLogout});}function countdownLogout(xmlHttp){countdownLogoutCount=countdownLogoutCount-1;if(countdownLogoutCount<=0){window.location.href=homePageLoginUrl;}}function updateRetryCount(url){$.ajax({type:"GET",url:url,success:function(msg){}});return true;}function getHotListUrl(temp){var firstPart=temp.substring(0,(temp.indexOf("ReturnURL")+("ReturnURL".length)+1));var lastPart=doEscapeUrl(temp.substring(temp.indexOf("ReturnURL")+("ReturnURL".length)+1));var finalPart=firstPart+doEscapeUrl(lastPart);return finalPart;}