$(document).ready(function(){
    active_value = false;
    hash_pos = location.hash.lastIndexOf("#");
    if (hash_pos != -1) {
        person_id = location.hash.substr(hash_pos + 2);
        $("#accordion h3").each(function(i) {
            if (this.className == "p_" + person_id) {
                active_value = i;
                change_image(this.id);
                return false;
            }
        });
    }
    $("#accordion").accordion({
        active: active_value,
        header: "h3",
        collapsible: true,
        autoHeight: false,
        change: function(event, ui) {
            change_image($(ui.newHeader).attr("id"));
        }
    });
});
function change_image(header_id) {
    if (typeof header_id == "undefined" || header_id == '') {
        $("#spalte2").html("");
    }
    else {
        info_parts = header_id.split("_");
        $("#spalte2").html('<a href="/media/team/'+ info_parts[1] + '.jpg"  class="lightbox"><img src="/media/team/'+ info_parts[1] + '_tn.jpg" /></a>');
        $(".lightbox").lightbox({/*fitToScreen: true*/});
    }
}
