wpniSite='wpni';
wpniDomain='washingtonpost.com';
show_doubleclick_ad = true;
rssString = "fromrss=y";
tileThatGetsDcopt = 1;
hourScope = 24;
numPop = 5;
//this declares what kinds of ads are on this site

wpniAds.templates.initRule('defaultTemplate');
wpniAds.templates.rules.defaultTemplate.what = new Array('!336x35','!leaderboard_2','!featurebar','!tiffany_tile','!336x60','!bigbox','!pushdown','!sponsor_realtor');

if(!location.href.match('suppress_fb'))
{

//10758-HS
wpniAds.templates.initRule('trulia');
wpniAds.templates.rules.trulia.what = new Array('bigbox');
wpniAds.templates.rules.trulia.where = new Array('trulia');

wpniAds.templates.initRule('local_homepage');
wpniAds.templates.rules.local_homepage.what = new Array('!leaderboard');
wpniAds.templates.rules.local_homepage.where = new Array('washingtonpost.com');

//9720-JM
wpniAds.templates.initRule('innovation_test');
wpniAds.templates.rules.innovation_test.what = new Array('!bigbox','!200x50');
wpniAds.templates.rules.innovation_test.where = new Array('^innovation$');

//Loudoun Hack
wpniAds.templates.initRule('le_tiff');
wpniAds.templates.rules.le_tiff.what = new Array('tiffany_tile');
wpniAds.templates.rules.le_tiff.where = new Array('metro/va/loudoun');
wpniAds.templates.rules.le_tiff.hardcodes = '<div id="adTiff" style="top:0;"><scr'+'ipt src="http://media.washingtonpost.com/wp-srv/ad/tiffany_manager.js" type="text/javascript"></script></div>';

//11413-AR-219032676
wpniAds.templates.initRule('starbucks');
wpniAds.templates.rules.starbucks.what = new Array('leaderboard');
wpniAds.templates.rules.starbucks.where = new Array('washingtonpost.com');
wpniAds.templates.rules.starbucks.when = new Array('200910280000/200910282359');

//11384-PM-order_id#4036787
wpniAds.templates.initRule('bofa');
wpniAds.templates.rules.bofa.what = new Array('leaderboard');
wpniAds.templates.rules.bofa.where = new Array('washingtonpost.com');
wpniAds.templates.rules.bofa.when = new Array('200911040000/200911042359;200912020000/200912022359');

//11493-AR-219252920,219252926
if(typeof adOpsLocalFlag != 'undefined' && adOpsLocalFlag)
{
	wpniAds.templates.initRule('lhp_pushdown');
	wpniAds.templates.rules.lhp_pushdown.what = new Array('pushdown');
	wpniAds.templates.rules.lhp_pushdown.where = new Array('washingtonpost.com');
	wpniAds.templates.rules.lhp_pushdown.when = new Array('200911070000/200911082359');
}

//11398-AR
wpniAds.templates.initRule('applehp');
wpniAds.templates.rules.applehp.what = new Array('!tiffany_tile','pushdown');
wpniAds.templates.rules.applehp.where = new Array('washingtonpost.com');
wpniAds.templates.rules.applehp.when = new Array('200911130000/200911132359;200911160000/200911162359');

wpniAds.templates.initRule('sappush');
wpniAds.templates.rules.sappush.what = new Array('pushdown');
wpniAds.templates.rules.sappush.where = new Array('washingtonpost.com');
wpniAds.templates.rules.sappush.when = new Array('200911170000/200911172359');

//11759-AL-219901960
wpniAds.templates.initRule('lhpTiff');
wpniAds.templates.rules.lhpTiff.what = new Array('tiffany_tile');
wpniAds.templates.rules.lhpTiff.where = new Array('washingtonpost.com');
wpniAds.templates.rules.lhpTiff.when = new Array('200911231200/200911271200');

}
function initAdType(what)
{
 var thisAdType = new AdInstance()
 thisAdType.testFlagArray = new Array('test_ads','test_' + what); 
 thisAdType.debugFlagArray = new Array('debugAdCode','debug' + what);
 
 thisAdType.dcCode += orbitFlag() + getWPATCookie() + realEstateAreaId() + aptco() + locExpSponsor()  + article();
 
 switch(what)
 {
	 
  case 'featurebar':
   thisAdType.size = "446x33";
   thisAdType.code = "ad=fb;";
  break

  case 'leaderboard':
   thisAdType.size = "728x90";
   thisAdType.code = "ad=lb;";
  break
  
  case 'bigbox':
   thisAdType.size = "300x250";
   thisAdType.code = "ad=bb;";
  break
  
  case 'skyscraper':
   thisAdType.size = "160x600";
   thisAdType.code = "ad=ss;";
  break
  
  case 'tiffany_tile':
   thisAdType.size = "200x60,200x80,234x60,290x60,300x45";
   thisAdType.code = "ad=tiff;"
  break
  
  case 'flex_ss_bb_hp':
   thisAdType.size = "160x600,300x250,336x850";
   thisAdType.code = "ad=ss;ad=bb;ad=hp;";
  break
  
  case 'flex_bb_tp':
   thisAdType.size = "300x250,300x600";
   thisAdType.code = "ad=bb;ad=tp;";
  break
  
   case '336x35':
   thisAdType.size = "336x35";
   thisAdType.code = "ad=336x35;";
  break
  
   case '336x60':
   thisAdType.size = "336x60";
   thisAdType.code = "ad=336x60;";
  break
  
   case '200x50':
   thisAdType.size = "200x50";
   thisAdType.code = "ad=200x50;";
  break
  
  case '120x240':
   thisAdType.size = "120x240";
   thisAdType.code = "ad=120x240;";
  break
  
  case '285x29':
   thisAdType.size = "285x29";
   thisAdType.code = "ad=285x29;";
  break
  
  case 'pushdown':
   thisAdType.size = "1x1";
   thisAdType.code = "";
  break
  
  case 'sponsor':
  	thisAdType.size = '1x1';
	thisAdType.tile = 'false';
  break
  
  case 'inline_bb':
    thisAdType.size = '300x250';
	thisAdType.tile = 'ad=bb;';
 }
  
return thisAdType
}
//this translates from the old placeAd to the new one
function posMaker(adType,posOverride,delivery)
{
	
	if(posOverride || delivery=='AJAX')
	{
		var returnValue = adType + ((posOverride) ? '_' + posOverride : '');
	}
	else
	{
		if (typeof this.usedSpots == 'undefined')
		{
			this.usedSpots = new Array();
		}
		if (this.usedSpots[adType] == null)
		{
			this.usedSpots[adType] = 1;
			returnValue = adType;
		}
		else
		{
			this.usedSpots[adType]++;
			returnValue = adType+"_"+this.usedSpots[adType];
		}
	}
	var posArray = { 'leaderboard':1,'leaderboard_2':2,'skyscraper':3,'flex_ss_bb_hp':6,'flex_bb_tp':6,'featurebar':7,'tiffany_tile':14,'336_35':19,'bigbox':20,'pushdown':43};
	
	if ( typeof posArray[returnValue] != 'undefined' && (typeof commercialNode!='undefined' && commercialNode=='washingtonpost.com') )
	{
		posArray['flex_ss_bb_hp'] = 16;
	}
	
	return  { 'keyvalue' : ( (typeof posArray[returnValue] != 'undefined') ? 'ad' + posArray[returnValue] : returnValue ) , 'slug' : returnValue };

}



