// JavaScript Document var oLibView = {BizID:"", ID:"", sKey:"", sDiv:"LibViewDiv", sAttachDiv:"LibStoryDiv", SiteID:"0", Count:"1", Group:"", Year:"", Tag:"", Filter:"", Output:"0", Page:"1", sNav:"1", sTools:"", Rss:"1", ShowDate:"1", iDateFormat:"1", ShowBack:"1", UseTemplate:"", sHttp:"https", iPopoutDiv:"1", sSearch:"", CSS:"", sPdf:"", sPdfText:"", sPrint:"", sPrintText:"", sServer:"www.b2i.us", sHeadlineDiv:"HeadlineDiv"}; var currItem=''; var currItemID=''; //SetMeta(); try{ var sI = getParameterByName("i", ""); if(!sI){ }else{ if(sI.length>0){ oLibView.ID=sI; } } } catch (error) { console.log("Caught Error:" + error); } //-------------------------------------- function getPRViewData(){ if(oLibView.BizID=='') { console.log('Business ID missing. You should have received this from our support team.'); return; } //if(oLibView.Group=='') { //console.log('Group Parameter missing. You should have received this from our support team.'); //return; //}; currItem=''; var sUrl = CreatePRViewURL(); GetPRViewApiContent('2', sUrl, null, oLibView.sDiv, 0); } //-------------------------------------- function getHeadline(){ var sUrl = CreateHeadlineURL(); GetPRViewApiContent('2', sUrl, null, oLibView.sHeadlineDiv, 0); } //-------------------------------------- function CreateHeadlineURL(){ var sUrl = oLibView.sHttp + "://" + oLibView.sServer + "/b2i/LibraryView.asp?m=2&b=" + oLibView.BizID; if(oLibView.sKey!='') {sUrl += "&api=" + oLibView.sKey}; if(oLibView.ID!='') {sUrl += "&id=" + oLibView.ID}; if(oLibView.Group!='') {sUrl += "&g=" + oLibView.Group}; return sUrl; } //-------------------------------------- function CreatePRViewURL(){ var sUrl = oLibView.sHttp + "://" + oLibView.sServer + "/b2i/LibraryView.asp?b=" + oLibView.BizID; if(oLibView.sKey!='') {sUrl += "&api=" + oLibView.sKey}; if(oLibView.SiteID!='') {sUrl += "&s=" + oLibView.SiteID}; if(oLibView.ID!='') {sUrl += "&id=" + oLibView.ID}; if(oLibView.Group!='') {sUrl += "&g=" + oLibView.Group}; if(oLibView.Output!='0') {sUrl += "&o=" + oLibView.Output}; if(oLibView.Tag!='') {sUrl += "&t=" + oLibView.Tag}; if(oLibView.Filter!='') {sUrl += "&f=" + oLibView.Filter}; if(oLibView.ShowBack!='') {sUrl += "&sb=" + oLibView.ShowBack}; if(oLibView.CSS!='') {sUrl += "&css=" + oLibView.CSS}; if(oLibView.sPdf!=''){sUrl += "&pdf=1"}; if(oLibView.sPrint!=''){sUrl += "&print=1"}; if(oLibView.sPdfText!=''){sUrl += "&pdft=1"}; if(oLibView.sPrintText!=''){sUrl += "&printt=1"}; if(oLibView.iDateFormat!='1') { sUrl += "&df=" + oLibView.iDateFormat }; return sUrl; } //-------------------------------------- function GetPRViewApiContent(requestType, sURL, varString, myDiv, iHash){ // requestType: 1 = get 0 = post // sURL: page requested // varString: null if none // myDiv: where to put returned value var xmlHttp; var PostOrGet; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Your browser does not support this function.\n\nPlease have your IT department configure your computer to work with AJAX."); return false; } } } if(requestType==1){ PostOrGet = "GET" }else{ PostOrGet = "POST" } xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4) { var sReturn = xmlHttp.responseText; if(oLibView.sPdf!='') sReturn = sReturn.replace(/=PDF=/gi, oLibView.sPdf); if(oLibView.sPrint!='') sReturn = sReturn.replace(/=Print=/gi, oLibView.sPrint); if(oLibView.sPdfText!='') sReturn = sReturn.replace(/=PdfText=/gi, oLibView.sPdfText); if(oLibView.sPrintText!='') sReturn = sReturn.replace(/=PrintText=/gi, oLibView.sPrintText); var oStoryDiv = document.getElementById(myDiv); oStoryDiv.innerHTML=sReturn; oStoryDiv.scrollTop = 0; if(oLibView.iPopoutDiv=="0" && currItem!=''){ //ShowDisplayListIcon(); } if(iHash==2){ LibScrollTo(myDiv); GotoHash('b2iLibScrollTo'); }else if(iHash==3){ LibScrollTo('Anchor' + myDiv); GotoHash('Anchor' + myDiv); }else if(iHash==1){ GotoHash('b2iLibScrollTo'); } } } xmlHttp.open(PostOrGet, sURL, true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.send(varString); } //-------------------------------------- function ShowDisplayListIcon(){ var oDisplayListDiv1 = document.getElementById("DisplayListDiv1"); oDisplayListDiv1.style.display="block"; var oDisplayListDiv2 = document.getElementById("DisplayListDiv2"); oDisplayListDiv2.style.display="block"; } //-------------------------------------- function GotoHash(sHash){ location.hash = ''; location.hash=sHash; } //-------------------------------------- function LibScrollTo(name) { LibScrollToResolver(document.getElementById(name)); } //-------------------------------------- function LibScrollToResolver(elem) { var jump = parseInt(elem.getBoundingClientRect().top) -100 -oLibView.iTopOffset; document.body.scrollTop += jump; document.documentElement.scrollTop += jump; } //-------------------------------------- function getParameterByName(name, url) { try{ if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } catch (error) { console.log("Caught Error:" + error); } } //-------------------------------------- function SetMeta(){ try{ var link = !!document.querySelector("link[rel='canonical']") ? document.querySelector("link[rel='canonical']") : document.createElement('link'); link.setAttribute('rel', 'canonical'); link.setAttribute('href', location.protocol + '//' + location.host + location.pathname + location.search); document.head.appendChild(link); link = document.createElement('meta'); link.setAttribute('property', 'og:url'); link.content = location.protocol + '//' + location.host + location.pathname + location.search; document.getElementsByTagName('head')[0].appendChild(link); } catch (error) { console.log("Caught Error:" + error); } } function SetMetaDesc(sDesc){ try{ var meta=document.getElementsByTagName("meta"); for (var i=0; i