// 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]	="itris_banner.gif";
links[4]	="http://www.itecsystems.com/?r=ukr";
alts[4]		="ITRIS"


adImages[5]	="mypeoplebiz_homepage.gif";
links[5]	="http://www.mypeoplebiz.com";
alts[5]		="mypeoplebiz"


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]	="Jobrapido_152x40.gif";
links[8]	="http://www.jobrapido.co.uk/info/business-campaigns?campaign=blog201005&source=ukrecruiter.com/home-page-banner";
alts[8]		="Jobrapido"

adImages[9]	="antal_homebanner.gif";
links[9]	="http://www.ventures.antal.com";
alts[9]		="Antal"

adImages[10]    ="darwin_homepage.gif";
links[10]	="http://www.darwin.com";
alts[10]	="Darwin"

adImages[11]    ="changeboard_homepage.gif";
links[11]	="http://www.ukrecruiter.co.uk/jobs/index.htm";
alts[11]	="UKRecruiter Jobs"
// ********* 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)
}
