// Removed affiliate advertisers
// Date modified:  01/26/2009
// Temporarily STOP an Ad by removing its number from the following list.
// Take care when adding a new Ad to appropriately resequence their numbers etc...
//
var adsPublished="0,2,3,4,5,7,8,9,10,11,12,13,14,15,16,18,19";
var adsRecent=new Array();
//
//
var adsText=new Array(
//new Array(url,Head,Body,Foot,"Cats"),
//
// Ads begin below starting at 0...
//

// Text ad00
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.WestchesterTowns.com/htm/pp/Promote1.html",
//Head
"Featured Listing",
//Body
"<br><br><b>Promote<br>your<br>Business<br><br>To Our<br><br>60,000 +<br>Monthly Visitors</b>",
//Footer
"<br>Click here!",
1,
//Categories, CSV string
""
),

// Text ad01 *** Remove Ad01 until we hear from Lynda - Main Street Pediatric Dentistry
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.mainstreetpediatricdentistry.com",
//Head
"Header - ignore this field.",
//Body
"<img src='MainStreetAd-1.gif'>",
//Footer
"Footer - ignore this field.",
0,
//Categories, CSV string
"14,119,88,124,243,293,330,444,451,452 "
),


// Text ad02
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.LaFontanellaPelham.com/",
//Head
"La Fontanella Ristorante",
//Body
"<br>ZAGAT<br>\"Everything is done right at this rare Pelham gem where<br>Fabulous Northern Italian fare<br>Rivals that of Florence\"<br>",
//Footer
"914-738-3008<br>Pelham",
0,
//Categories, CSV string
"151,181,189,197"
),


// Text ad03  R & K Pest Control, Inc. 
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.allpestsbegone.com",
//Head
"R & K<br>Pest Control",
//Body
"<br><b>Since 1976<br><br><font color=#910003'>\No more<br><br>Bugs<br>Rodents<br>Insects<br><br>Licensed Exterminators\</font></b><br>",
//Footer
"914-632-5374",
0,
//Categories, CSV string 
"427,220,343,338,293,290,246,197,189,157"
),


// Textad04	
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://clickserve.cc-dt.com/link/click?lid=41000000015745008",
//Head
"Zagat",
//Body
"<br>Reviews & Ratings<br><font color=#910003'><br>Restaurants<br>Nightlife<br>Hotels<br>Attractions<br></font>",
//Footer
"Click here!",
0,
//Categories, CSV string
""
),


// Text ad05
new Array(
//Each ad begins with the 'Target URL'
"/dsplybox.html?http://www.TyryndaThai.com/",
//Head
"Tyrynda Thai<br>",
//Body7
"Traditional<br>Authentic<br>Thai Cuisine<br><br>Wonderful Reviews<br><br>\"Excellent\"<br>",
//Footer
"Sleepy Hollow<br>914-524-5003",
0,
//Categories, CSV string
"119,248,157,186,210,220,293,338,343"
),


// Text ad06  *** reuse ***
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.westchestertowns.com/htm/lnk/Link0373.html",
//Head
"Find a Therapist",
//Body
"<br>Suffering from anxiety<br> or depression?<br><br>Are you having<br>relationship problems?<br>",
//Footer
"Get Help Now",
0,
//Categories
"139,254"
),


// Text ad07 Bullyproof Your Child
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.respectu.com",
//Head
"Header - ignore this field.",
//Body
"<img src='BullyProof-Ad.gif'>",
//Footer
"Footer - ignore this field.",
0,
//Categories, CSV string
"270,373,22,444,429,102"
),


// Text ad08
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://homesny.com",
//Head
"Westchester<br>Real Estate",
//Body 
"<br><b>The Best<br>Real Estate<br>Agents</b><br><br>To<br>Buy a Home<br>or<br>Sell a Home<br>",
//Footer
"Eastchester<br>914-961-5510",
0,
//Categories, CSV string
"124, 100, 40, 384, 29, 124, 150, 157, 158, 342"
),


