// ie 5.5 through 6 need alpha correction for transparent pngs
var needAlphaCorrection = is_ie5 || is_ie6;

//sets the image to its Hover/rolled over value
function hoverImage(link) {
    if (needAlphaCorrection){
        link.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").Src=link.firstChild.src.replace('.png','Hover.png');
    }
    link.firstChild.src = link.firstChild.src.replace('.png','Hover.png');
}

// sets the image to its default value
function defaultImage(link) {
    if (needAlphaCorrection) {
        link.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").Src=link.firstChild.src.replace('Hover.png','.png');
    }
    link.firstChild.src = link.firstChild.src.replace('Hover.png','.png');
}
// sets the value (true or false) of the remeber choice checkbox to a parameter in the href attribute of link
function setRememberSite(link) {
    // if there is no other parameter attached to this href, add a '?' before we add one, other wise add an '&'
    var divider = ( link.href.indexOf("?") == -1) ? "?" : "&";
    var remember = document.getElementById("rememberChoice").checked;
    link.href = link.href + divider + "rememberSite=" + remember;
}

// initialize buttons to use rollover images
function initButtons() {
    var buttons = document.getElementsByClassName("button");
    for(var i=0;i<buttons.length;i++) {
        buttons[i].onmouseover  = function() { hoverImage(this); }
        buttons[i].onmouseout   = function() { defaultImage(this); }
    }
}

// initialize links to add the rememberSite property to href
function initLinks() {
    var links = document.getElementsByTagName("a");
    for(var i=0;i<links.length;i++) {
        links[i].onclick = function() { setRememberSite(this); }
    }
}

// allows us to execute multiple funtions at load time
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

// set init funtions to execute when the page loads
addLoadEvent(initButtons);
addLoadEvent(initLinks );