wpniDomain = 'washingtonpost.com';

// BEGIN import rev. science segments
if (document.domain != '')
{	
	document.write('<s\cript type="text/javascript" src="http://js.revsci.net/gateway/gw.js?csid=J05531"></s\cript>');
}
// END import rev. science segments




//hack for JF ads
	
	if (location.href.indexOf('politicalads') != -1) {thisNode = 'politics'; commercialNode='politics'}
	
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 in geo_area_id_array)
    			{
    				if(typeof geo_area_id_array[x] == 'string')
					{
						this.returnREAIValue += 'areaId=' + geo_area_id_array[x] + ';'
					}
    			}
    		}
    	}
    	return this.returnREAIValue
    }

function popUnders()
{
	//these two variables control everything	
	maxPer24 = 5;
	minutesBetween = 2;
	//end
	minuteInMillis = 60000;
	dayInMillis = 86400000;
	rightNow = new Date();
	rightNowNum = parseInt(rightNow.getTime());
	rightNowPlusDay = rightNowNum + dayInMillis;
	rightNowPlusYear = rightNowNum + (dayInMillis * 365);
	rightNowPlusDayString = new Date(rightNowPlusDay);
	rightNowPlusYearString = new Date(rightNowPlusYear);
	popUnderRetValue = ''
		
	if (getCookie('popUnderAds'))
	{	
		cookieString=getCookie('popUnderAds');
		
		cookieArray=cookieString.split('/');

		newCookieArray = new Array();
		newCookieArrayIndex = 0;	
		
		for(var x=1;x<cookieArray.length+1;x++)
		{	var z = parseInt(rightNowNum) - parseInt(cookieArray[x]);
			if(z < dayInMillis)
			{	
				newCookieArray[newCookieArrayIndex] = cookieArray[x];
				newCookieArrayIndex++;
				testOutputDate = new Date(parseInt(cookieArray[x]));
			}
		}
		
		
		var underDailyLimit = newCookieArray.length < maxPer24;
		var enufTimeSinceLast = rightNowNum - parseInt(newCookieArray[newCookieArray.length-1]) > (minutesBetween * minuteInMillis);
		var noPopOnLastPage=cookieString.match('popOnLast=false/');
		newCookieString = "popOnLast=false/";
		
		if((underDailyLimit && noPopOnLastPage && enufTimeSinceLast) || newCookieArray.length == 0)
		{
			popUnderRetValue = 'ad=pop';
			newCookieArray.push(rightNowNum);
			newCookieString = "popOnLast=true/";
		}
		else
		{
			
		}
	
		
		for(var x=0;x<newCookieArray.length;x++)
		{
			newCookieString += newCookieArray[x] + '/';
		}
		
		newCookieString = newCookieString.substring(0,newCookieString.length-1);
		setCookie('popUnderAds',''+newCookieString+'',''+rightNowPlusYearString.toString()+'','/','.washingtonpost.com','');

	}
	else
	{	
		//make sure you can write a cookie at all
		setCookie('popUnderAds','*',''+rightNowPlusYearString.toString()+'','/','.washingtonpost.com','');
		if(!getCookie('popUnderAds'))
		{
			return '';
		}
		//if so, proceed
		
		setCookie('popUnderAds','popOnLast=true/'+rightNowNum+'',''+rightNowPlusYearString.toString()+'','/','.washingtonpost.com','');
		popUnderRetValue='ad=pop;'
	}
	return popUnderRetValue;
}

function isAnyOfTheseInTheUrl()
{
	var returnValue = false;
		for(var x=0;x<arguments.length;x++)
		{
			if(location.href.match(arguments[x]))
			{
				returnValue = true;
			}
		}
	return returnValue
}

function interstitials()
{	
	if(typeof this.intReturnValue == 'undefined' && isAnyOfTheseInTheUrl('washingtonpost.com') && !isAnyOfTheseInTheUrl('no_interstitials'))
	{
		popUnderVal = (!isAnyOfTheseInTheUrl('g=1','o=','sid=','reload=true'))?popUnders():'';
		this.intReturnValue = "dcopt=ist;" + popUnderVal;
	}
	else
	{
			this.intReturnValue = ''
	}
	return this.intReturnValue;
}


function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

var debugAdCode = false;
var show_doubleclick_ad = true ;
if (document.domain == 'www.shoplocal.com') thisNode = 'shoplocal';
if (location.href.indexOf("debugAdCode")+1) debugAdCode = true ;
show_doubleclick_ad = (location.href.match("no_ads"))?false:true
if (typeof thisNode == 'undefined') thisNode = (typeof adNode != 'undefined')?adNode:'technology';
if (typeof commercialNode == 'undefined') commercialNode = (typeof thisNode != 'undefined')?thisNode:'technology';



