﻿//browser detection
var strUserAgent = navigator.userAgent.toLowerCase();
var isIE = strUserAgent.indexOf("msie") > -1;

// Manage window.onload scripts
var onloadScripts = new Array();

function onloadProcess() {
    for (var i = 0; i < onloadScripts.length; i++) {
        eval(onloadScripts[i]);
    }
}

function onloadAdd(func) {
    onloadScripts[onloadScripts.length] = func;
}

// Add onload
window.onload = onloadProcess;

/* Mouse Overs */
function mouseover(o, imgsrc) {
    if (imgsrc) {
        o.firstChild.setAttribute("src", imgsrc);
    }
    else {
        if (o.firstChild.getAttribute("src").contains("-over.")) {
            o.firstChild.setAttribute("src", o.firstChild.getAttribute("src").replace("-over.", "."));
        }
        else {
            o.firstChild.setAttribute("src", o.firstChild.getAttribute("src").replace(".", "-over."));
        }
    }
}

// Contains
if (!String.prototype.contains) {
    String.prototype.contains = function(content) {
        return (this.indexOf(content) > -1);
    };
}

/* Project Focus */
onloadAdd("initialisefocus()");
var focus;
function initialisefocus() {
    // Create the list
    focus = new focuslist(document.getElementById("focus"), 10000);
}
var hb;
function initialisebanner() {
    // Create the list
    hb = new focuslist(document.getElementById("homebanner"), 5300);
}

function focuslist(l, s) {

    this.list = l;
    this.speed = s;
    this.current = this.list.getElementsByTagName("LI")[0];

    var self = this;
    function changefocustimed() {
        self.timeout = null;
        var ni = self.current.nextSibling;
        while (ni.tagName != "LI" && ni.nextSibling) {
            ni = ni.nextSibling;
        }
        if (ni.tagName != "LI") {
            ni = self.list.getElementsByTagName("LI")[0];
        }

        // hide the current product and show the new one
        self.current.className = "hidden";
        ni.className = "";
        // Set the current item
        self.current = ni;

        self.timeout = window.setTimeout(changefocustimed, self.speed);
    }

    this.timeout = window.setTimeout(changefocustimed, this.speed);
}