// Text ad09
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.FaustHarrisonPianos.com/",
//Head
"Header - ignore this field.",
//Body
"<img src='FaustHarrisonRun-Site-Ad.gif'>",
//Footer
"Footer - ignore this field.",
0,
//Categories, CSV string
"402,338,222,343,220,307,388,29,451,46,464,429"
),


// Text ad10 ***Ronald A. Mermer, C.P.A.
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.mermcpas.com",
//Head
"Header - ignore this field.",
//Body
"<img src='CPARonaldMermerAD.gif'>",
//Footer
"Footer - ignore this field.",
0,
//Categories, CSV string
"1,87,619,635,234,807,258"
),

// Text ad11
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.thethaigarden.com/",
//Head
"Thai Garden",
//Body
"<br>Excellent Reviews<br><br>Zagat<br>Journal News<br>New York Times<br><br>\"Delicious Thai Cuisine\"<br>and<br>Vegetarian Menu<br>",
//Footer
"Rockland County<br>(845) 680-6437",
0,
//Categories
"29,240,322,442,536,696,757,575,604"
),


// Text ad12
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.buyersedgerealty.com/",
//Head
"Header - ignore this field.",
//Body
"<img src='BuyersEdgeRealtyAd.gif'>",
//Footer
"Footer - ignore this field.",
0,
//Categories, CSV string
"40,429,29,83,87,97,157,186,189,197,200,273,234"
),


// Text ad13
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://http://www.westchestertowns.com/htm/lnk/Link0056.html",
//Head
"Outdoor Dining",
//Body
"<br>Dine Outdoors<br>In the Fresh Air<br><br>Visit<br>Al Fresco<br>Dining<br>Destinations<br>",
//Footer
"Westchester",
0,
//Categories
"174,343,29"
),

// Text ad14  *** Counseling & Psychotherapy Group ***
new Array(
//Each ad begins with the 'Target URL'
"/dsplybox.html?http://www.therapyfairfield.com/",
//Head
"Counseling<br>&<br>Psychotherapy",
//Body
"<b><br><br>Highly Trained<br><br>and<br><br>Experienced<br>Psychotherapists</b><br><br>",
//Footer
"Get Help Now<br>(203) 329-1578",
0,
//Categories
"29,142,83,112,149,186,221,307,308,336"
),


// Text ad15  *** Oakwood Center ***
new Array(
//Each ad begins with the 'Target URL'
"/dsplybox.html?http://www.therapywestchester.com/",
//Head
"Counseling<br>&<br>Therapy",
//Body
"<br>Anxiety<br>Depression<br>Couples Therapy<br>Bipolar Disorder<br>Anger Issues<br>Alcoholism<br>Mediation<br><br><b>We Can Help</b><br>",
//Footer
"Oakwood<br>914-949-7359",
0,
//Categories
"338,270,373,449,498,523,527,222"
),

// Text ad16   
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.cravebarandgrillNY.com/",
//Head
"Header - ignore this field.",
//Body
"<img src='CraveAd.gif'>",
//Footer
"Footer - ignore this field.",
0,
//Categories
"791,338,222,197"
),

// Text ad17
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.ThroughGrandmasEyes.com/",
//Head
"English Villages",
//Body
"<br>Beautiful<br>Serene<br>PhotoArt<br>",
//Footer
"Fine Art Photography",
0,
//Categories
""
),


// Text ad18
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.memphismaes.com",
//Head
"Memphis Mae's<br>BBQ Bistro<br><br>Voted",
//Body
"<br><font color='#990033'><b>Best of<br> Westchester<br><br>\"BBQ & Ribs\"<br></font><br>by<br>Westchester Magazine<br></b></font>",
//Footer
"914-271-0125",
0,
//Categories, CSV string
"399,29,165,478,344,307,210,234,89,114,"
),


// Text ad19
new Array(
//Each ads begins with the 'Target URL'
"/dsplybox.html?http://www.WestchesterTowns.com/htm/lnk/Link0040.html",
//Head
"Real&nbsp;Estate Listings",
//Body
"<br>Buying<br>or<br>Selling<br>a<br>Home in Westchester?<br>",
//Footer
"Click Here",
0,
//Categories, CSV string
""
)


);

