/////////////////////////////////////////////////////
//                                                 //
//  SECTION 5: BROWSER SNIFFER & DOMS              //
//  ---------------------------------------------  //
//  Document Object switch routine use to          //
//  maintain cross-browser compatibility.          //
//                                                 //
/////////////////////////////////////////////////////


// BROWSER SNIFFER (Sniff out the good and bad browsers)

function Is() {
 
       if (document.getElementById)
         {this.nav6up = ('nav6up')}
       if (document.all)
         {this.ie4up = ('ie4up')}
}

var is = new Is();
  
function onerror() {
    document.location.href = "javascript:";
}

// DOCUMENT OBJECT SWITCH (Used for building cross_browser functions)

 if(is.ie4) {
    doc = "document.all";
    sty = ".style";
    htm = ""
} else  {
    doc = "document.all";
    sty = ".style";
    htm = ""
}

/////////////////////////////////////////////////////
//                                                 //
//  SECTION 6: PRELOADING                          //
//  ---------------------------------------------  //
//  Preload images memory for realtime animation.  //
//                                                 //
/////////////////////////////////////////////////////

var count = 0;

function preLoad() {
    button_up = new Image();
    button_up.onload = loadCheck;
    button_up.src = "images/button_up.gif";

    button_dn = new Image();
    button_dn.onload = loadCheck;
    button_dn.src = "images/button_dn.gif";

    pipes1 = new Image();
    pipes1.onload = loadCheck;
    pipes1.src = "images/hu_logo0.gif";

    tall2 = new Image();
    tall2.onload = loadCheck;
    tall2.src = "images/tall2.jpg";

    tall4 = new Image();
    tall4.onload = loadCheck;
    tall4.src = "images/tall4.jpg";

    bartxxx = new Image();
    bartxxx.onload = loadCheck;
    bartxxx.src = "images/bartxxx.gif";

}

function loadCheck() {
    count++;
    if(count == 6) {
        var status = eval(doc + '["msgLyr"]' + sty);
        status.visibility = "hidden";
        positionLayers();
    } else {
        var status = eval(doc + '["msgLyr"]' + htm);
        var msg = '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=300><TR><TD WIDTH=' + Math.round((count/6)*100) + '% BGCOLOR=#FF0000 ALIGN=RIGHT>' + '<FONT class="status">' + Math.round((count/6)*100) + '%</FONT>' +'</TD><TD BGCOLOR=#800000 VALIGN=MIDDLE>&nbsp;</TD></TR><TR><TD COLSPAN=2 ALIGN=CENTER><FONT class="main">Percent Images Loaded</FONT></TD></TR></TABLE>';
        if(is.ie4up) { 
            status.innerHTML = msg; 
        } else if(is.nav6up) {
	      document.open(); 
            document.write(msg);
	      document.close(); 
        } 
    }
}

/////////////////////////////////////////////////////
//                                                 //
//  SECTION 7: POSITIONING                         //
//  ---------------------------------------------  //
//  Build layer objects then position using        //
//  screen width and height dimensions, then       //
//  turn on layer visibility.                      //
//                                                 //
/////////////////////////////////////////////////////

function positionLayers() {
    buttonImg = eval(doc + '["menuLyr"]' + '.document');
    menuObj = eval(doc + '["menuLyr"]' + sty);
    menuObj.left = 8;
    menuObj.top = 0;

    sunObj = eval(doc + '["sunLyr"]' + sty);
    sunObj.left = 30;
    sunObj.top = 460;
     
    homeObj = eval(doc + '["homeLyr"]' + sty);
    homeObj.left = 190;
    homeObj.top = 10;

    blogObj = eval(doc + '["blogLyr"]' + sty);
    blogObj.left = 190;
    blogObj.top = 10;

    linksObj = eval(doc + '["linksLyr"]' + sty);
    linksObj.left = 190;
    linksObj.top = 10;

    touringObj = eval(doc + '["touringLyr"]' + sty);
    touringObj.left = 190;
    touringObj.top = 10;

    ripoffObj = eval(doc + '["ripoffLyr"]' + sty);
    ripoffObj.left = 190;
    ripoffObj.top = 10;

    gearObj = eval(doc + '["gearLyr"]' + sty);
    gearObj.left = 190;
    gearObj.top = 10;

    wheelsObj = eval(doc + '["wheelsLyr"]' + sty);
    wheelsObj.left = 190;
    wheelsObj.top = 10;

    funObj = eval(doc + '["funLyr"]' + sty);
    funObj.left = 190;
    funObj.top = 10;

    modObj = eval(doc + '["modLyr"]' + sty);
    modObj.left = 190;
    modObj.top = 10;

    arrowObj = eval(doc + '["arrowLyr"]' + sty);
    arrowObj.left = available_width-40;
    arrowObj.top = 100;

    sunObj.visibility = "visible";
    menuObj.visibility = "visible";
    arrowObj.visibility = "visible";
     
    menuToggle('home');
    buttonOver('home');
}


/////////////////////////////////////////////////////
//                                                 //
//  SECTION 8: ANIMATION (Image Data Array)        //
//  ---------------------------------------------  //
//  Create data array for random layer and image   //
//  animation.                                     //
//   DELETED                                              //
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
//                                                 //
//  SECTION 9: INTERACTIVITY (Menu Selector)       //
//  ---------------------------------------------  //
//  Techniques for toggling and selecting buttons  //
//  then displaying the selected page while hiding //
//  previous page.                                 //
//                                                 //
/////////////////////////////////////////////////////

var menu_selection = "home";

function buttonOver(selection,pos) {
    if(menu_selection != selection) {
        buttonImg[selection].src = button_dn.src;
    }
}

function buttonOut(selection) {
    if(menu_selection != selection) {
        buttonImg[selection].src = button_up.src;
    }
}

function menuToggle(selection) {
    buttonImg[menu_selection].src = button_up.src;
    buttonImg[selection].src = button_dn.src;

    var old_page = eval(menu_selection + "Obj");
    old_page.visibility = "hidden";

    var new_page = eval(selection + "Obj");
    new_page.visibility = "visible";

    sunObj.left = 0;

    menu_selection = selection;

}

/////////////////////////////////////////////////////
//                                                 //
//  SECTION 9: INTERACTIVITY (Page Scroller)       //
//  ---------------------------------------------  //
//  Layer animation technique for srolling page.   //
//                                                 //
/////////////////////////////////////////////////////

var loop = true;
var direction = "up";
var speed = 10;
var timer1 = null;

function scroll(dir,spd) {
    direction = dir;
    speed = spd;
    var page = eval(menu_selection + "Obj");
    var y_pos = parseInt(page.top);
    var x_pos = parseInt(sunObj.left);
    if(loop == true) {
        if(direction == "dn") {
            page.top = (y_pos-(speed));
            if(x_pos < available_width) {
                sunObj.left = x_pos + 1;
            } else {
                sunObj.left = -100;
            }
            clearTimeout(timer1);
            timer1 = setTimeout("scroll(direction,speed)", 1);
        } else if(direction == "up" && y_pos < 10) {
            page.top = (y_pos+(speed));
            if(x_pos > -100) {
                sunObj.left = x_pos - 1;
            } else {
                sunObj.left = available_width;
            }
            clearTimeout(timer1);
            timer1 = setTimeout("scroll(direction,speed)", 1);
        } else if(direction == "top") {
            page.top = 10;
            sunObj.left = 0;
        }
    }
}