var _rs  = ''; // revenue science data
var _poe = ''; // point of entry
var _tc = 'tile'; // tiling category
var _cn = ''; // commercial node
var _an = false; // ad node
var _t = '';
var urlLoc = new String(document.location.href);



(typeof thisNode != 'undefined')?_tn = thisNode:null;


blu = (typeof blu_name != 'undefined')?true:false;


if (typeof commercialNode != 'undefined' && commercialNode != '') {

_cn = 'cn=yes;pnode='+thisNode.split("/")[0]+';';
_an = true;


}
var static_wpatc = getWPATCookie();

// changed on first call to placeAd
var firstTimeCalled = true ;
var firstTimeCalledNew = true ;
var adUniqueNumber = '' ;
var newsAncestorAsString = new String("") ;

// changed on first call to placeAd or when assertive is true
var adAncestor = new String() ;
var adNode = new String() ;
var adSite = new String() ;
var adZone = new String() ;
var adSiteZone = new String() ;
var adDir = new String() ;
var adArgs = 0 ;

function tileNum()
{
	this.tnReturnValue = (typeof this.tnReturnValue != 'undefined')?this.tnReturnValue+1:1;
	return this.tnReturnValue
}

function revSci()
{
	if (typeof rsinetsegs != 'undefined' && typeof this.rsReturnValue == 'undefined')
	{
		this.rsReturnValue = '';
		for(i=0;i<rsinetsegs.length;i++)
		{
			this.rsReturnValue += "rs="+rsinetsegs[i].replace("J05531_","j")+";"
		}
	}
	return this.rsReturnValue;
}

