wpniSite='slate'
wpniDomain='slate.com'
show_doubleclick_ad = true
rssString = "from=rss"
hourScope = 5;
numPop = 2;
tileThatGetsDcopt = 3;

wpniAds.templates.initRule('defaultTemplate');
wpniAds.templates.rules.defaultTemplate.what = new Array('!120x60','!88x31','!120x90');

wpniAds.templates.initRule('homepage');
wpniAds.templates.rules.homepage.what = new Array('120x90')
wpniAds.templates.rules.homepage.where = new Array('homepage');
wpniAds.templates.rules.homepage.when= new Array('');

//5055-GL
wpniAds.templates.initRule('apple');
wpniAds.templates.rules.apple.what = new Array('!tiffanytile')
wpniAds.templates.rules.apple.where = new Array('homepage');
wpniAds.templates.rules.apple.when = new Array('200806160000/200806162359');



function funcPStax()
{
	return (typeof PStax != 'undefined') ? 'dept=' + PStax + ';' : '' ;
}

function initAdType(what)
{
 var thisAdType = new AdInstance()
 thisAdType.testFlagArray = new Array('test_ads','test_' + what); 
 thisAdType.debugFlagArray = new Array('debugAdCode','debug' + what);
 
 thisAdType.dcCode += msnCobrand()  + funcPStax()  + frayId() + articleId() 
 
 switch(what)
 {
  case 'toolbar':
   thisAdType.size = "120x60"
   thisAdType.code = "ad=120x60;"
  break
  
  case 'leaderboard':
   thisAdType.size = "728x90"
   thisAdType.code = "ad=lb;"
  break
  
  case 'bigbox':
   thisAdType.size = "300x250"
   thisAdType.code = "ad=bb;"
  break
  case '150x29':
   thisAdType.size = "150x29"
   thisAdType.code = "ad=150x29;"
  break
  
  case '120x240top':
   thisAdType.size = "120x240"
   thisAdType.code = "ad=120x240;"
  break
  
  case '120x240bottom':
   thisAdType.size = "120x240"
   thisAdType.code = "ad=120x240;"
  break
  
  case 'skyscraper':
   thisAdType.size = "160x600"
   thisAdType.code = "ad=ss;"
  break
  
  case 'featurebar':
   thisAdType.size = "446x33"
   thisAdType.code = "ad=fb;"
  break
  
  case 'midarticleflex':
  thisAdType.size = "446x33,300x250"
   thisAdType.code = "ad=fb;ad=bb;"
  break
  case '1x1':
   thisAdType.size = "1x1"
   thisAdType.code = "ad=onebyone;"
  break
  
  case 'tiffanytile':
   thisAdType.size = "264x120"
   thisAdType.code = "ad=tiff;"
   /*if('1|3|5|6'.match(thisDate().getDay()))
   {
	   
	   thisAdType.adExecute = function ()
	   {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="264" height="120" id="SweetSpot" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://www.washingtonpost.com/wp-adv/slate/SweetSpot.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" />	<embed src="http://www.washingtonpost.com/wp-adv/slate/SweetSpot.swf" quality="high" bgcolor="#000000" width="264" height="120" name="SweetSpot" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>')
	   }
   }*/
  break
  
  case '120x60':
   thisAdType.size = "120x60"
   thisAdType.code = "ad=120x60;"
  break
  
  case '88x31':
   thisAdType.size = "88x31"
   thisAdType.code = "ad=88x31;"
  break
  
  case '120x90':
   thisAdType.size = "120x90";
   thisAdType.code = "ad=120x90;";

  break
  
  case 'rightflex':
   thisAdType.size = "160x600,336x850,300x250"
   thisAdType.code = "ad=ss;ad=hp;ad=bb;"
  break  
  
  case 'video':
   thisAdType.adServer = 'http://ad.doubleclick.net/pfadx/'
   thisAdType.code = "ad=video"
   thisAdType.adExecute = function (currentLoc,varDcCount,what,delivery)
   {
    if(typeof config == 'undefined')
    {
     config = new Array();
    }
    config['adServerURL'] = this.adServer + currentLoc + ";" + this.code + ";" + thisAdType.testAction(thisAdType.testFlagArray) + ";";
    config['additionalAdTargetingParams'] = ';' + this.dcCode
    
    for(var x in this.debugFlagArray)
    {
     if (location.href.match(this.debugFlagArray[x]))
     {
      this.debugAction()
     }
    }
   }
   
   thisAdType.debugAction = function()
   {
    var output = "config['adServerURL']:" + config['adServerURL'] + "\n\r"
    output += "config['additionalAdTargetingParams']:" + config['additionalAdTargetingParams'] + "\n\r"  
   }
  break
 }
  
return thisAdType
}
//this translates from the old placeAd to the new one




