document.write("<script language='javascript' src='/js/2/adconfig.js'><\/script>");
document.write("<script language='javascript' src='/js/2/ad-layering-logic.js'><\/script>");

// Ad Display Globals
var zzzadslot = Math.floor(Math.random() * 10000000000000);
var adurl = "http://ad.doubleclick.net/adj/nym.nymag";
var pageads=new Array();
var ns4webtv=(((!document.images && navigator.userAgent.indexOf('Mozilla/2.') >= 0)||navigator.userAgent.indexOf("WebTV")>= 0))?true:false;
var gAdSubSection='';
var adid = '';  // gets initialized through a DART call in order to manage "comp" attribute
var rewriteAdId=false;	//allows for ad size increace, ie 300x250 ad spot displays a 300x600 ad

var rotate_timer_id;
var rotate_timer_interval = 1;  // seconds
var rotate_timer_counter = 0;
var rotate_ads = new Array;
var rotate_ads_index = 0;



addOnload(rotateOnload);


//searchs a list for a value
//return index of value + 1 or false
//*Note: although .indexOf function can be used
//this function is not compatible with IE and older browsers
//safer to use user defined isInList()
function isInList(list, value)
{
	var returnValue=false;
	var i=0;
	for ( i; i < list.length;i++ )
	{
		if(list[i]==value)
		{
			returnValue=i+1;
			break;
		}
	}
	return returnValue;

}

function keywordCampaign()
{
	//instantitate variables
	//subection : keyword targeted subsection
	//sizeID : list of size id's that will be targetd
	//section : section of current page
	//adsizeReWrite : targets a larger ad size for a small ad space
	//isAdCampaign = boolean, determines if there is an adcampaign for a section 
 	this.subsection;
	this.sizeID=[];
	this.section;
	this.adsizeReWrite;
	var isAdCampaign = false;

	this.checkMeta =function ()
	{
		//get list of meta tags
		var metas = document.getElementsByTagName('meta');
			
		//find keywords meta tag
		var count;
		for (count = 0; count<metas.length; count++)
		{
			if (metas[count].getAttribute('name') == "keywords")
				break;
		}

		//blacklist check
		if(this.isBlacklist(document.URL))
		{
			count = metas.length;
		}
		//if count is equal to meta length
		//meta keywords were not found!
		if(count != metas.length)
		{
	
			//get list of keywords
			var keywords = metas[count].getAttribute('content');
			var keys = keywords.split(",");
	
			//check for current ad campaigns
			for (count = 0; count < keys.length; count++)
			{
				//check for blacklisted keywords
				if(this.ltrim(keys[count])== "adnormal")
					break;
				isAdCampaign=this.insertAdCampaign(keys[count]);
				if(isAdCampaign)
					break;
			}
		}
		return isAdCampaign;

	}//end checkMeta

	//function to disable targeting on specific pages
	//blacklisted pages found in adconfig
	this.isBlacklist = function (url)
	{
		
		var count = 0;
		var retStmt = false;
		for(count; count < blacklisted_pages.length; count ++)
		{
			//if page is blacklisted return true
			if(blacklisted_pages[count] == url )
			{
				retStmt = true;
				break;
			}	
		}
		return retStmt;
	}	

//functions to trim white spaces

	this.ltrim =function (stringToTrim) 
	{
		return stringToTrim.replace(/^\s+/,"");
	}
	this.rtrim = function(stringToTrim) {
		return stringToTrim.replace(/\s+$/,"");
	}	

//function to check again current keyword campaigns
	this.insertAdCampaign = function(keyword)
	{
		this.subsection = false;
		this.section = gAdTag;
		//remove leading white space
		keyword = this.ltrim(keyword).toLowerCase();
		
		//switch based off section
		switch (this.section)
		{
			case "news":
				//switch based off keyword
				switch (keyword)
				{
				/*	case "baseball":
					this.subsection = "baseball";
					this.sizeID = ["336x280"];
					this.adsizeReWrite="300x600";	//specificy the acutal ad size displayed
					break;
				*/
					case "gossip girl":
					this.subsection = "gossip_girl";
					this.sizeID = ["336x280","728x90","260x60"];
					this.adsizeReWrite = "300x600";
					break;

				}//end keyword switch
			break; //end news

			case "arts":
				//switch based off keyword
				switch (keyword)
				{
					case "gossip girl":
					this.subsection = "gossip_girl";
					this.sizeID = ["336x280","728x90","260x60"];
					this.adsizeReWrite = "300x600";
					break;

				}// end keyword switch
			break; //end arts

			case "FFF":
				//switch based off keyword
				switch (keyword)
				{							
					case "gossip girl":
					this.subsection = "gossip_girl";
					this.sizeID = ["336x280","728x90","260x60"];
					this.adsizeReWrite = "300x600";
					break;

					//beauty marks	
					case "beauty":
					this.subsection = "Sebastian";
					this.sizeID = ["336x280", "728x90"];
					//this.adsizeReWrite = "300x600";
					break;

				}
			break; //end fashion

			case "restaurants":
				//switch based off keyword
				switch (keyword)
				{
					case "gossip girl":
					this.subsection = "gossip_girl";
					this.sizeID = ["336x280","728x90","260x60"];
					this.adsizeReWrite = "300x600";
					break;

				}// end keyword switch
			break; //end restaurants

		}//end section switch
 		return this.subsection;
	}//end insertAdCampaign

}//end keywordCampaign obj

