wpniSite='doublex'
wpniDomain='doublex.com'
show_doubleclick_ad = true
rssString = "from=rss"
hourScope = 5;
numPop = 2;
tileThatGetsDcopt = 1;

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() + articleId() 

wpniAds.templates.initRule('defaultTemplate');

//9818-CS,rev-10132-PW,rev-AL-10055
wpniAds.templates.rules.defaultTemplate.what = new Array('!tiffanytile');


 switch(what)
 {
	 
  case 'leaderboard':
   thisAdType.size = "728x90"
   thisAdType.code = "ad=lb;"
  break
  
  case 'midarticleflex':
  thisAdType.size = "446x33,300x250"
   thisAdType.code = "ad=fb;ad=bb;"
  break

  case 'tiffanytile':
   thisAdType.size = "336x90"
   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 'rightflex':
   thisAdType.size = "160x600,300x250,336x850";
   thisAdType.code = "ad=ss;ad=bb;ad=hp;";
  break

  case '336x90':
   thisAdType.size = "336x90"
   thisAdType.code = "ad=336x90;"
  break  
  
  case '120x90':
   thisAdType.size = "120x90"
   thisAdType.code = "ad=120x90;"
  break 

   
   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





//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 comeback(){
    return (urlCheck(/your.*?comeback/gi))?'ad=comeback;':'';
}

function hackBin(_arg,currentLoc,what,delivery,onTheFly)
{
	var hackReturnValue=eval(_arg)
	switch(_arg)
	{
		case 'onTheFly':
			if(what.match('leaderboard'))
			{
				hackReturnValue += '!c=intrusive;';
			}
			if(urlCheck('thedesirelab'))
			{
				hackReturnValue += 'cont=desirelab;';	
			}
			hackReturnValue += comeback();
		break;
	}
	return hackReturnValue
}

//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
}