function placeAd(layer,node,kw,pos,dir,w,h,tile)
{

	// 'Date Lab' & 'Making It' article hacks
	if (typeof wp_headline != 'undefined' && wp_headline == 'Making It'){ node = 'smallbiz/makingit' }
	if (typeof wp_headline != 'undefined' && wp_headline.match('Date Lab')){ node = 'artsandliving/datelab' }


    node+=(node=='washingtonpost.com')? ( '/hp' + ( ( location.href.match('reload=true') )? 'refresh' : '') ) :'';


		
	if (show_doubleclick_ad)
	{
	
		if (thisNode == 'opinion/columns/politics/feddiary') {node = 'opinion/politics/feddiary'}
	


		heavy="heavy=n;"

		if (typeof document.referrer != "undefined")
		{
			if (document.referrer == '') 
			{	
				heavy="heavy=y;"
				setCookie('heavy','y',''+wpniPOE.toString()+'','/','.washingtonpost.com','')
			}
		else
			{
				heavy="heavy=y;"
				setCookie('heavy','y',''+wpniPOE.toString()+'','/','.washingtonpost.com','')
			}
		}

		// This is a temporary hack for Fantasy Jobs ( Chris Stith: added 7/20/2006 ) 
		agent = navigator.userAgent.toLowerCase();
		if ((agent.indexOf('firefox') != -1 || agent.indexOf('safari') != -1) && node == 'sports/fantasyjob' && kw == 4)
		{ document.write('<div style="position:absolute;top:353;padding-left:45;">')}

			if (typeof spec_ord != 'undefined')
			{
			adUniqueNumber = spec_ord+'?'
			}
			else {
		    var axel = Math.random()+"";
		    var ord = Math.floor(axel * 1000000000000000000);
    		adUniqueNumber = ord+'?' ;
    		}
			
  		if (node.indexOf("/") == -1) node += "/" ;
		var na = [arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]] ;
    	adArgs = 5 ;
    	platform = na[0] ;
    	//if (_an) {node = cleanNode(commercialNode)}
		//else node = cleanNode(na[1]) ;
		node = cleanNode(na[1]) ;
	
		if (location.href.indexOf('http://www.uclick.com/client/wpc/wpdoc/') != -1)
		{
			node = 'artsandliving/crosswords/sudoku'
		}


		if (node.indexOf("media") >= 0 || node.indexOf("gallery") >= 0) node = 'photo';

		//temp fix for email-friend problem
		if (node == '') node = 'technology';
		//temp fix for contentconversion
		if (node == 'contentconversion') node = 'nation';
		//temp fix for uncategorized
		if (node == 'uncategorized') node = 'technology';
		if (node == 'high schools') node = 'technology';
		if (node == 'wizards') node = 'technology';
		if (node == 'search/newssearch' && location.href.match("adv")) node = 'search/newsadvanced';

		tile = na[2] ;
		kw = na[3];
		flexdisplay = na[4] ;
	
		pos = setPosition(tile);
		//turned off for multiple size switch 6/18/07
		//w = setWidth(tile); h = setHeight(tile); f = setFlexvalue(tile);

		// Fantasy Football one-off for Nissan
		oo_url = document.location.href;
		if (oo_url.indexOf("LI2005042101450") != -1) kw= 'kw=cruise;'; 
		if (oo_url.indexOf("DI2005083101900") != -1) kw= 'kw=redskins;'; 
		if (oo_url.indexOf("test_ads") != -1) kw += 'kw=wpni_test;';
		if (oo_url.indexOf("smallbusiness101") != -1) kw = 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005100501552") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005100500899") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005110101296") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005102001378") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005103101365") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005102602804") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("DI2005101100729") != -1) kw= 'kw=smallbus101;';
		if (oo_url.indexOf("welcome_to_post.html") != -1) kw = 'kw=remix;';
		if (oo_url.indexOf("GA2006021301885_metaRefresher.htm") != -1) kw = 'kw=olympics;'
		if (oo_url.indexOf("/wp-srv/sports/interactives/olympics06/") != -1) kw = 'kw=olympics;'
		if (oo_url.indexOf("AR2005040701359") != -1) kw = 'kw=montgomery;';
		if (oo_url.indexOf("cherryblossom/06/") != -1) kw = 'kw=cherryblossom;';
		if (oo_url.indexOf("onbalance") != -1) kw = 'kw=onbalance;';
		if (tile == 10){kw = 'kw=shermans;';};
	
		if (kw.indexOf(';') == -1)
		{
			kw = kw + ';'
		}	
	
    	if ( firstTimeCalledNew )
		{
	  		adAncestor = getAdAncestor(node) ;
		 	adSite = getAdSite(adAncestor) ;
		  	adNode = getAdNode(node,adAncestor) ;
			adZone = getAdZone(adNode) ;
	  		adDir = getAdDir(node) ;
	  		firstTimeCalledNew = true;

			if (adZone)
	  			adSiteZone = adSite + "/" + adZone ;
			else
	  			adSiteZone = adSite ;
	  	}


		//this is where the old interstitial routine went--is backed up in oldinterstitial.js
	
		//turned off for multiple size swith 6/18/07
		//(flexdisplay)?adSize = "":adSize = 'sz='+w+'x'+h+';';

		passArticle = (platform.toLowerCase().indexOf("article") != -1)?'article':'';
		page_a = (passArticle.indexOf("article") != -1)?'page=article;':'page=section;';
		if (passArticle != 'article' ) page_a = 'page=section;front=y;'
		//&& commercialNode.split("/").length == 1
		if (typeof v2 != 'undefined')
		{
			if ( typeof adTemplate != 'undefined' && (( adTemplate & BANNER_FLEX_TOP ) == BANNER_FLEX_TOP && ( adTemplate & BIG_FLEX_RIGHT ) == BIG_FLEX_RIGHT) ) _t = (tile == 1)?'t=y;':'';
		}
	
		//var keyvalues = adSiteZone+";"+static_wpatc+inter_value+adDir+kw+"pos="+pos+";"+adSize+setFlexvalue(tile)+_cn+_tc+"="+tile+";ord="+adUniqueNumber ;
	
		dtile = (typeof dfpcomp == 'undefined')?'':"dfpcomp="+dfpcomp+";";


		var exempt = "";
		if (thisNode == 'nation' || thisNode.indexOf("nation/special") != -1)
		{
			exempt = "!category=supremecourt;";
		}
		if (tile == 20 && location.href.match('/article/'))
		{
			exempt += "!c=intrusive;";
		}
	
		var fedpage = new Array('opinion/columns/politics/feddiary','opinion/columns/politics/kamena','opinion/columns/politics/sarasohnj','opinion/columns/politics/lanec','opinion/columns/politics/offcamera','politics/congress')

		for (i=0; i<fedpage.length; i++)
		{
			if (thisNode == fedpage[i])
			{
				exempt = 'dir=fedpage;'
			}
		}

		// wpid TEST!
		if(typeof(wpidTestCheck) == 'undefined')
		{
			var url = document.location.href.split('?')[0];
			url = url.toLowerCase()
			var urlarray = url.split('/');
			var tail = urlarray[urlarray.length -1];
			if (tail.indexOf('nav=') != -1)
			{
				tail = tail.substring(0,tail.indexOf('nav='));
			}
			var illegals = ['test_ads','debugAdCode','?test_ads','?debugadcode','wpidtest','?template_test','?','=','/','\\',':',';',',','*','(',')','&','$','%','@','!','^','+',' ','[',']','{','}','.html','.htm','.',];
			for (i=0;i<illegals.length;i++)
			{
				sRE = new RegExp('(\\' + illegals[i] + ')', 'g');
				tail = tail.replace(sRE,"");
			}
			if (tail == 'index' || tail == '')
			{
				tail = urlarray[urlarray.length -2];
			}
			var nodedump = thisNode.split('/');
			var wpidnode = '';
			for (i=0;i < nodedump.length;i++)
			{
				wpidnode += nodedump[i];
			}
			wpid = 'wpid='+wpidnode+'_'+tail;
			if (wpid.length > 55)
			{
				wpid = wpid.substring(0,55);
			}
			if (url.indexOf('?wpidtest') != -1)
			{
				prompt('wpid',wpid);
			}
			wpidTestCheck = 1;
	
			if(typeof wpid == 'undefined')
			{
				wpid=''
			}
			
			
			//small biz hack
			sba = new Array('jobs_inside-job','liveonlinespecialsjobs_di2006102000737','liveonlinejobsslayterm_talk_di2006100900744','liveonlinespecialsjobs_di2006102000740','liveonlinespecialsjobs_di2006102000739','liveonlinespecialsjobs_di2006102000738','opinioncolumnsbusinessslayterm_ar2006101400332','jobs_ar2006102001235','jobs_success-stories','liveonline_smallbusiness101','liveonline_di2005110101296','liveonlinespecialsjobs_di2006022700702','liveonline_di2005101100729','liveonline_di2005100500899','liveonline_di2005103101365','liveonline_di2005100501552','liveonline_di2005110101296','liveonlinejobsslayterm_talk_di2005111601352','liveonline_di2005102001378','technologywashtech_ar2005112000918','opinioncolumnsbusinessslayterm_ar2005102900440','jobscareernews_ar2005111101484','jobscareernews_ar2005101401501','jobscareernews_ar2005101401472','jobs_ar2005100501786','jobscareernews_ar2005101000794');
			var sbatest=wpidnode+'_'+tail;
			for(i in sba)
			{
				if(sbatest == sba[i]){wpid+=';kw=smallbiz';}
			}
			//end small biz hack
		}
		//end wpid
		grp = '';
		if (location.href.indexOf('financial') != -1) {grp = "grp=financial;"}

		/*if(commercialNode=='washingtonpost.com' && tile==20)
		{	
			tile = 15;
			pos = 'ad15';
		}*/

		if(tile==99)
		{
			config['adServerURL'] =  "http://ad.doubleclick.net/pfadx/wpni." + node + ";";
			config['additionalAdTargetingParams'] =  ";" + static_wpatc +  heavy + 'ad=video;' + grp + kw +  _rs + poe + ";";
	
			if(location.href.match('debugAdCode'))
			{
				var output = "config['adServerURL']:" + config['adServerURL'] + "\n\r";
				output += "config['additionalAdTargetingParams']:" + config['additionalAdTargetingParams'] + "\n\r";
				alert(output);
			}  
		}
		
			if(wpid == 'wpid=politics_politics' && tile == 6 && now < '03292359')
			{
				adSiteZone = 'wpni.politics/bigbox'
			}
		
		function setPos(argTile)
		{
			if(argTile=='16' || argTile=='6' || argTile=='5')
			{
				return "pos=ad5;"
			}
			return "pos=ad" + tile + ";";
		}
		var thisTileVal = tileNum()
		
		if(tile == 20 && location.href.match('/article/'))
		{
			adSiteZoneArray = adSiteZone.split('/');
			adSiteZone = '';
			for(var a = 0; a< adSiteZoneArray.length;a++)
			{
				adSiteZone += adSiteZoneArray[a] + '/';
				if(a==0) adSiteZone += 'inlinead/';
			}
			adSiteZone = adSiteZone.substring(0,adSiteZone.length-1)
		}
		var keyvalues = adSiteZone + ";" + static_wpatc +  adDir + heavy + interstitials() + realEstateAreaId() +  grp + kw + setPos(tile) + dtile + setFlexvalue(tile) + _t + ((typeof revSci() != 'undefined')?revSci():'') + _rs + poe + page_a + _cn + _tc + "=" + thisTileVal + ";"+wpid+ ";"+exempt+"ord=" + adUniqueNumber ;
	
		// end if (show_doubleclick_ad)

		// adSiteZone = wpni.site (if article is first param them site has aritlce appended to it.
		// static_wpatc = registration data
		// inter_value = interstitial value;
		// adDir = key values for the node
		// pos = ad position #.
		// adSize = size of ad;
		// f = flex display value;
		// _rs = revenue science values
		// _cn = commercial node;
		// _tc = tile category (tile v. ptile)
		// adUniqueNumber = random number	
		var adCode = "" ;
		if(tile == 20 && location.href.match('/article/'))
		{
			
			adCode += ('<iframe width="336" height="280" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://ad.doubleclick.net/adi/'+keyvalues+'">');
			adCode += ('</iframe>');

		}
		else
		{
			adCode += ('<script language="JavaScript1.1" src="http://ad.doubleclick.net/adj/'+keyvalues+'">');
			adCode += ('</script>');
			
		}
		if ( (typeof ceTag != 'undefined') && (ceTag) ) adCode = '';
		if (debugAdCode) {  adCode += debugTextArea(adCode); }
		
	
		if(tile!=99)
		{
			if (tile == 24)
			{ 
				document.writeln ('<div align="left" style="padding:6px 0px 4px 0px"><img src="http://media3.washingtonpost.com/wp-srv/hp/img/ad_label_leftjust.gif" alt="ad_icon" width="100" height="13" border="0"/></div>' );  
			}
			if (tile == 7 && thisNode == "artsandliving/cityguide")
			{
				document.write('<img src="http://media.washingtonpost.com/wp-srv/hp/img/ad_label_vertical_small.jpg" border="0" width="14" height="33">');
			}
			else if(tile == 7 && thisNode != "business" && (location.href.indexOf('?test_ads') != -1))
			//else if(tile == 7 || tile == 24) // Turn on ad label for tile 24 ('save and share box')
		  	{	
				document.write('<div style="padding-top:10px"><img src="http://media.washingtonpost.com/wp-srv/hp/img/ad_label_leftjust.gif" border="0" width="100" height="13" valign="top"></div>');
		  	}
			if (document.domain == 'washingtonpost.homescape.com' || document.domain == 'washingtonpost.homehunter.com')
			{
				if (typeof sponsor != 'undefined' && sponsor)
				{
					if (tile != 5) document.write(adCode);
				}
				else document.write(adCode);
			}
			else document.write(adCode.toString());
		}
		

	}// end of show_doubleclick_ad test
	
	firstTimeCalled = false ;
} //end of placeAd





