CityPaperAds = {
	them: 'http://ad.doubleclick.net/',
	us: '/washingtondc.creativeloafing/',
	slots: 	{ '1': { type: 'leaderboard', width: '728', height: '90' },
						'3': { type: 'skyscraper', width: '160', height: '600' },
						'4' : { type: 'rectangle', width: '300', height: '250' },
						'6': { type: 'skyscraper', width: '160', height: '600' }
					},

	randomNumber : Math.round(Math.random() * 20000),

	getAd: function (slot, pageKeyword, zoneKeyword, withAdWarning) {
		var size = 'sz=' + this.slots[slot].width + 'x' + this.slots[slot].height + ';';
		var tile = 'tile=' + slot + ';';
		var key = (pageKeyword == '') ? '' : 'pg=' + pageKeyword + ';';
		var zone = zoneKeyword + ';';
		var inter = (slot == 1) ? 'dcopt=ist;' : '';
		var path = this.us + zone + key + size + inter + tile + 'ord=' + this.randomNumber + '?';
		var iframe = '<iframe src="' + this.them + 'adi' + path + '" width="' + this.slots[slot].width + '" height="' + this.slots[slot].height + '" class="' + this.slots[slot].type + '" scrolling="no" frameborder="0">';
		var href = '<a href="' + this.them + 'jump' + path + '">';
		var img = '<img src="' + this.them + 'ad' + path + '" width="' + this.slots[slot].width + '" height="' + this.slots[slot].height + '" alt="">';

		if (typeof withAdWarning == "undefined") {
	    withAdWarning = true;
	  }

		if (withAdWarning == true) {
			var adHtml = '<div class="advertCaption">advertisement</div>' + iframe + href + img + '</a>' + '</iframe>';
		} else {
			var adHtml = iframe + href + img + '</a>' + '</iframe>';
		}

		if (slot == 1) {
			adHtml = '<div id="topAdvert">' + adHtml + '</div>';
		}

		return adHtml;
	}
}

RandomCPNumber = Math.round(Math.random() * 20000);

function writeAd(slot) {
	them = 'http://ad.doubleclick.net/N622/';
	us = '/washingtondc.creativeloafing/';
	if (slot == 1) {
		w = '728';
		h = '90';
		type = 'leaderboard';
	}
	if (slot == 3) {
		w = '160';
		h = '600';
		type = 'skyscraper';
	}
	if (slot == 4) {
		w = '300';
		h = '250';
		type = 'rectangle';
	}
	if (slot == 6) {
		w = '160';
		h = '600';
		type = 'skyscraper';
		zoneKW = 'sky2';
	}
	if (slot == 7) {
		w = '728';
		h = '90';
		type = 'leaderboard';
		zoneKW = 'lead2';
	}

	sz = 'sz=' + w + 'x' + h + ';';
	tile = 'tile=' + slot + ';';
	if (pageKW == '') {
		var key = '';
	} 	else {
		var key = 'pg=' + pageKW + ';';
	}
	var zone = zoneKW + ';';
	// for interstitials
	if (slot == 1) {
		var inter = 'dcopt=ist;';
	} else {
		var inter = '';
	}
 	path = us + zone + key + sz + tile + 'ord=' + RandomCPNumber + '?';
	iframe = '<iframe src="' + them + 'adi' + path + '" width="' + w + '" height="' + h + '" scrolling="no" frameborder="0">';
	href = '<a href="' + them + 'jump' + path + '">';
	img = '<img src="' + them + 'ad' + path + '" width="' + w + '" height="' + h + '" alt="">';
//	alert(type);
	document.write(iframe);
	document.write(href);
	document.write(img);
	document.write('</a>');
	document.write('</iframe>');
}
