var pictures = new Array();
pictures[0] = {img: "images/pictures/BEDROOM2.jpg", url: "#"};
pictures[1] = {img: "images/pictures/BEDROOM.jpg", url: "#"};
pictures[2] = {img: "images/pictures/FAMILY.jpg", url: "#"};
pictures[3] = {img: "images/pictures/MOVING.jpg", url: "#"};
pictures[4] = {img: "images/pictures/TEA.jpg", url: "#"};
pictures[5] = {img: "images/pictures/EASTBOURNE1.jpg", url: "#"};
pictures[6] = {img: "images/pictures/EASTBOURNE2.jpg", url: "#"};
pictures[7] = {img: "images/pictures/EASTBOURNE3.jpg", url: "#"};
pictures[8] = {img: "images/pictures/EASTBOURNE4.jpg", url: "#"};
pictures[9] = {img: "images/pictures/EASTBOURNE5.jpg", url: "#"};
pictures[10] = {img: "images/pictures/EASTBOURNE6.jpg", url: "#"};
pictures[11] = {img: "images/pictures/EASTBOURNE7.jpg", url: "#"};
pictures[12] = {img: "images/pictures/EASTBOURNE8.jpg", url: "#"};


// number of pictures to show on the page
var numAds = 3;

// id prefix for <img> and <a> tags
var img_prefix = "adImg";
var a_prefix = "adLink";

// this will be used to stop us showing the same ad more than once on the same page
var chosenAds = new Array();

// ------------------------------------------------
// choose which ads to show
function choosePics()
{
	for(var i = 1; i <= numAds; i++)
	{
	
		var randNum = -1;
		while(randNum == -1 || alreadyPicked(randNum)) randNum = Math.floor ((Math.random() * pictures.length));


		var img = document.getElementById(img_prefix + i);
		if(! img) continue;
		var a = document.getElementById(a_prefix + i);
		if(! a) continue;

		chosenAds.push(randNum);

		img.src = pictures[randNum].img;
		a.href = pictures[randNum].url;
	}
}


// ------------------------------------------------
// has this advert already been picked to show?
function alreadyPicked(num)
{
	for(var i in chosenAds) if(num == chosenAds[i]) return true;

	return false;
}