//checks to see if a 2nd ad is displayed in fashion slideshows
function is2ndAdSlideShow()
{
	return isBannerCampaign;
}

//adds a new function to the onload event
function addOnload(new_function) {
	var old_onload = window.onload; //get current onload event functions

	if (typeof window.onload != "function") { 
		window.onload = new_function; // if no previous functions, assign new function
	} else { 
		window.onload = function() {
			old_onload();		//else create new function
			new_function();		// with 2 function calls 
		}
	} 
}

function getHashLength(h) {
	var ctr = 0;
	for (i in h) ctr++;
	return ctr;
}

function getTimestamp() {
	var dt = new Date();
	return dt.toString().replace(/^.+(\d\d:\d\d:\d\d).+$/, "$1");
}

function logmsg(s) {
	var logger = document.getElementById("logger");
	if (logger) {
		logger.innerHTML = "[" + getTimestamp() + "] " + s + "<br>" + logger.innerHTML;
	}
}

function updateOrd() {
	zzzadslot = Math.floor(Math.random() * 10000000000000);
}

function getRandomNum() {
	return Math.random() * 10000000000000000;
}

function rotateOnload() {
	logmsg("** rotateOnload **");

	if (!rotate_ads_flag) {
		logmsg("ad reloading disabled");
		return;
	}

	if (rotate_timer_id) {
		logmsg("rotate timer has already been set");
		return;
	}

	rotate_timer_id = window.setInterval("rotateAds()", rotate_timer_interval * 1000);
}

function rotateStop() {
	logmsg("** ad reload stopped **");
	window.clearInterval(rotate_timer_id);
	rotate_timer_id = null;
}

function rotateAds() {
	rotate_timer_counter++;

	for (ad_id in rotate_ads) {
		var first_time = rotate_ads[ad_id].display_time == 0;

		if ((rotate_timer_counter - rotate_ads[ad_id].display_time) >= rotate_ads[ad_id].reload_interval) {
			if (first_time) {
				insertIframe({ id: ad_id, width: rotate_ads[ad_id].width, height: rotate_ads[ad_id].height });
				rotate_ads[ad_id].display_time = rotate_timer_counter;
			}

			if (rotate_ads_index >= getHashLength(rotate_ads)) {
				rotate_ads_index = 0;
				updateOrd();
			}

			reloadAd({ ad_id: ad_id, js_uri: rotate_ads[ad_id].js_uri });
			rotate_ads[ad_id].display_time = rotate_timer_counter;
			rotate_ads_index++;

			break;
		}
	}
}

