// JavaScript Document
// To add random advert positioning to a page
// A. add this file to comps folder on web site and link it into the desired page
// B. place the following code in script blocks where each banner advert is to appear
//		generateBanner(n)
// 		where n takes the values 0,1,2, etc
// C. Take the following 4 steps

// ********* step 1 - specify number of image slots named advert1, advert2, etc
noImages = 12

// ********* step 2 - specify the the number of images to be anchored in the first few slots
fixedImages = 0;

adImages = new Array(noImages); //image file names, stored in images folder
links= new Array (noImages);	//links to advertisers sites
alts = new Array(noImages);	//contents on alt attribute of img tag

advertUsed= new Array (noImages);  	//enry n contains a poiner to the entries of the above arrays
									// which relate to img with name advertn

// ********* step 3 assign banner filename, url and alt to each loacation in the table
// fixed adverts must be specified first

adImages[0]	="recruitstudio_homebanner.gif";
links[0]	="http://www.recruitstudio.co.uk";
alts[0]		="Recruit Studio"


adImages[1]	="TriSys_ban.gif";
links[1]	="http://www.trisys.biz/adresponse.aspx?Action=UKRecruiter";
alts[1]		="Trisys"


adImages[2]	="rdbpronet_152x40.gif";
links[2]	="http://www.rdbpro.co.uk";
alts[2]		="RDB ProNet"


adImages[3]	="microdecbanner.gif";
links[3]	="http://www.microdec-profile.com";
alts[3]		="Microdec"


adImages[4]	="assessday_152-40.gif";
links[4]	="http://www.assessmentday.co.uk/aff.htm";
alts[4]		="assessment day"


adImages[5]	="zoho_banner.gif";
links[5]	="http://www.zoho.com/recruit/lp/online-recruitment-software.html?utm_source=ukrecruiter.com&utm_medium=152x40ban&utm_campaign=product";
alts[5]		="Zoho"


adImages[6]	="EployBanner.gif";
links[6]	="http://www.itssystems.co.uk";
alts[6]		="eploy Recruitment Software"


adImages[7]	="ARC_banner.GIF";
links[7]	="http://www.arc-org.net";
alts[7]		="ARC"

adImages[8]	="advhere_ban.gif";
links[8]	="http://www.ukrecruiter.co.uk/contact.htm";
alts[8]		="ukrecruiter"

adImages[9]	="antal_homebanner.gif";
links[9]	="http://www.ventures.antal.com";
alts[9]		="Antal"

adImages[10]	="evolve_banner.gif";
links[10]	="http://www.evolvedb.co.uk/features-and-benefits/evolve-recruitment-software-features-benefits-and-solutions-overview";
alts[10]		="Evolve"

adImages[11]	="engauge_banner.gif";
links[11]	="http://www.e-ngauge.com";
alts[11]		="e-nguage"


// ********* step 4 specify image location from root of web site
imageLocation="images/"

//set up fixed advert positions in advertUsed
for (i=0; i<fixedImages; i++) {
	advertUsed[i]=i;
}
// choose random floating advert to appear in first available slot
floatingImages=noImages-fixedImages;
position=Math.floor(Math.random()*floatingImages)+fixedImages; //floating image that will appear first

//set up flaoting advert positions in advertUsed
j=0
while (j<floatingImages){
	advertUsed[fixedImages+j]=position;
	j++;
	position++;
	if (position>=noImages) position=fixedImages;
}

// create an entry of the form:
//		<a href="http://www.mkh.co.uk">
//      <img border="0" src="images/mkh_hmban.gif" width="152" height="40" name="advert2"></a>
function generateBanner(position){
	advertNo=advertUsed[position]
	aStartTag	= '<a href="' + links[advertNo] + '">'
	imgTag 		= '<img border="0" src="' + imageLocation + adImages[advertNo] 
					+ '" width="152" height="40" alt="' + alts[advertNo] + '">'
	aEndTag		=	'</a>'
	document.write (aStartTag)
	document.write (imgTag + aEndTag)
}

