
Untitled
By: a guest on
May 13th, 2012 | syntax:
None | size: 1.81 KB | hits: 16 | expires: Never
function init()
{
var alt = new Array()
,banner = new Array()
,EXTENSION
,htmlImg = {}
,i
,idx
,myImg = {}
,PATH
,str
,url = new Array();
PATH = "images/";
EXTENSION = ".png";
banner = [
"test01"
,"test02"
,"test03"
,"test04"
,"test05"
,"test06"
,"test07"
,"test08"
,"test09"
,"test10"
];
alt = [
"test01"
,"test02"
,"test03"
,"test04"
,"test05"
,"test06"
,"test07"
,"test08"
,"test09"
,"test10"
];
url = [
"test01.html"
,"test02.html"
,"test03.html"
,"test04.html"
,"test05.html"
,"test06.html"
,"test07.html"
,"test08.html"
,"test09.html"
,"test10.html"
];
setTimeout("init()",4000);
for(i = 0; i < 3; i++)
{
idx = Math.floor(Math.random() * banner.length);
myImg[i] = new Image();
myImg[i].src = PATH + banner[idx] + "_on" + EXTENSION;
htmlImg[i] = document.getElementById("bn" + i);
htmlImg[i].setAttribute("src", PATH + banner[idx] + EXTENSION);
htmlImg[i].setAttribute("alt", alt[idx]);
htmlImg[i].setAttribute("onmouseout", "this.src='" + PATH + banner[idx] + EXTENSION + "';");
htmlImg[i].setAttribute("onmouseover", "this.src='" + myImg[i].src + "';");
htmlImg[i].parentNode.setAttribute("href", url[idx]);
delete banner[idx];
str = banner.join(",");
str = str.replace(/,,/, ",");
str = str.replace(/^,/, "");
str = str.replace(/,$/, "");
if(i != 2)
banner = str.split(",");
delete alt[idx];
str = alt.join(",");
str = str.replace(/,,/, ",");
str = str.replace(/^,/, "");
str = str.replace(/,$/, "");
if(i != 2)
alt = str.split(",");
delete url[idx];
str = url.join(",");
str = str.replace(/,,/, ",");
str = str.replace(/^,/, "");
str = str.replace(/,$/, "");
if(i != 2)
url = str.split(",");
}
}
try
{
window.addEventListener("load", init, false);
}
catch(e)
{
window.attachEvent("onload", init);
}