function reloadAds() {
	if (pageads && pageads.length > 0) {
		updateOrd();
		resetAdTimers();

		for (i in pageads) {
			logmsg("*** reloadAds(): " + pageads[i].AdId);
			if (pageads[i].AdId) {
				insertIframe({
					id: pageads[i].AdId,
					width: pageads[i].iWidth,
					height: pageads[i].iHeight
				});
				reloadAd({ ad_id: pageads[i].AdId, js_uri: pageads[i].dartjsuri });
			}
		}
	}
}

// args: { ad_id, js_uri }
function reloadAd(args) {
	var code = '<ht' + 'ml><bo' + 'dy><scr' + 'ipt type="text/javascript" language="JavaScript" src="' +
		args.js_uri + ';ord=' + zzzadslot + ';random=' + getRandomNum() +
		'"></sc' + 'ript></b' + 'ody></h' + 'tml>';
	logmsg("reloadAd(): reloading " + args.ad_id + ": " + escapeHtml(code));
	injectIframe("adfr_" + args.ad_id, code);
}

function resetAdTimers() {
	for (id in rotate_ads) {
		rotate_ads[id].display_time = rotate_timer_counter;
	}
}

function escapeHtml(s) {
	return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}

function formatForHtml(s) {
	return s.replace(/\n/g, "<br>");
}

function getIframeObj(id) {
	return document.getElementById(id);
}

function getIframeDoc(id) {
	var idoc;
	var iobj = getIframeObj(id);

	if (iobj)	{
		if (iobj.contentDocument) {
			idoc = iobj.contentDocument; 
		} else if (iobj.contentWindow) {
			idoc = iobj.contentWindow.document;
		} else {
			idoc = iobj.document;
		}
	}

	return idoc;
}

// args: { id, width, height }
function insertIframe(args) {
	var ad_div = document.getElementById(args.id);
	if (!ad_div) {
		logmsg("error: missing ad container id=" + args.id);
		return false;
	}

	if (getIframeDoc("adfr_" + args.id)) {
		//logmsg("iframe document already exists id=" + args.id);
		return false;
	}

	ad_div.innerHTML = '<ifra' + 'me id="adfr_' + args.id + '" src="about:blank" width="' +
		args.width + '" height="' + args.height +
		'" allowtransparency="true" marginwidth="0" marginheight="0" frameborder="0" ' +
		'scrolling="no"' + 'z-index="0" onload=\'fixIframeSize("adfr_' + args.id +
		'")\'></ifra' + 'me>';
}

function injectIframe(id, str) {
	var idoc = getIframeDoc(id);

	if (!idoc) {
		logmsg("error: undefined frame document for " + id);
		return false;
	}

	idoc.open();
	idoc.write(str);
//	idoc.close();
	window.setTimeout("closeIframeDoc('" + id + "')", 3000);
}

function closeIframeDoc(id) {
	var idoc = getIframeDoc(id);
	idoc.close();
}

function fixIframeSize(id) {
	var iobj = getIframeObj(id);
	var idoc = getIframeDoc(id);

	if (idoc && idoc.body) {
		if (iobj.width == 336) iobj.width = 300;
		if (iobj.height == 800) iobj.height = 600;
		window.setTimeout('fixIframeSize2("' + id + '")', 100);
	}
}

function fixIframeSize2(id) {
	var iobj = getIframeObj(id);
	var idoc = getIframeDoc(id);

	if (idoc && idoc.body) {
		if (idoc.body.scrollWidth > 300) iobj.width = idoc.body.scrollWidth;		
		if (idoc.body.scrollHeight > 600) iobj.height = idoc.body.scrollHeight;
	}
}