function setPosition(tile)
{
  var p = "ad"+tile ;
  // document.write(p) ;
  if (tile == 4 || tile == 5 || tile == 6) var p = "ad6";
  return p ;
}

function setWidth(tile)
{
  var wi ;
  if ( tile >= 1 && tile <= 1) { wi = "728"; } // top leaderboard
  else if ( tile >= 2 && tile <= 2 ) { wi = "728"; } // bottom leaderboard
  else if ( tile >= 3 && tile <= 3 ) { wi = "160"; } // skyscraper left only
  else if ( tile >= 4 && tile <= 4 ) { wi = "160"; } // skyscraper only
  else if ( tile >= 5 && tile <= 5 ) { wi = "300"; } // big box and skyscraper
  else if ( tile >= 6 && tile <= 6 ) { wi = "336"; } // skyscraper, big box and half page
  else if ( tile >= 7 && tile <= 7 ) { wi = "446"; } // feature bar
  else if ( tile >= 8 && tile <= 8 ) { wi = "336"; } // travel tile
  else if ( tile >= 9 && tile <= 9 ) { wi = "479"; } // rss tile
  else if ( tile >= 10 && tile <= 10 ) { wi = "336"; } // travel tile right
  else if ( tile >= 11 && tile <= 11 ) { wi = "120"; } // 120x60 tile
  else if ( tile >= 12 && tile <= 12 ) { wi = "260"; } // 260X30 tile
  else if ( tile >= 13 && tile <= 13 ) { wi = "300"; } // 300x190 tile
  else if ( tile >= 14 && tile <= 14 ) { wi = "300"; } // 300x45 tile
  else if ( tile >= 15 && tile <= 15 ) { wi = "120"; } // 120x240 tile
  else if ( tile >= 16 && tile <= 16 ) { wi = "336"; } // 120x240 tile
  else if ( tile >= 17 && tile <= 17 ) { wi = "88"; } // 88x31
  else if ( tile >= 18 && tile <= 18 ) { wi = "180"; } // 180x20
  else if ( tile >= 19 && tile <= 19 ) { wi = "336"; } // 336x35
  else if ( tile == 20 ) { wi = "300"; } // big box 
	else if ( tile >= 22 && tile <= 22 ) { wi = "110"; } // 110x90 tile
	else if ( tile >= 23 && tile <= 23 ) { wi = "446"; } // 446x45 blog feature bar
	else if ( tile >= 24 && tile <= 24 ) { wi = "208"; } // 208x40
	else if ( tile >= 25 && tile <= 25 ) { wi = "314"; } // 314x57
	else if ( tile >= 26 && tile <= 26 ) { wi = "336"; } // 336x60
	else if ( tile >= 27 && tile <= 27 ) { wi = "120"; } // 120x30
	else if ( tile >= 28 && tile <= 28 ) { wi = "180"; } // 180x31
	
    //99 is for brightcove

/*TM 06/20/06 this hack recreates old tile 12 left sky for real estate area maps. if the url
contains areaId, which is the variable the RE maps use, then tile 12 is a sky*/
if (tile == 12 && location.href.indexOf('areaId') != -1) {wi="160"}

  // document.write(wi) ;
  return wi ;
}

