wpniSite = 'wpni';
wpniDomain = 'washingtonpost_test.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','!deal');

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('gogdeal');
wpniAds.templates.rules.gogdeal.what = new Array('deal');
wpniAds.templates.rules.gogdeal.where = new Array('cityguide');

wpniAds.templates.initRule('local_homepage');
wpniAds.templates.rules.local_homepage.what = new Array('!leaderboard','336x60_2');
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$');

//12316-AR-215768984
if(typeof adOpsLocalFlag !== 'undefined' && adOpsLocalFlag){
	wpniAds.templates.initRule('mw_tiff');
	wpniAds.templates.rules.mw_tiff.what = new Array('tiffany_tile');
	wpniAds.templates.rules.mw_tiff.where = new Array('washingtonpost.com');
	wpniAds.templates.rules.mw_tiff.when = new Array('201001200000/201001212359');
}

//12357-HS-221657821
wpniAds.templates.initRule('realestate_featured_realtor');
wpniAds.templates.rules.realestate_featured_realtor.what = new Array('sponsor_realtor');
wpniAds.templates.rules.realestate_featured_realtor.where = new Array('realestate');
wpniAds.templates.rules.realestate_featured_realtor.when = new Array('201002010000/201003142359');

//12452-AR-221797419,12468-AR-221045340
wpniAds.templates.initRule('mark_tiff');
wpniAds.templates.rules.mark_tiff.what = new Array('tiffany_tile');
wpniAds.templates.rules.mark_tiff.where = new Array('washingtonpost.com');
wpniAds.templates.rules.mark_tiff.when = new Array('201001251200/201001312359');

//12430-AR-221767211,rev#8-AR-01/25/2010
wpniAds.templates.initRule('gog_tiff');
wpniAds.templates.rules.gog_tiff.what = new Array('tiffany_tile');
wpniAds.templates.rules.gog_tiff.where = new Array('^cityguide$');
wpniAds.templates.rules.gog_tiff.when = new Array('201001250000/201001272359');

//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>';

//12685-RZ
wpniAds.templates.initRule('xerox_tiff');
wpniAds.templates.rules.xerox_tiff.what = new Array('tiffany_tile');
wpniAds.templates.rules.xerox_tiff.where = new Array('washingtonpost.com');
wpniAds.templates.rules.xerox_tiff.when = new Array('201002090000/201002092359');

//12679-MB-222312528
wpniAds.templates.initRule('infiniti_tiff');
wpniAds.templates.rules.infiniti_tiff.what = new Array('tiffany_tile');
wpniAds.templates.rules.infiniti_tiff.where = new Array('washingtonpost.com');
wpniAds.templates.rules.infiniti_tiff.when = new Array('201002100000/201002102359');


}
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 'flex_re':
   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 'deal':
  	thisAdType.size = "1x1";
	thisAdType.tile = "ad=1x1;";
  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,'deal':45};
	
	if ( typeof posArray[returnValue] != 'undefined' && (typeof commercialNode!='undefined' && commercialNode=='washingtonpost.com') )
	{
		posArray['flex_ss_bb_hp'] = 16;
	}
	//trulia fix
	if((typeof commercialNode!='undefined' && commercialNode=='trulia') && (typeof posArray[returnValue] != 'undefined' && returnValue=='flex_bb_tp') )
	{
		return  { 'keyvalue':'flex_re','slug':'flex_bb_tp' };
	}
	
	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]*(?=;)/gi,'').replace(/[^a-z\d\-\_]/gi,'') + ';';
	}
	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;';
			}
			//11958-MB
			if(currentLoc=='trulia')
			{
				hackReturnValue += ((what=='leaderboard')?'!c=media':(what=='flex_bb_tp')?'!c=intrusive':'')+';';
			}
			//12622-ML
			if (currentLoc.match('admin')) {
				hackReturnValue += '!c=media;';
			}

		break;
		
		//11510-RZ
		case 'delivery':
			if(delivery=='AJAX' && what=='leaderboard')
			{
				ord_override = true;
			}
		break;
		
		case 'what':
			if(what=='tiffany_tile' && currentLoc=='washingtonpost.com' && typeof jQuery != 'undefined')
			{
				$(function(){
					$("#slug_tiffany_tile").addClass("ad-tiffany");
					var tiff_tile = $("#slug_tiffany_tile");
					var tiff_tile_slug = $('#slug_tiffany_tile img');
					if(tiff_tile_slug && (tiff_tile_slug.height()==60 || tiff_tile_slug.height()==80))
					{
						tiff_tile.css({'height':tiff_tile_slug.height()+'px','top':((tiff_tile.parent().height() - tiff_tile_slug.height())/2)+'px'});	
					}
					else
					{
						tiff_tile.css({'height':'auto','top':((tiff_tile.parent().height() - tiff_tile.height())/2)+'px'});
					}
 				});
			}
			
			if(what=='pushdown' && currentLoc=='washingtonpost.com' && navigator.userAgent.match(/msie 6/gi))
			{
				document.write('<style type="text/css">.ie.ie6 .module.ad-pushdown{ padding:0px !important }</style>');
			}
			
		break;
		
		case 'currentLoc':
			if(currentLoc=='washingtonpost.com' && what=='flex_ss_bb_hp' && location.href.match('reload=true')){
				hackReturnValue+='/hpflexrefresh';
			}
		break;
		
	}
	return hackReturnValue
}

//sponsored advertiser links
if(!urlCheck('no_ads')){
document.write('<s\cript src="http://media.washingtonpost.com/wp-srv/ad/textlink_driver.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>');
}




