// STEP 5

function Is() {
     var agent = navigator.userAgent.toLowerCase();
     this.major = parseInt(navigator.appVersion);
     this.minor = parseFloat(navigator.appVersion);
     this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
     this.ns2 = (this.ns && (this.major == 2));
     this.ns3 = (this.ns && (this.major == 3));
     this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
     this.ns4 = (this.ns && (this.major == 4));
     this.ns5 = (this.ns && (this.major >= 5));
     this.ie   = (agent.indexOf("msie") != -1);
     this.ie3  = (this.ie && (this.major == 2));
     this.ie4  = (this.ie && (this.major == 4));
     this.ie5  = (this.ie && (this.major == 5));
     this.ie6  = (this.ie && (this.major == 6));
     this.ie7  = (this.ie && (this.major == 7));
     this.ie8  = (this.ie && (this.major >= 8));
     this.op3 = (agent.indexOf("opera") != -1);
}

var is = new Is()

if(is.ie6) {
     doc = "document";
     sty = "";
     htm = ".document"
} else {
     doc = "document.all";
     sty = ".style";
     htm = ""
}

// STEP 6

var count = 0;

function preLoad() {
     tree = new Image();
     tree.onload = (is.ns6) ? loadCheck() : loadCheck;
     tree.src = "picbox/adhoc/tree.gif";

     river = new Image();
     river.onload = (is.ns6) ? loadCheck() : loadCheck;
     river.src = "picbox/adhoc/river.jpg";

     magic = new Image();
     magic.onload = (is.ns6) ? loadCheck() : loadCheck;
     magic.src = "picbox/adhoc/unclejoe.gif";
}

function loadCheck() {
     count++;
     if(count == 3) {
          layerSetup();
     }
}

// STEP 7

function layerSetup() {
     riverLyr = eval(doc + '["riverLayer"]' + sty);
     riverLyr.left = available_width-303;
     riverLyr.top = 323;

     treeLyr = eval(doc + '["treeLayer"]' + sty);
     treeLyr.left = available_width-214;
     treeLyr.top = 186;

     scrollLyr = eval(doc + '["scrollLayer"]' + sty);
     scrollLyr.left = 10;
     scrollLyr.top = 170;

     magicLyr = eval(doc + '["magicLayer"]' + sty);
     magicLyr.left = 10;
     magicLyr.top = available_height-90;

     visibilitySetup();
}

// STEP 8

function visibilitySetup() {
     riverLyr.visibility = "visible";
     treeLyr.visibility = "visible";
     scrollLyr.visibility = "visible";
     magicLyr.visibility = "visible";

     arraySetup();
}

// STEP 9

function arrayValues(msg, delay) {
     this.message = msg;
     this.delay = delay;
}

function arraySetup() {
     msgArray = new Array()
     msgArray[0] = new arrayValues("未来を予測する", 1500);
     msgArray[1] = new arrayValues("最善の方法は", 1000);
     msgArray[2] = new arrayValues("それを", 1500);
     msgArray[3] = new arrayValues("それを発明することだ", 1000);
     msgArray[4] = new arrayValues("", 1500);
     msgArray[5] = new arrayValues("Alan Kay", 1000);

     setTimeout("scrollingText()", 1000);

     setTimeout("subNewWin()", 11000);
}

// STEP 10

var message_index = 0;
var character = 1;
var character_speed = 50;

function scrollingText() {
     var scrollHTML = eval(doc + '["scrollLayer"]' + htm);

     if(message_index <= msgArray.length-1) {
          if(character <= msgArray[message_index].message.length) {
               var msg = '<TABLE BORDER="0" WIDTH="630"><TR><TD ALIGN=LEFT><FONT CLASS=text>' + msgArray[message_index].message.substring(0, character) + '</TD></TR></TABLE>';
               if(is.ns4) {
                    scrollHTML.write(msg);
                    scrollHTML.close();
               } else {
                    scrollHTML.innerHTML = msg;
               }
               setTimeout("scrollingText()",character_speed);
               character++;
          } else {
               character = 1;
               setTimeout("scrollingText()",msgArray[message_index].delay);
               message_index++;
          }
     }
}

// STEP 11

function subNewWin() {
     newWin = window.open("http://top.uncle-joe.net/","_self","");
}