// DART section targeting
function convertSect(SectionName,SubSectionName) {
	cvtSect = new Object;
	
	//check for subsection
	if(SubSectionName)
		cvtSect.SubSectionName = SubSectionName;

	// Convert DART section identifiers to Falk IDs (baseline)
	if (SectionName == 'gHome')		cvtSect.SectionName='homepage'
	else if (SectionName == 'gNews')	cvtSect.SectionName='news'
	else if (SectionName == 'gArts')	cvtSect.SectionName='arts'
	else if (SectionName == 'gShops')	cvtSect.SectionName='shopping'
	else if (SectionName == 'gFFF') 	cvtSect.SectionName='fashion'
	else if (SectionName == 'gFFF') 	cvtSect.SectionName='fashionshows'
	else if (SectionName == 'gTravel') 	cvtSect.SectionName='travel'
	else if (SectionName == 'gTest')	cvtSect.SectionName='test'
	else if (SectionName == 'arts')	 	cvtSect.SectionName='arts'
	else if (SectionName == 'bony') 	cvtSect.SectionName='bestofny'
	else if (SectionName == 'doctors') 	cvtSect.SectionName='bestdoctors'
	else if (SectionName == 'lawyers') 	cvtSect.SectionName='lawyers'
	else if (SectionName == 'homepage') 	cvtSect.SectionName='homepage'
	else if (SectionName == 'news') 	cvtSect.SectionName='news'
	else if (SectionName == 'personals') 	cvtSect.SectionName='arts'
	else if (SectionName == 'realestate') 	cvtSect.SectionName='realestate'
	else if (SectionName == 'propdetail') 	cvtSect.SectionName='propdetail'
	else if (SectionName == 'restaurants') 	cvtSect.SectionName='restaurants'
	else if (SectionName == 'shopping') 	cvtSect.SectionName='shopping'
	else if (SectionName == 'travel') 	cvtSect.SectionName='travel'
		else if (SectionName == 'family') 	cvtSect.SectionName='family'
		else if (SectionName == 'beauty') 	cvtSect.SectionName='beauty'
	else if (SectionName == 'test')		cvtSect.SectionName='test'
	else if (SectionName == 'everything')		cvtSect.SectionName='everything'
	else 								cvtSect.SectionName='ros';

	// Regex the DART based on URL criteria
	// This overrides page-based rules, so use conservatively
	// Note: hierarchical ranking, highest depth items must go first!
	var currenturl = parent.location.href;

	if (currenturl.match("bestofny"))		cvtSect.SectionName='bestofny';
	else if (currenturl.match("bestdoctors"))	cvtSect.SectionName='bestdoctors';
	else if (currenturl.match("lawyers"))		cvtSect.SectionName='lawyers';
	else if (currenturl.match("urban")) 		cvtSect.SectionName='guides';
	else if (currenturl.match("guides"))		cvtSect.SectionName='guides';
	else if (currenturl.match("visitorsguide"))	{ cvtSect.SectionName='travel'; cvtSect.SubSectionName='visitorsguide'; }
	else if (currenturl.match("nymetro/arts"))	cvtSect.SectionName='arts';
	else if (currenturl.match("news"))		cvtSect.SectionName='news';
	else if (currenturl.match("fashion/fashionshows")) cvtSect.SectionName='fashionshows';
	else if (currenturl.match("fashion"))		cvtSect.SectionName='fashion';
	else if (currenturl.match("homedesign"))	cvtSect.SectionName='homedesign';
	else if (currenturl.match("movies"))		cvtSect.SectionName='movies';
	else if (currenturl.match("nightlife"))		cvtSect.SectionName='nightlife';
	else if (currenturl.match("restaurants"))	cvtSect.SectionName='restaurants';
	else if (currenturl.match("food"))			cvtSect.SectionName='restaurants';
	else if (currenturl.match("marketplace"))	cvtSect.SectionName='shopping';
	else if (currenturl.match("storeopenings"))	cvtSect.SectionName='shopping';
	else if (currenturl.match("weddings"))		cvtSect.SectionName='weddings';
	else if (currenturl.match("everything"))	cvtSect.SectionName='everything';
	else if (currenturl.match("travel"))		cvtSect.SectionName='travel';
	else if (currenturl.match("family"))		cvtSect.SectionName='family';
	else if (currenturl.match("beauty"))		cvtSect.SectionName='beauty';


	// Populate Falk sub-section based on destination URL
	// This overrides all previous rules defined
	var adflag = 0;
	
	for (var i=0; i < adsection.length; i++) {
		var pattern = adsection[i][0];
		if (!adflag && currenturl.match(pattern)) {
			cvtSect.SectionName=adsection[i][1];
			
			//check if subsection is already established
			if(!cvtSect.SubSectionName)
				cvtSect.SubSectionName=adsection[i][2];	
			adflag = 1;
		}
	}
	
	if (!adflag) cvtSect.SubSectionName='';

	if (document.referrer.match("halstead.com") &&
		(cvtSect.SectionName == "restaurants" || cvtSect.SectionName == "shopping")) {
		cvtSect.SubSectionName += ";referral=halstead";
	}
	
	return cvtSect;
}

