/****************************
Social Share After Subs Pop-up
Basic config options
****************************/
// Heading
var spuHeading = 'Thanks for joining us!',
// Copy
spuCopy ='
Help us grow the BD community by sharing this with people you know
',
nlheading = 'Sign up to our newsletters',
// URL to be passed when sharing
URLtoShare = 'http://bit.ly/11pmZbZ',
// Title when sharing on Facebook
fbShareTitle = 'I\'ve just joined the BD community',
// Description when sharing on Facebook
fbShareDesc = 'Join me to get the latest news, views and debate on UK architecture',
// Title when sharing on LinkedIn
linShareTitle = 'I\'ve just joined the BD community',
// Description when sharing on LinkedIn
linShareDesc = 'Join me to get the latest news, views and debate on UK architecture',
// Copy when Tweeting
twitterShareCopy = 'I\'ve just joined the BD community! Get news, views and debate',
// Twitter handle for the "via" part of the tweet
twitHandle = 'bdonline',
/*--------------------------------
End basic customisations
---------------------------------*/
// Share URLs to use
spuTwitURL = 'https://twitter.com/intent/tweet?original_referer='+URLtoShare+'&source=subscribe&text='+encodeURIComponent(twitterShareCopy)+'&url='+encodeURIComponent(URLtoShare)+'&via='+twitHandle,
spuFacebookURL = 'http://www.facebook.com/sharer.php?s=100&p[title]='+encodeURIComponent(fbShareTitle) + '&p[summary]=' + encodeURIComponent(fbShareDesc) + '&p[url]=' + encodeURIComponent(URLtoShare),
spuLinkedInURL = 'http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(URLtoShare)+'&title='+encodeURIComponent(linShareTitle)+'&summary='+encodeURIComponent(linShareDesc),
spuGPlusURL = 'https://plus.google.com/share?url='+encodeURIComponent(URLtoShare);
// Social share pop-up functions
// Share window browser popup function
window.popupCenter=function(earl,wid,hei,targ){var leftt,topp;return leftt=screen.width/2-wid/2,topp=screen.height/2-hei/2,window.open(earl,targ,"menubar=no,toolbar=no,status=no,width="+wid+",height="+hei+",toolbar=no,left="+leftt+",top="+topp)}
// Generate the pop-up function
function regSPU(gethead,getcopy) {
var nlbox;
if (!jQuery('#ubmspu-cont').length) {
if (jQuery('#newsletter_block').length) {
var nlbox = '';
nlbox += jQuery('#newsletter_block').html().replace('my-account/my-newsletters','my-account/my-newsletters?origin=reg-popup').replace('
Sign in ','').replace(/id="([^"]*?)"/g,'id="$1_mv"').replace(/getElementById\(\'([^"]*?)\'\)/g,"getElementById('$1_mv')").replace(/\
([^"]*?)\<\/h2\>/,''+nlheading+' ').replace(/\ ([^"]*?)\<\/p\>/,'');
nlbox += '
';
}
var spuHTML = '
'+gethead+' '+getcopy+''+nlbox+'
';
jQuery(function(){
jQuery('body').append(spuHTML);
var ubmspuh = (jQuery('#ubmspu-cont').height())/2;
jQuery('#ubmspu-cont').css('marginTop','-'+ubmspuh+'px');
jQuery('#ubmspu-cont .ubmspu-l, #ubmspu-cont .ubmspu-r').height(jQuery('#ubmspu-cont').height()-238);
jQuery('#ubmspu-cont .ubmspu-close').click( function() {
jQuery('#ubmspu-cont').fadeOut( function() { jQuery('#ubmspu-cont').remove(); });
});
jQuery('.ubmspu-facebook a').click( function() {
popupCenter(spuFacebookURL,685,300);
shareRegSocial('reg:facebook');
return false;
});
jQuery('.ubmspu-linkedin a').click( function() {
popupCenter(spuLinkedInURL,600,500);
shareRegSocial('reg:linkedin');
return false;
});
jQuery('.ubmspu-twitter a').click( function() {
popupCenter(spuTwitURL,685,260);
shareRegSocial('reg:twitter');
return false;
});
jQuery('.ubmspu-gplus a').click( function() {
popupCenter(spuGPlusURL,600,600);
shareRegSocial('reg:googleplus');
return false;
});
jQuery('#ubmspu-cont').fadeIn();
});
}
}
// Cat name hack
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
jQuery(document).ready( function() {
if ( jQuery('#crumbtrail .current').html() === 'Stream' || jQuery('#crumbtrail .current').html() === 'Section 1' ) {
jQuery('#content_sleeve .story_small, #content_sleeve .story_large').each( function() {
var earl = jQuery(this).find('h2 a').attr('href');
if (typeof earl !== 'undefined') {
var myDomain = location.protocol + '//' + location.hostname + '/';
var prinav = earl.replace(myDomain, '');
prinav = prinav.split('/');
if (prinav.length > 2 ) {
if (prinav.length === 3) {
prinav = ' | ' + toTitleCase(prinav[0]);
}
else if (prinav.length === 4) {
prinav = ' | ' + toTitleCase(prinav[0]) + ' | ' + toTitleCase(prinav[1]);
}
else if (prinav.length === 5) {
prinav = ' | ' + toTitleCase(prinav[0]) + ' | ' + toTitleCase(prinav[1]) + ' | ' + toTitleCase(prinav[2]);
}
jQuery(this).find('.meta .date').after(' '+prinav+' ');
}
}
});
}
});
//TOOLSBOX JAVASCRIPT
//Allows the user to add BD Search and Bookmark the page
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
function addSearchProviderBD() {
try {
window.external.AddSearchProvider('/pictures/doubleclick/SearchPlugin/BDSearchPlugin.xml');
}
catch (e) {
alert("This plugin needs Firefox 2.0, Internet Explorer 7 or higher to work.");
return;
}
}
// Get Query String Vars Function
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i 0) return prefix + metas[i].content;
}
}
return "";
}
// SpiltStringWithPrefix Function
// Splits out truncated vars such as comma separated categories
function SplitStringWithPrefix(string,prefix,divider)
{
var i;
var string_array=(string).split(",");
var result="";
for (i=0;i0) {result = result + divider;};
result = result + prefix + string_array[i];
}
return result;
};
// Header Puffs
/* jQuery(document).ready(function(){
jQuery(".carousel").jCarouselLite({
btnNext: "#headpuffs .next",
btnPrev: "#headpuffs .prev",
hoverPause:true,
visible: 3,
auto:10000,
speed:250
});
});
*/
function contains(a, obj) {
var ln = a.length;
for (var i = 0; i < ln; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
//define DART site value
var dartsite = '/4782/cmpibe-bd';
// Super zones. These superseed navigated zones.
var superzones = new Array("sustainability","bim");
// Zone calculation
// Will always try to use a navigation path as a zone. The fallback would be the calculated navigation (crumbtrail) if a navigation path doesn't exist
var cz1 = getMeta('calcnavlevel1','');
var nz1 = getMeta('navlevel1','')
var cz2 = getMeta('calcnavlevel2','');
var nz2 = getMeta('navlevel2','')
var cz3 = getMeta('calcnavlevel3','');
var nz3 = getMeta('navlevel3','');
var storyheadline = getMeta('subject','');
if ( cz1 !== '' ) { var calcchannel = true; } else { var calcchannel = false; }
if (calcchannel) {
var omchannel = cz1;
var omtitlepref = cz1 + getMeta('calcnavlevel2',':') + getMeta('calcnavlevel3',':') + getMeta('subject',':');
}
else {
var omchannel = nz1;
var omtitlepref = nz1 + getMeta('navlevel2',':') + getMeta('navlevel3',':') + getMeta('subject',':');
}
var navzone = '/' + nz1 + getMeta('navlevel2','/') + getMeta('navlevel3','/');
var calczone = '/' + cz1 + getMeta('calcnavlevel2','/') + getMeta('calcnavlevel3','/');
var page = getMeta('pagename','');
var channel = '';
var zone = '';
var gated = '';
var story = '';
var kw = '';
var cats = '';
// Super zones, Homepage and Search Results pages override navigation zones
if ( contains(superzones,cz1) ) { channel = calczone; }
else if ( page == 'index' ) { channel = '/homepage'; }
else if ( page == 'searchresults' ) { channel = '/searchresults'; }
else if ( navzone == '/home' ) { channel = calczone; }
else
{
if (navzone == '/' && navzone != 'login-to-your-account' && navzone != '/home' ) {
if (calczone == '/') { channel = '/' + page; }
else { channel = calczone; }
}
else { channel = navzone; }
}
zone = dartsite + channel;
// Story string - only populates if you're on a story page
story = getMeta('storycode','');
if ( story !== '') {
if (getMeta('storyclassification','') == 'true') { gated = 'true'; }
else { gated = 'false'; }
cats = getMeta('storycats','');;
if (cats !== '') { cats = cats.split(","); }
}
if (page === 'signin') {
story = document.URL.match(/storycode\%3D(.*?)\%26/);
story = story[1];
}
// Search keywords
kw = getMeta("searchkeywords","");
if (kw !== '') { kw = kw.split(","); }
// Other metas being passed into vars. Allows for easier use with Omniture also
var userstatus = getMeta("userstatus","");
var usernm = getMeta("username","").replace(' ','-');
var stype = getMeta("subtype","");
var cosec = getMeta("cosec","");
var josec = getMeta("josec","");
var jlev = getMeta("jlev","");
var sectionname = getMeta('sectionname','');
// Renew date calculation
var rnew;
var dex = getMeta('dex','');
if (dex) {
dexParts = dex.split("/");
var dexDate = new Date(dexParts[2],dexParts[1]-1,dexParts[0]);
var todaysDate = new Date();
var one_day=1000*60*60*24;
var Diff = Math.ceil(((dexDate.getTime()-todaysDate.getTime())/(one_day)) + 1 - 1);
if (Diff === 1) {
rnew = '001dyr';
}
else if (Diff <= 7) {
rnew = '001wkr';
}
else if (Diff > 7) {
wks = Diff / 7;
wksrnd = Math.round(wks);
if (wks > wksrnd) {
wks = wksrnd+1;
}
else {
wks = wksrnd;
}
var wks = wks + '';
while(wks.length < 3) {
wks = "0" + wks;
}
rnew = wks+'wkr';
}
else {
rnew = ''
}
}
else {
rnew = '';
}
var dfpqs = getQueryVariable('dfp');
var dfporigin = getQueryVariable('origin');
if (!dfporigin) {
var dfporigin = getQueryVariable('cid');
if (!dfporigin) {
var dfporigin = getQueryVariable('bid');
if (!dfporigin) {
var dfporigin = getQueryVariable('seg');
if (!dfporigin) {
var dfporigin = getQueryVariable('lid');
if (!dfporigin) {
var dfporigin = getQueryVariable('kw');
if (!dfporigin) {
var dfporigin = getQueryVariable('utm_campaign');
if (!dfporigin) {
var dfporigin = getQueryVariable('utm_medium');
if (!dfporigin) {
var dfporigin = getQueryVariable('utm_source');
if (!dfporigin) {
var dfporigin = getQueryVariable('_mc,source');
}
}
}
}
}
}
}
}
}
// alert('channel = '+channel+'\nzone = '+zone+'\npage = '+page+'\nstory = '+story+'\nkw = '+kw+'\nrnew = '+rnew+'\nusernm = '+usernm+'\ncats = '+cats);
if (getQueryVariable("showadtag") == "1") {
jQuery(document).ready( function() {
jQuery('#toptile').remove();
jQuery('body').append('
');
jQuery('#bumme').html(' ');
});
}
var doAds;
if ( (page === 'story') && (storyheadline === "") ) {
var gatepage = true;
}
else { var gatepage = false; }
if ((gatepage !== true) && ( sectionname !== 'Information - BD' ) && ( typeof customAds === 'undefined' ) ) {
doAds = true;
}
else { doAds = false; }
function pick(arg, def) {
return (typeof arg == 'undefined' ? def : arg);
}
var topah;
function DFPboilerplate(top, undernav, mpu, mpu2, bottom, ooo, toppx, left)
{
var top1 = pick(top, false);
var undernav1 = pick(undernav, false);
var mpu1 = pick(mpu, false);
var mpu21 = pick(mpu2, false);
var bottom1 = pick(bottom, false);
var ooo1 = pick(ooo, false);
var toppx1 = pick(toppx, '49px');
var left1 = pick(left, '0px');
if (dogoog !== 1) {
if (top1 || undernav1 || mpu1 || mpu21 || bottom1 || ooo1) {
if(top1) {
topah = true;
document.write('');
googletag.defineSlot(zone, [[468, 60],[728, 90],[728, 100]], 'div-gpt-ad-topah').addService(googletag.pubads()).setTargeting("pos", 'top');
}
if(undernav1) {
googletag.defineSlot(zone, [977, 25], 'div-gpt-ad-undernav').addService(googletag.pubads()).setTargeting("pos", 'undernav');
}
if(mpu1) {
googletag.defineSlot(zone, [[300, 250],[300,300]], 'div-gpt-ad-mpu').addService(googletag.pubads()).setTargeting("pos", 'mpu');
}
if(mpu21) {
googletag.defineSlot(zone, [[300, 250],[300,600]], 'div-gpt-ad-mpu2').addService(googletag.pubads()).setTargeting("pos", 'mpu2');
}
if(bottom1) {
googletag.defineSlot(zone, [[468, 60],[728, 90],[728, 110]], 'div-gpt-ad-bottom').addService(googletag.pubads()).setTargeting("pos", 'bottom');
}
if(ooo1) {
googletag.defineOutOfPageSlot(zone, 'div-gpt-ad-outofpage').addService(googletag.pubads());
}
googletag.pubads().setTargeting("page", page).setTargeting("story", story).setTargeting("kw", kw).setTargeting("rnew", rnew).setTargeting("usernm", usernm).setTargeting("stype", stype).setTargeting("cosec", cosec).setTargeting("josec", josec).setTargeting("jlev", jlev).setTargeting("login", userstatus).setTargeting("origin", dfporigin).setTargeting("dfpqs", dfpqs);
googletag.pubads().enableSingleRequest();
googletag.pubads().enableSyncRendering();
googletag.enableServices();
var dogoog = 1;
}
else {
console.log('DFPboilerplate(): No Ad Units Specified');
}
}
else {
console.log('DFPboilerplate(): DFP Boilerplate already fired elsewhere');
}
}