imagesToPreload.push('http://amazingdiscoveries.org/assets/templates/AD02/img/icons/close.png');
imagesToPreload.push('http://amazingdiscoveries.org/assets/templates/AD02/img/sidebars/section_explore_bg.png');

function ExploreSections() {
    this.HIDE_TIME = 300;
    this.SUSTAIN_TIME = 250;
    this.timer = null;
}

ExploreSections.prototype.activateMenuItem = function(id) {
    es.deactivateMenuItem();
    jQuery('#explore-sections-item'+id).addClass('explore-sections-item-active');
}

ExploreSections.prototype.deactivateMenuItem = function() {
    jQuery('.explore-sections-item-active').removeClass('explore-sections-item-active');
}

ExploreSections.prototype.showSection = function(id) {
    clearTimeout(es.timer);
    jQuery('#document-content-explore-sections-content').html(jQuery('#explore-sections-content-item'+id).html());
    jQuery('#document-content-explore-sections-close-bar-title').html(jQuery('#explore-sections-item'+id).html());
    jQuery('#document-content-explore-sections').show(0);
    es.activateMenuItem(id);
}

ExploreSections.prototype._hideSections = function() {
    jQuery('#document-content-explore-sections').fadeOut(es.HIDE_TIME);
    es.deactivateMenuItem();
}

ExploreSections.prototype.hideSections = function() {
    clearTimeout(es.timer);
    es.timer = setTimeout(es._hideSections, es.SUSTAIN_TIME);
}

ExploreSections.prototype.sustainSection = function() {
    clearTimeout(es.timer);
}

var es = new ExploreSections();