function cDARTAd(AdId, Ord,hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, sSubSect){
	
	this.base = __cDARTAd;
	this.base(AdId, Ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, sSubSect);

	if (AdId) {
		if (AdId == "160x60") {
			AdId += (sSubSect == "left") ? "_left" : "_right";
		}

		var config_section = this.sectionname + (this.subsection ? "-" + this.subsection : "");
		if (!rotate_config[config_section]) {
			config_section = this.sectionname;
		}
		logmsg("cDARTAd(): config_section: " + config_section + ", ad_id: " + AdId +
			", sectionname: " + this.sectionname + ", subsection: " + this.subsection);

		if (rotate_config[config_section] && rotate_config[config_section]["formats"]) { 
			for (var i=0; i < rotate_config[config_section]["formats"].length; i++) {
				if (rotate_config[config_section]["formats"][i] == AdId) {
					rotate_ads[AdId] = {
						reload_interval: rotate_config[config_section].reload_interval,
						display_time: 0,
						js_uri: this.getJsUri(),
						width: (this.iWidth == 336) ? 300 : this.iWidth,
						height: (this.iHeight == 800) ? 600 : this.iHeight
					};

					logmsg("cDARTAd(): adding " + AdId + " to rotate list with reload interval=" +
						rotate_ads[AdId].reload_interval);
				}
			}
		}
	}
}

