﻿
function GetClientHeight() {
    var clientHeight = 0;

    if (typeof (window.innerHeight) == 'number') {
        //Non-IE
        clientHeight = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        //IE 6+ in 'standards compliant mode'
        clientHeight = document.documentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        //IE 4 compatible
        clientHeight = document.body.clientHeight;
    }

    return clientHeight;
}

function GetClientWidth() {
    var clientWidth = 0;

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        clientWidth = window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        //IE 6+ in 'standards compliant mode'
        clientWidth = document.documentElement.clientWidth;
    } else if (document.body && document.body.clientWidth) {
        //IE 4 compatible
        clientWidth = document.body.clientWidth;
    }

    return clientWidth;
}

function GetScrollTop() {
    var scrollTop = document.body.scrollTop;

    if (scrollTop == 0) {
        if (window.pageYOffset)
            scrollTop = window.pageYOffset;
        else
            scrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }

    return scrollTop
}

function GetElement(elemID) {
    var elem;

    if (document.getElementById)
        elem = document.getElementById(elemID);
    else if (document.all)
        elem = document.all[elemID];
    else if (document.layers)
        elem = document.layers[elemID];

    return elem;
}

function SetOpacity(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;

    // Object should be visible before setting opacity (for IE8)

    // IE/Win
    obj.style.filter = "alpha(opacity:" + opacity + ")";
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity / 100;
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity / 100;
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity / 100;
}

function openimage(URL, name, width, height) {
    aWindow = window.open(URL, /*name*/'', "toolbar=no,width=" + (width + 20) + ",height=" + (height + 30) + ",status=0,scrollbars=0,resize=0,menubar=0,statusbar=0");
}

function SetTabImages(selectedtab) {
    if (!document) return;

    var tabs = ["HOMETAB", "VANSTAB", "THINGSTAB", "HIREPRICESTAB", "FERRYPRICESTAB", "TOURINGTAB", "INSURANCETAB", "BUYTAB", "FERRYTAB", "SITEPLANTAB", "FINDUSTAB", "DOWNLOADSTAB"];

    var images = ["graphics/bluehome.gif", "graphics/bluethevans.gif", "graphics/bluethingstodo.gif", "graphics/bluehireprices.gif",
                   "graphics/blueferryprices.gif", "graphics/bluetouring.gif", "graphics/blueinsurance.gif", "graphics/bluebuyavan.gif",
                   "graphics/blueferryinfo.gif", "graphics/bluesiteplan.gif", "graphics/bluefindus.gif", "graphics/bluedownloads.gif"];

    if (tabs.length != images.length) return;

    for (i = 0; i < tabs.length; i++) {
        var element = document.getElementById(tabs[i]);
        if (element) element.src = images[i];
    }

    if (document.getElementById(selectedtab)) {
        var element = document.getElementById(selectedtab);

        if (element) {
            var i = element.src.indexOf("blue");

            if (i > 0) {
                element.src = "graphics/grey" + element.src.substring(i + 4, element.src.length);
            }
        }
    }
}