//Modified:  6-June-2010 for Image Ad support

function adsWrite(){
//Arg 0: Mode V/H 
//Arg 1: Box width
//Arg 2: Set
//Arg 3: Count
//Arg N..N: Ad Categories

var adsThisPage=new Array();
var adsToDisplay=new Array();
var adsSubCat=new Array();
var arTemp=new Array();

adsToDisplay=adsPublished.split(",");

var iLookBack=Math.floor(adsToDisplay.length/3)+1;
var iIx=0;
var iSkip=0;

if(adsWrite.arguments.length>2){
//Modified:  6-June-2010 for Image Ad support
	var iDepth=0;
	var iIx=location.pathname.indexOf("htm");
	if(iIx>0){
		if(location.pathname.substr(iIx-1,1)=='.')iIx=-1;
	}
	if(iIx<0) iIx=location.pathname.indexOf("php");
	if(iIx>0){
		if(location.pathname.substr(iIx-1,1)=='.')iIx=-1;
	}
	if(iIx<0){
		iIx=location.pathname.indexOf("js");
		iIx=iIx+2;
	}else{ 
		iIx=iIx+3;
	}
	var dlm=location.pathname.substr(iIx,1);
	for(iIx=iIx+1;iIx<location.pathname.length;iIx++){
		if(location.pathname.substr(iIx,1)==dlm)iDepth++;
	}
	var sPathPfx='';
	for(iIx=0;iIx<=iDepth;iIx++)sPathPfx=sPathPfx + '..' + dlm;
	sPathPfx=sPathPfx + 'js/billbox/img/';
//Above Modified:  6-June-2010 for Image Ad support
	if(adsWrite.arguments.length>4){
		for(var i=0;i<adsToDisplay.length;i++){
			arTemp=adsText[adsToDisplay[i]][5].split(",");
			iSkip=0;			
			for(var k=4;k<adsWrite.arguments.length && iSkip==0;k++){
				for(var j=0;j<arTemp.length && iSkip==0;j++){
					if(arTemp[j]==adsWrite.arguments[k]){
						if(k==4){
							adsThisPage.push(adsToDisplay[i]);
						}else{
							adsSubCat.push(adsToDisplay[i]);
						}
						iSkip=1;
					}
				}
			}
		}
	}
	adsToDisplay=new Array();
	document.writeln('<table border="0" cellpadding="0" cellspacing="0"><tr><td align="right">');
	document.writeln('<div ID="BillBox' + adsWrite.arguments[2] + '">');
	document.writeln('<table class="BillBox">');
	document.writeln('<tr>');
	
	do{
		if(adsThisPage.length==0)
			if(adsSubCat.length>0){
				adsThisPage=adsSubCat;
				adsSubCat=new Array();
			}else{
				adsThisPage=adsPublished.split(",");
			}
		iIx=Math.floor(Math.random()*adsThisPage.length);
		for(i=0;i<adsRecent.length && adsThisPage[iIx]!=adsRecent[i];i++);
		if(i==adsRecent.length){
			adsToDisplay.push(adsThisPage[iIx]);
			adsRecent.push(adsThisPage[iIx]);
			if(adsRecent.length>iLookBack)adsRecent=adsRecent.slice(adsRecent.length-iLookBack);
		}
		adsThisPage.splice(iIx,1);
	}while(adsToDisplay.length<adsWrite.arguments[3] && adsToDisplay.length<255);

	for(i=0;i<adsToDisplay.length;i++){
		if(i==3 && adsWrite.arguments[0]==0){
			document.writeln('</tr>');
			document.writeln('</table>');
			document.writeln('</div>');
			document.writeln('</td></tr><tr><td align="right">');
			document.writeln('<div ID="BillBox' + adsWrite.arguments[2] + '2">');
			document.writeln('<table class="BillBox">');
			document.writeln('<tr>');
		}
		iIx=adsToDisplay[i];
		if(i>0 && adsWrite.arguments[0]==0)document.writeln('</tr><tr ALIGN="CENTER">');
		var newWindow='NEW TARGET="_blank" ';
		if(adsText[iIx][0].indexOf('WestchesterTowns.com')>0)newWindow='';

		document.writeln('<td  class="BillBox" WIDTH="' + adsWrite.arguments[1] + '" ALIGN="CENTER">');
//Modified:  6-June-2010 for Image Ad support
		if(adsText[iIx][2].substr(0,5)=='<img '){
			document.writeln('<a href="' + adsText[iIx][0] + '" ' + newWindow + 'onMouseOver="txtStatusSet(' + i + ',' + adsWrite.arguments[2] + '); return true;" onMouseOut="txtStatusClr(' + i + ',' + adsWrite.arguments[2] + ')" ID="adUrl_' + i + '_' + adsWrite.arguments[2] + '">');
			document.write(adsText[iIx][2].substr(0,10) + sPathPfx + adsText[iIx][2].substr(10));
		}else{
			document.writeln('<a href="' + adsText[iIx][0] + '" ' + newWindow + 'onMouseOver="adStatusSet(' + i + ',' + adsWrite.arguments[2] + '); return true;" onMouseOut="adStatusClr(' + i + ',' + adsWrite.arguments[2] + ')" ID="adUrl_' + i + '_' + adsWrite.arguments[2] + '">');
			document.writeln('<span Class="AdBoxLine1" ID="adv1_' + i + '_' + adsWrite.arguments[2] +'">' + adsText[iIx][1] + '</span><br>');
			document.writeln('<span Class="AdBoxLine2" ID="adv2_' + i + '_' + adsWrite.arguments[2] +'">' + adsText[iIx][2] + '</span><br>');
			document.writeln('<span Class="AdBoxLine3" ID="adv3_' + i + '_' + adsWrite.arguments[2] +'">' + adsText[iIx][3] + '</span>');
			if(adsText[iIx][4]!=0)document.writeln('&nbsp;<img border="0" src="' + imgCache[btnModeNormal].src + '" ID="advB_' + i + '_' + adsWrite.arguments[2] + '">');
		}
//Above Modified:  6-June-2010 for Image Ad support
		document.writeln('</a></td>');
	}

	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</div>');
	document.writeln('</td></tr></table>');
}
}