function orbitFlag()
{
	return (document.location.href.match('/wp-dyn/')?'orbit=y;':'');
}

function getWPATCookie()
{
  if (document.cookie.indexOf("WPATC") != -1)
  {
    var start = (document.cookie.indexOf("WPATC") + 6);
    var end = (document.cookie.indexOf(";",start)) == -1 ? document.cookie.length : document.cookie.indexOf(";",start);
    var cookie = document.cookie.substring(start,end) + ";";
    while (cookie.indexOf(":") != -1)
      cookie = cookie.substring(0,cookie.indexOf(":"))+";"+cookie.substring(cookie.indexOf(":")+1,cookie.length);
    if (cookie.lastIndexOf(";") != cookie.length - 1) cookie += ';';
    if (cookie.indexOf("=") == 0) cookie = cookie.substring(cookie.indexOf(";")+1,cookie.length);
  }
  else var cookie = "" ;
  return cookie ;
}

function getQueryVariable(variable)
{ 
	var query = location.href.split('?')[1]; 
	if(!query)
	{
		return null
	}
	var vars = query.split("&");
	for(var i=0;i<vars.length;i++)
	{ 
		var pair = vars[i].split("="); 
		if (pair[0] == variable)
		{ 
			return pair[1]; 
		} 
	}
	return null
} 


