// Ad Display Globals
var zzzadslot = Math.random() * 10000000000000000;
var pageads=new Array();
var ns4webtv=(((!document.images && navigator.userAgent.indexOf('Mozilla/2.') >= 0)||navigator.userAgent.indexOf("WebTV")>= 0))?true:false;
var adurl='http://ad.doubleclick.net';
var gAdSubSection='';

function cDARTAd(Ord,hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, sSubSect){
	this.ord=Ord;
	this.hrefname=hRefName;
	this.sectionname=SectionName;
	this.slot=sSlot;
	this.layer=sSlotLayer;
	this.tile=iTile;
	this.w=iWidth;
	this.h=iHeight;
	this.sW=iWidth+"x"+iHeight;
	this.subsection=sSubSect;
	this.core='metronewyork.primedia.com/citiestown_metronewyork_'+this.hrefname+'_;!category=;subs='+this.subsection+';sect='+this.sectionname+';svc=;kw=;site=metronewyork;chan=citiestown;sz='+this.sW+';tile='+this.tile+';ord='+this.ord+((pageads.length==0)?';dcopt=ist':'');
	pageads[pageads.length]=this; // Ad to Collection for CloseAds
	this.write=function() { // write out Ad
		document.writeln('<'+'script src='+adurl+'/adj/'+this.core+';abr=!webtv></'+'script'+'>');
		if (ns4webtv)
			document.writeln('<a href="'+adurl+'/jump/'+this.core+'" target="_blank"><img src="'+adurl+'/ad/'+this.core+'" width='+this.w+' height='+this.h+' border=0></a>');
	}
	this.close=function() { // close ads
		if (ns4webtv) return true;
		for (var i=0;i<pageads.length;i++){
			var a=pageads[i];
			var core = adurl+'/adl/'+a.core;
			var swh=(2+a.w)+","+(2+a.h);
			var s='<layer clip="'+swh+'" src="'+core+'" target="_blank" visibility="hide" onload="moveToAbsolute('+a.layer+'.pageX,'+a.layer+'.pageY); visibility=\'show\';"></layer>';
			document.writeln(s);
		}
	}
}

function DisplayAd( ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection ) {
	var oDartAd=new cDARTAd(ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection);
	oDartAd.write();
}

function EndAds() {	if (pageads.length>0)pageads[0].close(); }

function InsertAd( SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight ) {
	DisplayAd( zzzadslot, SectionName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight);
}

function InsertBanner() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:1;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 468, 60, sSub );
}

function InsertSquare() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:9;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 180, 150, sSub );
}

function InsertSmallSquare1() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:5;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 120, 60, sSub );
}

function InsertSmallSquare2() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:6;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 120, 60, sSub );
}

function InsertBigSquare() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:1;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 250, 250, sSub);
}

function InsertTower() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:2;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 120, 600, sSub );
}
function InsertButton() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:3;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 125, 125, sSub);
}
function InsertPopup() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:5;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 1, 1, sSub );
}

function InsertHalfB() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:2;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 234, 60, sSub );
}

function InsertFashionAd() {
	// var bNum=(arguments.length>0)?arguments[0]:'';
	var sSect=(arguments.length>1)?arguments[1]:'fashion';
	var iTile=(arguments.length>2)?arguments[2]:5;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 100, 60, sSub);
}

// Soon to be obsolete
function DisplayBanner( hRefName, SectionName ) {
	DisplayAd( zzzadslot, hRefName, SectionName, "slot1", "adslot1", 1, 468, 60, gAdSubSection );
}

function DisplayTower( hRefName, SectionName ) {
	DisplayAd( zzzadslot, hRefName, SectionName, "vmslot1", "vmslot1", 2, 120, 600, gAdSubSection );
}


function DisplayButton( hRefName, SectionName ) {
	DisplayAd( zzzadslot, hRefName, SectionName, "sqslot1", "sqslot1", 3, 125, 125, gAdSubSection );
}

// CloseAds function is obsolete. Use EndAds.
var CloseAds=EndAds;