//Modified:  6-June-2010 for Image Ad support
function txtStatusSet(i,s){
	var strWk=document.getElementById('adUrl_' + i + '_' + s).href + '/';
	var iSt=strWk.indexOf('/dsplybox.html?');
	if(iSt>0)strWk=strWk.substr(iSt+15);
	if(strWk.indexOf('westchestertown')>0){
		window.status=strWk.substr(0,strWk.length-1);
	}else{
		if(strWk.indexOf('linksynergy')>0){
			window.status='Click for special offers!';
		}else{
			iSt=strWk.indexOf('/',10);
			window.status=strWk.substr(0,iSt);
		}
	}
}

function txtStatusClr(i,s){
	window.status="";
}
//Above Modified:  6-June-2010 for Image Ad support

function adStatusSet(i,s){
	var elm=document.getElementById("advB_" + i + "_" + s);
	if(elm!=null)elm.src=imgCache[btnModeHover].src;
	classChange(document.getElementById('adv1_' + i + '_' + s),"AdBoxLine1Hover");
	classChange(document.getElementById('adv3_' + i + '_' + s),"AdBoxLine3Hover");
//Modified:  6-June-2010 for Image Ad support
	txtStatusSet(i,s);
//Above Modified:  6-June-2010 for Image Ad support
}

function adStatusClr(i,s){
	var elm=document.getElementById("advB_" + i + "_" + s);
	if(elm!=null)elm.src=imgCache[btnModeNormal].src;
	classChange(document.getElementById('adv1_' + i + '_' + s),"AdBoxLine1");
	classChange(document.getElementById('adv3_' + i + '_' + s),"AdBoxLine3");
	window.status="";
}

function classChange(element,newclass) {
	element.className = newclass;
}