function realEstateAreaId()
{
   if(typeof this.returnREAIValue == 'undefined')
    {
    	this.returnREAIValue = '';
	   	if(getQueryVariable('areaId'))
    	{
    		this.returnREAIValue = 'areaId=' + getQueryVariable('areaId') + ";"
    	}
    	if(typeof hs != 'undefined' && typeof hs.geo_area_id != 'undefined')
    	{
    		geo_area_id_array = hs.geo_area_id.split(';');
    		for(var x =0; x < geo_area_id_array.length; x++)
    		{
    			if(typeof geo_area_id_array[x] == 'string')
				{
					this.returnREAIValue += 'areaId=' + geo_area_id_array[x] + ';'
				}
    		}
    	}
    }
    return this.returnREAIValue
}

function aptco()
{
	var a = getQSValue('aptco');
	var b = getQSValue('metro');
	if(a && b)
	{
		return 'aptco=' + a + ';metro=' + b + ';';
	} 
	return '';
}

function locExpSponsor(){
if (typeof countyName != 'undefined' && typeof stateName != 'undefined')
{
	var invalidKW = ['?','=','/','\\',':',';',',','*','(',')','&','$','%','@','!','^','+',' ','[',']','{','}','.'];
	for (var i=0;i<invalidKW.length;i++)
	{
		csRE = new RegExp('(\\' + invalidKW[i] + ')', 'g');
		countyName = countyName.replace(csRE,"").toLowerCase();
		stateName = stateName.replace(csRE,"").toLowerCase();
	}
	locExpKV = "lexp_spon=" + countyName + "-" + stateName + ";";
	}
	else 
	{
		locExpKV = '';
	}
	return locExpKV
}

function realEstateCoSpon()
{
	if( (typeof _AD_TARGETING != 'undefined') && _AD_TARGETING.county && _AD_TARGETING.state )
	{
		var co_spon = _AD_TARGETING.county + '-' + _AD_TARGETING.state;
		return ';co_spon=' + co_spon.toLowerCase().replace(/ /gi,'_').replace(/[^a-z\d\-\_]/gi,'') + ';';
	}
	else
	{
		return '';
	}
}

function front()
{
	return 'front=' + ((typeof commercialPageType != 'undefined' && commercialPageType=='front')?'y':'n') + ';';
}

function article()
{
	return  'article=' + ((typeof commercialPageType != 'undefined' && commercialPageType=='article')?'y':'n') + ';';
}

function beta_kv()
{
	return (typeof commercialNode != 'undefined' && commercialNode=='washingtonpost.com')?'!c=intrusive;beta=y;':'beta=n;';
}

function hackBin(_arg,currentLoc,what,delivery,onTheFly)
{
	var hackReturnValue=eval(_arg)
	switch(_arg)
	{
		case 'onTheFly':
		

			hackReturnValue += beta_kv();
		
			if(what=='sponsor|new_home_builder')
			{
				if(commercialNode == 'realestate' || commercialNode == 'realestate/front' || commercialNode == 'realestate/buy')
				{
					hackReturnValue += ';tn=4;tr=2;tcp=0;to=v;ta=left;tva=top;';
				}
				else
				{
					hackReturnValue += ';tn=4;tr=1;tcp=0;to=v;ta=left;tva=top;';
				}
			}
			if(what=='sponsor|rental')
			{
				hackReturnValue += ';tn=12;tr=1;tcp=0;to=v;ta=left;tva=top;'
			}
			if(currentLoc.match('realestate') || currentLoc.match('trulia'))
			{
				hackReturnValue += realEstateCoSpon();
			}
			if( ( currentLoc.match('^wiki') || currentLoc.match('innovation') ) && what.match('leaderboard') )
			{
				hackReturnValue += '!category=bigleaderboard;';
			}
			//10522-RZ
			if(currentLoc=='reachwall')
			{
				hackReturnValue += '!c=media;';
			}

		break;
		
		//11510-RZ
		case 'delivery':
			if(delivery=='AJAX' && what=='leaderboard')
			{
				ord_override = true;
			}
		break;
	}
	return hackReturnValue
}



