Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 13th, 2012  |  syntax: None  |  size: 1.81 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function init()
  2. {
  3.         var alt = new Array()
  4.         ,banner = new Array()
  5.         ,EXTENSION
  6.         ,htmlImg = {}
  7.         ,i
  8.         ,idx
  9.         ,myImg = {}
  10.         ,PATH
  11.         ,str
  12.         ,url = new Array();
  13.         PATH = "images/";
  14.         EXTENSION = ".png";
  15.         banner = [
  16.                 "test01"
  17.                 ,"test02"
  18.                 ,"test03"
  19.                 ,"test04"
  20.                 ,"test05"
  21.                 ,"test06"
  22.                 ,"test07"
  23.                 ,"test08"
  24.                 ,"test09"
  25.                 ,"test10"
  26.         ];
  27.         alt = [
  28.                 "test01"
  29.                 ,"test02"
  30.                 ,"test03"
  31.                 ,"test04"
  32.                 ,"test05"
  33.                 ,"test06"
  34.                 ,"test07"
  35.                 ,"test08"
  36.                 ,"test09"
  37.                 ,"test10"
  38.         ];
  39.         url = [
  40.                 "test01.html"
  41.                 ,"test02.html"
  42.                 ,"test03.html"
  43.                 ,"test04.html"
  44.                 ,"test05.html"
  45.                 ,"test06.html"
  46.                 ,"test07.html"
  47.                 ,"test08.html"
  48.                 ,"test09.html"
  49.                 ,"test10.html"
  50.         ];
  51.         setTimeout("init()",4000);
  52.         for(i = 0; i < 3; i++)
  53.         {
  54.                 idx = Math.floor(Math.random() * banner.length);
  55.                 myImg[i] = new Image();
  56.                 myImg[i].src = PATH + banner[idx] + "_on" + EXTENSION;
  57.                 htmlImg[i] = document.getElementById("bn" + i);
  58.                 htmlImg[i].setAttribute("src", PATH + banner[idx] + EXTENSION);
  59.                 htmlImg[i].setAttribute("alt", alt[idx]);
  60.                 htmlImg[i].setAttribute("onmouseout", "this.src='" + PATH + banner[idx] + EXTENSION + "';");
  61.                 htmlImg[i].setAttribute("onmouseover", "this.src='" + myImg[i].src + "';");
  62.                 htmlImg[i].parentNode.setAttribute("href", url[idx]);
  63.                 delete banner[idx];
  64.                 str = banner.join(",");
  65.                 str = str.replace(/,,/, ",");
  66.                 str = str.replace(/^,/, "");
  67.                 str = str.replace(/,$/, "");
  68.                 if(i != 2)
  69.                         banner = str.split(",");
  70.                         delete alt[idx];
  71.                 str = alt.join(",");
  72.                 str = str.replace(/,,/, ",");
  73.                 str = str.replace(/^,/, "");
  74.                 str = str.replace(/,$/, "");
  75.                 if(i != 2)
  76.                         alt = str.split(",");
  77.                 delete url[idx];
  78.                 str = url.join(",");
  79.                 str = str.replace(/,,/, ",");
  80.                 str = str.replace(/^,/, "");
  81.                 str = str.replace(/,$/, "");
  82.                 if(i != 2)
  83.                         url = str.split(",");
  84.         }
  85. }
  86. try
  87. {
  88.         window.addEventListener("load", init, false);
  89. }
  90. catch(e)
  91. {
  92.         window.attachEvent("onload", init);
  93. }