// mazda NGW general javascript

// generic popup window allowing size to be set
function openWindow (url, winName, w, h, properties) {
    properties = properties || "resizable"
        LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
        settings =
        'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+','+ properties;
        newWindow = window.open(url,winName,settings);
        if(url.indexOf("://") == -1) newWindow.focus();
        top.newWindow = true;
}

// full screen popup window
function launchFullScreen(url, winName, properties) {
        properties = properties || "resizable"
        LeftPostion = 0;
        TopPosition = 0;
        settings = properties;
        newWindow = window.open(url,winName,settings);
        newWindow.moveTo(0,0);
        newWindow.resizeTo(screen.availWidth,screen.availHeight);
        newWindow.focus();
}

// footer scrolling under IE
if(navigator.appName.indexOf('Microsoft') >= 0) {
var scrollCur = document.documentElement.scrollTop;
window.onscroll = scrollFooter;

function scrollFooter() {
        var footer = document.getElementById('footer');
        var y = footer.offsetTop;
        var scroll = document.documentElement.scrollTop;
        var dy = scroll - scrollCur;

        footer.style.top = (y + dy) + "px";

        scrollCur = document.documentElement.scrollTop;
}
}

// Top navigation navigation
sfHover = function() {
        if (document.getElementById("nav") !== null) {
                var sfEls = document.getElementById("nav").getElementsByTagName("LI");
                for (var i = 0; i < sfEls.length; i++) {
                        sfEls[i].onmouseover = function() {
                                this.className += " sfhover";
                        }
                        sfEls[i].onmouseout = function() {
                                this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
                        }
                }
        }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);