// JavaScript Document
var transitionSpeed = 'fast';
$.fn.animateCloseTheLI = function(transitionSpeed) {
var $this = $(this);
if ($.browser.msie) {
$this.customFadeOut(transitionSpeed);
} else {
$this.slideUp(transitionSpeed);
}
};
$.fn.animateOpenTheLI = function(transitionSpeed) {
var $this = $(this);
if ($.browser.msie) {
$this.customFadeIn(transitionSpeed);
} else {
$this.slideDown(transitionSpeed);
}
};
$.fn.closeTheLI = function(closeChildren) {
if (closeChildren !== false) closeChildren = true;
var $this = $(this);
$("#debug").append($this.children("a.link").html() + ".closeTheLI()
");
$this.children("ul").each(function() {
var $this = $(this);
$this.animateCloseTheLI(transitionSpeed);
if (closeChildren) {
$this.children("li").each(function() {
var $this = $(this);
$this.closeTheLI();
});
}
});
$this.children("a.expand").removeClass("opened");
$this.children("a.expand").addClass("closed");
};
$.fn.openTheLI = function() {
var $this = $(this);
$("#debug").append($this.children("a.link").html() + ".openTheLI()
");
$this.siblings("li").each(function() {
// close all open sibling menus
var $this = $(this);
$this.closeTheLI(false);
});
// open the menu
$(this).children("a.expand").removeClass("closed");
$(this).children("a.expand").addClass("opened");
$this.children("ul").animateOpenTheLI(transitionSpeed);
};
$.fn.customFadeIn = function(speed, callback) {
$(this).fadeIn(speed, function() {
if($.browser.msie) $(this).get(0).style.removeAttribute('filter');
if(callback != undefined) callback();
});
};
$.fn.customFadeOut = function(speed, callback) {
$(this).fadeOut(speed, function() {
if($.browser.msie) $(this).get(0).style.removeAttribute('filter');
if(callback != undefined) callback();
});
};
$(document).ready(function() {
$(".accordion a.expand").each(function() {
var $li = $(this).parent("li");
if ($li.hasClass("current_path")) {
$(this).addClass("opened");
} else {
$(this).addClass("closed");
}
});
$(".accordion ul ul").each(function() {
var $li = $(this).parent("li");
if (!$li.hasClass("current_path")) {
$(this).hide();
}
});
$(".accordion a.expand").bind("click", function() {
var $li = $(this).parent("li");
if ($(this).hasClass("opened")) {
$li.closeTheLI();
} else if ($(this).hasClass("closed")) {
$li.openTheLI();
}
return false;
});
/* prevents the flicker on pageload in some browsers when menu is briefly fully expanded */
$(".accordion").css("visibility", "visible");
$(".accordion a.expand").each(function() {
var $li = $(this).parent("li");
if ($li.hasClass("current_page")) {
$li.openTheLI();
}
});
$.fn.show_abstract = function(speed, callback) {
var $this = $(this);
var $link = $this.parents(".abstract_wrapper").find(".toggle_abstract");
$this.parents(".minimize").css('background-color', '#eed');
$this.slideDown("fast");
$link.html($link.html().replace("Read", "Hide"));
};
$.fn.hide_abstract = function(speed, callback) {
var $this = $(this);
var $link = $this.parents(".abstract_wrapper").find(".toggle_abstract");
$this.parents(".minimize").css('background-color', '#fff');
$this.slideUp("fast");
$link.html($link.html().replace("Hide", "Read"));
};
if ((".toggle_abstract").length > 0) {
$(".toggle_abstract").click(function() {
var $this = $(this);
var $abstract = $this.parents(".abstract_wrapper").children(".abstract");
var $all_abstracts = $(".abstract");
if ($abstract.css("display") == "none") {
$all_abstracts.each(function(index) { $(this).hide_abstract("fast") });
$abstract.show_abstract("fast");
} else {
$abstract.hide_abstract("fast");
}
});
var id_to_toggle = window.location.href.substr(window.location.href.indexOf("#") + 1);
$("#toggle_" + id_to_toggle).click();
}
});