function setHeight(tile)
{
  var he ;
  if ( tile >= 1 && tile <= 1) { he = "90"; } // top leaderboard
  else if ( tile >= 2 && tile <= 2 ) { he = "90"; } // bottom leaderboard
  else if ( tile >= 3 && tile <= 3 ) { he = "600"; } // skyscraper left only
  else if ( tile >= 4 && tile <= 4 ) { he = "600"; } // skyscraper only
  else if ( tile >= 5 && tile <= 5 ) { he = "250"; } // big box and skyscraper
  else if ( tile >= 6 && tile <= 6 ) { he = "850"; } // skyscraper, big box and half page
  else if ( tile >= 7 && tile <= 7 ) { he = "33"; } // feature bar
  else if ( tile >= 8 && tile <= 8 ) { he = "45"; } // travel tile
  else if ( tile >= 9 && tile <= 9 ) { he = "40"; } // rss tile
  else if ( tile >= 10 && tile <= 10 ) { he = "45"; } // travel tile right
  else if ( tile >= 11 && tile <= 11 ) { he = "60"; } // 120x60
  else if ( tile >= 12 && tile <= 12 ) { he = "30"; } // 260X30
  else if ( tile >= 13 && tile <= 13 ) { he = "190"; } // 300x190
  else if ( tile >= 14 && tile <= 14 ) { he = "45"; } // 300x45
  else if ( tile >= 15 && tile <= 15 ) { he = "240"; } // 120x240
  else if ( tile >= 16 && tile <= 16 ) { he = "850"; } // 120x240
  else if ( tile >= 17 && tile <= 17 ) { he = "31"; } // 88x31
  else if ( tile >= 18 && tile <= 18 ) { he = "20"; } // 180x20
  else if ( tile >= 19 && tile <= 19 ) { he = "35"; } // 336x35
	else if ( tile == 20 ) { he = "250"; } // big box 
	else if ( tile >= 22 && tile <= 22 ) { he = "90"; } // 110x90 tile
	else if ( tile >= 23 && tile <= 23 ) { he = "45"; } // 446x45 blog feature bar
	else if ( tile >= 24 && tile <= 24 ) { he = "40"; } // 208x40
	else if ( tile >= 25 && tile <= 25 ) { he = "57"; }
	else if ( tile >= 26 && tile <= 26 ) { he = "60"; } // 336x60
	else if ( tile >= 27 && tile <= 27 ) { he = "30"; } // 120x30
	else if ( tile >= 28 && tile <= 28 ) { he = "31"; } // 180x31
	
	//99 is for brightcove
	
/*TM 06/20/06 see above*/
if (tile == 12 && location.href.indexOf('areaId') != -1) {he="600"}
  // document.write(he) ;
  
  return he ;
}

