﻿//=======================================================
//=======================================================
$(document).ready(function() {
    $('.title').css('color',$('.breadcrumbs').css('backgroundColor'));
});

//=======================================================
//=======================================================
function gotoTab(anchor) {
    $('a[name="' + anchor + '"] ~ div').click();
}

//=======================================================
//=======================================================
function setBubbles_sm() {
    //click events
    $(".bubble_sm > div").click(function() {
        // clear other selected classes
        if (getSelectedBubbles().get(0)) {
            getSelectedBubbles().attr("class", getSelectedBubbles().attr("class").replace("s", ""));
        }

        $(".details").css("display", "none");
        var $p = $(this).parent();
        $(".details:eq(" + $p.parent().children().index($p) + ")").css("display", "inline");

        $(this).attr('class', $(this).attr('class') + 's');

        $(".bubble_sm").css('zIndex', 0);
        $(this).parent().css('zIndex', 1);
        getBubbles().css('backgroundPosition', '0px 0px');
    });

    //mouse overs
    getBubbles().hover(
        function() {
            hoverOn_sm(this);
        },
        function() {
            hoverOff_sm(this);
        }
    );
}

//=======================================================
//=======================================================
function hoverOn_sm(obj) {
    $(obj).css('backgroundPosition', '0px -61px');
    $(obj).parents(".bubble_sm").css('zIndex', 2);
    $(obj).css('cursor', 'pointer');
}

//=======================================================
//=======================================================
function hoverOff_sm(obj) {
    if ($(obj).attr('class').indexOf('s') == -1) {
        $(obj).css('backgroundPosition', '0px 0px');
        $(obj).parents(".bubble_sm").css('zIndex', 0);
    } else {
        $(obj).css('backgroundPosition', '0px -122px');
        $(obj).parents(".bubble_sm").css('zIndex', 1);
    }
}

//=======================================================
//=======================================================
function anchorNav(defaultTab) {
    var u = document.location.toString();
    if (u.match('#')) { // the URL contains an anchor
        // click the navigation item corresponding to the anchor
        var myAnchor = u.split('#')[1];
        if (myAnchor.match('.')) {
            var parts = myAnchor.split('.');
            $('a[name="' + parts[0] + '"] ~ div').click();
            window.location = '#' + myAnchor;
        } else {
            $('a[name="' + myAnchor + '"] ~ div').click();
        }
    } else {
        if (defaultTab >= 0) {
            $('.bubbles .bubble_sm:eq(' + defaultTab + ') div').click();
            $('.bubbles .bubble:eq(' + defaultTab + ') div').click();
        }
    }
}

//=======================================================
//=======================================================
function getBubbles() {
    return $('.bubbles div').filter(function() { return $(this).attr('class').match(/^[t|g|b|p][l|r]?$/); });
}

//=======================================================
//=======================================================
function getSelectedBubbles() {
    return $('.bubbles div').filter(function() { return $(this).attr('class').match(/^[t|b|g|p][l|r]?[s]/); });
}

