
// javascript for ads
// file: rotated_ads.js
// called from any or all softwareqatest.com pages
// copyright 2011 Digital Media Group Inc. 
//=============== ===============
// Setup for anywhere from 1 to 5 ads
MaxAds = 5;

Ad1 = 0;
Ad2 = 1;
Ad3 = 2;
Ad4 = 3;
Ad5 = 4;

//=============== ===============

var Ad = new Array(MaxAds);
//Note: Ad 'length' now = 5;  Ad[0], Ad[1], etc each with value of NULL

var AdHTMLcode = new Array(MaxAds);


//=============== ===============

// Set up an array for holding lines of HTML code for each ad (up to
// MaxAds # of ads, set above) allowing up to 20 lines of HTML code 
// for each ad, which should be more than enough lines in all cases
var CounterA = 0;
var CounterB = 0;
for(CounterA = 0; CounterA < MaxAds; CounterA++)
{
	Ad[CounterA] = new Array;
  	for (CounterB = 0; CounterB < 20; CounterB++)
  	{
  		Ad[CounterA][CounterB] = "";
  	}
}

// enumerate these values as a reminder of numbering details.
Line1 = 0;
Line2 = 1;
Line3 = 2;
Line4 = 3;
Line5 = 4;
Line6 = 5;
Line7 = 6;
Line8 = 7;
Line9 = 8;
Line10 = 9;
Line11 = 10;
Line12 = 11;
Line13 = 12;
Line14 = 13;
Line15 = 14;
Line16 = 15;
Line17 = 16;
Line18 = 17;
Line19 = 18;
Line20 = 19;

//=============== =============== 
//Setup templates for 5 ads and fill in as needed
//Any lines not specified here are defaulted
//as having only a single-space value - set previously 
// NOTE - NEED \ in front of "quote" chars
//===================== ==================


//------- Start Ad1 ----------
Ad[Ad1][Line1] = '';
Ad[Ad1][Line2] = '<A href=\"redirect_ad_wapt.html\"><img src=\"wapt-125x125-v2.gif\" alt="WAPT Ad"></A>';
Ad[Ad1][Line3] = '<p>';
//------- End Ad1 ----------	


//------- Start Ad2 ----------
Ad[Ad2][Line1] = '';
Ad[Ad2][Line2] = '';
Ad[Ad2][Line3] = '<p>';

//------- End Ad2 ----------

//------- Start Ad3 ----------
Ad[Ad3][Line1] = '';
Ad[Ad3][Line2] = '';
Ad[Ad3][Line3] = '<p>';
//------- End Ad3 ----------

//------- Start Ad4 ----------
Ad[Ad4][Line1] = '';
Ad[Ad4][Line2] = '';
Ad[Ad4][Line3] = '<p>';
//------- End Ad4 ----------





//=============== =============== 


// These next few lines will concatenate the lines 
// for each ad into 1 string, with spaces between each line.
// ?unclear if this might cause memory problems??
// old browsers mentioned 256 char limit as best...?

CounterA = 0;
for (CounterA = 0; CounterA < MaxAds; CounterA++)
{
	AdHTMLcode[CounterA] = Ad[CounterA].join("");
}


// Count  number of Ads (those not blank)
var NumOfAds = 0;
while( NumOfAds < MaxAds  &&  AdHTMLcode[NumOfAds] != "")
{
	NumOfAds++;
}


// Set up a random start Ad 

var now = new Date();
var sec = now.getSeconds();
var StartingAdNum = sec % NumOfAds;
StartingAdNum +=1;

CounterA = 1;
AdToSend = StartingAdNum;


while (CounterA <= NumOfAds)
{
	document.write(AdHTMLcode[AdToSend - 1]);
	CounterA++;
	AdToSend++;
	if (AdToSend > NumOfAds)
	{
		AdToSend = 1;
	}
}

// End of rotated_ads.js 
// =============================== ==========================
// =============================== ==========================