function setFlexvalue(tile) {
  var fv ;
  if ( tile >= 1 && tile <= 2) { fv = "ad=lb;sz=728x90;"; } // top leaderboard
  else if ( tile >= 2 && tile <= 2 ) { fv = "ad=lb;sz=728x90;"; } // bottom leaderboard
  else if ( tile >= 3 && tile <= 3 ) { fv = "ad=ss;sz=160x600;"; } // skyscraper left only
  else if ( tile >= 4 && tile <= 4 ) { fv = "ad=ss;sz=160x600;"; } // skyscraper only
  else if ( tile >= 5 && tile <= 5 ) { fv = "ad=ss;ad=bb;sz=160x600,300x250;"; } // big box and skyscraper
  else if ( tile >= 6 && tile <= 6 ) { fv = "ad=ss;ad=bb;ad=hp;sz=160x600,300x250,336x850;"; } // half page
  else if ( tile >= 7 && tile <= 7 ) { fv = "ad=fb;sz=446x33;"; } // feature bar
  else if ( tile >= 8 && tile <= 8 ) { fv = "ad=tt;sz=336x45;"; } // travel tile
  else if ( tile >= 9 && tile <= 9 ) { fv = "ad=rss;sz=479x40;"; } // rss tile
  else if ( tile >= 10 && tile <= 10) { fv = "ad=tt;sz=336x45;"; } // travel tile right
  else if ( tile >= 11 && tile <= 11) { fv = "ad=tl;sz=120x60;"; } // 120x60
  else if ( tile >= 12 && tile <= 12) { fv = "ad=260x30;sz=260x30;"; } // 260X30
  else if ( tile >= 13 && tile <= 13) { fv = "ad=re300;sz=300x190;"; } // 300x190
  else if ( tile >= 14 && tile <= 14) { fv = "ad=tif;sz=300x45;"; } // 300x45
  else if ( tile >= 15 && tile <= 15) { fv = "ad=vb;sz=120x240;"; } // 120x240
  else if ( tile >= 16 && tile <= 16) { fv = "ad=bb;ad=hp;sz=300x250,336x850;"; } // 120x240
  else if ( tile >= 17 && tile <= 17 ) { fv = "ad=88x31;sz=88x31;";} // 88x31
  else if ( tile >= 18 && tile <= 18 ) { fv = "ad=180x20;sz=180x20;"; } // 180x20
  else if ( tile >= 19 && tile <= 19 ) { fv = "ad=336x35;sz=336x35;";} // 336x35
  else if ( tile >= 20 && tile <= 20 ) { fv = "ad=bb;sz=300x250;";} // 300x250
  else if ( tile >= 22 && tile <= 22 ) { fv = "ad=110x90;sz=110x90;"; } // 110x90 tile
  else if ( tile >= 23 && tile <= 23) { fv = "ad=blog;sz=446x45;"; } // 446x45 blog feature bar
  else if ( tile >= 24 && tile <= 24) { fv = "ad=208x40;sz=208x40;"; } // 446x45 blog feature bar
  else if ( tile >= 25 && tile <= 25) { fv = "ad=314x57;sz=314x57;"; } // 314x57 
  else if ( tile >= 26 && tile <= 26) { fv = "ad=336x60;sz=336x60;"; } // 336x60
  else if ( tile >= 27 && tile <= 27) { fv = "ad=120x30;sz=120x30;"; } // 120x30
  else if ( tile >= 28 && tile <= 28) { fv = "ad=toolbox_tile;sz=180x31;"; } // 180x31
  //99 is for brightcove

/*TM see above*/
if (tile >= 12 && tile <= 12 && location.href.indexOf('areaId') != -1) {fv="ad=ss120;sz=160x600;"}

return fv ;

}