function __cDARTAd(AdId, Ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, sSubSect){
	this.AdId=AdId;
	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.iWidth=iWidth;
	this.iHeight=iHeight;
	this.sW=iWidth+"x"+iHeight;
	this.subsection=sSubSect;

	cvtSect=convertSect(this.sectionname,this.subsection);
	
	this.sectionname=cvtSect.SectionName;
	if (this.subsection.length == 0) {
		this.subsection=cvtSect.SubSectionName;
	} else if ((this.subsection == "left") || (this.subsection == "right")) {
		this.position=this.subsection;
		if (cvtSect.SubSectionName.length > 0) {
			// this.position=this.subsection;
			this.subsection=cvtSect.SubSectionName;
		}
	} else {
	 	this.subsection=sSubSect;
	}

	// DART specific tuning here
	var position = '';
	if (this.position == 'left') {
		position='pos=left;';
		if (this.subsection == 'left')
			this.subsection='';
	} else if (this.position == 'right') {
		position='pos=right;';
		if (this.subsection == 'right')
			this.subsection='';
	}

	if (this.AdId == "260x60") {
		position = "pos=top;";
	}

	if (this.AdId == "260x60_2") {
		position = "pos=bottom;";
	}

	var multimedia = '';
	if (this.AdId == "260x60") {
		multimedia = 'dcopt=ist;';
	}

	// DART Initiate
	if (this.subsection.length > 0)
		this.dartsubsect = this.subsection;

		if ((this.w == 300) && (this.h == 250)) {
		this.w = ''; this.h = '';
		this.dartres='300x250';
	} else if ((this.w > 0) && (this.w != 336))
		this.dartres=this.w+'x'+this.h;
	else if ((this.w == 336) && (this.h == 280)) {
		this.w = ''; this.h = '';
		this.dartres='300x250';
	} else if (this.w == 336) {
		this.w = '300'; this.h = '600';
		this.dartres='300x600';
	} 

	if (this.dartres == '3x3')
		this.sectionname = 'ros';


	// Show target placement (useful for testing)
	// document.writeln('<font color=\"#DD0000\" size=1>Ad tag: sect='+this.sectionname+((this.subsection.length>0)?';subs='+this.dartsubsect:'')+';comp='+adid+((position.length>0)?';'+position:'')+'</font><br>');

	this.zone = this.sectionname;

 // temp setting custom zone for Lindsay Lohan story 
	         if (this.sectionname == "fashion" && this.subsection == "special") { 	 
	                 this.zone = "special"; 	 
	         }


	// DART Build Tag
	//check for ad size rewrite
	if(rewriteAdId){
	this.dartjsuri = adurl + '/' + this.zone + ';sect=' + this.sectionname +
		((this.subsection.length > 0) ? ';subs=' + this.dartsubsect : '') + ';comp=' + adid +
		((position.length > 0)?';'+position:';') + 'tile=' + this.tile + ';' + multimedia + 'sz=' + this.dartres + ',' + rewriteAdId;
		// ';' + position + ';tile=' + this.tile + ';' + multimedia + 'sz=' + this.dartres ;
		rewriteAdId = false;
	}
	else
	{
	this.dartjsuri = adurl + '/' + this.zone + ';sect=' + this.sectionname +
		((this.subsection.length > 0) ? ';subs=' + this.dartsubsect : '') + ';comp=' + adid +
		((position.length > 0)?';'+position:';') + 'tile=' + this.tile + ';' + multimedia + 'sz=' + this.dartres;
		// ';' + position + ';tile=' + this.tile + ';' + multimedia + 'sz=' + this.dartres ;
		rewriteAdId = false; //reset rewrite rule
	}

	this.dartjssrc='<scr' + 'ipt type="text/javascript" language="JavaScript" src="'+this.dartjsuri +
		';ord=' + this.ord + '?"></sc' + 'ript>';

	this.core=this.dartjssrc;

	// document.writeln('<font color=\"#DD0000\" size=1>Ad url: '+adurl+'/'+this.sectionname+((this.subsection.length>0)?this.dartsubsect:'')+';sect='+this.sectionname+((this.subsection.length>0)?'subs='+this.dartsubsect:'')+';tile='+this.tile+';'+multimedia+'sz='+this.dartres+';'+position+'ord='+this.ord+'</font><p>');

	pageads[pageads.length]=this; // Ad to Collection for CloseAds

	this.write=function() { // write out Ad
		document.writeln(this.getAdCode());

	}

	this.getAdCodeBody = function() {
		return this.dartjsbody;
	}
	
	this.getAdCode = function() {
		return this.core;
	}

	this.getJsUri = function() {
		return this.dartjsuri;
	}

	this.close=function() { }
}

function DisplayAd(AdId, ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection) {
	var keywordAd = new keywordCampaign;
	rewriteAdId = false;
	if(is_keyword_targeting && keywordAd.checkMeta())
	{
		var tmp;
		if(tmp=isInList(keywordAd.sizeID,AdId)){
			//alert("Modifying subsection: " + keywordAd.sizeID[tmp-1]);
			SubSection = keywordAd.subsection;
			if(AdId == "336x280"){
				rewriteAdId = keywordAd.adsizeReWrite;
			}
			}
	}
	var oFalkAd=new cDARTAd(AdId, ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection);
	oFalkAd.write();
}

function GetAdCode( AdId, ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection ) {
	var oFalkAd=new cDARTAd(AdId, ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection);
	return oFalkAd.getAdCode();
}

function GetAdCodeBody( AdId, ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection ) {
	var oFalkAd=new cDARTAd(AdId, ord, hRefName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight, SubSection);
	return oFalkAd.getAdCodeBody();
}

function EndAds() {	if (pageads.length>0)pageads[0].close(); }

function InsertAd(AdId, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight) {
	DisplayAd(AdId, zzzadslot, SectionName, SectionName, sSlot, sSlotLayer, iTile, iWidth, iHeight);
}

function InsertRichMedia() {
	// 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,'','', sSub);
}

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("468x60", zzzadslot, sSect, sSect, '', '', 7, 468, 60, sSub);
}

function InsertBanner2() {
	// 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("728x90", zzzadslot, sSect, sSect, '', '', 2, 728, 90, 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("180x150", 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("120x60", 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("120x60", zzzadslot, sSect, sSect, '', '', iTile, 120, 60, sSub);
}

