imagesToPreload.push('http://amazingdiscoveries.org/assets/templates/AD02/img/header/breadcrumbs/home_hover.png');
imagesToPreload.push('http://amazingdiscoveries.org/assets/templates/AD02/img/header/breadcrumbs/arr_down_hover.png');

function Breadcrumbs() {
    this.HIDE_TIME = 300;
    this.hideTimer = new Array();
}

Breadcrumbs.prototype.showSubMenu = function(domObj, menuId) {
    for(var i = 1; i <= jQuery('.document-breadcrumbs-level1').children().size(); i++) {
        if(i == menuId) continue;
        bc.hideSubMenuImmediately(i);
    }
    clearTimeout(bc.hideTimer[menuId]);

    var currentElement = jQuery('#document-breadcrumbs-level2-menu'+menuId);
    var parentElementPosition = jQuery(domObj).position();

    currentElement.css('left', parentElementPosition.left-20);
    currentElement.css('top', parentElementPosition.top+36);

    if(jQuery.browser.msie) { currentElement.show(); }
    else { currentElement.slideDown(100); }
}

Breadcrumbs.prototype.sustainSubMenu = function(menuId) {
    clearTimeout(bc.hideTimer[menuId]);
}

Breadcrumbs.prototype.hideSubMenuImmediately = function(menuId) {
    jQuery('#document-breadcrumbs-level2-menu'+menuId).hide(0);
}

Breadcrumbs.prototype.hideSubMenu = function(menuId) {
    bc.hideTimer[menuId] = setTimeout("bc.hideSubMenuImmediately("+menuId+")", bc.HIDE_TIME);
}

var bc = new Breadcrumbs();
