mmcore.SetCookie('mmid','-1024342188|AQAAAArp5O0A+AoAAA==',365,1);mmcore.SetCookie('pd','-166316943|AQAAAAoBQunk7QD4CsHej34BACFKUyDfmdFIAA0AAAAhSlMg35nRSAAAAAD/////AP//////////AAZEaXJlY3QB+AoBAAAAAAABAAABAAD///////////////8CAIIgAAAApnkyKPgK/////wD4CvgK//8BAACjECtpAcB2AADxmwAAAIIkAAA+qKcRwvgK/////wD4CvgK//8BAACtX5e9AT+DAAC2qQAAAAAAAAFF',365);mmcore.SetCookie('srv','nycvwcgeu02',365);(function(){if(typeof(mmcore.GenInfo)!='object')mmcore.GenInfo={};mmcore.EH=function(e){var s=e.message+'\r\n';if(!window.mm_error)window.mm_error=s;else window.mm_error+=s;};
mmcore.GenInfo['T5MonitoringCam']={'element1':'Default'};
mmcore.GenInfo['T5 CID']={'element1':'Default'};
var tc={'Element1':{'h':[],'c':[],'l':[]},'Element1':{'h':[],'c':[],'l':[]}}
try{
// Maxymiser Core - Attach Style v0.0.0 http://gitlab.maxymiser.net/gts/mmcore-attach-style/tree/master
(function(){'use strict';mmcore.AttachStyle=function(){var c={STYLE_ID:"mm-style",createStyle:function(){var b=document.createElement("style");b.type="text/css";return b},appendCssToStyle:function(){var b,a;"styleSheet"in c.createStyle()?(b=function(a){return a.styleSheet.cssText},a=function(a,b){a.styleSheet.cssText=b}):(b=function(a){return a.innerHTML},a=function(a,b){a.innerHTML=b});return(c.appendCssToStyle=function(c,d){a(d,b(d)+c)}).apply(this,arguments)}};return function(b){var a=document.getElementById(c.STYLE_ID);a||(a=c.createStyle(),a.id=c.STYLE_ID,function(){this.parentNode.insertBefore(a,this)}.call(document.getElementsByTagName("head")[0].lastChild));c.appendCssToStyle(b,a)}}()})();
}catch(err){mmcore.EH(err);}
try{
(function ( window, mmcore, undefined ) {

	'use strict';

	var ecOmnitureUserSubCookie = mmcore.GetCookie( 'ec_omniture_user_sub', 1 ),
		logInState,
		subscriber,
		regState;

	/**
	 * Name: setCustomPersCrit function
	 * Description: adding pers criterion to the mmcore.uat cookie.
	 * Author: Edward Shveday
	 */
	function setCustomPersCrit( name, val ) {
		var _m = mmcore,
			_old = _m.GetCookie( 'uat' ),
			_f = _old.indexOf( name + '=' ) + 1,
			_re = new RegExp( name + "=[^;]*" ),
			_new = name + '=' + val;

		_m.SetCookie( 'uat', _old ? (_f ? _old.replace( _re, _new ) : _old + ';' + _new) : _new, 30 );
	}

	function getPaywallPersCritVal( val, type ) {
		switch ( val.toString() ) {
			case '1':
				return type + '1';

			case '2':
				return type + '2';

			case '3':
				return type + '3';

			case '4':
				return type + '4';

			case '5':
				return type + '5';

			case '6':
			case '7':
				return type + '6-7';

			case '8':
			case '9':
				return type + '8-9';

			case '10':
			default:
				return type + '10plus';
		}
	}

	function handlePaywall( paywallName ) {
		var oldCookieVal,
			newCookieVal,
			type;

		oldCookieVal = mmcore.GetCookie( 'mm_' + paywallName, 1 );
		oldCookieVal = parseInt( oldCookieVal, 10 );
		type = paywallName.substring( 0, 3 );

		if ( !oldCookieVal ) {
			oldCookieVal = 0;
		}

		newCookieVal = oldCookieVal + 1;

		mmcore.SetCookie( 'mm_' + paywallName, newCookieVal, 1, -1 );
		setCustomPersCrit( paywallName, getPaywallPersCritVal( newCookieVal, type ) );
	}

	function setPaywallPersCrit() {
		var val;

		try {
			val = window.Drupal.settings.ec_wallpage.ec_wallpage_paywall_name.toLowerCase();
			if ( val === 'article paywall anonymous' ) {
				handlePaywall( 'RegwallViews' );
			} else if ( val === 'article paywall registered' ) {
				handlePaywall( 'SubwallViews' );
			}
		} catch ( err ) { /* silence */ }
	}

	logInState = JSON.parse( mmcore.GetCookie( 'Econ.user.user', 1 ) || '{"name": null}' ).name === null ? 'LoggedOut' : 'LoggedIn';
	regState = 'NotRegistered';

	switch ( ecOmnitureUserSubCookie.toLowerCase() ) {
		case 'bulk-ip':
			subscriber = 'BulkIP';
			break;

		case 'bulk-referrer':
			subscriber = 'BulkReferrer';
			break;

		case 'subscriber':
			subscriber = 'DigitalPrint';
			break;

		case 'print-subscriber':
			subscriber = 'Print';
			break;

		case 'digital-subscriber':
			subscriber = 'Digital';
			break;

		case 'ex-subscriber':
		case 'registered':
			regState = 'Registered';
		default:
			subscriber = 'NotSubscribed';
			break;
	}

	setCustomPersCrit( 'LogInState', logInState );
	setCustomPersCrit( 'Subscriber', subscriber );
	setCustomPersCrit( 'RegState', regState );
	setPaywallPersCrit();


	// -----------------------------------
	// New Pers Criterions
	// -----------------------------------
	(function ( m ) {
		var obj, PCs, temp, nowTime, filterAfterPoint;

		PCs = {
			ClickDepth: 0,
			Recency: 0,
			Loyalty: 0,
			Brand: 0,
			Interaction: 0,
			SignedIn: 0
		};

		obj = m.GetCookie( 'mm_PCObj', 1 );

		filterAfterPoint = function ( number ) {
			number = Math.round( number * 100 ) * 0.01;
			number = (function () {
				switch ( true ) {
					case number < 0.05:
						return 0;
					case number < 0.15:
						return 0.1;
					case number < 0.25:
						return 0.2;
					case number < 0.35:
						return 0.3;
					case number < 0.45:
						return 0.4;
					case number < 0.55:
						return 0.5;
					case number < 0.65:
						return 0.6;
					case number < 0.75:
						return 0.7;
					case number < 0.85:
						return 0.8;
					case number < 0.95:
						return 0.9;
					default:
						return 1;
				}
			}());

			return number;
		};

		if ( obj ) {
			obj = JSON.parse( obj );
		} else {
			obj = {
				wFV: false,
				sD: [],
				ss: [],
				cD: 0
			};
		}

		if ( !m.GetCookie( 'mm_Session', 1 ) ) {
			//	m.SetCookie( 'mm_Session', 1, 5 / (24 * 60), 1 );
			m.SetCookie( 'mm_Session', 1, 0, 1 );

			temp = {
				t: new Date().getTime(),
				r: 0,
				i: 0,
				s: 0
			};

			try {
				if ( JSON.parse( m.GetCookie( 'Econ.user.user', 1 ) ).name ) {
					temp.s = 1;
				}
			} catch ( e ) { }

			if ( document.referrer ) { temp.r = 1; }
			obj.ss.push( temp );

			if ( obj.wFV ) {
				obj.sD.push( obj.cD );
				obj.cD = 0;
			}
		} else {
			obj.cD += 1;
		}

		obj.wFV = 1;

		if ( location.href.indexOf( '/comments' ) + 1 ) {
			obj.ss[obj.ss.length - 1].i = 1;
		}

		// is it first visit
		if ( obj.sD.length ) {
			// -----------------------------------
			// ClickDepth
			// -----------------------------------
			temp = 0;
			$.each( obj.sD, function ( idx, val ) {
				if ( val < 4 ) { return; }
				temp += 1;
			} );

			temp = temp / obj.sD.length;
			PCs.ClickDepth = temp;
			temp = filterAfterPoint( temp );
			setCustomPersCrit( 'ClickDepth', 'Ci' + temp );

			// -----------------------------------
			// Recency
			// -----------------------------------
			temp = 1;
			if ( obj.ss.length > 1 ) {
				temp = 0;
				temp = obj.ss.slice( -2 );
				temp = (temp[1].t - temp[0].t) / (1000 * 60 * 60 * 24);
				if ( temp < 1 ) {
					temp = 1;
				}
			}
			temp = 1 / temp;
			PCs.Recency = temp;
			temp = filterAfterPoint( temp );
			temp = 'Ri' + temp;
			setCustomPersCrit( 'Recency', temp );

			// -----------------------------------
			// Loyalty
			// -----------------------------------
			temp = 0;
			nowTime = new Date().getTime();
			$.each( obj.ss, function ( idx, val ) {
				var difference = (nowTime - val.t) / (1000 * 60 * 60 * 24);
				if ( difference > 28 ) { return; }
				//				var difference = (nowTime - val.t) / (1000 * 60);
				//				if ( difference > 30 ) { return; }
				temp += 1;
			} );
			if ( !temp ) { temp = 1; }
			temp = 1 - 1 / temp;
			PCs.Loyalty = temp;
			temp = filterAfterPoint( temp );
			setCustomPersCrit( 'Loyalty', 'Li' + temp );

			// -----------------------------------
			// Interaction
			// -----------------------------------
			temp = 0;
			$.each( obj.ss, function ( idx, val ) {
				if ( obj.ss.length - 1 === idx ) { return; }
				if ( !val.i ) { return; }
				temp += 1;
			} );
			temp = temp / (obj.ss.length - 1);
			PCs.Interaction = temp;
			temp = filterAfterPoint( temp );
			setCustomPersCrit( 'Interaction', 'Ii' + temp );
		} else {
			setCustomPersCrit( 'ClickDepth', '' );
			setCustomPersCrit( 'Recency', '' );
			setCustomPersCrit( 'Loyalty', '' );
			setCustomPersCrit( 'Interaction', '' );
		}

		// -----------------------------------
		// Brand
		// -----------------------------------
		temp = 0;
		$.each( obj.ss, function ( idx, val ) {
			if ( val.r ) { return; }
			temp += 1;
		} );
		temp = temp / obj.ss.length;
		PCs.Brand = temp;
		temp = filterAfterPoint( temp );
		setCustomPersCrit( 'Brand', 'Bi' + temp );

		// -----------------------------------
		// SignedIn
		// -----------------------------------
		temp = 0;
		if ( obj.ss.length > 0 ) {
			$.each( obj.ss, function ( idx, val ) {
				if ( !val.s ) { return; }
				temp += 1;
			} );
			temp = temp / obj.ss.length;
		}
		temp = filterAfterPoint( temp );
		PCs.SignedIn = temp;
		setCustomPersCrit( 'SignedIn', 'Si' + temp );

		if ( obj.sD.length ) {
			// -----------------------------------
			// VEI
			// -----------------------------------
			temp = 0;
			$.each( PCs, function ( idx, val ) {
				if ( val ) {
					temp += val;
				}
			} );
			temp = filterAfterPoint( temp / 6 );
			setCustomPersCrit( 'VEI', 'VEI' + temp );
		} else {
			setCustomPersCrit( 'VEI', '' );
		}

		obj.sD = obj.sD.slice( obj.sD.length - 25, obj.sD.length );
		obj.ss = obj.ss.slice( obj.ss.length - 25, obj.ss.length );

		m.SetCookie( 'mm_PCObj', JSON.stringify( obj ), 365, 1 );

	}( window.mmcore ));

	/*
	 * Referrer
	 * */

	var drf = document.referrer;

	switch ( true ) {
		// referrer contains terms: “yahoo”, “google” or “bing”
		// THEN set PC [Referrer] = Search
		case !!drf.match( /^https?:\/\/[^?\/]*(yahoo|google|bing)\.\w{1,3}(\.\w{2})?/i ) :
		{
			setCustomPersCrit( 'Referrer', 'Search' );
			break;
		}
		case !!drf.match( /^https?:\/\/[^?\/]*(facebook|t.co|reddit|digg)\.\w{1,3}(\.\w{2})?/i ) :
		{
			setCustomPersCrit( 'Referrer', 'Social' );
			break;
		}
		case !drf.match( /^https?:\/\/[^?\/]*economist.com/i ) :
		{
			setCustomPersCrit( 'Referrer', 'External' );
			break;
		}
		case !!drf.match( /^https?:\/\/[^?\/]*economist.com/i ) :
		{
			setCustomPersCrit( 'Referrer', 'Internal' );
			break;
		}
		default :
		{
			setCustomPersCrit( 'Referrer', 'TypedBM' );
		}
	}

	/*
	 * Referrer [end]
	 * */

	/*
	 * Entry
	 * */
	(function () {
		'use strict';

		var wlh = window.location.href,
			entryAttr = null,
			$mediator = $( {} ),
			runWaiter = function () {
				var sourceNode = $( 'script:contains("\"| From the print edition\"")' );
				var $body = $( 'body' );

				if (
					(
						sourceNode.size() ||
						$( 'footer' ).size()
						) &&
					$body.size()
					) {
					entryAttr = (function () {
						switch ( false ) {
							case !($body.hasClass( 'node-type-article' ) && sourceNode.size()):
								return 'PrintEd';
							case !($body.hasClass( 'node-type-article' )):
								return 'Article';
							case !($body.hasClass( 'node-type-channel' )):
								return 'Category';
							default:
								return '';
						}
					})();
					$mediator.trigger( 'finishWait' )
				} else {
					setTimeout( runWaiter, 19 );
				}
			};

		if ( wlh.match( /https?:\/\/www\.economist\.com(\/|#.*|\?.*|\/#.*|\/\?.*)?$/i ) ) {
			entryAttr = 'Homepage';
		} else if ( wlh.match( /https?:\/\/www\.economist\.com\/blogs.*/i ) ) {
			entryAttr = 'Blogs';
		} else if ( wlh.match( /https?:\/\/subscriptions\.economist\.com.*/i ) ) {
			entryAttr = 'SubsPage';
		} else {
			runWaiter();
		}

		if ( entryAttr === null ) {
			$mediator.bind( 'finishWait', function () {
				setCustomPersCrit( 'Entry', entryAttr );
			} );
		} else {
			setCustomPersCrit( 'Entry', entryAttr );
		}
	})();

})( window, window.mmcore );
}catch(err){mmcore.EH(err);}
try{
//Essentials

// Maxymiser Core - Try Catch v0.0.0 http://gitlab.maxymiser.net/gts/mmcore-try-catch/tree/master
(function(){'use strict';mmcore.tryCatch=function(){return function b(c,d){var e=arguments.length;return function(){try{return c.apply(this,arguments)}catch(a){try{mmcore.EH(a)}finally{1<e&&b(d)(a)}}}}}()})();

// Maxymiser Essentials - Deferred v0.0.1
(function(){var n,r,e,t,u,i,o,l,c,s,a,f,p=[].slice;r="pending",t="resolved",e="rejected",l=function(n,r){return null!=n?n.hasOwnProperty(r):void 0},c=function(n){return l(n,"length")&&l(n,"callee")},s=function(n){return l(n,"promise")&&"function"==typeof(null!=n?n.promise:void 0)},o=function(n){return c(n)?o(Array.prototype.slice.call(n)):Array.isArray(n)?n.reduce(function(n,r){return Array.isArray(r)?n.concat(o(r)):(n.push(r),n)},[]):[n]},u=function(n,r){return 0>=n?r():function(){return--n<1?r.apply(this,arguments):void 0}},a=function(n,r){return function(){var e;return e=[n].concat(Array.prototype.slice.call(arguments,0)),r.apply(this,e)}},i=function(n,r,e){var t,u,i,l,c;for(l=o(n),c=[],u=0,i=l.length;i>u;u++)t=l[u],c.push(t.call.apply(t,[e].concat(p.call(r))));return c},n=function(){var u,l,c,a,f,h,g;return g=r,a=[],f=[],h=[],c={resolved:{},rejected:{},pending:{}},this.promise=function(u){var l,y;return u=u||{},u.state=function(){return g},y=function(n,e,t){return function(){return g===r&&e.push.apply(e,o(arguments)),n()&&i(arguments,c[t]),u}},u.done=y(function(){return g===t},a,t),u.fail=y(function(){return g===e},f,e),u.progress=y(function(){return g!==r},h,r),u.always=function(){var n;return(n=u.done.apply(u,arguments)).fail.apply(n,arguments)},l=function(r,e,t){var i,o;return o=new n,i=function(n,r,e){return u[n](e?function(){var n,t;return n=1<=arguments.length?p.call(arguments,0):[],t=e.apply(null,n),s(t)?t.done(o.resolve).fail(o.reject).progress(o.notify):o[r](t)}:o[r])},i("done","resolve",r),i("fail","reject",e),i("progress","notify",t),o},u.pipe=l,u.then=l,null==u.promise&&(u.promise=function(){return u}),u},this.promise(this),u=this,l=function(n,e,t){return function(){return g===r?(g=n,c[n]=arguments,i(e,c[n],t),u):this}},this.resolve=l(t,a),this.reject=l(e,f),this.notify=l(r,h),this.resolveWith=function(n,r){return l(t,a,n).apply(null,r)},this.rejectWith=function(n,r){return l(e,f,n).apply(null,r)},this.notifyWith=function(n,e){return l(r,h,n).apply(null,e)},this},f=function(){var r,e,t,i,l,c,a;if(e=o(arguments),1===e.length)return s(e[0])?e[0]:(new n).resolve(e[0]).promise();if(l=new n,!e.length)return l.resolve().promise();for(i=[],t=u(e.length,function(){return l.resolve.apply(l,i)}),e.forEach(function(n,r){return s(n)?n.done(function(){var n;return n=1<=arguments.length?p.call(arguments,0):[],i[r]=n.length>1?n:n[0],t()}):(i[r]=n,t())}),c=0,a=e.length;a>c;c++)r=e[c],s(r)&&r.fail(l.reject);return l.promise()},mmcore.Deferred=function(){return new n},mmcore.when=f}).call(this);

// Maxymiser Essentials - Wait for v0.1.1
!function(){"use strict";mmcore.waitFor=function(e,t){var i,o;return o=mmcore.Deferred(),o.isComplete=function(){return"pending"!==o.state()},t=t||{},t.interval=t.interval||50,t.isNotStoppedOnDocumentReadiness=t.isNotStoppedOnDocumentReadiness||!1,t.isNotPeriodicallyChecked=t.isNotPeriodicallyChecked||!1,i=function(){o.isComplete()||(e.call(o)&&o.resolve(),o.isComplete()||(!t.isNotStoppedOnDocumentReadiness&&(mmcore.$&&mmcore.$.isReady||!mmcore.$&&"complete"===document.readyState)?o.reject():t.isNotPeriodicallyChecked||setTimeout(i,t.interval)))},t.hasOwnProperty("initializer")&&t.initializer.call(o),i(),o.isComplete()||(t.hasOwnProperty("timeout")&&!function(){var e=setTimeout(o.reject,t.timeout);o.always(function(){clearTimeout(e)})}(),t.isNotStoppedOnDocumentReadiness||mmcore.AddDocLoadHandler(t.isNotPeriodicallyChecked?o.reject:i)),o.promise()}}();

// Maxymiser Core - Campaign v0.3.0 http://gitlab.maxymiser.net/gts/mmcore-campaign/tree/master
(function(){"use strict";function e(e,t){var n=false;for(var r=0;r<t.length;r++){if(t[r]===e){n=true}}return n}function n(e,t,n){this.name=e;this.maxyboxNames=t;this.prefix=n;this.preventDefaultRendering();this.preventDefaultHiding()}mmcore.Campaign=n;var t=function(e,t,n){var r,i=[],s=0,o=e.length;n=!!n;for(;s<o;s++){r=!!t(e[s],s);if(n!==r){i.push(e[s])}}return i};n.prototype.preventDefaultRendering=function(){var e=mmcore._r_mbs;var t=this.maxyboxNames;var n=t.length;while(n--){e[t[n]]=1}};n.prototype.preventDefaultHiding=function(){var n=this;mmcore.HideMaxyboxes=function(r){return function(){var i=arguments;mmcore.tryCatch(function(){i=t(i,function(t){return e(t,n.maxyboxNames)})})();if(i.length){return r.apply(this,i)}}}(mmcore.HideMaxyboxes)};n.prototype.hideContent=function(e,t){var n;var r;var i;var s;var o=document.getElementsByTagName("html")[0];var u=o.getAttribute("class");this.hidingClass=this.prefix+"-hidden-content";if(u!==null&&u===""){u=this.hidingClass}else{u=u+" "+this.hidingClass}o.setAttribute("class",u);if(arguments.length<2){t="left: -33554430px; position: absolute; top: -33554430px;"}n=this.hidingClass;s=e.split(",");i=s.length;r="";while(i--){r+="."+n+" "+s[i]+"{"+t+"}"}mmcore.AttachStyle(r)};n.prototype.showContent=function(){if(this.hasOwnProperty("hidingClass")){var e=document.getElementsByTagName("html")[0];var t=e.getAttribute("class");if(t!==null&&t!==""){t=t.replace(this.hidingClass,"");e.setAttribute("class",t)}}};n.prototype.getExperience=function(){return mmcore.GenInfo.hasOwnProperty(this.name)?mmcore.GenInfo[this.name]:null};n.prototype.hasNonDefaultExperience=function(){var e,t;e=this.getExperience();if(!e){return false}t=false;for(var n in e){if(e.hasOwnProperty(n)&&e[n]!=="Default"){t=true;return false}}return t};n.prototype.hasMaxybox=function(){return this.hasNonDefaultExperience()};n.prototype.renderMaxyboxes=function(){var n;var r;var i;r=this.maxyboxNames;if(arguments.length){r=t(arguments,function(t){return!e(t,r)})}n=this;for(i in mmcore._renderers){if(e(i,r)&&typeof mmcore._renderers[i]==="function"){mmcore._renderers[i].call(n)}}}})();

// Maxymiser Essentials - Request 0.2.0
(function(){"use strict";var e=mmcore.jQuery;var t="event";var n=2250;var r;var i=function(){r=mmcore.Deferred();mmcore.request.promise=r.promise()};mmcore.request=function(e,s){var o=r;i();if(!arguments.length){e=t}mmcore.SetPageID(e);mmcore._async=!s;mmcore.CGRequest(o.resolve);setTimeout(mmcore.tryCatch(o.reject),n);return o.promise()};i()})();

//Maxymiser Essentials - Mediator 0.2.0
(function(){"use strict";function e(){var e=function(){return((1+Math.random())*65536|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}function t(n,r,i){if(!(this instanceof t)){return new t(n,r,i)}this.id=e();this.fn=n;this.options=r;this.context=i;this.channel=null}function n(e,t){if(!(this instanceof n)){return new n(e)}this.namespace=e||"";this._subscribers=[];this._channels=[];this._parent=t;this.stopped=false}function r(){if(!(this instanceof r)){return new r}this._channels=new n("")}t.prototype={update:function(e){if(e){this.fn=e.fn||this.fn;this.context=e.context||this.context;this.options=e.options||this.options;if(this.channel&&this.options&&this.options.priority!==undefined){this.channel.setPriority(this.id,this.options.priority)}}}};n.prototype={addSubscriber:function(e,n,r){var i=new t(e,n,r);if(n&&n.priority!==undefined){n.priority=n.priority>>0;if(n.priority<0){n.priority=0}if(n.priority>=this._subscribers.length){n.priority=this._subscribers.length-1}this._subscribers.splice(n.priority,0,i)}else{this._subscribers.push(i)}i.channel=this;return i},stopPropagation:function(){this.stopped=true},getSubscriber:function(e){var t=0,n=this._subscribers.length;for(t,n;t<n;t++){if(this._subscribers[t].id===e||this._subscribers[t].fn===e){return this._subscribers[t]}}},setPriority:function(e,t){var n=0,r=0,i,s,o,u;for(r=0,u=this._subscribers.length;r<u;r++){if(this._subscribers[r].id===e||this._subscribers[r].fn===e){break}n++}i=this._subscribers[n];s=this._subscribers.slice(0,n);o=this._subscribers.slice(n+1);this._subscribers=s.concat(o);this._subscribers.splice(t,0,i)},addChannel:function(e){this._channels[e]=new n((this.namespace?this.namespace+":":"")+e,this)},hasChannel:function(e){return this._channels.hasOwnProperty(e)},returnChannel:function(e){return this._channels[e]},removeSubscriber:function(e){var t=this._subscribers.length-1;if(!e){this._subscribers=[];return}for(t;t>=0;t--){if(this._subscribers[t].fn===e||this._subscribers[t].id===e){this._subscribers[t].channel=null;this._subscribers.splice(t,1)}}},publish:function(e){var t=0,n=this._subscribers.length,r=false,i,s,o,u;for(t,n;t<n;t++){r=false;if(!this.stopped){i=this._subscribers[t];if(i.options!==undefined&&typeof i.options.predicate==="function"){if(i.options.predicate.apply(i.context,e)){i.fn.apply(i.context,e);r=true}}else{o=this._subscribers.length;i.fn.apply(i.context,e);u=this._subscribers.length;n=u;if(u===o-1){t--}r=true}}if(r&&i.options&&i.options!==undefined){i.options.calls--;if(i.options.calls<1){this.removeSubscriber(i.id);n--;t--}}}if(this._parent){this._parent.publish(e)}this.stopped=false}};r.prototype={getChannel:function(e){var t=this._channels,n=e.split(":"),r=0,i=n.length;if(e===""){return t}if(n.length>0){for(r,i;r<i;r++){if(!t.hasChannel(n[r])){t.addChannel(n[r])}t=t.returnChannel(n[r])}}return t},subscribe:function(e,t,n,r){var i=this.getChannel(e);n=n||{};r=r||{};return i.addSubscriber(t,n,r)},once:function(e,t,n,r){n=n||{};n.calls=1;return this.subscribe(e,t,n,r)},getSubscriber:function(e,t){return this.getChannel(t||"").getSubscriber(e)},remove:function(e,t){this.getChannel(e).removeSubscriber(t)},publish:function(e){var t=Array.prototype.slice.call(arguments,1),n=this.getChannel(e);t.push(n);this.getChannel(e).publish(t)}};r.prototype.on=r.prototype.subscribe;r.prototype.bind=r.prototype.subscribe;r.prototype.emit=r.prototype.publish;r.prototype.trigger=r.prototype.publish;r.prototype.off=r.prototype.remove;r.Channel=n;r.Subscriber=t;mmcore.mediator=new r})();
}catch(err){mmcore.EH(err);}
try{
;(function ( m ) {
	var clientID;

	clientID = 'economistcomprod';

	(function ( config ) {
		var m = mmcore, gi = m.GenInfo, testName;

		if ( typeof m._omnitureTests === 'undefined' ) {
			m._omnitureTests = [];
		}

		function contains( arr, val ) {
			var i = arr.length;
			while ( i-- ) {
				if ( arr[i] === val ) return true;
			}
			return false;
		}

		function trackOmniture( testName ) {
			if ( contains( m._omnitureTests, testName ) ) {
				return;
			}

			m._omnitureTests.push( testName );

			var mgi = m.GenInfo[testName],
				arr = [testName], el, prop, genString;

			for ( el in mgi ) if ( mgi.hasOwnProperty( el ) ) {
				arr.push( mgi[el].toLowerCase() );
			}

			// current test experience
			genString = arr.join( '|' );

			if ( !window.mmcoreSV ) {
				window.mmcoreSV = {};
				window.mmcoreSV[config.eVar] = genString;
				window.mmcoreSV[config.prop] = genString;
			} else {
				if ( typeof window.mmcoreSV === 'object' ) {
					for ( prop in window.mmcoreSV ) if ( window.mmcoreSV.hasOwnProperty( prop ) ) {
						window.mmcoreSV[prop] += ';' + genString;
					}
				}
			}

			(function waitSgi() {
				var s;

				if ( !window.s_gi ) {
					setTimeout( function () {
						waitSgi();
					}, 500 );
					return;
				}

				s = s_gi( config.clientID );
				s[config.eVar] = mmcoreSV[config.eVar];
				s[config.prop] = mmcoreSV[config.prop];
				s.linkTrackVars = config.prop + ',' + config.eVar;

				s.tl( true, 'o', window.mmcoreSV );
			}());
		}

		mmcore.AddDocLoadHandler( function () {
			setTimeout( function () {
				for ( testName in gi ) if ( gi.hasOwnProperty( testName ) ) {
					if ( testName.match( /master/i ) ) continue;
					trackOmniture( testName );
				}
			}, 0 )
		} );

	}( {
		clientID: clientID,
		eVar: 'eVar51',
		prop: 'prop51'
	} ));

}( window.mmcore ));
}catch(err){mmcore.EH(err);}
try{
// --------------------------------------------------------------------------------
// Common show-hide solution for all campaigns at the domain level. 
// To extend campaign with additional functions just add them to Campaign.prototype
// --------------------------------------------------------------------------------
;(function (m) {
    'use strict';
	
    function Campaign(config) {
        this._objStyle = {};
        this._config = config;
        this.name = config.name;
        this.mmPath = config.mmPath;
    }
    Campaign.prototype.addStyle = (function () {
        var cg1 = document.getElementById(m.cprefix + '1'), st;
        return function (css, name) {
            st = this._objStyle[name];
            name = name || "mm_style";
            if (!st) {
                st = document.createElement("style");
                st.type = "text/css";
                cg1.parentNode.insertBefore(st, cg1);
                this._objStyle[name] = st;
            }
            if (st.styleSheet) {
                st.styleSheet.cssText += css;
            } else {
                st.innerHTML += css;
            }
        };
    }());
    Campaign.prototype.removeStyle = function (name) {
        var st = this._objStyle[name];
        name = name || "mm_style";
        if (st) {
            st.parentNode.removeChild(st);
        }
        delete this._objStyle[name];
    };
    Campaign.prototype.preloadImages = function (tc) {
        if (!tc) {
            return false;
        }
        var self = this, mb, con, v, tcc, src, i, gi = m.GenInfo[self._config.name];
        self.mb = {};
        self._rmb = [];
        for (mb in tc) {
            if (tc.hasOwnProperty(mb)) {
                v = gi[mb.toLowerCase()];
                self.mb[mb] = v;
                if (!/undefined|default/i.test(v)) {
                    self._rmb.push(mb);
                    if (!self._config.mmPath) {
                        continue;
                    }
                    for (con in tc[mb]) {
                        if (tc[mb].hasOwnProperty(con)) {
                            tcc = tc[mb][con];
                            i = tcc.length;
                            while (i--) {
                                tc[mb][con][i] = tcc[i].replace(/\[mm_path\]([^)'"]+)/g, function (m, img) {
                                    src = (new Image()).src = self._config.mmPath + img;
                                    return src;
                                }); 
                            } 
                        }
                    } 
                }
            }
        }
        return self._rmb.length;
    };
    Campaign.prototype.render = function () {
        var self = this,
            isAsync = !!self._config.pageID,
            content = {
                show: function () {
                    self.removeStyle(self._config.name);
                },
                hide: function () {
                    self.addStyle(self._config.hide + '{position: relative; left:-10000px}', self._config.name);
                }
            },
            checker = (function () {
                var is_checker_set = typeof self._config.checker === 'function',
                    exit = (isAsync) ? false : m._docEnd;
                return function () {
                    return is_checker_set ? (self._config.checker() || exit) : exit;
                };
            }()),
            stopChecker = (function () {
                var is_checker_set = typeof self._config.stopChecker === 'function',
                    exit = m._docEnd;
                if (isAsync) {
                    exit = false;
                    setTimeout(function () { exit = true; }, self._config.checkerTimeout || 5000);
                }
                return function () {
                    return is_checker_set ? (self._config.stopChecker() || exit) : exit;
                };
            }());
        if (isAsync || self.preloadImages(tc || null)) {
            content.hide();
        } else {
            return;
        }
        (function waiter() {
            if (checker()) {
                if (isAsync) {
                    m._async = true;
                    m.SetPageID(self._config.pageID);
                    if (typeof self._config.beforeCGRequest === 'function') {
                        self._config.beforeCGRequest();
                    }
                    m.AddDocLoadHandler(function () {});
                    m.CGRequest(function () {
                        m.AddDocLoadHandler(function () {
                            if (typeof self._config.afterCGRequest === 'function') {
                                self._config.afterCGRequest();
                            }
                            content.show();
                        });
                    });
                    m.HideMaxyboxes = function () {};
                    setTimeout(content.show, self._config.emergencyOpenTimeout || 3000);
                } else if (self._rmb.length) {
                    m.RenderMaxyboxes(self._rmb);
                    content.show();
                }
            } else if (!stopChecker()) {
                setTimeout(waiter, 50);
            } else {
                content.show();
            }
        }());
    };
    m.initCampaign = function (config) {
        return new Campaign(config);
    };
}(window.mmcore));
}catch(err){mmcore.EH(err);}
try{
;(function () {
	if ( document.querySelector( 'meta[name="articleid"][content]' ) ) {
		mmcore._async = false;
		mmcore.SetPageID( 'ArticlePage' );
		mmcore.CGRequest();
	}
}());
}catch(err){mmcore.EH(err);}
try{
// Registrations Action
// Registrations2 Action (has Attrs)

(function () {
	'use strict';

	var $ = window.jQuery;
	var m = window.mmcore;
	var tmt;
	var wlpn = window.location.pathname;

	$( function () {
		// Registrations2 - Regwall
		$( document ).ajaxComplete( function ( e, xhr, settings ) {
			if ( xhr && xhr.readyState === 4 && xhr.status === 200 ) {
				var isThankYou = $( '#column-content #ec-homepage-overlay-ref-form h2:contains("Thank you for registering")' ).length;
				if ( settings.url.indexOf( '/ec-homepage/regov/js' ) + 1 && isThankYou ) {
					m.$Action( 'Registrations2', '1', 'Regwall' );
					m._async = true;
					m.SetPageID( 'mmevents' );
					m.CGRequest();
				}
			}
		} );

		// Registrations2 - Overlay
		var isOverlayTracked = false;
		$( document ).ajaxComplete( function ( event, XMLHttpRequest, ajaxOptions ) {
			var isThankYou = $( '#simplemodal-container #ec-homepage-overlay-ref-form h2:contains("Thank you for registering")' ).length;
			if ( ajaxOptions.url === '/ec-homepage/regov/js' && isThankYou ) {
				isOverlayTracked = true;
				m.$Action( 'Registrations', '1' );
				m.$Action( 'Registrations2', '1', 'Overlay' );
				m._async = true;
				m.SetPageID( 'events' );
				m.CGRequest();
			}
		} );

		// Registrations2 - Comment
		$( 'form.context-user_register_comment' ).live( 'submit', function () {
			m.SetCookie( 'mm_regComment', '1', 0, 1 );
		} );

		if ( !$( 'form.context-user_register_comment' ).length && m.GetCookie( 'mm_regComment', 1 ) ) {
			m.SetAction( 'Registrations2', '1', 'Comment' );
			m._async = true;
			m.SetPageID( 'events' );
			m.CGRequest();
			m.SetCookie( 'mm_regComment', '', -1, 1 );
		}
	} );

	if ( m.GetCookie( 'mmRegisterTry', 1 ) !== '' && (m.GetCookie( 'ec_omniture_user_sub', 1 ) === 'registered' || m.GetCookie( 'ec_omniture_user_sub', 1 ) === 'subscriber') ) {
		m.$Action( 'T4Registrations', '1' );

		(function () {
			var attr = '';
			if ( m.GetCookie( 'mm_regActivate', 1 ) ) {
				attr = 'Activate';
			} else if ( m.GetCookie( 'mm_regNewsletter', 1 ) ) {
				attr = 'Newsletter';
			} else if ( m.GetCookie( 'mmRWused', 1 ) ) {
				attr = 'Regwall';
			}
			m.$Action( 'Registrations2', '1', attr );
		}());

		m._async = true;
		m.SetPageID( 'events' );
		m.CGRequest();
		m.SetCookie( 'mm_regNewsletter', '', -1, 1 );
		m.SetCookie( 'mm_regActivate', '', -1, 1 );
		m.SetCookie( 'mmRegisterTry', '', -1, 1 );
		m.SetCookie( 'mmRWused', '', -1, 1 );
	}

	// Logic 1
	(function waiter() {
		var iframe;

		iframe = $( '#simplemodal-data iframe:visible' );

		if ( iframe.attr( 'src' ) && !!~iframe.attr( 'src' ).indexOf( 'registration_complete=true' ) ) {
			//action( 'T4Registrations', 1, '' );
			m.$Action( 'T4Registrations', '1' );
		} else {
			tmt = setTimeout( waiter, 500 );
		}
	})();

	setTimeout( function () {
		tmt && clearTimeout( tmt );
	}, 10000 );

	// Logic 2
	if ( wlpn === '/user/register' ) {
		$( function () {
			var NOerrors;

			NOerrors = $( '#user-register .form-item-error:visible' ).size() === 0;

			setTimeout( function () {
				$( '#user-register' ).submit( function () {
					NOerrors = $( '#user-register .form-item-error:visible' ).size() === 0;

					if ( NOerrors ) {
						m.SetCookie( 'mmRegisterTry', true, 0, 1 );

						if ( location.href.indexOf( 'destination=newsletters' ) + 1 ) {
							m.SetCookie( 'mm_regNewsletter', 1, 0, 1 );
						}

						if ( $( '#page-title:contains(Activate digital access)' ).length ) {
							m.SetCookie( 'mm_regActivate', 1, 0, 1 );
						}

						if ( location.search.indexOf( 'rp=paywall' ) + 1 ) {
							m.SetCookie( 'mmRWused', 1, 0, 1 );
						}
					}
				} );
			}, 1000 );

			if ( NOerrors === false ) {
				m.SetCookie( 'mm_regNewsletter', '', -1, 1 );
				m.SetCookie( 'mm_regActivate', '', -1, 1 );
				m.SetCookie( 'mmRegisterTry', '', -1, 1 );
				m.SetCookie( 'mmRWused', '', -1, 1 );
			}
		} );
	}

})();
}catch(err){mmcore.EH(err);}
try{
mmcore.$Mediator = mmcore.$Mediator || $( {} );

$( function () {
	var wlp = window.location.pathname,
		m = mmcore;

	// ----------------------------------------
	// login via form
	// ----------------------------------------
	var loginInteract = function () {
		var attr = 'Blank';

		if ( $( this ).find( '.ec-error-msg' ).length !== 0 ) { return; }

		if ( m.GetCookie( 'mm_WasRegwall', 1 ) ) {
			attr = 'Regwall';
		}
		else if ( $( '#page-title:contains(Activate digital access)' ).length ) {
			attr = 'Activate';
		}
		else if ( $( '.short-reg-comment-preview' ).size() ) {
			// m.$Action( 'Logins2', '1', 'Comment' );
			attr = 'Comment';
		}

		m.SetCookie( 'mm_loginForm', attr, 0, 1 );
	}

	if ( ~wlp.indexOf( '/user/' ) ) {
		$( '#user-login-block, #user-login' ).live( 'submit', loginInteract );
	} else {
		$( 'form[action*="www.economist.com/user/login?"]' ).live( 'submit', loginInteract );
	}

	if ( m.GetCookie( 'mm_loginForm', 1 ) ) {
		(function () {
			var user, attr;
			user = JSON.parse( m.GetCookie( 'Econ.user.user', 1 ) );
			attr = '';

			if ( user.name !== null ) {
				m._async = true;
				m.SetPageID( 'events' );
				attr = m.GetCookie( 'mm_loginForm', 1 );

				if ( $( '.messages-error:contains(Your account already has full digital access.)' ).length || attr === 'Blank' ) { attr = ''; }
				m.SetAction( 'Logins2', '1', attr );
				m.CGRequest();
			}
		}());
	}

	m.SetCookie( 'mm_loginForm', '', -1, 1 );
	m.SetCookie( 'Logins2', '', -1, 1 );

	// set cookie for Reg wall
	(function () {
		var cookieName = 'mm_WasRegwall';
		if ( $( '#paywall-content' ).length ) {
			m.SetCookie( cookieName, 1, 0, 1 );
		} else {
			if ( m.GetCookie( cookieName, 1 ) === '1' ) {
				m.SetCookie( cookieName, 2, 0, 1 );
			} else {
				m.SetCookie( 'mm_WasRegwall', '', -1, 1 );
			}
		}
	}());


	// ----------------------------------------
	// login via social links
	// ----------------------------------------
	if ( window.janrain && window.janrain.engage && window.janrain.engage.signin && window.janrain.engage.signin.loginHandler ) {
		var _socialLoginHandler = window.janrain.engage.signin.loginHandler;
		window.janrain.engage.signin.loginHandler = function () {
			mmcore.SetCookie( 'mm_socialLogin', 'true', 365, 1 );
			_socialLoginHandler.apply( this, arguments );
		}
	} else {
		$( document ).ajaxComplete( function ( event, XMLHttpRequest, ajaxOptions ) {
			if ( (ajaxOptions.url.indexOf( '/ajax/login' ) > -1) ) {
				(function waitForLoginHandler() {
					if ( window.janrain && window.janrain.engage && window.janrain.engage.signin && window.janrain.engage.signin.loginHandler ) {
						var _socialLoginHandler = window.janrain.engage.signin.loginHandler;
						window.janrain.engage.signin.loginHandler = function () {

							mmcore.SetCookie( 'mm_socialLogin', 'true', 365, 1 );
							_socialLoginHandler.apply( this, arguments );
						}
					} else {
						setTimeout( waitForLoginHandler, 100 );
					}
				})();
			}
		} );
	}

	var trackLoginBlank = function ( actionName, cookieName ) {
		var user = JSON.parse( m.GetCookie( 'Econ.user.user', 1 ) );
		if ( user.name !== null ) {
			m._async = true;
			m.SetPageID( 'events' );
			m.SetAction( actionName, '1' );
			m.CGRequest();
			m.SetCookie( cookieName, '', -1, 1 );
		}
	};

	if ( m.GetCookie( 'mm_socialLogin', 1 ) ) {
		trackLoginBlank( 'Logins', 'mm_socialLogin' );
		trackLoginBlank( 'Logins2', 'mm_socialLogin' );
	}
} );
}catch(err){mmcore.EH(err);}
try{
(function ( m, $ ) {
	if ( !$ || !$.fn ) { return; }

	var lh = location.href;

	$( function () {
		// -----------------------------------
		// For action SubsByEntry
		// -----------------------------------
		$( '#reg-overlay a:contains(View subscription offers)' ).live( 'click', function () {
			if ( lh.indexOf( '//www.economist.com//ec-homepage/regov/start' ) + 1 ) {
				m.SetCookie( 'mm_attrSubsByEntry', 'Overlay', 0, 1 );
			}
		} );

		$( '.paywall-left-text #paybarrier_subscription_link' ).live( 'click', function () {
			m.SetCookie( 'mm_attrSubsByEntry', 'Subwall', 0, 1 );
		} );

		$( '.right-bottom #paybarrier_subscription_link, #reg-overlay .container-offer-button a' ).live( 'click', function () {
			if ( lh.indexOf( '//www.economist.com//ec-homepage/regov/start' ) === -1 ) {
				m.SetCookie( 'mm_attrSubsByEntry', 'Regwall', 0, 1 );
			}
		} );


		$( '#subslug-ad a' ).live( 'click', function () {
			var attr, width;

			width = parseFloat( $( this ).find( 'img' ).attr( 'width' ), 10 );
			attr = (width > 300) ? 'PencilSlugAd' : 'SlugAd';

			m.SetCookie( 'mm_attrSubsByEntry', attr, 0, 1 );
		} );

		(function () {
			var flag;

			$( '#block-ec_ads-pencil_slug_ad_ad_container' )
				.live( 'mouseover', function () {
					flag = true;
				} )
				.live( 'mouseout', function () {
					flag = false;
				} );

			$( window ).blur( function () {
				if ( !flag ) {return;}
				m.SetCookie( 'mm_attrSubsByEntry', 'PencilSlugAd', 0, 1 );
			} );
		}());

		(function () {
			var flag;

			$( '#block-ec_ads-subscription_ad_ad_container' )
				.live( 'mouseover', function () {
					flag = true;
				} )
				.live( 'mouseout', function () {
					flag = false;
				} );

			$( window ).blur( function () {
				if ( !flag ) {return;}
				m.SetCookie( 'mm_attrSubsByEntry', 'SlugAd', 0, 1 );
			} );
		}());

		$( '.mh-user-menu a:contains(Subscribe to The Economist)' ).live( 'click', function () {
			m.SetCookie( 'mm_attrSubsByEntry', 'Masthead', 0, 1 );
		} );

		$( '#subscription_slider #main a' ).live( 'mouseup', function () {
			m.SetCookie( 'mm_attrSubsByEntry', 'SliderAd', 0, 1 );
		} );

		(function () {
			var flag;

			$( '#paywall-slug-size-ad' )
				.live( 'mouseover', function () {
					flag = true;
				} )
				.live( 'mouseout', function () {
					flag = false;
				} );

			$( window ).blur( function () {
				if ( !flag ) {return;}
				m.SetCookie( 'mm_attrSubsByEntry', 'Regwall', 0, 1 );
			} );
		}());


		// -----------------------------------
		// For action SubsByType
		// -----------------------------------
		if ( lh.indexOf( '//www.economist.com/user/password' ) + 1 ) {
			$( '#user-pass' ).submit( function () {
				m.SetCookie( 'mm_FPsent', 1, 0, 1 );
			} );
		}
		if ( lh.indexOf( '//www.economist.com/user/password-reset' ) + 1 ) {
			if ( m.GetCookie( 'mm_FPsent', 1 ) ) {
				m.SetCookie( 'mm_PW', 1, 0, 1 );
			}
		}
		m.SetCookie( 'mm_FPsent', '', -1, 1 );


		// -----------------------------------
		// Thank you page
		// -----------------------------------

		if ( lh.indexOf( '//subscriptions.economist.com/GLB/ECOM/' ) === -1 ||
			lh.indexOf( 'index.php' ) === -1 ) {
			m.SetCookie( 'mm_attrUpsells', '', -1, 1 );
			return;
		}


		var getPeriod = function () {
			var period;
			var periodNode = $( 'td:contains(Subscription term):last' ).text().replace( 'Subscription term:', '' );

			if ( periodNode.indexOf( '12' ) + 1 ) { period = '12w'; }
			else if ( periodNode.indexOf( '6' ) + 1 ) { period = '6m'; }
			else if ( periodNode.indexOf( '3' ) + 1 ) { period = '3y'; }
			else if ( periodNode.indexOf( '2' ) + 1 ) { period = '2y'; }
			else if ( periodNode.indexOf( '1' ) + 1 ) { period = '1y'; }

			return period;
		};

		var getPaymentType = function () {
			var paymentTypeNode = $( 'td:contains(Payment type):last' ).text().replace( 'Payment type:', '' );
			return paymentTypeNode.indexOf( 'renewal' ) + 1 ? 'R' : 'C';
		};

		var addToAttr = function ( isSecondPart ) {
			var type;
			var attr = m.GetCookie( 'mm_attrUpsells', 1 );

			if ( isSecondPart ) {
				if ( !attr ) {
					return;
				}
				type = 'to';
			} else {
				attr = '';
				type = 'F';
			}
			attr += type;

			var period = getPeriod();

			if ( !period ) {
				return;
			}

			attr += period;

			attr += getPaymentType();

			if ( isSecondPart ) {
				m.SetAction( 'Upsells', 1, attr );
				m._async = true;
				m.SetPageID( 'events' );
				m.CGRequest();
				m.SetCookie( 'mm_attrUpsells', '', -1, 1 );
			} else {
				m.SetCookie( 'mm_attrUpsells', attr, 0, 1 );
			}
		};

		if ( $( '#thankYouID:contains(your order is being processed)' ).length ) {
			(function a( b ) {
				var c = mmcore, d = window.onunload, e = "mm_refresh_" + (b.suffix || "default");
				!c.GetCookie( e, 1 ) && "function" === typeof b.callback && (b.async ? c.AddDocLoadHandler( b.callback ) : b.callback());
				window.onunload = function () {
					c.SetCookie( e, 1, (b.sec || 3) / 86400, 1 );
					if ( d ) {return d.apply( this, arguments );}
				};
			}
			( {
				callback: function () {
					addToAttr( true );
				},
				suffix: 'upsells',
				async: false
			} ));
		} else {
			addToAttr();
		}

	} );

}( window.mmcore, window.jQuery ));
}catch(err){mmcore.EH(err);}
try{
mmcore.T3 = mmcore.initCampaign({
	name: 'T3Master',
	mmPath: '',
	hide: '#paywall-coin, #paywall-content, #paywall-teaser-text',
	getRequiredFields: function () {
		return window.Drupal && window.Drupal.settings && window.Drupal.settings.ec_wallpage;
	},
	checker: function () {
		'use strict';

		var requiredFields;

		requiredFields = this.getRequiredFields();

		if (
			requiredFields &&
			requiredFields.ec_wallpage_paywall_name === 'Article Paywall Anonymous' &&
			document.getElementById('paywall-coin') &&
			document.getElementById('paywall-teaser-text')
		) {
			return true;
		}
	},
	pageID: 'T3',
	stopChecker: function () {
		return (
					document.querySelector('#page footer') &&
					document.querySelector('.main-content') &&
					mmcore._docEnd
			) ||
			(
				this.getRequiredFields() &&
				this.getRequiredFields().ec_wallpage_paywall_name !== 'Article Paywall Anonymous'
			) ||
			/* exclude from 21.03.2014 spec's slide 4 */
			window.location.href.match(/^https?:\/\/www\.economist\.com\/news\/essays.*/);
	},
	beforeCGRequest: function () {
		function setCustomPersCrit(name, val){
			var _m = mmcore,
				_old = _m.GetCookie('uat'),
				_f = _old.indexOf(name+'=') + 1,
				_re = new RegExp(name+"=[^;]*"),
				_new = name+'='+val;

			_m.SetCookie('uat', _old ? (_f ? _old.replace(_re, _new) : _old + ';' + _new) : _new, 30);
		}
		
		var rows = mmcore.T3.lineCounter.calc(document.getElementById('paywall-teaser-text'), function (rows) {
			return rows;
		});

		if ( !rows || rows <= 0 ) {
			setCustomPersCrit('T3Preview', 'None');
		} else if ( rows === 1 || rows === 2 ) {
			setCustomPersCrit('T3Preview', 'LessThan3');
		} else {
			setCustomPersCrit('T3Preview', 'ThreeOrMore');
		}
	},
	afterCGRequest: function () {},
	emergencyOpenTimeout: 3000,
	checkerTimeout: 5000
});

(new Image()).src = '//service.maxymiser.net/cm/images-eu/1/1/1/8F1272D9415F134D784798281D41786D6D85EC5C5AFD4D6C705B974754393A0E/economist-com/T3RegwallOffers/fade.png';

mmcore.T3.lineCounter = (function (window, undefined) {
	'use strict';

	var calc,
		buildDummy,
		updateDummy,
		getComputedStyle,
		dummy = false,
		elem = false;

	calc = function (element, callback) {
		var heigh,
			dummyHeight,
			lineCount = false;

		elem = element;

		if (!elem) return new Error('Element wasn\'t found');

		if (!dummy) {
			dummy = buildDummy();
		}

		updateDummy();
		heigh = elem.offsetHeight;
		dummyHeight = dummy.offsetHeight;

		lineCount = Math.floor(heigh / dummyHeight);

		if (callback && typeof callback === 'function') {
			callback(lineCount);
		}

		return lineCount;
	};

	buildDummy = function () {
		var body = document.body,
			dummy = document.createElement('div');

		dummy.style.visibility = 'hidden';
		dummy.style.position = 'absolute';
		dummy.style.left = '-9999px';
		dummy.innerHTML = 'H';

		body.appendChild(dummy);

		return dummy;
	};

	updateDummy = function () {
		var computedStyle = getComputedStyle();

		// apply only style that does matter for element size
		dummy.style.display       = computedStyle.display;
		dummy.style.boxSizing     = computedStyle.boxSizing;
		dummy.style.lineHeight    = computedStyle.lineHeight;
		dummy.style.fontFamily    = computedStyle.fontFamily;
		dummy.style.fontSize      = computedStyle.fontSize;
		dummy.style.fontStretch   = computedStyle.fontStretch;
		dummy.style.fontStyle     = computedStyle.fontStyle;
		dummy.style.fontVariant   = computedStyle.fontVariant;
		dummy.style.fontWeight    = computedStyle.fontWeight;
		dummy.style.paddingTop    = computedStyle.paddingTop;
		dummy.style.paddingRight  = computedStyle.paddingRight;
		dummy.style.paddingBottom = computedStyle.paddingBottom;
		dummy.style.paddingLeft   = computedStyle.paddingLeft;

		return dummy;
	};

	getComputedStyle = function () {
		var computedStyle = false;

		if (elem.currentStyle) {
			computedStyle = elem.currentStyle;
		} else if (window.getComputedStyle) {
			computedStyle = document.defaultView.getComputedStyle(elem, null);
		}

		return computedStyle;
	};

	return {
		calc: calc
	};

})(window);
mmcore.T3.render();
}catch(err){mmcore.EH(err);}
try{
// T3Registrations blank
;(function () {
	'use strict';

	if ( mmcore.$Mediator ) {
		mmcore.$Mediator.bind('Registrations', function () {
			mmcore._async = true;
			mmcore.SetPageID('events');

			if (
				mmcore.GetCookie('mmRWused', 1)
			) {
				mmcore.SetAction('T3Registrations', 1, 'Regwall');
			} else {
				mmcore.SetAction('T3Registrations', 1, '');
			}

			mmcore.CGRequest(function () {});
		});
	}

	$(document).ready(function () {
		var was;

		was = false;

		// Logic for T4 overlay
		$('#reg-overlay').ajaxComplete(function () {
			if ( $('#simplemodal-container #ec-homepage-overlay-ref-form h2:contains("Thank you for registering")').size() && !was ) {
				was = true;

				mmcore._async = true;
				mmcore.SetPageID('events');
				mmcore.SetAction('T3Registrations', 1, '');
				mmcore.CGRequest(function () {});
			}
		});
	});
})();
}catch(err){mmcore.EH(err);}
try{
(function ( m ) {
	var acyncClick;

	acyncClick = function ( self, e ) {
		href = self.attr( 'href' );
		is_done = false;

		m._async = true;
		m.SetPageID( 'events' );

		function move() {
			is_done = true;
			if ( /firefox/i.test( navigator.userAgent ) ) {
				location.hash = 'mm';
			}
			location.assign( href );
		}

		m.CGRequest( move );
		setTimeout( function () {
			if ( !is_done ) {
				move();
			}
		}, 3000 );

		e.preventDefault();
	};


	// -----------------------------------
	// action T5HPClicks
	// -----------------------------------
	(function () {
		var an, sa;

		if ( location.pathname !== '/' || location.host.indexOf( 'www.economist.com' ) === -1 ) { return; }

		an = 'T5HPClicks';
		sa = function ( attr ) {
			m.$Action( an, 1, attr );
		};

		$( '#leaderboard a, .mh a' ).live( 'click', function ( e ) {
			var self, href;

			self = $( this );
			href = self.attr( 'href' );

			sa( 'Header' );

			if ( href.indexOf( 'moreintelligentlife.com' ) + 1 || href.indexOf( 'jobs.economist.com' ) + 1 || href.indexOf( 'store.economist.com' ) + 1 ) {
				acyncClick( self, e );
			} else if ( self.closest( '#leaderboard-ad' ).length || self.is( ':contains(Log in or register)' ) ) {
				m._async = true;
				m.SetPageID( 'events' );
				m.CGRequest();
			}
		} );

		$( function () {
			var flag;

			$( '.gstl_50' ).live( 'mouseup', function () {
				if ( !flag ) {
					sa( 'Header' );
					flag = true;
				}
			} );
			$( '#search-theme-form' ).live( 'submit', function () {
				if ( !flag ) {
					sa( 'Header' );
					flag = true;
				}
			} );
			$( '#search-theme-form' )[0].onsubmit = (function ( func ) {
				return function () {
					if ( !flag ) {
						sa( 'Header' );
						flag = true;
					}
					if ( func ) { return func.apply( this, arguments ); }
				}
			}( $( '#search-theme-form' )[0].onsubmit ));
		} );

		$( '#superhero .hero-superhero a' ).live( 'click', function () {
			sa( 'Main' );
		} );

		$( '#superhero .cover-image-container a' ).live( 'click', function () {
			sa( 'Print' );
		} );
		$( '.qtip a' ).live( 'click', function () {
			if ( $( this ).is( '.qtip-button' ) ) {
				return;
			}
			sa( 'Print' );
			m._async = true;
			m.SetPageID( 'events' );
			m.CGRequest();
		} );

		$( '.side-box a' ).live( 'click', function () {
			sa( 'LHCol' );
		} );

		$( '.news-package a' ).live( 'click', function () {
			if ( $( this ).is( 'a:contains(More in Multimedia)' ) ) { return; }
			sa( 'CentreCol' );
		} );

		$( '#social-share-buttons-block a' ).live( 'click', function () {
			m.SetAction( an, 1, 'Follow' );
			m._async = true;
			m.SetPageID( 'events' );
			m.CGRequest();
		} );

		$( '#block-ec_blogs-ec_blogs_block_recent .latest_blogs, #block-ec_blogs-ec_blogs_block_recent a:contains(More from our blogs)' ).live( 'click', function () {
			sa( 'Blogs' );
		} );

		$( '#block-ec_mostx-mostpopular a' ).live( 'click', function () {
			sa( 'MostPop' );
			if ( $( this ).closest( '#tabs' ).length ) {
				m._async = true;
				m.SetPageID( 'events' );
				m.CGRequest();
			}
		} );

		$( function () {
			$( '#block-block-1 div.linked' ).unbind( 'click' ).click( function ( e ) {
				sa( 'Products' );
				acyncClick( $( this ).find( 'a.social-link' ), e );
			} );

			$( '#block-block-1 div.linked a' ).click( function () {
				return false;
			} );
		} );
	}());


	// -----------------------------------
	// action T5TopNavClicks
	// -----------------------------------
	(function () {
		var sa, attrs;

		sa = function ( attr ) {
			m.$Action( 'T5TopNavClicks', 1, attr );
		};

		attrs = {
			politics: 'Politics',
			finance: 'Business',
			Economics: 'Economics',
			technology: 'Science',
			Culture: 'Culture',
			Blogs: 'Blogs',
			Debate: 'Debate',
			Multimedia: 'Multimedia',
			Print: 'PrintEdition'
		};

		$( '.mh-nav a' ).live( 'click', function ( e ) {
			var p, text, self;

			self = $( this );

			if ( self.find( '.mh-logo' ).length ) {
				sa( 'Home' );
			} else {
				text = self.closest( '.mh-nav-links > li' ).find( '> a' ).text()
				for ( p in attrs ) {
					if ( attrs.hasOwnProperty( p ) ) {
						if ( text.indexOf( p ) + 1 ) {
							sa( attrs[p] );
							if ( self.attr( 'href' ).indexOf( 'moreintelligentlife.com' ) + 1 ) {
								acyncClick( self, e );
							}
							break;
						}
					}
				}
			}
		} );
	}());


}( window.mmcore ));
}catch(err){mmcore.EH(err);}
try{
// T3Logins
$(document).ready(function () {
	$('#mmT3User-login, #mmUser-login').live('submit', function () {
		mmcore.SetCookie('mmT3LoginRW', 'Regwall', 1, 1);
	});

	$('#paybarrier_login_link, .mmLoginBtn').live('click', function () {
		mmcore.SetCookie('mmT3LoginRW', 'Regwall', 1, 1);
	});
});

(function () {
	'use strict';

	var attr;

	// is used regwall
	attr = mmcore.GetCookie('mmT3LoginRW', 1) || '';

	if ( mmcore.$Mediator ) {
		mmcore.$Mediator.bind('Logins', function () {
			mmcore.SetAction('T3Login', 1, attr);
			mmcore._async = true;
			mmcore.SetPageID('events');
			mmcore.CGRequest(function () {});
		});
	}

	if (
		attr &&
		window.location.pathname === '/user/login'
	) {
		$(window).unload(function () {
			mmcore.SetCookie('mmT3LoginRW', 'Regwall', 1, 1);
		});
	}

	mmcore.SetCookie('mmT3LoginRW', '', -1, 1);
})();
}catch(err){mmcore.EH(err);}
try{
mmcore.checkGoodChromeOnIOS = function () {
	var iosRe = /iPhone OS/i;
	var ios7chromeRe = /CriOS/i;
	var ios7targetChromeRe = /iPhone OS 7.*CriOS/i;
	var agent = navigator.userAgent;
	if (agent.match(iosRe)) {
		if (agent.match(ios7chromeRe)) {
			if (agent.match(ios7targetChromeRe)) {
				return true;
			}
			return false;
		}
		return true;
	}
	return true;
};

mmcore.T6 = mmcore.initCampaign({
	name                : 'T6_FlexiBannerMn',
	mmPath              : '',
	hide                : 'NOT_AN_ELEMENT',
	checker             : function () {
		return mmcore.GetCookie('ec-reg-overlay-seen', 1) === '' &&
			mmcore.T6.isUserNotLoggedIN() &&
			mmcore.T6.isCookieNormal() &&
			window.Drupal &&
			window.Drupal.regoverlay &&
			window.Drupal.regoverlay.displayOverlay &&
			mmcore.T6.isPageExcluded() === false;
	},
	pageID              : 'T6',
	stopChecker         : function () {
		return mmcore.GetCookie('ec-reg-overlay-seen', 1) ||
			mmcore.T6.stopCheck ||
			mmcore.T6.isCookieNormal() === false ||
			mmcore.T6.isUserNotLoggedIN() === false ||
			mmcore.T6.isPageExcluded();
	},
	beforeCGRequest     : function () {
	},
	afterCGRequest      : function () {
		var testArrived = mmcore.GenInfo && mmcore.GenInfo.T6OverlayROS && mmcore.GenInfo.T6OverlayROS.t6overlay !== 'Default';

		if ( !testArrived ) {
			$('.mmRegOverlT6').remove();
			delete window.Drupal.regoverlay;
		}
	},
	emergencyOpenTimeout: 10000,
	checkerTimeout      : 17000
});

mmcore.T6.userRegWallScript = function () {
	var css = '#reg-overlay{width:938px;position:relative;display:none;z-index:1000001 !important;padding-top:0 !important;}#reg-overlay.simplemodal-data{overflow:visible !important;}body.front #simplemodal-container .simplemodal-wrap{border:none;overflow:visible !important;}.simplemodal-overlay{height:360px;width:600px;color:#bbb;background-color:#333;border:4px solid #444;padding:12px;}#simplemodal-container{z-index:1000000 !important;}#simplemodal-container a.modalCloseImg{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/close.jpg) no-repeat;width:82px;height:25px;display:inline;z-index:1000100 !important;position:absolute;top:0;right:18px;cursor:pointer;}#reg-overlay .ov-body{height:388px;}#reg-overlay .ov-reg-callout{font-size:15px;font-weight:normal;color:#363636;padding-top:22px;display:block;}#reg-overlay .overlay-thankyou{padding-top:22px;}#reg-overlay .ec-button{text-shadow:none !important;font-size:17px !important;padding:5px 15px !important;}#reg-overlay .ov-reg-label{font-size:15px;font-weight:bold;font-family:Arial,Helvetica,sans-serif;display:block;padding-bottom:15px;}#reg-overlay #edit-finish{width:110px;}#reg-overlay .ov-header{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/bg-header.jpg) no-repeat;padding-left:22px;height:97px;}#reg-overlay .ov-header h2{font-family:Georgia,"Times New Roman",Times,serif;font-size:42px;color:#e3120b;padding-top:20px;font-weight:normal;}#reg-overlay .ov-header p.sub-header{font-family:Arial,Helvetica,sans-serif;font-size:15px;color:#363636;}#reg-overlay .ov-reg{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/bg-reg-left.jpg) no-repeat;width:224px;height:100%;float:left;}#reg-overlay .ov-offers{height:100%;float:left;}#reg-overlay .ov-offers-ribbon{margin-left:-36px;padding-top:13px;}#reg-overlay .ov-offers-ribbon div,#reg-overlay .ov-offers-ribbon p{float:left;}#reg-overlay .ov-offers-ribbon p{font-family:Georgia,"Times New Roman",Times,serif;padding-top:13px;color:#FFF;font-size:20px;font-weight:normal;padding-left:22px;}#reg-overlay .ov-offers-ribbon-grey .ov-offers-ribbon-head{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/ribbon-grey-elbow.png) no-repeat;height:57px;width:36px;}#reg-overlay .ov-offers-ribbon-grey .ov-offers-ribbon-body{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/ribbon-grey-body.png) repeat-x;height:48px;min-width:20px;}#reg-overlay .ov-offers-ribbon-grey .ov-offers-ribbon-cap{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/ribbon-grey-end.png) no-repeat;height:57px;width:36px;}#reg-overlay .ov-offers-ribbon-red{padding-top:13px !important;}#reg-overlay .ov-offers-ribbon-red .ov-offers-ribbon-head{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/ribbon-red-elbow.png) no-repeat;height:57px;width:36px;}#reg-overlay .ov-offers-ribbon-red .ov-offers-ribbon-body{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/ribbon-red-body.png) repeat-x;height:48px;min-width:20px;}#reg-overlay .ov-offers-ribbon-red .ov-offers-ribbon-cap{background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/ribbon-red-end.png) no-repeat;height:57px;width:36px;}#reg-overlay .ov-offers-list{padding-top:15px;}#reg-overlay .ov-offers-list ul{padding-left:20px;}#reg-overlay .ov-offers-list:first ul{padding-left:0;}#reg-overlay .ov-offers-list ul.offer{float:left;width:152px;display:block;}#reg-overlay .ov-offers-list ul.offer li.offer-img{height:70px;padding-bottom:20px;}#reg-overlay .ov-offers-list ul.offer li{font-family:Arial,Helvetica,sans-serif;}#reg-overlay .ov-offers-list ul.offer li.offer-title h2{padding-bottom:10px;font-size:14px;color:#e3120b;}#reg-overlay .ov-offers-list ul.offer li.offer-desc p{font-size:13px;color:#363636;}#reg-overlay .ov-offers span.container-offer-button{position:absolute;bottom:15px;right:25px;}#reg-overlay ul.web li.offer-img{text-indent:-9999px;background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/offer-web.png) no-repeat center;}#reg-overlay ul.digital li.offer-img{text-indent:-9999px;background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/offer-digital.png) no-repeat center;}#reg-overlay ul.audio li.offer-img{text-indent:-9999px;background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/offer-audio.png) no-repeat center;}#reg-overlay ul.print-edition{border-left:1px solid #CCCCCC;margin-left:10px;height:212px;}#reg-overlay ul.print-edition li.offer-img{text-indent:-9999px;background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/offer-print.png) no-repeat center;}#reg-overlay form#ec-homepage-overlay-ref-form{padding:22px;padding-top:0;}#reg-overlay div.form-item input.form-text{border:1px solid #CCCCCC;color:#000000;font-size:1.4rem;font-size:14px;height:19px;margin:5px 0;padding:3px 2px;width:180px;}#reg-overlay div.form-item label,#reg-overlay div.legal,#reg-overlay div.description{font-size:1.1rem;font-size:11px;line-height:11px;}#reg-overlay div.form-checkboxes label{width:160px;}#reg-overlay div.legal a,#reg-overlay label.option a{text-decoration:underline;}#reg-overlay #edit-news-features,#reg-overlay #edit-news-editor-picks{float:left;display:block;}#reg-overlay #edit-news-features div.description,#reg-overlay #edit-news-editor-picks div.description{width:170px;float:left;display:block;padding-top:5px;}#reg-overlay #edit-country-id-wrapper{width:184px;height:27px;overflow:hidden;background:url(/sites/all/modules/ec_homepage/./images/hp-reg-overlay/dropdown-arrow.png) no-repeat 165px 13px transparent;border:1px solid #ccc;}#reg-overlay #edit-country-id-wrapper #edit-country-id{-moz-appearance:window;background:transparent;width:190px;padding:0 5px 0 5px;font-size:16px;line-height:20px;border:0;border-radius:0;height:28px;-webkit-appearance:none;}#reg-overlay .form-checkboxes,#reg-overlay .form-item{margin:0;padding:0;}#reg-overlay .ahah-progress-bar div.bar{width:190px;}#reg-overlay .progress-disabled{float:none;}#reg-overlay #ahah-progress-edit-finish{width:16em;clear:both;float:none;}#reg-overlay .ahah-progress-bar{display:none;}#reg-overlay .form-checkboxes label{display:block;padding-left:27px;}#reg-overlay .form-checkboxes input{padding:0;margin:0;vertical-align:bottom;position:relative;top:12px;*overflow:hidden;}#reg-overlay .overlay-thankyou h2,#reg-overlay .overlay-thankyou p{padding-bottom:15px;}#reg-overlay .overlay-thankyou h2{font-size:15px;width:200px;}#reg-overlay .overlay-thankyou p{font-size:13px;}#reg-overlay .messages-inline{display:none;}#reg-overlay span.ec-error-msg{position:relative;top:auto;display:block;padding-top:5px;}#reg-overlay .ec-form-error{margin-top:0;}#reg-overlay .ec-button{font-family:Arial,Verdana,sans-serif;font-size:1.4rem;font-weight:400;color:#ffffff;background:#5f8ea3;-webkit-border-radius:0px;border:0;text-shadow:0 -0.1rem 0.1rem rgba(0,0,0,0.5);text-align:center;text-decoration:none;margin:10px 0 15px;padding:8px 25px;text-transform:none;-webkit-appearance:none;}#reg-overlay .ec-button{margin-top:10px;display:inline-block;}#reg-overlay .ec-button:hover{text-decoration:none;background-color:#55859b;}#reg-overlay .ec-button:active,.ec-button:visited{color:#ffffff;}#reg-overlay input[type="submit"]:active,#reg-overlay input[type="submit"]:hover{background:#55859b;text-decoration:none;}#reg-overlay span.ajax-loading{background:url("/sites/all/themes/econfinal/images/icons/ajax-loader.gif") no-repeat scroll 0 0 transparent;display:-moz-inline-stack;display:inline-block;height:15px;left:10px;position:relative;top:1px;width:15px;*display:inilne;_height:250px;}';

	mmcore.TseattachStyle = function (text) {
		var style = document.createElement('style'),
			mmcore_script;

		style.type = 'text/css';
		if ( /WebKit|MSIE/i.test(navigator.userAgent) ) {
			if ( style.styleSheet ) {
				style.styleSheet.cssText = text;
			} else {
				style.innerText = text;
			}
		} else {
			style.innerHTML = text;
		}
		mmcore_script = document.getElementById('mmcore.1');
		if ( mmcore_script ) {
			mmcore_script.parentNode.insertBefore(style, mmcore_script);
		} else {
			document.getElementsByTagName('head')[0].appendChild(style);
		}
		return style;
	};
	mmcore.TseattachStyle(css);
	var Drupal = window.Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} };

	/**
	 * Attach all registered behaviors to a page element.
	 *
	 * Behaviors are event-triggered actions that attach to page elements, enhancing
	 * default non-Javascript UIs. Behaviors are registered in the Drupal.behaviors
	 * object as follows:
	 * @code
	 *    Drupal.behaviors.behaviorName = function () {
	 *      ...
	 *    };
	 * @endcode
	 *
	 * Drupal.attachBehaviors is added below to the jQuery ready event and so
	 * runs on initial page load. Developers implementing AHAH/AJAX in their
	 * solutions should also call this function after new page content has been
	 * loaded, feeding in an element to be processed, in order to attach all
	 * behaviors to the new content.
	 *
	 * Behaviors should use a class in the form behaviorName-processed to ensure
	 * the behavior is attached only once to a given element. (Doing so enables
	 * the reprocessing of given elements, which may be needed on occasion despite
	 * the ability to limit behavior attachment to a particular element.)
	 *
	 * @param context
	 *   An element to attach behaviors to. If none is given, the document element
	 *   is used.
	 * @param step
	 *   Is ised in ahah behavior.
	 */
	Drupal.attachBehaviors = function (context, step) {
		context = context || document;
		// Execute all of them.
		jQuery.each(Drupal.behaviors, function () {
			this(context, step);
		});
	};
	/* global jQuery, Drupal */

	/**
	 * Ajax forms.
	 */
	(function ($) {
		"use strict";

		Drupal.behaviors.ec_ajax_form = function (context) {
			$('[data-form-ajax]', context).each(function () {
				var $this = $(this, context);

				$this.bind('click', function (e) {
					e.preventDefault();
					// Add an ajax loader option, to be styled if needed.
					$this.append('<span class="ajax-loading"></span>');
					$.ajax({
						url     : $this.attr('data-form-ajax'),
						dataType: 'json',
						type    : 'GET',
						cache   : false,
						success : function (data) {
							// Append the form.
							var form = '<div class="ajax-form">' + data.form + '</div>',
							// Use the custom callback.
								jsCallback = data.js_callback,
								jsNamespace;

							// Remove the ajax loader.
							$(".ajax-loading").remove();

							// Determine if callback is namespaced or if it's global.
							if ( jsCallback && jsCallback.indexOf('.') === -1 ) {
								window[jsCallback]($this, form);
							}
							else if ( jsCallback && jsCallback.indexOf('.') !== -1 ) {
								jsNamespace = jsCallback.substring(0, jsCallback.indexOf('.'));
								jsCallback = jsCallback.substring(jsCallback.indexOf('.') + 1);
								window[jsNamespace][jsCallback]($this, form);
							}
							else {
								$this.after(form);
								var ajaxForm = $('.ajax-form form');
								var newActionForm = ajaxForm.attr('action').replace('/ajax/', '/');
								ajaxForm.get(0).setAttribute('action', newActionForm);
							}
						}
					});
				});
			});
		};
	})(jQuery);

	(function (window) {
		'use strict';

		// Create a namespace to shield our functions.
		var Econ = window.Econ = window.Econ || {},
			document = window.document,
			$ = window.jQuery,
			Drupal = window.Drupal;

		// Copy value from a field to textarea
		Econ.insertToTxtarea = function (textarea, val) {
			var sel, t_start, t_end, val_start, val_end;
			if ( document.selection ) {
				sel = document.selection.createRange();
				textarea.focus();
				sel.text = val;
				return;
			}
			if ( textarea.selectionStart || textarea.selectionStart === 0 ) {
				t_start = textarea.selectionStart;
				t_end = textarea.selectionEnd;
				val_start = textarea.value.substring(0, t_start);
				val_end = textarea.value.substring(t_end, textarea.value.length);
				textarea.value = val_start + val + val_end;
			}
			else {
				textarea.value += val;
			}
		};

		// Create the main validateForm object.
		Econ.validateForm = function (submitBtn) {
			this.submitBtn = submitBtn;
			this.error = function (msg) {
				return '<span class="error-msg">' + msg + '</span>';
			};
			this.errorSelector = '.error-msg';
		};

		// Create the textareaMaxlength prototype.
		Econ.validateForm.prototype.textareaMaxlength = function (field, maxlength) {
			var errorMsg = this.error('You have exceeded ' + maxlength + ' characters.'),
				errorSelector = this.errorSelector,
				submitBtn = this.submitBtn,
				textLength;
			field.keyup(function () {
				var $this = $(this),
					parent = $this.parent();
				textLength = $(this).val().length;
				if ( textLength > maxlength ) {
					$(errorSelector, parent).remove();
					// Display an error if you type more than maxlength characters.
					$this.before(errorMsg);
					// Disable submit btn to avoid multiple submissions.
					submitBtn.attr('disabled', 'disabled');
				} else {
					$(errorSelector, parent).remove();
					submitBtn.attr('disabled', '');
				}
			});
			return this;
		};

		// Create the emptyForm prototype.
		Econ.validateForm.prototype.emptyForm = function (field) {
			var errorMsg = this.error('This field is required.'),
				errorSelector = this.errorSelector,
				submitBtn = this.submitBtn,
				elmLength;
			return submitBtn.click(function () {
				var fieldParent = field.parent();
				if ( field.length ) {
					elmLength = $.trim(field.val()).length;
					if ( elmLength > 0 ) {
						$(errorSelector, fieldParent).remove();
					} else {
						if ( !$(errorSelector, fieldParent).length ) {
							field.before(errorMsg);
						}
						return false;
					}
				}
				return true;
			});
		};

		// Return true = touch based devices.
		Econ.isTouchDevice = function () {
			return (window.ontouchstart !== undefined || window.navigator.msMaxTouchPoints);
		};

		// Return touchstart  || click according to the device supported event.
		Econ.addTouchStartEvent = function () {
			var touchEvent;
			if ( window.ontouchstart !== undefined ) {
				touchEvent = 'touchstart';
			}
			if ( window.navigator.msMaxTouchPoints ) {
				touchEvent = 'click';
			}
			return touchEvent;
		};

		// Return true if the object passed is empty. jQuery from version 1.4 has implemented the isEmptyObject(object) method
		// (http://api.jquery.com/jQuery.isEmptyObject/) when/if we update the jQuery library this function can be replaced
		// with the isEmptyObject method.
		Econ.isEmptyObject = function (o) {
			var p;
			for (p in o) {
				if ( o.hasOwnProperty(p) ) {
					return false;
				}
			}
			return true;
		};

		// Includes a javascript file in another js file. It use the ajax method in sync
		// mode (note async = false). This because we need to be sure that the file is
		// loaded before moving to the rest of the script execution. The downside
		// of course is that if the file doesn't exists the page will be stack (js
		// single threaded).
		Econ.includeJsFile = function (script) {
			$.ajax({
				url     : script,
				dataType: "script",
				async   : false,
				error   : function () {
					throw new Error("Could not load script " + script);
				},
				cache   : false
			});
		};

		/**
		 * Append a js file via <script> to the <head>.
		 *
		 * @param src the source of the js file.
		 * @param id
		 *   The id to assign to the <script> tag to avoid to add multiple times the
		 *   same file.
		 */
		Econ.appendJSFileHeader = function (src, id) {
			var js, d = document, s = 'script', fjs = d.getElementsByTagName(s)[0];
			if ( d.getElementById(id) ) {
				return;
			}
			js = d.createElement(s);
			js.src = src;
			js.id = id;
			fjs.parentNode.appendChild(js, fjs);
		};

		// Create a character counter to append to text and textarea fields.
		Drupal.behaviors.charCount = function (context) {
			// Pass the selectors to the function via Drupal add_js.
			var fieldsSettings = (Drupal.settings.charCount !== undefined) ? Drupal.settings.charCount.targets : false;

			// Return the number of characters.
			function countChars (chars, maxVal) {
				var countedChars;
				// Remove all the HTML tags and HTML entities.
				chars = chars.replace(/<[a-zA-Z][^<>]*?>/g, '').replace(/&nbsp;|&#160;/gi, ' ');
				countedChars = chars.length;
				if ( maxVal ) {
					countedChars = (chars.length > maxVal) ? '<span style="color:#ff0000">' + countedChars + '</span>' : countedChars;
				}
				return countedChars;
			}

			// Append the counter to the field.
			function appendChars ($elm, target_id, maxVal) {
				$elm.keyup(function () {
					// Get the current chars counter.
					var counterBox = $(".counter-box-" + target_id);
					// Update the chars counter box with the new chars value.
					counterBox.empty().append("Chars: " + countChars($(this).val(), maxVal));
				});
			}

			if ( fieldsSettings ) {
				$.each(fieldsSettings, function (k, v) {
					var $elm = $(v[0], context),
					// Pass the maxValue via drupal. The Max value will spceify the number of chars
					// e specific field may contain. When the max value is riched the counter will
					// turn red but it will NOT truncate or blocked the field.
						maxVal = v[1];
					$($elm).each(function () {
						var $this = $(this), target_id, counterBox;
						if ( ($this.attr('type') === 'text') || $this.is('textarea') ) {
							target_id = $this.attr('id');
							counterBox = '<div class="counter-box">';
							counterBox += '<span class="counter-box-' + target_id + '" style="margin-left: ' + ($this.width() - 100) + 'px">Chars: ' + countChars($this.val(), maxVal) + '</span>';
							counterBox += '</div>';
							// Create the chars counter box.
							if ( !$('span.counter-box-' + target_id).length ) {
								$this.after(counterBox);
								appendChars($this, target_id, maxVal);
							}
						}
					});
				});
			}
		};

		// Utility function that look for the data-href-redirect attribute and use the
		// attribute's value to redirect the page. Please not that to redirect to external
		// site you need to use the full URL (including http://).
		Econ.dataHrefRedirect = $(function () {
			var hrefRedSelector = $('[data-href-redirect]');
			hrefRedSelector.click(function (e) {
				var thisHref = $(this).attr('data-href-redirect');
				e.preventDefault();
				// Open in a new tab is ctrl/cmd is pressed together with the mouse click.
				if ( e.metaKey ) {
					window.open(thisHref, '_blank');
				}
				else {
					window.location.href = thisHref;
				}
			});
		});

		// Utility functions for browser versions.
		Econ.browserOlder = function (name, ver) {
			return ($.browser[name] && parseFloat($.browser.version) < ver);
		};
		Econ.browserNewer = function (name, ver) {
			return ($.browser[name] && parseFloat($.browser.version) > ver);
		};

		// Generates a grey overlay on the page.
		Econ.generateOverlay = function (/*settings*/) {
			var h = $(document).height(),
				w = $(document).width(),
				overlay = $('<div class="ec-overlay"></div>');
			overlay.css({
				'height': h,
				'width' : w
			});
			$('body').append(overlay);
		};

		// Returns true if an element has scrolled into view.
		Econ.isScrolledIntoView = function (elem) {
			var $elem = $(elem),
				$window = $(window),
				docViewTop = $window.scrollTop(),
				docViewBottom = docViewTop + $window.height(),
				elemTop = $elem.offset().top,
				elemBottom = elemTop + $elem.height();
			return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop));
		};

	}(window));

	// Below are shims for various latest ECMA features.
	// This is a shim for Array::forEach.
	if ( !Array.prototype.forEach ) {
		Array.prototype.forEach = function (fn, scope) {
			'use strict';
			var i, len;
			for (i = 0, len = this.length; i < len; ++i) {
				if ( this.hasOwnPreperty(i) ) {
					fn.call(scope, this[i], i, this);
				}
			}
		};
	}

	Drupal.behaviors.ec_tip = function (context) {
		$.fn.qtip.styles.ecSimple = {
			border    : {
				width: '1',
				color: '#CCDADA'
			},
			background: '#E5F6FE'
		};
		$.fn.qtip.styles.econ = {
			border: {
				width: '1',
				color: '#CCDADA'
			},
			tip   : {
				corner: 'topMiddle',
				size  : {x: 17, y: 15},
				color : '#fff'
			}
		};
		if ( $('.ec-tip-simpletip-link').length ) {
			$('.ec-tip-simpletip-link').each(function () {
				jQuery(this).qtip({
					content : jQuery(this).next('.ec-tip-simpletip-contents').html(),
					style   : {
						name: 'ecSimple'
					},
					position: {
						target: 'mouse'
					},
					show    : 'mouseover',
					hide    : 'mouseout'
				});
			});
		}

		// WMBA forum tooltip.
		if ( $('#forum-how-link').length ) {
			$('#forum-how-link').qtip({
				content : $('#forum-how-reveal').html(),
				style   : {
					name   : 'econ',
					width  : 480,
					classes: {
						content: 'qtip-wmba-content',
						tip    : 'qtip-wmba-tip'
					}
				},
				position: {
					corner: {
						target : 'bottomLeft',
						tooltip: 'topLeft'
					}
				},
				show    : 'click',
				hide    : {
					fixed: true,
					when : {
						event: 'unfocus'
					}
				}
			});
			$('#forum-how-link').qtip('api').onRender = function () {
				$('#forum-how-link').qtip('api').elements.tip
					.html('<p></p>')
					.css('background', 'url(/sites/all/themes/econfinal/images/bubble-triangle.png) no-repeat')
					.css('z-index', '6001')
					.css('top', '1px')
					.css('margin-left', '-200px');
			};
		}

		// Masthead persistent login tooltip.
		var $persistent_tip = $('.persistent-tip');
		if ( $persistent_tip.length ) {
			$persistent_tip.qtip({
				content : $persistent_tip.next().html(),
				style   : {
					name   : 'econ',
					tip    : 'leftMiddle',
					width  : 165,
					classes: {
						content: 'qtip-persistent-content',
						tip    : 'qtip-persistent-tip'
					}
				},
				position: {
					corner: {
						target : 'rightMiddle',
						tooltip: 'leftMiddle'
					}
				},
				show    : 'click',
				hide    : {
					fixed: true,
					when : {
						event: 'unfocus'
					}
				}
			});
		}
	};
	;

	(function ($, Drupal) {

		Drupal.jsonify = {

			/**
			 * Performs an AJAX GET request on the URL returning
			 * the results as JSON.  If a callback is supplied, the
			 * request is asynchronous. If not, the request is synchronous.
			 */
			get: function (url, callback) {
				if ( typeof callback == "function" ) {
					$.ajax({
						type    : "GET",
						url     : url,
						success : function (data) {
							callback(data);
						},
						error   : function () {
							callback(false);
						},
						dataType: "json"
					});
				}
				else {
					var result;

					$.ajax({
						async   : false,
						type    : "GET",
						url     : url,
						success : function (data) {
							result = data;
						},
						error   : function (data) {
							result = false;
						},
						dataType: "json"
					});

					return result;
				}
			},

			load: function (type, id, callback) {
				var urls = {
					node   : Drupal.settings.basePath + "jsonify/node/" + id,
					comment: Drupal.settings.basePath + "jsonify/comment/" + id
				};

				if ( type in urls ) {
					return Drupal.jsonify.get(urls[type], callback);
				}
				else {
					throw Drupal.t("Jsonify Error: Unsupported type: @type. Supported types: node, comment.", {'@type': type});
				}
			}
		};

	})(jQuery, Drupal);
	;
	(function ($) {

		/**
		 * Open Mollom privacy policy link in a new window.
		 *
		 * Required for valid XHTML Strict markup.
		 */
		Drupal.behaviors.mollomPrivacy = function (context) {
			$('.mollom-privacy a', context).click(function () {
				this.target = '_blank';
			});
		};

		/**
		 * Attach click event handlers for CAPTCHA links.
		 */
		Drupal.behaviors.mollomCaptcha = function (context) {
			$('a.mollom-switch-captcha', context).click(getMollomCaptcha);
		};

		/**
		 * Fetch a Mollom CAPTCHA and output the image or audio into the form.
		 */
		function getMollomCaptcha () {
			// Get the current requested CAPTCHA type from the clicked link.
			var newCaptchaType = $(this).hasClass('mollom-audio-captcha') ? 'audio' : 'image';

			var context = $(this).parents('form');

			// Extract the Mollom session id from the form.
			var mollomSessionId = $('input.mollom-session-id', context).val();

			// Retrieve a CAPTCHA:
			$.getJSON(Drupal.settings.basePath + 'mollom/captcha/' + newCaptchaType + '/' + mollomSessionId,
				function (data) {
					if ( !(data && data.content) ) {
						return;
					}
					// Inject new CAPTCHA.
					$('.mollom-captcha-content', context).parent().html(data.content);
					// Update session id.
					$('input.mollom-session-id', context).val(data.session_id);
					// Add an onclick-event handler for the new link.
					Drupal.attachBehaviors(context);
					// Focus on the CATPCHA input.
					$('input[name="mollom[captcha]"]', context).focus();
				}
			);
			return false;
		}

	})(jQuery);
	;
	// $Id: og.js,v 1.9.2.3 2010/01/24 14:44:56 amitaibu Exp $

	// Content type form
	Drupal.behaviors.og_content_type = function () {
		// Disable the group limit textarea if the content type is not a standard group post
		$('input[name="og_content_type_usage"]').click(function () {
			if ( !$('#edit-og-content-type-usage-group-post-standard').attr('checked') ) {
				$('#edit-og-max-groups').attr('disabled', 'disabled');
			} else {
				$('#edit-og-max-groups').removeAttr('disabled');
			}
		});

		// Initial check to see if content type is standard group post
		if ( !$('#edit-og-content-type-usage-group-post-standard').attr('checked') ) {
			$('#edit-og-max-groups').attr('disabled', 'disabled');
		}
	};

	Drupal.verticalTabs = Drupal.verticalTabs || {};

	Drupal.verticalTabs.og_nodeapi = function () {
		var values = [];
		$('.vertical-tabs-og_nodeapi #edit-og-groups :selected')
			.each(function (i, selected) {
				values[i] = $(selected).text();
			});

		return values.join(', ');
	};

	Drupal.verticalTabs.og = function () {
		var type = $('.vertical-tabs-og input[type=radio]:checked').val();

		switch (type) {
			case 'group':
				return Drupal.t('Group node');
				break;

			case 'omitted':
				return Drupal.t('May not be posted into a group.');
				break;

			case 'group_post_standard':
				return Drupal.t('Standard group post');
				break;

			case 'group_post_wiki':
				return Drupal.t('Wiki group post');
				break;
		}
	}
	;
	if ( window.Econ == undefined ) {
		Econ = {};
	}

	Econ = Econ || window.Econ;
	Econ.user = {
		loaded: false
	};

	/** For user reciepts. **/
	Drupal.behaviors.userAppleReceipt = function (context) {
		// Replace the string, and use a popup to show it.
		$('.user-receipts .raw-receipt-container').each(function (i, item) {
			var text = $(item).text();
			var id = 'raw-receipt-container-' + i;
			var html = '<a class="ec-button" style="margin-right: 10px;" id="' + id + '-view" href="#">view</a><div style="display:none;" id="' + id + '">' + text + '</div>';
			$(item).text(text.substring(0, 55) + '...').prepend(html);
			$(item).find('a').click(function (e) {
				var $id = id;
				var options = {
					maxHeight: 800,
					minHeight: 600,
					maxWidth : 800,
					dataCss  : {
						overflow     : "scroll",
						"padding-top": "20px"
					}
				};
				$('#' + $id).modal(options);
			});
		});
	}

	Drupal.behaviors.userLoad = function (context) {
		if ( !$.cookie || !$.JSON || context != document ) {
			return;
		}

		if ( !Econ.user.user ) {
			// Pull the user from a session cache.
			Econ.user.user = $.JSON.decode($.cookie('Econ.user.user'));
		}
		// Did we have the user?
		if ( Econ.user.user ) {
			// Yes.  Great!  Trigger onload.
			Econ.user.loaded = true;
			$(Econ.user).trigger('load', [Econ.user.user]);
		}
		else {
			// Grab user for logged in user.
			if ( typeof Drupal.settings.uid != 'undefined' && Drupal.settings.uid > 0 ) {
				// If we are on a page that has a regionalized cover, we need real data for that.
				// POST to get through Varnish.
				$.post(Drupal.settings.basePath + 'ec-user/load/json', {'1': '1'}, function (data, textStatus, jqXHR) {
					if ( data.status ) {
						Econ.user.user = data.data;
						// Store the user into a session cache.
						$.cookie('Econ.user.user', $.JSON.encode(Econ.user.user), { path: '/' });
						// Now trigger onload.
						Econ.user.loaded = true;
						$(Econ.user).trigger('load', [Econ.user.user]);
					}
				}, 'json');
			}
			// Grab user for logged out user.
			else {
				var user_default = {"uid": 0, "name": null, "country": {"id": false, "name": "Unknown", "iso": "", "region": false}};

				var post_data = {1: '1'};
				var ip = null;
				if ( ip = location.search.match(/ec_user_geoip=(\d+\.\d+\.\d+\.\d+)/) ) {
					post_data = { 'ip': ip[1] };
				}

				// POST to get through Varnish.
				$.post(Drupal.settings.basePath + 'geoip.php', post_data, function (data, textStatus, jqXHR) {
					Econ.user.user = user_default;

					if ( data.status ) {
						Econ.user.user.country = data.data;
					}
					// This is anonymous.  Even if the call failed, we will cut our losses.
					// Store the user into a session cache.
					$.cookie('Econ.user.user', $.JSON.encode(Econ.user.user), { path: '/' });
					// Now trigger onload.
					Econ.user.loaded = true;
					$(Econ.user).trigger('load', [Econ.user.user]);
				}, 'json');
			}
		}

		// Auto-select country.
		if ( Drupal.settings.ec_user_settings && Drupal.settings.ec_user_settings.auto_select_country == true ) {
			var countryField = $("#edit-country-id");
			if ( Econ.user.user && Econ.user.user.country.id && countryField && (countryField.val() == 'invalid' || countryField.val() == '') ) {
				countryField.val(Econ.user.user.country.id);
			}
		}
	};

	Econ.FormFeatures = {};

	Econ.FormFeatures.Validate = function (formName, validateFields) {
		this.formName = formName;

		this.submitForm = function () {
			var thisObj = this;
			var formName = this.formName;
			$('form' + formName).submit(function () {
				return thisObj.emptyFields();
			});
		};
		this.emptyFields = function () {
			var formName = this.formName;
			var formSubmit = true;
			var thisObj = this;
			$(validateFields, formName).each(function () {
				var $this = $(this);
				var parentElm = $this.parent();
				if ( (($.trim($this.val()) == '' || $this.val() == 'invalid')) ) {
					thisObj.invalidField(parentElm, 'Required field');
					if ( formName == '#user-profile-form' ) {
						$('html, body').animate({
							scrollTop: ($('fieldset:not(.fieldset-editable) div.messages-inline').offset().top - 50)
						}, 600);
					}
					formSubmit = false;
				}
			});
			if ( $(formName + ' div.messages-inline').length ) {
				if ( $('div.messages-inline').length == 1 && $('fieldset.penname-fieldset div.messages-inline').length ) {
					formSubmit = true;
				} else {
					formSubmit = false;
				}
			}
			return formSubmit;
		};
		this.checkFields = function () {
			var thisObj = this;
			$(validateFields, formName).each(function () {
				var $this = $(this);
				var parentElm = $this.parent();
				var formid = thisObj.formName;

				$this.keypress(function () {
					var errorBox = parentElm.next('div.messages-inline');

					if ( $.trim($this.val()) == '' ) {
						parentElm.removeClass('valid');
					}
					if ( errorBox.length ) {
						parentElm.removeClass('form-item-error');
						errorBox.remove();
					}
					// Different DOM structure for these inline error messages.
					if ( ($this.is('#edit-pass') || $this.is('#edit-name')) && parentElm.prev('div.messages-inline').length ) {
						$this.removeClass('error');
						parentElm.prev('div.messages-inline').remove();
					}
				});
				$this.change(function () {
					if ( $this.val() == 'invalid' ) {
						thisObj.invalidField(parentElm, 'Required field');
					}
				});
				$this.blur(function () {
					switch ($this.attr('type')) {
						case 'text':
							// Browser that don't recognize HTML5 types
							if ( $this.hasClass('form-email') ) {
								thisObj.testEmail($this, parentElm, 'Enter a valid e-mail address');
							} else {
								thisObj.validField(parentElm);
							}
							break;
						case 'email':
							if ( $.trim($this.val()) ) {
								thisObj.testEmail($this, parentElm, 'Enter a valid e-mail address');
							} else {
								thisObj.validField(parentElm);
							}
							break;
						case 'password':
							if ( formid != '#user-login' && formid != '#user-login-block' ) {
								thisObj.verifyPassword($this, parentElm);
							} else {
								thisObj.validField(parentElm);
							}
							if ( $('input.password-confirm').length ) {
								thisObj.verifyMatch('.password-field', '.password-confirm', 'Passwords');
							}

							break;
						case 'select-one':
							if ( $this.val() != 'invalid' ) {
								thisObj.validField(parentElm);
							}
							break;
						default:
							thisObj.validField(parentElm);
					}
					if ( $.trim($this.val()) == '' && parentElm.hasClass('valid') ) {
						parentElm.removeClass('valid');
					}
				});
			});
		};
		this.validField = function (parentElm) {
			parentElm.removeClass('form-item-error').addClass('valid');
			parentElm.next('div.messages-inline').remove();
		};
		this.invalidField = function (parentElm, error) {
			parentElm.parents('form').removeClass('error-default').addClass('ec-inline-error');
			parentElm.addClass('form-item-error');
			if ( !parentElm.next('div.messages-inline').length ) {
				parentElm.removeClass('valid').after('<div class="messages-inline"><div class="messages-inline-icon"></div>' + error + '</div>');
			}
		};
		this.verifyMatch = function (idA, idB, type) {
			var elmA = $(idA).val();
			var elmB = $(idB).val();
			var parent = $(idB).parent();
			if ( elmA.length && elmB.length ) {
				if ( elmA == elmB ) {
					this.validField(parent);
				} else {
					this.invalidField(parent, type + ' don\'t match');
				}
			}
		};
		this.testEmail = function (field, parent, error) {
			var email_regex = field.val();
			var checkAt = email_regex.indexOf('@');
			var checkDot = email_regex.indexOf('.');
			if ( $.trim(field.val()) ) {
				if ( checkAt > 0 && checkDot > 0 ) {
					this.validField(parent);
				} else {
					this.invalidField(parent, error);
					return false;
				}
			}
			return true;
		};
		this.verifyPassword = function (field, parent) {
			var passwordInput = field.val();
			if ( passwordInput.length > 0 && passwordInput.length < 8 ) {
				this.invalidField(parent, 'Enter at least 8 characters');
			} else {
				this.validField(parent);
			}
		};
		this.checkFields();
		this.submitForm();
	};

	Drupal.behaviors.formFeatures = function () {
		if ( typeof Drupal.settings.formvalidation == "undefined" ) return;
		var formName = Drupal.settings.formvalidation.formname;
		var validateFields = ('input[required="required"], input.required, select.required, input[type="text"][id="edit-name"]');

		if ( !$.isArray(formName) ) {
			formName = [formName];
		}

		$.each(formName, function (key, value) {
			new Econ.FormFeatures.Validate(value, validateFields);
		});
		// Editable forms.
		if ( Drupal.settings.editableform != undefined ) {
			var editableForm = Drupal.settings.editableform.formedit;
		}
		if ( editableForm != undefined ) {
			// We need this only for the penname.
			var storedData = $('input#edit-name').val();

			$('*[name="editable"]').each(function () {
				$(this).prepend('<span class="edit-block">Edit</span>');
			});
			$('fieldset[name="editable"] input[type="checkbox"]').attr('disabled', 'disabled');
			$('<input type="reset" class="form-reset" value="Cancel">').appendTo(editableForm);
			edit(editableForm);
			// Special handling of the penname editing. Since it doesn't do AJAX, the inline messages can't just be
			// placed on the open field set. We need to open it. There is def a more robust and more complete way
			// of handling this. However, since this is a special case only needed for this one field, I decided
			// to use the quick method.
			if ( $('div#edit-name-messages-inline').length !== 0 ) {
				$('.penname-fieldset .edit-block').click();
			}
			submitEditable(editableForm, storedData);
			resetForm(editableForm, storedData);

			// Placeholder functionality to replace the HTML5 one available for modern browsers.
			Modernizr = {};
			Modernizr.input = {};
			if ( !Modernizr.input.placeholder ) {
				$('form input[placeholder]').each(function () {
					var $this = $(this);
					var placheholder = $this.attr('placeholder');
					$this.val(placheholder);
					$this.focus(function () {
						if ( $this.val() == placheholder ) {
							$this.val('');
						}
					});
					$this.blur(function () {
						if ( !$this.val().length ) {
							$this.val(placheholder);
						}
					});
				});
			}
		}
	};

	function edit (editableForm) {
		var editBlock = $('.edit-block');

		editBlock.click(function () {
			var parentFieldset = $(this).parents('fieldset');
			// Remove the edit block;
			$(this).remove();

			// Remove the edit state form all the other fieldsets (if any exists) and
			// reset the form values. This use the form reset default functionality.
			$('input.form-reset').trigger('click');
			// Show the form elements for editing.
			parentFieldset.addClass('fieldset-editable').find('span.label').hide();
			// Create the reset button and append to the current fildset.
			$('input.form-reset').appendTo(parentFieldset);
			// Append the form submit button to the current fieldset.
			$('input#edit-submit', editableForm).appendTo(parentFieldset);
			// Disable checkboxed.
			$('input[type="checkbox"], input[type="text"], select', parentFieldset).attr('disabled', '');
		});
	}

	function checkEmpty (jsFormValidation) {
		var formsubmit = true;
		$('form' + jsFormValidation + ' input[required="required"], form' + jsFormValidation + ' input.required, form' + jsFormValidation + ' select.required').each(function () {
			var $this = $(this);
			var parentElm = $this.parent('div.form-item').attr('id');

			var label = $('#' + jsFormValidation + ' #' + parentElm + ' label').text().toLowerCase();
			label = label.replace('*', '').replace(':', '');
			var error = 'Required field';

			if ( $.trim($this.val()) == '' || $this.val() == 'invalid' ) {
				invalidField(parentElm, error);
				formsubmit = false;
			}
		});
		return formsubmit;
	}

	function submitEditable (editableForm, storedData) {
		$('input#edit-submit', editableForm).live('click', function (e) {
			var parentFieldset = $(this).parents('fieldset');
			// Pen-name is submitted normally and not using ajax.
			if ( $('.form-reset').parents('fieldset').find('input#edit-name').length !== 0 ) {
				return true;
			}
			var $this = $(this);
			var empty = checkEmpty(editableForm);
			var submitBtn = $('<input type="submit" class="form-submit  editable-submit ec-button" value="Save changes" id="edit-submit" name="op">');
			var resetBtn = $('<input type="reset" class="form-reset" value="Cancel">');
			if ( empty == false ) {
				return false;
			}
			e.preventDefault();
			var form = $("form" + editableForm);
			var parentFieldsetClass = parentFieldset.attr('class');
			parentFieldsetClass = parentFieldsetClass.replace(' fieldset-editable', '');
			$this.attr('disabled', 'disabled');
			$('input.form-reset').attr('disabled', 'disabled');
			$('fieldset[name="editable"] input[type="checkbox"]').attr('disabled', '');
			var data = form.serialize();
			$.ajax({
				url       : form.attr('action'),
				type      : "POST",
				data      : data,
				beforeSend: function () {
					$this.after('<span class="ajax-working"></span>');
				},
				success   : function (html) {
					var htmlContent = $("form" + editableForm + " fieldset." + parentFieldsetClass, html).html();
					$("fieldset." + parentFieldsetClass, form).html(htmlContent);
					$("fieldset." + parentFieldsetClass).attr('name');
					// The form has no error.
					if ( !$('div.form-item-error').length ) {
						parentFieldset.removeClass('fieldset-editable');
						$('select').each(function () {
							var valueSelected = $(this).attr('id');
							$('label[for=' + valueSelected + '] span.label').text(': ' + $('#' + valueSelected + " :selected").text()).show();
						});
						$('div.form-item').removeClass('valid');
						// Re-add the edit block.
						if ( $("fieldset." + parentFieldsetClass, html).attr('name') == 'editable' ) {
							parentFieldset.prepend('<span class="edit-block">Edit</span>');
						}
						resetBtn.appendTo(form);
						submitBtn.appendTo(form);
						$('fieldset.' + parentFieldsetClass + ' legend').after('<div class="messages messages-status fieldset-message">Your personal information has successfully been updated.</div>');
						if ( $('div.fieldset-message').length ) {
							// After 4 seconds, slowly fadeout and then remove the confirmation.
							setTimeout(function () {
								$('div.fieldset-message').fadeOut('slow', function () {
									$("div.fieldset-message").remove();
								});
							}, 4000);
						}
						$('fieldset[name="editable"] input[type="checkbox"]').attr('disabled', 'disabled');
					}
					// The form has errors.
					else {
						$("fieldset." + parentFieldsetClass + " div.description").appendTo($("fieldset." + parentFieldsetClass));
						$('input.form-reset').appendTo(parentFieldset);
						$('input#edit-name').keypress(function () {
							var errorBox = $('div.messages-inline');
							if ( errorBox.length ) {
								$('div.form-item-error').removeClass('form-item-error');
								errorBox.remove();
							}
						});
						resetBtn.appendTo(parentFieldset);
						submitBtn.appendTo(parentFieldset);
					}
					edit(editableForm);
				}
			});
			return false;
		});
	}

	function resetForm (editableForm, storedData) {
		$(editableForm + ' input.form-reset').live('click', function (e) {
			var parentFieldset = $(this).parents('fieldset');
			var pennameFieldset = parentFieldset.hasClass('penname-fieldset');
			if ( pennameFieldset ) {
				e.preventDefault();
				$('input#edit-name').remove();
				$('label[for=edit-name]').after('<input type="text" class="form-text error" value="' + storedData + '" size="60" id="edit-name" name="name" maxlength="60">');
			}
			parentFieldset.removeClass('fieldset-editable');
			$('div.form-item');
			$('span.label').show();

			$('div.messages-inline').remove();
			$('div.form-item').removeClass('form-item-error').removeClass('valid');
			if ( !parentFieldset.children('span.edit-block').length ) {
				parentFieldset.prepend('<span class="edit-block">Edit</span>');
			}
			edit(editableForm);
			$('fieldset[name="editable"] input[type="checkbox"]').attr('disabled', 'disabled');
		});
	}

	function invalidField (parentElm, error) {
		var pElm = $('#' + parentElm);
		pElm.addClass('form-item-error');
		if ( !pElm.next('div.messages-inline').length ) {
			pElm.removeClass('valid').after('<div class="messages-inline">' + error + '</div>');
		}
	}

	/**
	 * Opens an iframe within an overlay using simplemodal library.
	 */
	function ecModal (modalOptions) {
		modalOptions.screenHeightCutoff = 800;

		modalPoller = setInterval(function () {
			ecModalListen(m, modalOptions);
		}, 1000);

		// Initialize a smaller height for smaller screens.
		if ( screen.height <= 864 ) {
			modalOptions.iframe.maxHeight = modalOptions.iframe.minHeight;
		}

		// Open the simplemodal dialog.
		var m = $.modal('<iframe id="ecIframe" src="' + modalOptions.url + '" width="' + modalOptions.iframe.width
			+ '" height="' + modalOptions.iframe.maxHeight + '" frameBorder="0">', {
			closeHTML   : '<div></div>',
			containerCss: {
				width  : modalOptions.iframe.width,
				height : modalOptions.iframe.maxHeight,
				padding: modalOptions.containerCss.padding
			},
			opacity     : modalOptions.opacity,
			overlayCss  : {
				backgroundColor: modalOptions.overlayCss.backgroundColor
			},
			overlayClose: false,
			zIndex      : modalOptions.zIndex,
			onClose     : ecModalClose
		});

		// Resize iframe based on browser window resizing.
		ecModalResize(modalOptions);
	}

	var ecModalNextUrl = null;
	var modalPoller = null;

	function ecModalListen (m, modalOptions) {
		var e = $.cookie('Econ.modal.event');
		if ( e ) {
			$.cookie('Econ.modal.event', null, { path: '/'});
			e = $.JSON.decode(e);

			switch (e.type) {
				case 'commentPosted':
					if ( e.data.url != undefined ) {
						ecModalNextUrl = e.data.url;
					}
					ecModalResize(modalOptions, e.type);
					break;
				case 'close':
					if ( e.data.url != undefined ) {
						ecModalNextUrl = e.data.url;
					}
					if ( e.data.delay != undefined ) {
						setTimeout(ecModalClose, e.data.delay);
					}
					else {
						ecModalClose();
					}
					break;

				default:
					break;
			}
		}
	}

	/**
	 * This function handles the closure of the modal box.
	 */
	function ecModalClose () {
		clearInterval(modalPoller);
		if ( ecModalNextUrl != null ) {
			var curr_url = window.location;
			// Captures:
			//   0) href
			//   1) protocol
			//   2) host
			//   3) pathname
			//   4) search
			//   5) hash
			var next_url = ecModalNextUrl.match(new RegExp("(?:(https?:)//([^/]+))?(/[^?#]+)(\\?[^#]+)?(#.+)?"));

			if ( next_url[4] == undefined ) {
				next_url[4] = '';
			}

			// Firefox does not want to reload the page is the only thing that changes is
			// the hash.  So if the path and the query string are the same, force a reload
			// after setting the href to the new location.
			if ( curr_url.pathname == next_url[3] && curr_url.search == next_url[4] ) {
				window.location.href = ecModalNextUrl;
				window.location.reload();
			}
			else {
				window.location.href = ecModalNextUrl;
			}
		}
		else {
			$.modal.close();
			$('form#comment-form #edit-submit, #ec-cartoon #publish-sc').removeAttr("disabled");
		}
	}

	/**
	 * Resizes iframe based on screen resolution and browser width/height.
	 */
	function ecModalResize (modalOptions, eventType) {
		if ( eventType == 'commentPosted' && screen.height > 1024 ) {
			modalOptions.iframe.maxHeight += 190;
			modalOptions.screenHeightCutoff += 190;
			$('#simplemodal-container').height(modalOptions.iframe.maxHeight);
			$('iframe#ecIframe').attr('height', modalOptions.iframe.maxHeight);
			$.modal.update();
		}

		$(window).resize(function () {
			if ( $(window).height() <= modalOptions.screenHeightCutoff ) {
				$('#simplemodal-container').height(modalOptions.iframe.minHeight);
				$('iframe#ecIframe').attr('height', modalOptions.iframe.minHeight);
			}
			else if ( $(window).height() > modalOptions.screenHeightCutoff ) {
				$('#simplemodal-container').height(modalOptions.iframe.maxHeight);
				$('iframe#ecIframe').attr('height', modalOptions.iframe.maxHeight);
			}
		});
	}
	;
	Drupal.behaviors.ecComments = function (context) {
		if ( jQuery().ec_timeago ) {
			$(context).find('.single-comment .created').ec_timeago();
		}

		$(context).find('.comment-forms').each(function (index, Element) {
			var commentForm = Element;
			var submitBtnSelector = (index == 0) ? '#edit-submit' : '#edit-submit-' + index;
			var submitBtn = $(submitBtnSelector, commentForm);
			var editComment = (index == 0) ? '#edit-comment' : '#edit-comment-' + index;
			var fields = $(editComment, commentForm);
			if ( fields.length ) {
				var validateCommentForm = addCommentLengthCheckHandlers(fields, submitBtn);
				$(Element).submit(function () {
					if ( !validateCommentForm ) {
						return false;
					}
					submitBtn.attr('disabled', 'disabled');
					return true;
				});
			}
			$('span.remove-form', commentForm).click(function () {
				$('.ajax-form').remove();
				$('a').parent().removeClass('opened');
			});
		});

		// Highlight comment footer links when the user hovers over a comment.
		// Achieved by adding and removing an active class on hover.
		$(context)
			.find('#comments-area article > div, .ec-featured-comment-showcase article > div')
			.hover(function (e) {
				$(this).parent().addClass("active");
			}, function (e) {
				$(this).parent().removeClass("active");
			});
	};

	/**
	 * Add event handlers for the comment boxes loaded by ajax.
	 */
	Drupal.behaviors.ecAjaxComments = function (context) {
		var submitBtn = $('#edit-submit-ajax', context);
		var fields = $('#edit-comment-ajax', context);
		addCommentLengthCheckHandlers(fields, submitBtn);
	}

	/**
	 * Add event handlers for a comment form.
	 *
	 * @param fields
	 *   Comment text field(s).
	 * @param submitBtn
	 *   Comment submit button.
	 *
	 * @return object|bool
	 *   validateForm object or false if element not found
	 */
	function addCommentLengthCheckHandlers (fields, submitBtn) {
		if ( fields.length ) {
			var validateCommentForm = new Econ.validateForm(submitBtn);
			return validateCommentForm.textareaMaxlength(fields, 5000).emptyForm(fields);
		}

		return false;
	}

	/**
	 * Highlight comments.
	 *
	 * If a user follows a link with a comment fragment in then highlight the
	 * the comment.
	 */
	Drupal.behaviors.ecCommentsHighlight = function (context) {
		var fragment = Drupal.checkPlain(window.location.hash);
		if ( fragment.match(/^#comment-[0-9]/) ) {
			$(fragment + ' > div', context)
				.not('.ec-comments-highlight-processed') // Marked so we do not repeat.
				.addClass('ec-comments-highlight-processed')
				.animate({
					backgroundColor: '#FAFAD4'
				}, 1500).animate({
					backgroundColor: '#FFFFFF'
				}, 1500);
		}
	}

	/**
	 * Toggle the display of deep comment replies.
	 */
	Drupal.behaviors.ecCommentsCollapseLongThreads = function (context) {
		var fragment = Drupal.checkPlain(window.location.hash);
		$('section.indented', context).each(function () {
			var replies = this;

			// If a a URL contains a fragment to a deep-comment then we do not
			// collapse the thread.
			if ( fragment.match(/^#comment-[0-9]/) && $(fragment, replies).hasClass('deep-reply') ) {
				$('article', replies).show();
				return;
			}
			var deepReplies = $('.deep-reply', replies);
			var deepRepliesContainer = $(deepReplies).wrapAll('<div class="deep-replies" />').parent();
			deepRepliesContainer.hide().children().show();
			if ( deepReplies.length ) {
				var expand = Drupal.formatPlural(
					deepReplies.length,
					'Expand 1 more reply',
					'Expand @count more replies'
				);
				var collapse = Drupal.formatPlural(
					deepReplies.length,
					'Collapse reply',
					'Collapse replies'
				);
				var control = $('<a class="deep-replies-control">' + expand + '</a>')
					.click(function (e) {
						e.preventDefault();
						if ( $(deepRepliesContainer).is(':visible') && !$(this).hasClass('mid-thread-control') ) {
							$('body, html').animate({scrollTop: '-=' + deepRepliesContainer.outerHeight()}, 'slow');
						}
						deepRepliesContainer.slideToggle('slow', function () {
							var controls = $('.deep-replies-control', replies);
							if ( $(deepRepliesContainer).is(':visible') ) {
								controls.text(collapse);
							} else {
								controls.text(expand);
							}
						});
					})
					.appendTo(replies);
				control.clone(true).addClass('mid-thread-control').insertBefore(deepReplies[0]);
			}
		});
	}

	Drupal.behaviors.commentPopup = function (context) {
		var settings = Drupal.settings,
			settings_comments_page = function () {
				return settings && typeof settings.ec_essay !== 'undefined' && settings.ec_essay.comments_page;
			};

		// Add hide/show to comment preview.
		$('.short-reg-comment-preview blockquote', context).expander({
			slicePoint      : 310,
			preserveWords   : true,
			widow           : 4,
			expandText      : 'show all',
			userCollapseText: 'show less'
		});

		// Hide the post comment button
		Drupal.Ajax.plugins.ecCommentsPlugin = function (hook, args) {
			switch (hook) {
				case 'message':
					if ( args.form_id == 'comment_form' ) {
						var errors = args.messages_error;
						if ( errors.length > 0 ) {
							/**
							 * We add a hash-tag to the end of the image URL specifically because
							 * some version of FF like to overly agressivley cache the mollom image
							 * and thus show the same image in an irregular manner. If this were
							 * not the case, we would just drop the rawForm in.
							 */
							var newForm = $(args.rawForm, context);
							var id = newForm.find('#edit-mollom-session-id').attr('value');
							var src = newForm.find('.mollom-image-captcha img').attr('src');
							newForm.find('.mollom-image-captcha img').attr('src', src + '?session=' + id);

							// Replace the old form with the new one.
							$('form#comment-form').replaceWith(newForm);

							// Rebind to the button since this was not in the DOM before hand.
							Drupal.Ajax.init($('form#comment-form').parent());
						}
					}
					break;

				case 'redirect':
					// Do not attach the plugin for essay comments for mobile devices.
					if ( settings_comments_page() && $.cookie('ec_device') != 'false' ) {
						return;
					}
					if ( args.form_id == 'comment_form' ) {
						// Build modal frame options.
						var modalOptions = {
							url         : args.redirect + '&modal=true',
							containerCss: {
								backgroundColor: "#fff",
								padding        : 0
							},
							iframe      : {
								width    : 880,
								minHeight: 500,
								maxHeight: 730
							},
							opacity     : 80,
							overlayCss  : {
								backgroundColor: "#fff"
							},
							zIndex      : 15000
						};
						// Popup simplemodal.
						ecModal(modalOptions);
						return false;
					}
					break;

				default:
					break;
			}
			return false;
		};
	};

	function pollModalBox (proxyID) {
		// Check to see if se have that id.
	}

	// Callback function to customize the reply form.
	function commentsActionsAjaxCallback (elm, form) {
		var attachedForm = elm.parents('ul');
		// Hide all ajax comment form, but not the main one, or the bottom comment form.
		$('.ajax-form').not('#comment-form, #comment-form-1').remove();
		attachedForm.append(form);
		$('a').parent().removeClass('opened');
		elm.parent().addClass('opened');
		var ajaxForm = $('.ajax-form form');
		var newActionForm = ajaxForm.attr('action').replace('/ajax/', '/');
		ajaxForm.get(0).setAttribute('action', newActionForm);
		$('#edit-submit', ajaxForm).before('<span class="remove-form">Cancel</span>');
		Drupal.attachBehaviors($('.ajax-form'));
	}

	/**
	 * Prevent page reloading if reply is on the same page.
	 */
	Drupal.behaviors.replyPageReload = function (context) {
		$('a.reply-to', context).click(function (e) {
			var comment_snippets = this.href.split('#');
			if ( $('article#' + comment_snippets[1]).length ) {
				e.preventDefault();
				document.location.href = '#' + comment_snippets[1];
			}
		});
	};
	;
	function janrainWidgetOnload () {
		janrain.events.onProviderLoginStart.addHandler(function (response) {
			var omniture_vars = {};
			omniture_vars.link_track_vars = 'events';
			omniture_vars.events = 'event45';
			Drupal.omniture.trackClick(true, 'onProviderLoginStart', omniture_vars);
		});
		janrain.events.onProviderLoginSuccess.addHandler(function (response) {
			var omniture_vars = {};
			omniture_vars.link_track_vars = 'events';
			omniture_vars.events = 'event46';
			Drupal.omniture.trackClick(true, 'onProviderLoginSuccess', omniture_vars);
		});
	}

	Drupal.behaviors.followBarHover = function (context) {
		if ( context == document ) {
			var pinned = null;

			// Note: The 'no-hover' class is going to be used in conjunction with an A/B
			// test to provide an alternate version of the block.

			// Handle delayed over.
			$(context).find('#social-share-buttons-block:not(.no-hover)').addClass('js-hover')
				.find('li').each(function () {
					var showTimer = null;
					var hideTimer = null;
					$(this).hover(
						function () {
							if ( pinned != null && $(this).parents('#social-share-buttons-block:not(.no-hover)').length ) {
								return;
							}

							if ( hideTimer ) {
								clearTimeout(hideTimer);
								hideTimer = null;
							}

							var el = $(this);
							showTimer = setTimeout(function () {
								showTimer = null;
								el.addClass('show-hover');
							}, 300);
						},
						function () {
							if ( pinned != null && $(this).parents('#social-share-buttons-block:not(.no-hover)').length ) {
								return;
							}

							if ( showTimer ) {
								clearTimeout(showTimer);
								showTimer = null;
							}

							var el = $(this);
							hideTimer = setTimeout(function () {
								hideTimer = null;
								el.removeClass('show-hover');
							}, 300);
						}
					);
				});

			// Handle clicks.
			$('body').click(function (e) {
				$('#social-share-buttons-block:not(.no-hover) li').removeClass('show-hover');

				var el = $(e.target).parents('#social-share-buttons-block:not(.no-hover) li');
				// Clicked icon or overlay.
				if ( el.length ) {
					var click_icon = $(e.target).next().hasClass('social-share-overlay');
					// Clicked icon.
					if ( click_icon ) {
						// If we click on the main row of icons, we don't want the user to go
						// anywhere.
						e.preventDefault();

						if ( pinned == null ) {
							pinned = el
							el.addClass('show-click');
						}
						else if ( el.get(0) == pinned.get(0) ) {
							pinned = null;
							el.removeClass('show-click');
						}
						else {
							pinned.removeClass('show-click');
							pinned = el
							el.addClass('show-click');
						}
					}
					// Clicked overlay.
					else {
						if ( pinned == null ) {
							pinned = el
							el.addClass('show-click');
						}
					}
				}
				// Clicked world and we have a pinned overlay.
				else if ( pinned ) {
					pinned.removeClass('show-click');
					pinned = null;
				}
			});
		}
	};

	var Econ = Econ || {};
	Econ.social = {};
	Econ.social.shareCover = function (cover) {
		var image_url = '';

		if ( arguments.length > 1 ) {
			image_url = arguments[1];
		}

		$(cover).each(function () {
			var share_link = $(Drupal.settings.socialShare.shareCoverLink);
			var share_overlay = $(Drupal.settings.socialShare.shareHTML);

			if ( image_url ) {
				// Media url reference for facebook.
				var href = share_overlay.find('li.share-icon-facebook a').attr('href');
				share_overlay.find('li.share-icon-facebook a').attr('href', href.replace('app_id=', 'picture=' + encodeURI(image_url) + '&app_id='));
				href = share_overlay.find('li.share-icon-pinterest a').attr('href');
				share_overlay.find('li.share-icon-pinterest a').attr('href', href + '&media=' + encodeURI(image_url));
			}

			Drupal.attachBehaviors(share_overlay);

			// QTip it.
			share_link.qtip({
				content : {
					title: {
						text  : Drupal.t('Share'),
						button: 'X'
					},
					text : share_overlay
				},
				style   : {
					width: 170
				},
				position: {
					corner: {
						target : 'rightTop',
						tooltip: 'rightTop'
					}
				},
				show    : {
					when  : {
						target: false,
						event : 'click'
					},
					effect: {
						type  : 'fade',
						length: 50
					}
				},
				hide    : {
					fixed: true,
					when : {
						event: 'unfocus'
					}
				}
			});

			$(this).after(share_link);
		});
	}
	;
	/* global $,Econ,s,brightcove,clearOmniVars,clearLinkVars */

	Drupal.homepage = Drupal.homepage || {};

	/**
	 * Replace all non-word characters with an underscore
	 */
	Drupal.homepage.sanitize = function (str) {
		"use strict";
		return str.replace(/[^\w]/ig, "_");
	};

	/**
	 * Set the correct src for the cover image based on region
	 */
	Drupal.homepage.setRegionalCover = function (region) {
		"use strict";
		// Get the correct image url
		/*var src = (region && region in Drupal.settings.regional_covers) ? Drupal.settings.regional_covers[region] : Drupal.settings.regional_covers['default'];
		 var homepage_cover = src.replace('imagecache/print-cover-thumbnail', 'imagecache/print-cover-thumbnail-superhero');

		 // Set the cover image
		 $(".cover-image").each(function() {
		 $(this).html($('<img />').attr({
		 alt: Drupal.t('The Economist print cover'),
		 title: Drupal.t('The Economist print cover'),
		 src: homepage_cover,
		 width: '165',
		 height: '217'
		 }));
		 });

		 // Add javascript cover share.
		 if (window.Econ !== undefined && Econ.social !== undefined) {
		 Econ.social.shareCover('.cover-image', src);
		 }*/
	};

	var ec_homepage_page_start = new Date().getTime();

	// Homepage behavoirs.
	(function ($) {
		"use strict";
		/**
		 * Set the cover based on the javascript user's region.
		 */
		Drupal.behaviors.homepageRegionalCover = function (context) {
			if ( context === document ) {
				if ( $('.cover-image img').length === 0 ) {
					if ( !Econ.user.loaded ) {
						$(Econ.user).bind('load', function () {
							Drupal.homepage.setRegionalCover(Econ.user.user.country.region);
						});
					}
					else {
						Drupal.homepage.setRegionalCover(Econ.user.user.country.region);
					}
				}
			}
		};

		/****** Begine registration overlay section ******/
		/**
		 * Password checker for the overlay and button attachments.
		 */
		Drupal.behaviors.homePageRegistrationOverlayAttach = function (context) {
			// Formats the inline errors.
			var items = $('#reg-overlay .messages-inline');
			var i = 0;
			var $ci, id, msg, html = null;
			for (i = 0; i < items.length; i++) {
				// Take the content and modify the errors.
				$ci = $(items[i]);
				// Find out what element this goes to.
				id = '#' + $ci.attr("id").replace("-messages-inline", "");
				msg = $ci.text();
				html = '<span class="ec-error-msg">' + msg + '</span>';
				$(id, context).addClass('ec-form-error').before(html);
			}

			// Attach to the submit buttons.
			var selector = '#ec-homepage-overlay-ref-form .form-submit';
			selector = selector + ':not(.ec-processed)';
			$(selector).mousedown(function (e) {
				$(this).after('<span class="ajax-loading"></span>');
				return true;
			}).addClass('ec-processed');
		};

		/**
		 * Homepage overlay. The following snippet of code should be use to DISPLAY this overlay.
		 * This is here as an example/reminder of the steps needed to property display it.
		 * A helper function is created in this function to pop up the overlay properly.
		 * Drupal.regoverlay.displayOverlay();
		 */
			// Object holder for helper functions for the registration homepage
			// overlay.
		Drupal.regoverlay = Drupal.regoverlay || {};
		Drupal.regoverlay.omniture = {};
		Drupal.regoverlay.modalOptions = {};
		var overlayHasBeenSetup = false;
		var overlayHasBeenSeen = Number($.cookie('ec-reg-overlay-seen')) !== 0;
		var pageContext = 1;
		Drupal.behaviors.homepageOverlay = function (context) {

			// This is so that omniture has context of which page we are on.
			Drupal.regoverlay.omniture.updatePageContext(context);

			// Below are setup items that we don't need to run twice. Above are items that we
			// want to run to re-attach to information/items on the page.
			if ( overlayHasBeenSetup === true ) {
				return;
			}

			// Handle out setup items.
			overlayHasBeenSetup = true;
			var id = 'reg-overlay';
			// If the overlay is not present, do nothing.
			if ( $('#' + id).length === 0 ) {
				return;
			}

			// Setup the modal options.
			Drupal.regoverlay.modalOptions = {
				minHeight   : 484,
				minWidth    : 940,
				dataCss     : {
					overflow     : "scroll",
					"padding-top": "20px"
				},
				close       : true,
				escClose    : true,
				overlayClose: true,
				closeHTML   : '<a class="modalCloseImg" href=' + Drupal.settings.basePath + ' title="Close"></a>',
				onClose     : function (dialog) {
					// Send omniture data.
					s.linkTrackVars = 'prop45,';
					if ( $('.ec-button-thankyou-clicked').length === 0 ) {
						s.prop45 = 'member_services|registration|registration_overlay_part_' + pageContext + '|close';
					}
					else {
						s.prop45 = 'member_services|registration|registration_overlay_part_3|start_reading';
					}
					s.tl(this, 'o', 'member_services|registration|registration_overlay_part_' + pageContext + '|close');
					clearLinkVars();

					// If we are on the 3rd step, meaning the user is now logged in,
					// we should replace the mast head.
					if ( Number(pageContext) === 3 ) {
						/**
						 * Makes a "post" request to get the masthead HTML, and replace it with this
						 * updated masthead.
						 */
						$.ajax({
							type    : "POST",
							url     : Drupal.settings.basePath + 'ec_user/js/masthead',
							data    : {},
							success : function (data) {
								$('header.mh ul.mh-user-menu').fadeOut('slow').replaceWith(data);
							},
							dataType: "html"
						});
					}
					dialog.data.fadeOut('slow', function () {
						dialog.container.slideUp('slow', function () {
							dialog.overlay.fadeOut('slow', function () {
								$.modal.close(); // must call this!
							});
						});
					});
				},
				onOpen      : function (dialog) {
					dialog.overlay.fadeIn('slow', function () {
						dialog.container.slideDown('slow', function () {
							dialog.data.fadeIn('slow');
						});
					});
				}
			};

			// Setup a helper function.
			Drupal.regoverlay.displayOverlay = function () {
				if ( overlayHasBeenSeen && Number($.cookie('ec-reg-overlay-bypass')) === 0 ) {
					return;
				}
				$.cookie('ec-reg-overlay-seen', 1, {expires: 365, path: '/'});
				overlayHasBeenSeen = true;
				// Remove the slider ad if we are showing the overlay.
				$('#block-ec_ads-slider_ad').remove();
				// Show the overlay.
				$('#' + id).modal(Drupal.regoverlay.modalOptions);

				// Generate a link-tracking.
				var s = s_gi(s_account);
				clearLinkVars();
				clearOmniVars();
				s.linkTrackVars = 'prop45';
				s.prop45 = s.pageName;
				var pageNameTemp = s.pageName;
				s.pageName = '';
				s.tl(this, 'o', pageNameTemp);
				s.pageName = pageNameTemp;

				// We need to attach the behaviors to our overlay when we pop it up as it
				// is not visiable to the behaviors at first.
				Drupal.behaviors.omniture($('#reg-overlay'));
				Drupal.behaviors.homePageRegistrationOverlayAttach();
			};

			// Pop-open for testing if we have a bypass cookie set.
			var bypass = Number($.cookie('ec-reg-overlay-bypass'));
			if ( bypass === 1 || (Number(Drupal.settings.EcRegOverlayEnabled) === 1 && !overlayHasBeenSeen) ) {
				Drupal.regoverlay.displayOverlay();
			}
		};

		// Update the page context.
		Drupal.regoverlay.omniture.updatePageContext = function (context) {
			var info = $('#reg-overlay-omniture-page-context', context);
			if ( info.length === 0 ) {
				return;
			}
			info = info.text();
			try {
				info = JSON.parse(info);
			}
			catch (e) {
				// Do nothing if we can not parse.
			}
			// Set the content.
			pageContext = info.pageContext;
		};

		/**
		 * This behavior runs each time the page is updated to fire the delayed omniture events.
		 * @param context
		 */
		Drupal.behaviors.regOverlaySendDelayedOmnitureEvents = function (context) {
			var info = $('#reg-overlay-omniture-page-context', context).text();
			try {
				info = JSON.parse(info);
				if ( info.omniture.length === 0 ) {
					return;
				}
				var oevent, event_name, p, current_page_name, i;
				current_page_name = Drupal.regoverlay.omniture.getPageNameInContext(info.pageContext);
				// Loop through the setup options
				for (i = 0; i < info.omniture.length; i++) {
					oevent = info.omniture[i];

					// Set the name of empty props to the current name.
					for (p in oevent) {
						if ( p.indexOf('prop') === 0 && oevent[p] === "" ) {
							oevent[p] = current_page_name;
						}
					}

					clearLinkVars();
					if ( typeof oevent.name === "undefined" || oevent.name === "" ) {
						event_name = current_page_name;
					}
					else {
						event_name = oevent.name;
					}
					oevent.skipDelay = true;
					Drupal.omniture.trackClick(null, event_name, oevent);
					clearLinkVars();
				}
			}
			catch (e) {
				return;
			}
		};

		// Helper function to get the context of the page.
		Drupal.regoverlay.omniture.getPageNameInContext = function (context) {
			var refContext = pageContext;
			if ( typeof context !== "undefined" ) {
				refContext = context;
			}
			// Set the current page context string name. Used as a prefix.
			var pn = "member_services|registration|registration_overlay_part_" + refContext;
			return pn;
		};
		Drupal.regoverlay.omniture.sendData = function (suffix_name) {
			var name = Drupal.regoverlay.omniture.getPageNameInContext() + '|' + suffix_name;
			s.linkTrackVars = 'prop45,';
			s.prop45 = name;
			s.tl(this, 'o', name);
			clearLinkVars();
		};

		/**
		 * Helper function that looks up the omniture index number by the
		 * name of the link.
		 */
		Drupal.regoverlay.findOmnitureIndexByName = function (name) {
			var os = Drupal.settings.omniture.click_tracking;
			var index = -1;
			var i = 0;
			for (i = 0; i < os.length; i++) {
				if ( os[i].name === name ) {
					index = i;
				}
			}
			return index;
		};
		/*** END REGISTRATION OVERLAY **/


		var overlayClicked = overlayClicked || {};
		Drupal.behaviors.homepageSelectHeroItems = function (context) {
			return false;
			// Get some settings.
			var rotato_interval = Drupal.settings.ecHomepage.rotato_interval;
			var rotato_initial_delay = Drupal.settings.ecHomepage.rotato_initial_delay;
			var page_load_time = (new Date().getTime() - ec_homepage_page_start) / 1000;
			var $superhero = $('#superhero');

			// Helper function to select a particular hero item.
			var select_hero = function (li) {
				if ( !li.hasClass("selected") ) {
					var other = li.siblings('.selected').removeClass('selected');
					li.addClass('selected');

					// Unselect other hero items and hide their images.
					other.find(".hero-media").stop().animate({opacity: 0}, 500, function () {
						$(this).css('visibility', 'hidden');
					});
					// Select this hero item and fade in its image.
					li.find(".hero-media").css('visibility', 'visible').stop().animate({opacity: 1}, 500);
				}
			};

			// If we have the rotato_interval set, wire up the auto rotating.
			if ( rotato_interval > 0 ) {
				$(context).find('.hero-multiple').each(function () {
					var $this = this;

					// If one isn't selected by default, select the first one.
					if ( $($this).find('> li.selected').length === 0 ) {
						$($this).find('> li:first').addClass('selected');
					}

					// This is the time (in seconds) between the transitions.
					function autoRotate () {
						var next = $($this).find('> li.selected').next();
						if ( next.length ) {
							select_hero(next);
							$this.rotato_timer = setTimeout(autoRotate, rotato_interval * 1000);
						}
						else {
							select_hero($($this).find('> li:first'));
						}
					}

					$this.rotato_timer = setTimeout(autoRotate, Math.max(0, rotato_initial_delay - page_load_time) * 1000);
				});
			}

			// Wire up the hover effect.
			$(context).find('.hero-multiple > li').hover(function () {
				select_hero($(this));
				if ( typeof($(this).parent().get(0).rotato_timer) !== 'undefined' ) {
					clearTimeout($(this).parent().get(0).rotato_timer);
					$(this).parent().get(0).rotato_timer = null;
				}
			});
			// Remove the overlays if we are using iframes.
			setTimeout(function () {
				if ( $superhero.find('iframe.BrightcoveExperience').length !== 0 ) {
					$superhero.find('.video-overlay').remove();
				}
			}, 500);
			$superhero.find('.video-overlay').click(function () {
				var id = $(this).parent().find('.BrightcoveExperience').attr('id');
				if ( overlayClicked[id] ) {
					return false;
				}
				overlayClicked[id] = true;
				var $this = this;
				var cssObj = {
					'background'      : 'url(/sites/all/themes/econfinal/images/icons/ajax-loader-medium.gif) no-repeat center center',
					'background-color': '#FFF',
					'opacity'         : '0.3'
				};
				$($this).css(cssObj);
				// Replace the image with a throbber image.
				function playVideo () {
					var player = brightcove.getExperience(id);
					if ( player && player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER) ) {
						setTimeout(function () {
							player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER).play();
							$($this).parents('.hero-media').find('img.video-still').remove();
							$($this).remove();
						}, 1000);
					}
					else {
						setTimeout(playVideo, 1000);
					}
				}

				playVideo();
				return false;
			}).removeClass('video-overlay-loading');
		};
		// End
	})(jQuery);

	/**
	 * Dynamic behaviour for products and events block.
	 */
	Drupal.behaviors.social = function () {
		"use strict";
		$("div.linked").click(function () {
			document.location.href = $(this).find('a.social-link').attr('href');
		});
	};

	Drupal.behaviors.homepageHeroWDYS = function (context) {
		"use strict";
		$(context).find('.media-overlay.ajax-success .voting-results').show();

		$(context).find('.media-overlay form.decisions-selection-voting-form').each(function () {
			var form = $(this);
			var container = form.parents('.media-overlay');

			form.bind('ajaxsubmit', function () {
				container.addClass('ajax-submit');
			});
			form.bind('ajaxsuccess', function () {
				container.removeClass('ajax-submit');
				container.addClass('ajax-success');
				form.find('.voting-results').show();
			});
			form.bind('ajaxerror', function () {
				container.removeClass('ajax-submit');
				container.addClass('ajax-error');
			});
		});
	};

	/**
	 * Provides AJAX-like page updating via AHAH (Asynchronous HTML and HTTP).
	 *
	 * AHAH is a method of making a request via Javascript while viewing an HTML
	 * page. The request returns a small chunk of HTML, which is then directly
	 * injected into the page.
	 *
	 * Drupal uses this file to enhance form elements with #ahah[path] and
	 * #ahah[wrapper] properties. If set, this file will automatically be included
	 * to provide AHAH capabilities.
	 */

	/**
	 * Attaches the ahah behavior to each ahah form element.
	 */
	Drupal.behaviors.ahah = function (context, step) {
		/*for (var base in Drupal.settings.ahah) {
		 if (!$('#'+ base + '.ahah-processed').size()) {
		 var element_settings = Drupal.settings.ahah[base];

		 $(element_settings.selector).each(function() {
		 element_settings.element = this;
		 var ahah = new Drupal.ahah(base, element_settings);
		 });

		 $('#'+ base).addClass('ahah-processed');
		 }
		 }*/

		var settingsForFinishBtn = {
			button  : {
				op: "Finish"
			},
			effect  : "fade",
			element : document.getElementById('edit-finish'),
			event   : "mousedown",
			keypress: true,
			method  : "replace",
			progress: {
				element: $('<div id="ahah-progress-edit-finish" class="progress ahah-progress ahah-progress-bar"></div>'),
				message: "Completing registration",
				object : {
					element       : $('<div id="ahah-progress-edit-finish" class="progress ahah-progress ahah-progress-bar"></div>'),
					errorCallback : undefined,
					id            : "ahah-progress-edit-finish",
					method        : "GET",
					updateCallback: undefined,
					uri           : null
				},
				type   : "bar"
			},
			selector: "#edit-finish",
			url     : "/ec-homepage/regov/js",
			wrapper : "ov-user-info-wrapper"
		};

		var settings = {
			button  : {
				op: "Register"
			},
			effect  : "fade",
			element : document.getElementById('edit-check-email'),
			event   : "mousedown",
			keypress: true,
			method  : "replace",
			progress: {
				message: "Validating e-mail",
				type   : "bar"
			},
			selector: "#edit-check-email",
			url     : "/ec-homepage/regov/js",
			wrapper : "ov-user-info-wrapper"
		};

		if ( step === 1 ) {
			var ahah = new Drupal.ahah('edit-check-email', settings);
		} else if ( step === 2 ) {
			var ahah = new Drupal.ahah('edit-finish', settingsForFinishBtn);
		}
	};

	/**
	 * AHAH object.
	 */
	Drupal.ahah = function (base, element_settings) {
		// Set the properties for this object.
		this.element = element_settings.element;
		this.selector = element_settings.selector;
		this.event = element_settings.event;
		this.keypress = element_settings.keypress;
		this.url = element_settings.url;
		this.wrapper = '#' + element_settings.wrapper;
		this.effect = element_settings.effect;
		this.method = element_settings.method;
		this.progress = element_settings.progress;
		this.button = element_settings.button || { };

		if ( this.effect == 'none' ) {
			this.showEffect = 'show';
			this.hideEffect = 'hide';
			this.showSpeed = '';
		}
		else if ( this.effect == 'fade' ) {
			this.showEffect = 'fadeIn';
			this.hideEffect = 'fadeOut';
			this.showSpeed = 'slow';
		}
		else {
			this.showEffect = this.effect + 'Toggle';
			this.hideEffect = this.effect + 'Toggle';
			this.showSpeed = 'slow';
		}

		// Record the form action and target, needed for iFrame file uploads.
		var form = $(this.element).parents('form');
		this.form_action = form.attr('action');
		this.form_target = form.attr('target');
		this.form_encattr = form.attr('encattr');

		// Set the options for the ajaxSubmit function.
		// The 'this' variable will not persist inside of the options object.
		var ahah = this;
		var options = {
			url         : ahah.url,
			data        : ahah.button,
			beforeSubmit: function (form_values, element_settings, options) {
				return ahah.beforeSubmit(form_values, element_settings, options);
			},
			success     : function (response, status) {
				// Sanity check for browser support (object expected).
				// When using iFrame uploads, responses must be returned as a string.
				if ( typeof(response) == 'string' ) {
					response = Drupal.parseJson(response);
				}
				return ahah.success(response, status);
			},
			complete    : function (response, status) {
				if ( status == 'error' || status == 'parsererror' ) {
					return ahah.error(response, ahah.url);
				}
			},
			dataType    : 'json',
			type        : 'POST'
		};

		// Bind the ajaxSubmit function to the element event.
		$(element_settings.element).bind(element_settings.event, function () {
			$(element_settings.element).parents('form').ajaxSubmit(options);
			return false;
		});
		// If necessary, enable keyboard submission so that AHAH behaviors
		// can be triggered through keyboard input as well as e.g. a mousedown
		// action.
		if ( element_settings.keypress ) {
			$(element_settings.element).keypress(function (event) {
				// Detect enter key.
				if ( event.keyCode == 13 ) {
					$(element_settings.element).trigger(element_settings.event);
					return false;
				}
			});
		}
	};

	/**
	 * Handler for the form redirection submission.
	 */
	Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) {
		// Disable the element that received the change.
		$(this.element).addClass('progress-disabled').attr('disabled', true);

		// Insert progressbar or throbber.
		if ( this.progress.type == 'bar' ) {
			var progressBar = new Drupal.progressBar('ahah-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback));
			if ( this.progress.message ) {
				progressBar.setProgress(-1, this.progress.message);
			}
			if ( this.progress.url ) {
				progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500);
			}
			this.progress.element = $(progressBar.element).addClass('ahah-progress ahah-progress-bar');
			this.progress.object = progressBar;
			$(this.element).after(this.progress.element);
		}
		else if ( this.progress.type == 'throbber' ) {
			this.progress.element = $('<div class="ahah-progress ahah-progress-throbber"><div class="throbber">&nbsp;</div></div>');
			if ( this.progress.message ) {
				$('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>')
			}
			$(this.element).after(this.progress.element);
		}
	};

	/**
	 * Handler for the form redirection completion.
	 */
	Drupal.ahah.prototype.success = function (response, status) {
		var wrapper = $(this.wrapper);
		var form = $(this.element).parents('form');
		// Manually insert HTML into the jQuery object, using $() directly crashes
		// Safari with long string lengths. http://dev.jquery.com/ticket/1152
		var new_content = $('<div></div>').html(response.data);
		var step;

		// Restore the previous action and target to the form.
		form.attr('action', this.form_action);
		this.form_target ? form.attr('target', this.form_target) : form.removeAttr('target');
		this.form_encattr ? form.attr('target', this.form_encattr) : form.removeAttr('encattr');

		// Remove the progress element.
		if ( this.progress.element ) {
			$(this.progress.element).remove();
		}
		if ( this.progress.object ) {
			this.progress.object.stopMonitoring();
		}
		$(this.element).removeClass('progress-disabled').attr('disabled', false);

		// Add the new content to the page.
		Drupal.freezeHeight();
		if ( this.method == 'replace' ) {
			wrapper.empty().append(new_content);
		}
		else {
			wrapper[this.method](new_content);
		}

		// Immediately hide the new content if we're using any effects.
		if ( this.showEffect != 'show' ) {
			new_content.hide();
		}

		// Determine what effect use and what content will receive the effect, then
		// show the new content.
		if ( $('.ahah-new-content', new_content).size() > 0 ) {
			$('.ahah-new-content', new_content).hide();
			new_content.show();
			$(".ahah-new-content", new_content)[this.showEffect](this.showSpeed);
		}
		else if ( this.showEffect != 'show' ) {
			new_content[this.showEffect](this.showSpeed);
		}

		// Attach all javascript behaviors to the new content, if it was successfully
		// added to the page, this if statement allows #ahah[wrapper] to be optional.
		if ( new_content.parents('html').length > 0 ) {
			if ( ~$(new_content).text().indexOf('Nearly there...') ) {
				step = 2;
			} else {
				step = 1;
			}
			Drupal.attachBehaviors(new_content, step);

		}

		Drupal.unfreezeHeight();
	};

	/**
	 * Handler for the form redirection error.
	 */
	Drupal.ahah.prototype.error = function (response, uri) {
		alert(Drupal.ahahError(response, uri));
		// Resore the previous action and target to the form.
		$(this.element).parent('form').attr({ action: this.form_action, target: this.form_target});
		// Remove the progress element.
		if ( this.progress.element ) {
			$(this.progress.element).remove();
		}
		if ( this.progress.object ) {
			this.progress.object.stopMonitoring();
		}
		// Undo hide.
		$(this.wrapper).show();
		// Re-enable the element.
		$(this.element).removeClass('progess-disabled').attr('disabled', false);
	};

	/**
	 * A progressbar object. Initialized with the given id. Must be inserted into
	 * the DOM afterwards through progressBar.element.
	 *
	 * method is the function which will perform the HTTP request to get the
	 * progress bar state. Either "GET" or "POST".
	 *
	 * e.g. pb = new progressBar('myProgressBar');
	 *      some_element.appendChild(pb.element);
	 */
	Drupal.progressBar = function (id, updateCallback, method, errorCallback) {
		var pb = this;
		this.id = id;
		this.method = method || "GET";
		this.updateCallback = updateCallback;
		this.errorCallback = errorCallback;

		this.element = document.createElement('div');
		this.element.id = id;
		this.element.className = 'progress';
		$(this.element).html('<div class="bar"><div class="filled"></div></div>' +
			'<div class="percentage"></div>' +
			'<div class="message">&nbsp;</div>');
	};

	/**
	 * Set the percentage and status message for the progressbar.
	 */
	Drupal.progressBar.prototype.setProgress = function (percentage, message) {
		if ( percentage >= 0 && percentage <= 100 ) {
			$('div.filled', this.element).css('width', percentage + '%');
			$('div.percentage', this.element).html(percentage + '%');
		}
		$('div.message', this.element).html(message);
		if ( this.updateCallback ) {
			this.updateCallback(percentage, message, this);
		}
	};

	/**
	 * Start monitoring progress via Ajax.
	 */
	Drupal.progressBar.prototype.startMonitoring = function (uri, delay) {
		this.delay = delay;
		this.uri = uri;
		this.sendPing();
	};

	/**
	 * Stop monitoring progress via Ajax.
	 */
	Drupal.progressBar.prototype.stopMonitoring = function () {
		clearTimeout(this.timer);
		// This allows monitoring to be stopped from within the callback
		this.uri = null;
	};

	/**
	 * Request progress data from server.
	 */
	Drupal.progressBar.prototype.sendPing = function () {
		if ( this.timer ) {
			clearTimeout(this.timer);
		}
		if ( this.uri ) {
			var pb = this;
			// When doing a post request, you need non-null data. Otherwise a
			// HTTP 411 or HTTP 406 (with Apache mod_security) error may result.
			$.ajax({
				type    : this.method,
				url     : this.uri,
				data    : '',
				dataType: 'json',
				success : function (progress) {
					// Display errors
					if ( progress.status == 0 ) {
						pb.displayError(progress.data);
						return;
					}
					// Update display
					pb.setProgress(progress.percentage, progress.message);
					// Schedule next timer
					pb.timer = setTimeout(function () {
						pb.sendPing();
					}, pb.delay);
				},
				error   : function (xmlhttp) {
					pb.displayError(Drupal.ahahError(xmlhttp, pb.uri));
				}
			});
		}
	};

	/**
	 * Display errors on the page.
	 */
	Drupal.progressBar.prototype.displayError = function (string) {
		var error = document.createElement('div');
		error.className = 'error';
		error.innerHTML = string;

		$(this.element).before(error).hide();

		if ( this.errorCallback ) {
			this.errorCallback(this);
		}
	};
};

mmcore.T6.isPageExcluded = function () {
	var pagesToExclude = [
			/^http:\/\/www\.economist\.com(\/|#.*|\?.*|\/#.*|\/\?.*)?$/i,
			/^https:\/\/subscriptions.economist.com(\/|#.*|\?.*|\/#.*|\/\?.*)?$/i
		],
		result = false;

	Array.prototype.forEach.call(pagesToExclude, function (page) {
		if ( page.test(window.location.href) ) {
			result = true;
		}
	});

	return result;
};

mmcore.T6.isUserNotLoggedIN = function () {
	return $('.mh-search').size() && !!~$('.show-login').text().indexOf('Log in');
};

mmcore.T6.isCookieNormal = function () {
	var cookie, cookieValueBreaks;

	cookie = mmcore.GetCookie('ec_omniture_user_sub', 1).toLowerCase();
	cookieValueBreaks = ['bulk-ip', 'bulk-referrer', 'subscriber',
		'print-subscriber', 'digital-subscriber', 'ex-subscriber',
		'registered'];

	return !!~$.inArray(cookie, cookieValueBreaks) === false;
};

mmcore.T6.__tmtWait2 = null;
(function wait2 () {
	'use strict';

	var cookie = mmcore.GetCookie('ec-reg-overlay-seen', 1),
		paywallName, _ref, _ref1, _ref2;

		paywallName = ((_ref = window.Drupal) != null ?
							(_ref1 = _ref.settings) != null ?
								(_ref2 = _ref1.ec_wallpage) != null ?
									_ref2.ec_wallpage_paywall_name : void 0 : void 0 : void 0) === 'Article Paywall Anonymous';

	if ( cookie || paywallName || mmcore.T6.isPageExcluded() ) {
		return false;
	}

	if ( window.Drupal && window.Drupal.Ajax && $('#page').size() ) {
		mmcore.T6.userRegWallScript();
		var html = '<div id="reg-overlay" class="mmRegOverlT6"> <div class="ov-header"> <h2>Welcome to <i>The Economist</i></h2> <p class="sub-header">Welcome to independent thinking and a distinctive world view.</p> </div> <!-- // End the header section --> <div class="ov-body clearfix"> <div class="ov-reg"> <div class="ov-offers-ribbon ov-offers-ribbon-red clearfix"> <div class="ov-offers-ribbon-head">&nbsp;</div> <div class="ov-offers-ribbon-body"><p>Register</p></div> <div class="ov-offers-ribbon-cap">&nbsp;</div> </div> <form id="ec-homepage-overlay-ref-form" method="post" accept-charset="UTF-8" action="/"> <div><div id="ov-user-info-wrapper"><span class="ov-reg-callout">Register now to enjoy your selection of up to <strong>three articles</strong> each week.</span> <div id="edit-mail-wrapper" class="form-item clearfix"> <input type="text" class="form-text" onkeypress="if (event.keyCode != 13) {  return true; } $(&quot;#edit-check-email&quot;).mousedown(); return false;" placeholder="E-mail address" value="" size="20" id="edit-mail" name="mail" maxlength="128"> </div> <input type="submit" data-ec-omniture="member_services|registration|registration_overlay_part_1|register" class="form-submit ec-button ec-processed ahah-processed" value="Register" id="edit-check-email" name="op"> <input type="submit" class="form-submit ec-processed ahah-processed" data-ec-omniture="member_services|registration|registration_overlay_part_2" style="display: none" value="Finish" id="edit-finish" name="op"> <span style="display:none;" id="reg-overlay-omniture-page-context">{"pageContext":1}</span></div><input type="hidden" value="ec_homepage_overlay_ref_form" id="edit-ec-homepage-overlay-ref-form" name="form_id"> </div><input type="text" style="display: none;" name="given_name" id="edit-given-name" value="Reader"><input type="text" style="display: none;" name="family_name" id="edit-family-name" value="Reader"></form> </div> <div class="ov-offers clearfix"> <div class="ov-offers-ribbon ov-offers-ribbon-grey clearfix"> <div class="ov-offers-ribbon-head">&nbsp;</div> <div class="ov-offers-ribbon-body"><p>Subscribe now and enjoy full access to <i>The Economist</i></p></div> <div class="ov-offers-ribbon-cap">&nbsp;</div> </div> <div class="ov-offers-list clearfix"> <ul class="offer web"> <li class="offer-img"><a href="#">Economist.com</a></li> <li class="offer-title"><h2>Economist.com</h2></li> <li class="offer-desc"><p>Get full access to Economist.com including each week\'s full issue, all blog content, and our online archive.</p></li> </ul> <ul class="offer digital"> <li class="offer-img"><a href="#">Digital apps</a></li> <li class="offer-title"><h2><i>The Economist</i> apps</h2></li> <li class="offer-desc"><p>Read or listen to each week\'s full issue via <br><i>The Economist</i> apps for iPad, iPhone, Android, Windows 8, Chrome, BlackBerry and Kindle Fire.</p></li> </ul> <ul class="offer audio"> <li class="offer-img"><a href="#">Audio edition</a></li> <li class="offer-title"><h2>Audio edition</h2></li> <li class="offer-desc"><p>Listen to each week\'s issue of <i>The Economist</i>, read by professional broadcasters.</p></li> </ul> <ul class="offer print-edition"> <li class="offer-img"><a href="#">Print edition</a></li> <li class="offer-title"><h2>Print edition</h2></li> <li class="offer-desc"><p>Add print copies to your subscription to enjoy delivery of the print edition to your home or office every week.</p></li> </ul> </div> <span class="container-offer-button"> <a onclick="Drupal.regoverlay.omniture.sendData(\'view_subscription_options\');" class="ec-button offer-btn" href="https://subscriptions.economist.com/GLB/OVL/T1/">View subscription offers</a>      </span> </div> </div> </div>';
		$(html).appendTo('#page');
		Drupal.behaviors.homepageOverlay('#page');
		Drupal.behaviors.ahah('', 1);
	} else {
		mmcore.T6.__tmtWait2 = setTimeout(wait2, 50);
	}
})();

mmcore.T6.render();

/* alternative show timeout */
setTimeout(function waiter () {
	if ( mmcore._docEnd ) {
		setTimeout(function () {
			clearTimeout(mmcore.T6.__tmtWait2);
		}, 3000);
		setTimeout(function () {
			mmcore.T6.stopCheck = true;
		}, 20000);
	} else {
		setTimeout(waiter, 150);
	}
}, 500);
}catch(err){mmcore.EH(err);}
mmcore._RenderOnLoad();if(typeof mmcore._callback=='object'&&typeof mmcore._callback[1]=='function'){try{mmcore._callback[1]();}catch(err){mmcore.EH(err);}
finally{mmcore._callback[1]=null;}}
})();