function mkKeyword(myKeyword,myNode)
{
  if (myKeyword == "" )
  {
    if (myNode.indexOf("/") != -1 )
    {
      nodeAry = myNode.split("/") ;
      myKeyword = nodeAry[1] ;
	}
  }
  return myKeyword ;
}






function debugTextArea(ac)
{
  var re = new RegExp("\"","g") ;
  ac = ac.replace(re,"\\\"") ;
  return '<form><textarea wrap=physical cols=\"+55+\" rows=\"+10+\">'+ac+'</textarea></form>';
}

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 ;
}



//Revenue Science Values
/*
function (name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}*/

var crumbs = (getCookie("DMSEG"))?"".concat(getCookie("DMSEG")).split("&"):"";
var segments = (crumbs[5])?crumbs[5]:"";
var seg = (segments)?segments.split(","):"";


// mimic revenue science value for rss users
// check to see if url has "rss" and set up a value
// that AMs can target to
// added 6/28/05 sja
function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function createTime() {
var cDate = new Date();
var cMil = cDate.getTime();
var e = cMil % (1000 * 60 * 60 * 24);
var r = (1000 * 60 * 60 * 24) - e;
var nr = 28 * 24 * 60 * 60 * 1000;
return(nr);
}

var wpniPOE = new Date();
var interval = 0;

var wpniWeek = wpniPOE.getTime() + createTime();
wpniPOE.setTime(wpniWeek);

