// JavaScript Document
var alltags = document.getElementsByTagName('*');
var galores = new Array();
var gdivs = new Array();
var gimgs = new Array();
numimgs = 8;


//Identifies all elems with class 'galore'. Should be the container elements: divs or paras
for (i in alltags) {if (alltags[i].className == 'galore') galores.push(alltags[i]);}
//Puts first image in each 'galore' into the gimgs array.
for (i in galores) {gimgs.push(galores[i].getElementsByTagName('img')[0]);}

//Randomize images
var galoreset = document.getElementById('galoreset').className; //The element with id 'galoreset' has a class defined in the document to tell this script which set of images to use.
for (i in gimgs) {
	var rand = Math.ceil(Math.random()*numimgs);
	gimgs[i].src = '/images/vg/galore/'+galoreset+'_'+rand+'.png';
}

//Randomize placement
for (i in galores) {
	var rand = Math.floor(Math.random()*51);
	galores[i].style.marginLeft = rand+'px';
	var rand = Math.floor(Math.random()*21)-21;
	galores[i].style.marginTop = rand+'px';
}