function InsertSmallSquare3() {
	// 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;
	var sSub = "right";
	DisplayAd("160x60_right", zzzadslot, sSect, sSect, '', '', 3, 160, 60, sSub);
}

function InsertSmallSquare3_2() {
	// 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;
	var sSub = "left";
	DisplayAd("160x60_left", zzzadslot, sSect, sSect, '', '', 1, 160, 60, sSub);
}

function InsertSmallSquare3_3() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:4;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd("160x60", zzzadslot, sSect, sSect, '', '', 3, 160, 60, sSub);
}

function InsertSmallSquare4() {
	// 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;
	var sSub = "left";
	DisplayAd("160x60_left", zzzadslot, sSect, sSect, '', '', 1, 160, 60, sSub);
}

function InsertMedSquare() {
	// 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("250x90", zzzadslot, sSect, sSect, '', '', 8, 250, 90, 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("250x250", zzzadslot, sSect, sSect, '', '', iTile, 250, 250, sSub);
}

function InsertBigSquare2() {
	// 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("336x280", zzzadslot, sSect, sSect, '', '', 5, 300, 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("120x600", zzzadslot, sSect, sSect, '', '', iTile, 120, 600, sSub);
}

function InsertTower2() {
	// 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('160x600', zzzadslot, sSect, sSect, '', '', 4, 160, 600, sSub);
}

function Insert260x60() {
	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('260x60', zzzadslot, sSect, sSect, '', '', iTile, 260, 60, sSub);
}

function Insert260x60_2() {
	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('260x60_2', zzzadslot, sSect, sSect, '', '', iTile, 260, 60, sSub);
}

// Start right tower units -------------------------------------------------
function InsertRightAd(ad_id) {
	if (show_ad_format_flags && show_ad_format_flags[ad_id]) {
		try {
			eval("InsertRight_" + ad_id + "()");
		} catch(er) {
		}
	}
}

function InsertRight_336x280() {
	// 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;
//	return GetAdCode(zzzadslot, sSect, sSect, '', '', iTile, 300, 250, sSub);
	// DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 336, 280, sSub );
	DisplayAd("336x280", zzzadslot, sSect, sSect, '', '', 5, 300, 250, sSub);
}

function InsertRight_336x280_2() {
	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("336x280_2", zzzadslot, sSect, sSect, '', '', 5, 300, 250, sSub);
}

function InsertRight_336x600() {
	// 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;
//	return GetAdCode(zzzadslot, sSect, sSect, '', '', iTile, 336, 600, sSub);
	//// DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 300, 250, sSub );
	DisplayAd("336x600", zzzadslot, sSect, sSect, '', '', 9, 336, 600, sSub);
}
function InsertRight_336x800() {
	// 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;
//	return GetAdCode(zzzadslot, sSect, sSect, '', '', iTile, 336, 800, sSub);
	//// DisplayAd( zzzadslot, sSect, sSect, '', '', iTile, 300, 250, sSub );
	DisplayAd("336x800", zzzadslot, sSect, sSect, '', '', 9, 336, 800, sSub);
}
function InsertRight_160x600() {
	// 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;
//	return GetAdCode(zzzadslot, sSect, sSect, '', '', iTile, 160, 600, sSub);
	DisplayAd("160x600", zzzadslot, sSect, sSect, '', '', 4, 160, 600, sSub);
}
// End right tower units ---------------------------------------------------


function InsertGoogle() {
	// var bNum=(arguments.length>0)?arguments[0]:1;
	var sSect=(arguments.length>1)?arguments[1]:gAdTag;
	var iTile=(arguments.length>2)?arguments[2]:8;
	var sSub=(arguments.length>3)?arguments[3]:gAdSubSection;
	DisplayAd( '', zzzadslot, sSect, sSect, '', '', iTile, 3, 3, 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);
}

function InsertFashionSlideshowInterstitial() {
	// 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('700x440', zzzadslot, sSect, sSect, '', '', iTile, 700, 440, sSub);
}

