/* Shows and hides elements in the drill table */
function toggle_children(myid) {
  $(myid+'_link').toggleClass("closed")
  $(myid+"_children").toggle()
}

// Adding class="disabled" to an anchor in subnavigation causes "Coming soon"
// to be displayed on hover
$(document).ready(function(){
    var previous_text = [];
    $("#subnavigation .disabled").hover(function() {
        previous_text[this] = [this.innerHTML];
        this.innerHTML = "Coming soon";
    }, function() {
        this.innerHTML= previous_text[this];
    });
});


/* Greys out a specific target div with a loader div covering it.
   Used when ajax request is updating a part of the page, and it
   needs some time for the results to come back from the server */
function greyOut(target_id, loader_id) {
  $('#' + loader_id).css('top', $('#' + target_id).offset().top);
  $('#' + loader_id).css('left', $('#' + target_id).offset().left);
  $('#' + loader_id).css('height', "1000px"); // a hack to use 1000px
  $('#' + loader_id).css('width', $('#' + target_id).width());
  $('#' + loader_id).fadeIn("normal");
}
 
/* Greys in a target div, to remove the loader div to indicate
   that results from the server have been loaded */
function greyIn(loader_id) {
  $('#' + loader_id).fadeOut(200);
}

/* throbs an element continuously by changing its opacity back and forth */
function throb(element_id, options) {
  var target_opacity = 1.0;
  var throbbing = function() {
    if (target_opacity == 0.7) {
      target_opacity = 1.0;
    } else {
      target_opacity = 0.7;
    }
    $("#" + element_id).fadeTo(1000, target_opacity, throbbing);
  }
  $("#" + element_id).fadeTo(1000, target_opacity, throbbing);
}
    
