adOpsLocalFlag = (typeof adOpsLocalFlag == 'undefined')?false:adOpsLocalFlag;

function dateToString(date) {
var yyyy = date.getYear();
var mm = date.getMonth() + 1;
var dd = date.getDate();
var hour = date.getHours();
var min = date.getMinutes();

if (mm < 10) mm = "0"+mm;
if (dd < 10) dd = "0"+dd;
if (hour < 10) hour = "0"+hour;
if (min < 10) min = "0"+min;
return ''+mm+dd+hour+min;
}

function getDay(today) {return today.getDay()}
var today = new Date();
var now = dateToString(today);


var doTiffany = false;
var tiffWidth = '300';
var tiffHeight = '45';
var tiffOnTheFly = '';
var ord=Math.floor(Math.random()*10000000000);
var tiffDelivery = 'adi';
var broadNode = new Array('politics','business','opinion');
var classifieds = new Array('weather','cars','cityguide','jobs','cars','shopping');

var doTiffCheck = false;

//commented out by TM 5:35 6/17/08--why is this here?
if(!doTiffany && typeof commercialNode != 'undefined' && commercialNode)
{
	doTiffCheck = true;
}

function cnm(a)
{
	var nodes = a.split(';');
	for (var b = 0; b < nodes.length; b++)
	{
		
if(commercialNode.match(nodes[b])) return true;
	}
	return false;
}


//4313-HS-185127576
if(doTiffCheck && commercialNode.match(/^realestate/gi))
{
	tiffWidth = "300";
	tiffHeight = "45";
	doTiffany = true;
	tiffDelivery = "adi";
}


//4294-MW-196774514
if(doTiffCheck && ( typeof contentCategories != 'undefined' && contentCategories(commercialNode,'style') || commercialNode == 'artsandliving/style' ) )
{
	tiffWidth = "300";
	tiffHeight = "45";
	doTiffany = true;
	tiffDelivery = "adi";
}



//5433-ST-206022970 (rev#9 20080722)
if(doTiffCheck && commercialNode.match('washingtonpost.com') && ( (now >= '07220000' && now <= '08032359') || (now >= '08110000' && now <= '09072359') || (now >= '09150000' && now <= '09252359') || (now >= '12030000' && now <= '12312359') ) )
{
	tiffWidth = "290";
	tiffHeight = "60";
	doTiffany = true;
	tiffDelivery = "adi";
}



//5433-ST-205755850 (rev#9 20080722)
//PAUSED by ML 08/01
/*if(doTiffCheck && typeof contentCategories != 'undefined' && contentCategories(commercialNode,'execnews') && !commercialNode.match('washingtonpost.com') && (now >= '08010000' && now <= '12202359'))
{
	
	tiffWidth = "300";
	tiffHeight = "45";
	doTiffany = true;
	tiffDelivery = "adi";
}*/


//5424-MB-order id: 2996903
if(doTiffCheck && commercialNode.match('washingtonpost.com') && ((now >= '07150000' && now <= '07212359') || (now >= '08040000' && now <= '08102359') || (now >= '09080000' && now <= '09142359')) )
{
	tiffWidth = "234";
	tiffHeight = "60";
	doTiffany = true;
	tiffDelivery = "adi";
}


//6172-ST-207109597
if(adOpsLocalFlag && now < '09072359' && ( commercialNode.match('jobs') || commercialNode.match('cars') || commercialNode.match('rentals') || commercialNode.match('realestate') ) )
{
	tiffWidth = "300";
	tiffHeight = "45";
	doTiffany = true;
	tiffDelivery = "adi";
}

//6363-HS-207439456
if(adOpsLocalFlag && now < '09072359' && ( commercialNode.match('jobs') || commercialNode.match('cars') || commercialNode.match('rentals') || commercialNode.match('realestate') ) )
{
	tiffWidth = "300";
	tiffHeight = "45";
	doTiffany = true;
	tiffDelivery = "adi";
}

//6363-HS-207439393
if( commercialNode.match('washingtonpost.com') && ( now.substring(1,4)=='0907' ) )
{
	tiffWidth = "290";
	tiffHeight = "60";
	doTiffany = true;
	tiffDelivery = "adi";
}

//6363-HS-207439456
if( location.href.match('/article/') &&  now > '09090000' && now <  '09112359' )
{
	tiffWidth = "300";
	tiffHeight = "45";
	doTiffany = true;
	tiffDelivery = "adi";
}

//6268-GL-turn off all homepage tiff tiles
if(commercialNode.match('washingtonpost.com') && ((now >= '09100000' && now <= '09102359') || (now >= '09150000' && now <= '09152359')))
{
	doTiffany = false;
}


if(location.href.match("test_ads"))
{
	tiffOnTheFly = "kw=test_ads;";
}

//end of logic for flights

if(doTiffany && !location.href.match('no_ads'))
{
	
	 tiffDiv = document.getElementById('adTiff')
	 tiffDiv.style.display = 'block';
	 tiffDiv.style.position = 'absolute';
	 tiffDiv.style.left = '';
	 tiffDiv.style.top = '';
	 tiffDiv.style.right = '0px';
	 tiffDiv.style.bottom = '0px';
	 tiffDiv.style.marginBottom = '2px';
	 tiffDiv.parentNode.style.position = 'relative';
	 
	 if(tiffDelivery == 'adi')
	 {
	  
	  tiffIframe = document.createElement('iframe')
	  tiffIframe.src= 'http://ad.doubleclick.net/' + tiffDelivery + '/wpni.' + commercialNode + ';ad=tiff;sz=234x60,300x45,290x60;' + tiffOnTheFly + 'ord=' + ord + '?';
	  tiffIframe.width = tiffWidth;
	  tiffIframe.height = tiffHeight;
	  tiffIframe.frameBorder = 0;
	  tiffIframe.marginHeight = 0;
	  tiffIframe.marginWidth = 0;
	  tiffIframe.scrolling = "no";
	  if(!document.getElementById('tiffTD'))
	   {
		document.write('<div id="tiffTD"></div>')
	   }
	  document.getElementById('tiffTD').appendChild(tiffIframe);
	 }
	 else if(tiffDelivery == 'adj')
	 {
	 	 placeAd('SECTION',commercialNode,14,'',true)
	 }
// We had to remove the placeAd and use an iframe so that the ad will function properly in channelNav.js
	
}