//quigo links
wpAds=(typeof wpAds!='undefined')?wpAds:{};
wpAds.textlinks =
{
		'templates':{
		'article':{
			'inner':{
				'artsandliving':[1483519,1900773,228,215],
				'business':[1483534,1900771,228,215],
				'education':[1484181,1909768,228,215],
				'health':[1484178,1909769,228,215],
				'politics':[1483549,1900769,228,215],
				'sports':[1483579,1900772,228,215],
				'technology':[1484175,1909767,228,215],
				'news':[1483491,1900767,228,215],
				'ros':[1483564,1900770,228,215]
			},
			'bottom':{
				'artsandliving':[1483522,1900773,624,225],
				'business':[1483537,1900771,624,225],
				'education':[1484172,1909768,624,225],
				'health':[1484169,1909769,624,225],
				'politics':[1483552,1900769,624,225],
				'sports':[1483582,1900772,624,225],
				'technology':[1484166,1909767,624,225],
				'news':[1483494,1900767,624,225],
				'ros':[1483567,1900770,624,225]
			}
		},
		'index':{
			'leftrail':{
				'washingtonpost.com':[1483488,1900768,305,215]
			},
			'rightrail':{
				'artsandliving':[1483525,1900773,336,230],
				'business':[1483540,1900771,336,230],
				'education':[1484190,1909768,336,230],
				'health':[1484187,1909769,336,230],
				'politics':[1483555,1900769,336,230],
				'sports':[1483585,1900772,336,230],
				'technology':[1484184,1909767,336,230],
				'news':[1483497,1900767,336,230],
				'ros':[1483570,1900770,336,230]
			}
		},
		'index2':{
			'rightrail':{
				'artsandliving':[1483528,1900773,336,230],
				'business':[1483543,1900771,336,230],
				'education':[1484199,1909768,336,230],
				'health':[1484196,1909769,336,230],
				'politics':[1483558,1900769,336,230],
				'sports':[1483588,1900772,336,230],
				'technology':[1484193,1909767,336,230],
				'news':[1483500,1900767,336,230],
				'ros':[1483573,1900770,336,230]
			}
		},
		'subsection':{
			'bottom':{
				'artsandliving':[1483531,1900773,420,230],
				'business':[1483546,1900771,420,230],
				'education':[1484208,1909768,420,230],
				'health':[1484205,1909769,420,230],
				'politics':[1483561,1900769,420,230],
				'sports':[1483591,1900772,420,230],
				'technology':[1484202,1909767,420,230],
				'news':[1483503,1900767,420,230],
				'ros':[1483576,1900770,420,230]
			}
		},
		'blog_main':{
			'inner':{
				'artsandliving':[1484031,1900773,454,215],
				'business':[1484034,1900771,454,215],
				'education':[1484133,1909768,454,215],
				'health':[1484130,1909769,454,215],
				'politics':[1484037,1900769,454,215],
				'sports':[1484043,1900772,454,215],
				'technology':[1484127,1909767,454,215],
				'news':[1484028,1900767,454,215],
				'ros':[1484040,1900770,454,215]
			},
			'rightrail':{
				'artsandliving':[1484049,1900773,336,215],
				'business':[1484052,1900771,336,215],
				'education':[1484142,1909768,336,215],
				'health':[1484139,1909769,336,215],
				'politics':[1484055,1900769,336,215],
				'sports':[1484061,1900772,336,215],
				'technology':[1484136,1909767,336,215],
				'news':[1484046,1900767,336,215],
				'ros':[1484058,1900770,336,215]
			}
		},
		'blog_permalink':{
			'inner':{
				'artsandliving':[1484067,1900773,454,215],
				'business':[1484070,1900771,454,215],
				'education':[1484154,1909768,454,215],
				'health':[1484151,1909769,454,215],
				'politics':[1484073,1900769,454,215],
				'sports':[1484079,1900772,454,215],
				'technology':[1484145,1909767,454,215],
				'news':[1484064,1900767,454,215],
				'ros':[1484076,1900770,454,215]
			},
			'rightrail':{
				'artsandliving':[1484085,1900773,336,215],
				'business':[1484088,1900771,336,215],
				'education':[1484163,1909768,336,215],
				'health':[1484160,1909769,336,215],
				'politics':[1484091,1900769,336,215],
				'sports':[1484097,1900772,336,215],
				'technology':[1484157,1909767,336,215],
				'news':[1484082,1900767,336,215],
				'ros':[1484094,1900770,336,215]
			}
		}
	},
	'cat_check':function(c){
		var c = c.split('/')[0];
		for(var b in wpAds.textlinks.category)
		{
			for(var e in wpAds.textlinks.category[b])
			{
				if(wpAds.textlinks.category[b][e]==c)
				{
					var d = b;
				}
			}
		}
		return d
	},
	'article_check':function(){
		return ((!urlCheck('_Comments.html')) && (urlCheck('/wp-dyn/content/article/') || urlCheck('/wp-dyn/content/discussion/')))?true:false;
	},
	'index_check':function(){
		var k = ['politics','opinion','business','technology'];
		var j = k.length;
		for(var i=0;i<j;i++)
		{
			if(typeof commercialNode != 'undefined' && commercialNode.match(k[i]))
			{
				return (commercialNode.match(k[i]+'/'))?false:'index';
			}
		}
		return 'index2'
	},
	'blog_check':function(){
		return (urlCheck(/\/\d{4}\/\d{2}\/.*\.htm/gi))?'blog_permalink':'blog_main';
	},
	'category':{
		'washingtonpost.com':['washingtonpost.com'],
		'artsandliving':['artsandliving','artsandlivingarticle','artsandleisure','artsandleisurearticle','dating','entertain','entertainarticle','entertainbestbets','entertainment','entertainmentarticle','food','foodarticle','market','pets','photo','photoarticle','shoplocal','shopping','shoppingNEW','shoppingUSED','style','stylearticle','tastepost','travel','traveldirectory','travel.sidestep','travelarticle'],
		'news':['nation','nationarticle','news','world','worldarticle','religion','realestate','digest','digestarticle','fairfaxextra','liveonline','liveonlinearticle','localportal','metro','metroarticle','mostemailed','mostviewedarticles','opinion','opinionarticle'],
		'business':['business','allbusiness','businessarticle'],
		'education':['education'],
		'health':['health'],
		'politics':['politics','supertuesday','wiki'],
		'technology':['technology'],
		'sports':['sports','sportsarticle']
	},
	'init':function(a,b,c){
		var c = (typeof wpAds.textlinks.cat_check(c)!='undefined') ? wpAds.textlinks.cat_check(c) : 'ros';
		var c = (typeof wpAds.textlinks.templates[a][b][c] == 'undefined') ? 'ros' : c;
		var d = a+'-'+b+'-'+c;
		wpAds.textlinks.exec(wpAds.textlinks.templates[a][b][c],d);
	},
	'exec':function(a,b)
	{
		if(urlCheck('debugAdCode'))
		{
			var b = b.split('-');
			document.write('template='+b[0]+';pos='+b[1]+';channel='+b[2]+';');	
		}
		document.write('<s'+'cript type="text/javascript">adsonar_placementId=' + a[0] + ';adsonar_pid=' + a[1] + ';adsonar_ps=-1;adsonar_zw=' + a[2] + ';adsonar_zh=' + a[3] + ';adsonar_jv="ads.adsonar.com";</s'+'cript><s'+'cript language="JavaScript" src="http://js.adsonar.com/js/adsonar.js"></s'+'cript>');
	}
}



// This code is calling an Orbit/Non-commercial javascript which piggy-backs on ad_v2.js because this file has such
// deep penetration across all our pages and vendors
if ( (typeof PIGGY_BACK_ALREADY_CALLED == "undefined" || !PIGGY_BACK_ALREADY_CALLED) && !location.href.match('https://') ) {
   document.write('<s\cript src="http://www.washingtonpost.com/wp-srv/javascript/piggy-back-on-ads.js"></s\cript>');
}