function Insert160x140() {
	// 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('160x140', zzzadslot, sSect, sSect, '', '', iTile, 160, 140, sSub);
}

// Soon to be obsolete
function DisplayBanner( hRefName, SectionName ) {
	DisplayAd( '', zzzadslot, hRefName, SectionName, "slot1", "adslot1", 7, 468, 60, gAdSubSection );
}

function DisplayTower( hRefName, SectionName ) {
	DisplayAd( '', zzzadslot, hRefName, SectionName, "vmslot1", "vmslot1", 2, 120, 600, gAdSubSection );

}

function DisplayTower2( hRefName, SectionName ) {
	DisplayAd( '', zzzadslot, hRefName, SectionName, "vmslot1", "vmslot1", 2, 160, 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;


/*
	Google AdSense handler. It gets called through Google ad framework once ad queue is formed and
	is ready to be integrated into a page. See google ads include files.
*/
function nym_google_ad_request_done(args) {
	var ad_container_id = args.ad_container_id;
	var google_ads = args.google_ads;
	var ad_code = '';

	if (!ad_container_id || !google_ads || google_ads.length == 0) {
		return;
	}

	if (google_ads[0].type == "flash") {
		ad_code += '<div class="google_ad_flash">' +
			'<a href="' + google_info.feedback_url + '" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
			'WIDTH="' + google_ad.image_width + '" HEIGHT="' + google_ad.image_height + '">' +
			'<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">' +
			'<PARAM NAME="quality" VALUE="high"><PARAM NAME="AllowScriptAccess" VALUE="never">' +
			'<EMBED src="' + google_ad.image_url + '" WIDTH="' + google_ad.image_width +
			'" HEIGHT="' + google_ad.image_height + '" TYPE="application/x-shockwave-flash" ' + 
			'AllowScriptAccess="never" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">' +
			'</EMBED></OBJECT></div>';
	} else if (google_ads[0].type == "image") {
		ad_code += '<div class="google_ad_image">' +
			'<a href="' + google_ads[0].url + '" target="_top" title="go to ' +
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\'; return true">' +
			'<img border="0" src="' + google_ads[0].image_url +
			' "width="' + google_ads[0].image_width + ' "height="' + google_ads[0].image_height + '"></a>';
	} else {
		if (google_ads.length == 1) {
			ad_code += '<div class="googleads-expandable">' +
				'<a href="' + google_ads[0].url + '" ' +
				'onMouseOver="window.status=\'' + google_ads[0].visible_url + '\'" ' +
				'onMouseOut="window.status=\'\'" ' + 'title="' + google_ads[0].visible_url + '">' +
				'<b>' + google_ads[0].line1 + '</b>' +
				'<div>' + google_ads[0].line2 + ' ' + google_ads[0].line3 + '</div>' +
				'<div><small>' + google_ads[0].visible_url + '</small></div>' +
				'</a></div>';
		} else {
			ad_code += '<div class="googleads"><ul>';

			for (var i = 0; i < google_ads.length; ++i) {
				ad_code += '<li><a href="' + google_ads[i].url + '" ' +
				'onMouseOver="window.status=\'' + google_ads[i].visible_url + '\'" ' +
				'onMouseOut="window.status=\'\'" ' +
				'title="' + google_ads[i].visible_url + '">' +
				'<b>' + google_ads[i].line1 + '</b>' +
				'<div>' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</div>' +
				'<div><small>' + breakLongString(google_ads[i].visible_url, 24, "<wbr/>") + '</small></div>' +
				'</a></li>';
			}

			ad_code += '</ul><br /></div>';
		}
	}

	var ad_container = document.getElementById(ad_container_id);
	if (ad_container) {
		ad_container.innerHTML = ad_code;
	}

	var feedback_link = document.getElementById(ad_container_id + "_feedback");
	if (feedback_link) {
		feedback_link.href = google_info.feedback_url;
	}
}

function breakLongString(str, break_interval_chars, break_with_str) {
    if (typeof(str) == "string" && str.length > break_interval_chars) {
        str = str.match(new RegExp(".{1," + break_interval_chars + "}", "g")).join(break_with_str);
    }
    return str;
}