function placeAd()
{
 //slate currentLoc syntax is site.zone/site so we reduce it to zone/site here
 var currentLoc=arguments[1].split('.')[1]
 var spot = arguments[0] 
 var onTheFly=''
 var transArray = new Array('','leaderboard','bigbox','120x240top','skyscraper','featurebar','120x240bottom','1x1','120x60','tiffanytile','','rightflex','rightflex','toolbar')

 //if (spot==11 || spot==12) {flexVal=true};

 placeAd2(currentLoc,transArray[spot],false,onTheFly)
}
//detects msn cobranding status--once a page
function msnCobrand()
{
 if (typeof this.msnReturnValue == 'undefined')
 {
  this.msnReturnValue='msn_refer=n;'
  if (typeof msn_cobrand != "undefined")
  {
   if (msn_cobrand != 0)
   {
    this.msnReturnValue='msn_refer=y;';
   }
  }
 }
 
 return this.msnReturnValue
}
//this is to for targeting ads to specific pages on fray==returns frayId
function frayId()
{
 //if fray is in the query string and id= has a query string value, return id=value
 returnValue =  (location.href.match('fray') && getQSValue('id')!='')?"frayId="+getQSValue('id')+";":"" 
 //this is a hack
 returnValue += (document.getElementById && document.getElementById( 'threadname' ) && getQSValue( 'tp',document.getElementById( 'threadname' ).getAttribute( 'href' ) ) == 'fixfray' )?"kw=cisco_landing;":""
 return returnValue
}

//this is for passing the unique number that corresponds to slate articles. It is either a number
//between slashes in the URL, or after id=.
function articleId()
{
	if(typeof this.aIdReturnValue != 'undefined')
	{
		return this.aIdReturnValue;
	}
	
	if(typeof s != 'undefined' && typeof s.prop12 != 'undefined')
	{
		this.aIdReturnValue = 'articleId=' + s.prop12 + ';';
		return this.aIdReturnValue;
	}
	
	this.aIdReturnValue = 'articleId=www.slate.com;';	
	var urlString = location.href;
	
	var idRegExp = RegExp('id=[0-9]{4,}','g');
	var slashRegExp = RegExp('/[0-9]{4,}[/\?]','g');
	var idMatchArray = urlString.match(idRegExp);
	var slashMatchArray = urlString.match(slashRegExp);
	if(idMatchArray)
	{
		this.aIdReturnValue = 'articleId='+idMatchArray[0].substring(3,idMatchArray[0].length)+';'
		return this.aIdReturnValue;
	}
	if(slashMatchArray)
	{
		var idIndex = 0;
		if(slashMatchArray.length > 1)
		{
			idIndex = 1;
		}
		this.aIdReturnValue = 'articleId='+slashMatchArray[idIndex].substring(1,slashMatchArray[0].length-1)+';'
		return this.aIdReturnValue;
	}
	return this.aIdReturnValue;
}

//override generic pageId function--make it the same as articleId


function front()
{
	if(typeof this.frontReturnValue != 'undefined')
	{
		return this.frontReturnValue;
	}


	this.frontReturnValue = 'front=' + ((location.href.match('/view/') || location.href.split('?')[0].match(/http:\/\/www.slate.com\/*$/gi))?'y':'n') + ";"
	return this.frontReturnValue
}

function hackBin(_arg,currentLoc,what,delivery,onTheFly)
{
	var hackReturnValue=eval(_arg)
	switch(_arg)
	{
		case 'currentLoc':
		    
			hackReturnValue += ( what == 'leaderboard' || what == 'rightflex' || what == 'midarticleflex' ) ? ('/' + what) : '';
			
			if(what == 'rightflex' && currentLoc == 'homepage')
			{	
				hackReturnValue += '/hp';
				hackReturnValue += ( location.href.match('reload=true') ) ? 'refresh' : '';
			}
			
		break;
		
		/*case 'flex':
			hackReturnValue = false;
		break;*/
	}
	return hackReturnValue
}