if (urlLoc.indexOf('nav=rss') != -1)
{_rs+="fromrss=y;";
setCookie('rss_now','true',''+wpniPOE.toString()+'','/','.washingtonpost.com','');
setCookie('rss','true',''+wpniPOE.toString()+'','/','.washingtonpost.com','');
}
else
{_rs+="fromrss=n;";
setCookie('rss_now','false',''+wpniPOE.toString()+'','/','.washingtonpost.com','');
}

if (getCookie("rss") == 'true') {_rs += 'rss=y;'}
else _rs += 'rss=n;';

	

var poe = 'poe=no;';
if (getCookie("wp_poe") == null || getCookie("wp_poe") == "false") {
poe = 'poe=yes;';
setCookie("wp_poe","true","","/",".washingtonpost.com",'')
}

if (getCookie("wp_poe") == null && !(urlLoc.match("washingtonpost.com")))
{
	poe = 'poe=no;';
}

// end rss code
/**
 * crk added 17 July 2002
 * methods for 5 parameter placeAd call
 * placeAd(platform,node,tile,kw,assertive)
 **/

  // get ancestor from node
  function getAdAncestor(node)
  {
	var end = node.indexOf("/") ;
	if ( end == -1 )
	  return node ;
    else
	{
	  var adAncestor = node.substring(0,end) ;	
      return adAncestor ;
	}
  }

  // get adSite
  function getAdSite(ancestor)
  {
    if ( isNewsAncestor(ancestor) )
      return "wpni.news" ;
    else
      return "wpni."+ancestor ;
  }
  
  // get ad node
  function getAdNode(node,ancestor)
  {
    if ( isNewsAncestor(ancestor) )
	  return node ;
	else
	{
	  var start = node.indexOf("/")+1 ;
	  if (start)
        return node.substring(start) ;
	  else
	    return "" ;
	}
  }

  // get ad node
  function getAdZone(node)
  {
    var ary = new Array() ;
	if ( node.indexOf("/") != -1 )
	  ary = node.split("/") ;
	else
	  ary[0] = node ;

	if ( ary.length <= 2 )
	  return node ;
	else
	{
	  var zone = '' ;
	  for(var i=0; i<2; i++)
	  {
	    zone += ary[i] ;
		if (i==0) zone += "/" ;
	  }
	  return zone ;
	}
  }
  
  function getAdDir(node)
  {
    var page = "" ;
    var ary = new Array() ;
	if ( node.indexOf("/") != -1 )
	  ary = node.split("/") ;
	else
	  ary[0] = node ;

	var dir = '' ;
	for(var i=0; i<ary.length; i++)
	{
	  // parse out article string if present in ancestor
	  if ( i == 0 &&
	       ary[i].indexOf("article") != -1 &&
		   ary[i].indexOf("article") == ary[i].length - "article".length &&
		   ary[i] != "article" )
	  {
	    ary[i] = ary[i].substring(0,ary[i].indexOf("article")) ;
		page = "page=article;" ;
	  }
	  dir += "dir="+ary[i]+";" ;
	}
	return "dir="+ary[ary.length-1]+"node;"+dir+page ;
  }

  // check if adSite should be wpni.news
  function isNewsAncestor(ancestor)
  {
    if ( newsAncestorAsString != null &&
	     newsAncestorAsString != ""   &&
		 newsAncestorAsString.indexOf(","+ancestor+",") != -1
	   )
      return true  ;
    else
	  return false ;
  }
  
  function cleanNode(node)
  {
	if ( node.charAt(node.length-1) == "/" )
	  return node.substring(0,node.length-1) ;
	else
	  return node ;
  }
// begin: for inline article ad
function getInlineAdGraf(container_id,obstacle_id) {
	if ( document.getElementById(obstacle_id) && document.getElementById(container_id) ) {
		var obstacle = document.getElementById(obstacle_id);
		var bottom_of_obstacle = obstacle.offsetTop+obstacle.offsetHeight ;

		var container = document.getElementById(container_id);
		var bottom_of_container = container.offsetTop+container.offsetHeight ;

		var grafs = container.getElementsByTagName("p");
		for( var i=0; i<grafs.length; i++ ) {
			var graf = grafs[i] ;
			// if ( (graf.offsetTop > bottom_of_obstacle) && (bottom_of_container - bottom_of_obstacle > 200) ) {
			if ( graf.offsetTop > bottom_of_obstacle + document.getElementById("content_column_table").clientHeight + 200) {
				return graf ;
			}
		}
	}
	return false;
}
function move_the_inline_ad(parent,ad,sibling) {
	if ( parent && ad && sibling )
		parent.insertBefore( ad, sibling ) ;
}
// end: for inline article ad
