var linksNumber=11; /* This is the number of links to be shown and matches the HTML */

var myimages=[ 
'images/JanDahl.jpg','images/LanceRampy.jpg', 
'images/MelissaSchwartz.jpg','images/MurraySullivan.jpg', 
'images/NicolasYale.jpg','images/PaigeWhitney.jpg', 
'images/RichardPlummer.jpg','images/ShawnHertzog.jpg', 
'images/SteveDonovan.jpg','images/JermeySchachter.jpg'];

var imagelinks=[ 
'http://www.jandahlphoenix.com','http://www.marketpoint1.com', 
'http://www.azhomesforsalenow.com','http://www.gayazinsurer.com', 
'http://www.nicholasyale.com','http://www.paigewhitney.com', 
'http://www.guaranteedrate.com/richardplummer','http://www.azrelocationteam.com', 
'http://www.donovanaz.com','http://www.76mortgage.com'
];

var ary0=[]; 
var ary1=[]; 
var k=0 
var c,n;

function randomImgdisplay() {

for(c=0;c<myimages.length;c++) { 
ary0[c]=c; /* Pre-populate 'ary0' with numbers 0 to 11 */ 
} 

while(ary0.length>0) {

n=Math.floor(Math.random()*ary0.length); /* Get a random 'ary0' index number */ 
ary1[k]=ary0[n]; /* Add 'ary0' value to 'ary1' */ 
k++; 
ary0.splice(n,1); /* Remove that element from the 'ary0'. The array gets shorter with each iteration */

}

for(c=0;c<linksNumber;c++){ 
document.getElementById('pic'+c).src=myimages[ary1[c]]; /* replace the image positions */ 
document.getElementById('lnk'+c).href=imagelinks[ary1[c]]; /* replace the link positions */

document.getElementById('pic'+c).alt=myimages[ary1[c]]; /* this is for testing, and maybe removed */

}

}

if(window.addEventListener){ 
window.addEventListener('load',randomImgdisplay,false); 
} 
else { 
if(window.attachEvent){ 
window.attachEvent('onload',randomImgdisplay); 
} 
}
