﻿var bannerId = 1;
var bstickyMenu = false;
var stickyMenuId = 0;
var islideInterval = 0;
var slideshowOn = false;

function bannerMenu(id) {
    bannerId = id;
    switch (id) {
        case 1: document.getElementById('i1').src = 'graphics/banner/button-residential-sales-on.jpg';
            document.getElementById('i2').src = 'graphics/banner/button-commercial-sales.jpg';
            document.getElementById('i3').src = 'graphics/banner/button-web-design.jpg';
            document.getElementById('i4').src = 'graphics/banner/button-social-media-marketing.jpg';
            break;
        case 2: document.getElementById('i2').src = 'graphics/banner/button-commercial-sales-on.jpg';
            document.getElementById('i1').src = 'graphics/banner/button-residential-sales.jpg';
            document.getElementById('i3').src = 'graphics/banner/button-web-design.jpg';
            document.getElementById('i4').src = 'graphics/banner/button-social-media-marketing.jpg';
            break;
        case 3: document.getElementById('i3').src = 'graphics/banner/button-web-design-on.jpg';
            document.getElementById('i2').src = 'graphics/banner/button-commercial-sales.jpg';
            document.getElementById('i1').src = 'graphics/banner/button-residential-sales.jpg';
            document.getElementById('i4').src = 'graphics/banner/button-social-media-marketing.jpg';
            break;
        case 4: document.getElementById('i4').src = 'graphics/banner/button-social-media-marketing-on.jpg';
            document.getElementById('i2').src = 'graphics/banner/button-commercial-sales.jpg';
            document.getElementById('i3').src = 'graphics/banner/button-web-design.jpg';
            document.getElementById('i1').src = 'graphics/banner/button-residential-sales.jpg';
            break;
    }

    if (document.getElementById('ci0').src != document.getElementById('c' + id).src) $('#ci0').hide();
    document.getElementById('ci0').src = document.getElementById('c' + id).src;

    document.getElementById('a0').href = document.getElementById('a' + id).href;
    document.getElementById('a0').title = document.getElementById('a' + id).title;

    $('#ci0').fadeIn();
}

function pauseSlideshow() {
    if (slideshowOn == true) window.clearInterval(islideInterval)
}

function restartSlideshow() {
    if (slideshowOn == true) islideInterval = window.setInterval('slideshow()', 5000);
    if (bstickyMenu == true) bannerMenu(stickyMenuId);
}

function stickyMenu(id) {
    bstickyMenu = true;
    stickyMenuId = id;
    bannerMenu(id);
}

function slideshow() {
    slideshowOn = true;
    if (bannerId < 4)
        bannerId = bannerId + 1
    else
        bannerId = 1;
    bannerMenu(bannerId);
}

function screenwidth() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return myWidth;
}

function toggleElem(elemName) {
    var elem = document.getElementById(elemName);
    if (elem.style.display == '')
        elem.style.display = 'none'
    else
        elem.style.display = '';
}
