/* Homepage Bilder wechseln */

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

var myimages=[
'/files/home1.jpg','/files/home2.jpg',
'/files/home3.jpg','/files/home4.jpg',
'/files/home5.jpg','/files/home6.jpg',
'/files/home7.jpg','/files/home8.jpg',
'/files/home9.jpg','/files/home10.jpg',
'/files/home11.jpg','/files/home12.jpg',
'/files/home13.jpg','/files/home14.jpg',
'/files/home15.jpg','/files/home16.jpg',
'/files/home17.jpg','/files/home18.jpg',
'/files/home20.jpg',
'/files/home21.jpg','/files/home22.jpg',
'/files/home23.jpg','/files/home24.jpg',
'/files/home25.jpg'
];

var imagelinks=[
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2','index.php?article_id=2',
'index.php?article_id=2'
]

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 number of images */
}

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);
}
}
