$(document).ready(function () {
     timeoutX = setTimeout('tooltip.init()', 1000);
    // Hover-Effekt für Bilder in der Navigation
    $('#navigation li li img, #navigation .container img').hover( function () {$(this).attr('src' ,$(this).attr('src').replace('.png','_a.png'));}, function () {$(this).attr('src' ,$(this).attr('src').replace('_a.png','.png'))} );
});

// Konstanten definieren
var col_w = 230;                                      // Spaltenbreite
var leftcol = 233;                                    // Linke Spalte plus Ränder (240+15+30)
var borders = 45;                                     // Ränder (15+30)
var correction = 0;                                   // Korrektur

// Variablen definieren
var cols_nr = 1;                                      // Anzahl Spalten (default)
var cols_vis = 1;                                     // Sichtbare Spalten (default)
var win_w = 1000;                                     // User Screen Breite
var win_h = 650;                                      // User Screen Höhe
var col_h = 600;                                      // Spalten Höhe

var timeout = null;

//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function renderCols(){
    // START DEBUGING 
    //$('#debug').remove();
    //var ts_start = new Date().getTime();
    //$('#navigation').append('<div id="debug"></div>');
    //$('#debug').append('Parse-Start: <br />');
    //$('#debug').append('Fenster: ' + win_w + 'x' + win_h + '<br />');
    win_w = $(window).width();
    win_h = $(window).height();
 
    $(document).ready(function () {
        $(window).load(function() {
            if (timeout) clearTimeout(timeout);
            timeout = setTimeout(parseInit, 10);
        });
    });
    $(window).resize((function() {
        if (!timeout){
            return function() {
                if(win_w != $(window).width() || win_h != $(window).height()){
                    if (timeout) clearTimeout(timeout);
                    timeout = setTimeout(parseInit, 500);                        

                    if (timeoutX) clearTimeout(timeoutX);
                    timeoutX = setTimeout('tooltip.init()', 1000);
                }
            };
        }
    })());
    // END DEBUGING
    //var ts_end = new Date().getTime();
    //$('#debug').append('Skriptzeit: ' + ((ts_end - ts_start)/1000) + 'Sek. <br />');
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function parseInit(){
    // Fenster-Dimensionen bestimmen
    win_w = $(window).width();
    win_h = $(window).height();
    
    getPageInfo();
    parseContentCol();
    showNavElements();
    
    if (timeoutX) clearTimeout(timeoutX);
    timeoutX = setTimeout('tooltip.init()', 1000);
    return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function getPageInfo(){
    // Sichtbare Spalten berechnen
    cols_vis = Math.floor((win_w-(leftcol+borders))/(col_w+7));
    // Spaltenhöhe berechnen
    col_h = win_h-70;    
    //$('#debug').append('Spaltenhöhe: ' + col_h + '<br />');
    //$('#debug').append('Sichtbare Spalten: ' + cols_vis + '<br />');
    return true;
}        
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function parseContentCol(){
    var curr_col_nr = 1;
    $('#full_content').css('display','block');
    $('.cols','#content').remove();
    addNewCol(curr_col_nr);
    var curr_col = $('#col' + curr_col_nr + ' .cols_inner');
    $('#full_content').children().each(function() {
        //curr_col.append($(this));
        //$(this).clone().appendTo('#col' + curr_col_nr + ' .cols_inner')
        if((curr_col.outerHeight(true) + $(this).outerHeight(true)) >= col_h-correction){ // Wenn die aktuelle Spalte plus das Element grösser als eine volle Spalte ist: Neue Spalte anlegen
            if($(this).get(0).tagName == 'P'){
                curr_col_nr = splitNewText($(this),curr_col,curr_col_nr,col_h,correction);
                curr_col = $('#col' + curr_col_nr + ' .cols_inner');
            } else {
                curr_col_nr++;
                addNewCol(curr_col_nr);
                curr_col = $('#col' + curr_col_nr + ' .cols_inner');
                curr_col.append($(this).clone());
            }
            // Ueberpruefen, ob das letzte Element alleine stehen darf
            if(checkFirstElement(curr_col_nr,curr_col)){
                checkLastElement(curr_col_nr,curr_col);
            }
        } else {
            if(((col_h-correction)-(curr_col.outerHeight(true)+$(this).outerHeight(true))) < 15 && $(this).get(0).tagName == 'P'){ //Wenn Text gerade noch so Platz hat.
                curr_col_nr = splitNewText($(this),curr_col,curr_col_nr,col_h,15);
                curr_col = $('#col' + curr_col_nr + ' .cols_inner');
            } else {
                curr_col.append($(this).clone());
            }
        }
    });
    $('#full_content').css('display','none');
    cols_nr = curr_col_nr;
    
    // Unsichtbare deaktivieren       
    for(var i=1; i<=cols_nr; i++){
        if(i > cols_vis){
            $('#col' + i).css('display','none');
        }     
    } 

    // Maximal so viele sichtbare Spalten wie es Spalten gibt
    if(cols_vis > cols_nr) cols_vis = cols_nr;
    return true;
}  
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function checkFirstElement(curr_col_nr,curr_col){
    var first_element = curr_col.children().first();
    if(first_element.hasClass("blind")){
        if(curr_col_nr > 1){
            first_element.remove();
        }
    }
    if(first_element.hasClass("link_container")){
        if(curr_col_nr > 1){
            var prev_col = $('#col' + (curr_col_nr-1) + ' .cols_inner');
            var last_element = prev_col.children().last();
            curr_col.prepend(last_element);
        }
    }
    return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function checkLastElement(curr_col_nr,curr_col){
    if(curr_col_nr > 1){
        var prev_col = $('#col' + (curr_col_nr-1) + ' .cols_inner');
        var last_element = prev_col.children().last();
        if(last_element.get(0).tagName == "H3"){
            curr_col.prepend(last_element);
            checkLastElement(curr_col_nr,curr_col);
        }
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function splitNewText(that,curr_col,curr_col_nr,col_h,correction){
    var words = that.html().split(' ');
    var wordsLen = words.length; // Anzahl Worte herausfinden
    
    curr_col.append('<p></p>'); // neuen Paragraphen in die letzte Spalte
    var item_p = curr_col.children().last();
    var text_p = '';
    
    for(var i=0;i<wordsLen;i++){
        item_p.html(text_p + ' ' + words[i]);

        if(curr_col.outerHeight(true) >= col_h-correction){  // neue Spalte
            item_p.html(text_p); // Es bleibt beim alten Text, das Wort wird nicht hinzugefügt
            curr_col_nr++;
            addNewCol(curr_col_nr);
            curr_col = $('#col' + curr_col_nr + ' .cols_inner');
            curr_col.append('<p></p>'); 
            item_p = curr_col.children().first();
            item_p.html(words[i]);
            text_p = '';
        }
        text_p += ' ' + words[i];
    }
    return curr_col_nr;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function addNewCol(curr_col){
    var html = '';
    html += '<div id="col' + curr_col + '" class="cols" style="height:' + col_h + 'px">\n';
    html += '  <div class="cols_inner">\n';
    html += '  </div>\n';
    html += '</div>\n';
    $('#content').append(html);
    return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function showNavElements(){
    // blätterfunktion hinzufügen
    $('#active_left').remove();
    $('#active_right').remove();
    $('#active_fwd').remove();
    $('#active_bwd').remove();
    $('#pager').remove();
    if(cols_nr > cols_vis){
        var html_1 = '';
        html_1 += '<div id="active_left" class="pointer" onclick="prevCol()" style=\"display:none\">&nbsp;</div>\n';
        html_1 += '<div id="active_right" class="pointer" onclick="nextCol()">&nbsp;</div>\n';
        $('#content').append(html_1);
        $('#active_left, #active_right').css('height',col_h + 'px');


        var html_2 = '';
        html_2 += '<div id="pager">\n';
        html_2 += '    <a class="pointer"><img src="/_files/img/first_i.png" /></a>\n';
        html_2 += '    <a class="pointer" style="margin-right:20px;"><img src="/_files/img/prev_i.png" /></a>\n';
        html_2 += '    <a class="pointer" onclick="nextCol()"><img src="/_files/img/next.png" /></a>\n';
        html_2 += '    <a class="pointer" onclick="lastCol()"><img src="/_files/img/last.png" /></a>\n';
        html_2 += '    <span style="padding-left:20px;" id="pager_first"> 1 </span> to <span id="pager_last"> ' + cols_vis + ' </span> of <span>' + cols_nr + '</span>\n';
        html_2 += '</div>\n';
        $('#page').append(html_2);
        // Hover-Effekt für Bilder
        $('#pager img,.link_container img').hover( function () {$(this).attr('src' ,$(this).attr('src').replace('.png','_a.png'));}, function () {$(this).attr('src' ,$(this).attr('src').replace('_a.png','.png'))} );
    }
    if($('#navigation').height() < col_h){
        $('#col_left').height(col_h);
    } else {
        $('#col_left').height($('#navigation').height()+70);
    }
    $('#page').width(leftcol+cols_vis*(col_w+8));
    $('#content').width(cols_vis*(col_w+8));
    $('#content').height(col_h);
}        
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function lastCol(){
    var cols_vis = $('.cols:visible').length;
    var cols_nr = $('.cols').length
    $('.cols:visible','#content').first().hide(0);
    $('.cols','#content').last(0);
    $('.cols:visible','#content').hide(100);
    for(var i=cols_nr;i>(cols_nr-cols_vis);i--){
        $('#col' + i).show(200);
    }
    timeout = setTimeout(renderPager, 500);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function nextCol(){
    $('#active_right').css('display','none');
    $('.cols:visible','#content').first().hide(100);
    $('.cols:visible','#content').last().next().show(100, function(){
        timeout = setTimeout(renderPager, 200);
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function prevCol(){
    $('#active_left').css('display','none');
    $('.cols:visible','#content').first().prev().show(100);
    $('.cols:visible','#content').last().hide(100, function(){
        timeout = setTimeout(renderPager, 200);
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function firstCol(){
    parseInit();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function renderPager(){
    // fwd-buttons
    var first = $('#pager a').first();
    if($('.cols','#content').first().css('display') == 'none'){ 
        $('#active_left').css('display','block');
        first.children().first().attr('src','/_files/img/first.png');
        first.next().children().first().attr('src','/_files/img/prev.png');
        first.attr('onclick','firstCol()');
        first.next().attr('onclick','prevCol()');
    } else { 
        $('#active_left').css('display','none'); 
        first.children().first().attr('src','/_files/img/first_i.png');
        first.next().children().first().attr('src','/_files/img/prev_i.png');
        first.removeAttr('onclick','firstCol()');
        first.next().removeAttr('onclick','prevCol()');
    }
    // bwd-buttons
    var last = $('#pager a').last();
    if($('.cols','#content').last().css('display') == 'none'){ 
        $('#active_right').css('display','block'); 
        last.children().first().attr('src','/_files/img/last.png');
        last.prev().children().first().attr('src','/_files/img/next.png');
        last.attr('onclick','lastCol()');
        last.prev().attr('onclick','nextCol()');
    } else { 
        $('#active_right').css('display','none'); 
        last.children().first().attr('src','/_files/img/last_i.png');
        last.prev().children().first().attr('src','/_files/img/next_i.png');
        last.removeAttr('onclick','lastCol()');
        last.prev().removeAttr('onclick','nextCol()');
    }
    // nrs
    var col_vis_first = $(".cols:visible",'#content').first().attr('id').match(/[\d]+$/);
    $('#pager_first').html(" " + col_vis_first + " ");
    var col_vis_last = $(".cols:visible",'#content').last().attr('id').match(/[\d]+$/);
    $('#pager_last').html(" " + col_vis_last + " ");
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function splitText(that,curr_col,col_h,correction){
    var words = that.html().split(' ');
    var wordsLen = words.length;
    $('#col' + curr_col + ' .cols_inner').append('<p></p>');
    var item_p = $('#col' + curr_col + ' .cols_inner').children().last();
    var text_p = '';
    
    for(var i=0;i<wordsLen;i++){
        item_p.html(text_p + ' ' + words[i]);
        if($('#col' + curr_col + ' .cols_inner').outerHeight(true) >= col_h-correction){  // neue spalte
            item_p.html(text_p); // bleibt beim alten text
            /*item_p.html(item_p.html() + ' ' + $('#col' + curr_col + ' .cols_inner').outerHeight(true) + ' - ' + col_h); ***/
            curr_col++;
            addCol(curr_col,col_h);
            $('#col' + curr_col + ' .cols_inner').prepend('<p></p>');
            item_p = $('#col' + curr_col + ' .cols_inner').children().first();
            item_p.html(words[i]);
            text_p = '';
        }
       text_p = text_p + ' ' + words[i];
    }
    return curr_col;
}
var resizedelay = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);
  };
})();
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function showProjectTitle(that){
    $(that).parent().next().children().first().fadeIn('fast');
    $(that).mouseout(function(){
        $(that).parent().next().children().first().fadeOut('fast');
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function showInterestTitle(that){
    $(that).parent().next().children().first().fadeIn('fast');
    $(that).mouseout(function(){
        $(that).parent().next().children().first().fadeOut('fast');
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function parseImages(a,b,c){
    //var debug = "";
    var win_w = $(window).width();
    var win_h = $(window).height();
    var size = 'small';
    var cont_h = 500;
    var cont_w = 666;
    if(win_h > 750){size = 'medium';cont_h = 700;cont_w = 933;}
    if(win_h > 950){size = 'large';cont_h = 900;cont_w = 1200;}
    if(win_h > 1250){size = 'xlarge';cont_h = 1200;cont_w = 1600;}
    
    //debug += 'Viewport w: ' + win_w + '<br />';
    //debug += 'Viewport h: ' + win_h + '<br />';
    //debug += 'Size: ' + size + '<br />';
    //debug += 'Content h: ' + cont_h + '<br />';
    
    if($('#col_left').height() < win_h-70){
        $('#page').height(win_h-40);
        $('#col_left').height(win_h-70);
    }
    $('#content_elements').height(cont_h);
    
    for (var i = 0; i < a.length; i++) { 
        var vis = '';
        if(i > 0) vis = ';display:none';
        if(c[i] > 0){
            var film = "/_data/videos/" + a[i];
            var vid = '<div class="videos" id="element' + i + '" title="' + b[i] + '" style="width:' + cont_w + 'px;height:' + cont_h + 'px;z-index:' + (i+50) + vis + '">';
            vid +=    '  <div class="film_container" id="jp_container_' + i + '" style="width:' + cont_w + 'px;height:' + cont_h + 'px;">\n';
            vid +=    '    <div id="project_film' + i + '" class="jplrfind"></div>\n';
            vid +=    '    <div class="jp-progress">\n';
            vid +=    '      <div class="jp-seek-bar">\n';
			vid +=    '        <div class="jp-play-bar"></div>\n';
			vid +=    '      </div>\n';
			vid +=    '    </div>\n';
            vid +=    '    <div class="jp-current-time"></div>\n';
			vid +=    '    <div class="jp-duration"></div>\n';
            vid +=    '    <div class="jp-video-play pointer">\n';
            vid +=    '      <a href="javascript:;" class="jp-video-play-icon pointer"><img src="/_files/img/play_icon.png" /></a>\n';
			vid +=    '    </div>\n';
            vid +=    '    <a href="javascript:;" class="jp-play pointer"><img src="/_files/img/play.png" /></a>\n';
            vid +=    '    <a href="javascript:;" class="jp-pause pointer"><img src="/_files/img/pause.png" /></a>\n';
            vid +=    '    <a href="javascript:;" class="jp-mute pointer"><img src="/_files/img/mute.png" /></a>\n';
            vid +=    '    <a href="javascript:;" class="jp-unmute pointer"><img src="/_files/img/unmute.png" /></a>\n';
            vid +=    '  </div>\n';
            vid +=    '</div>\n';
            $('#content_elements').append(vid);
            
            $("#project_film" + i).jPlayer( {
                ready: function () {
                    $(this).jPlayer("setMedia", {
                       flv: film
                    })
                },
                solution: "flash",
                supplied: "flv",
                swfPath: "/_files/js",
                cssSelectorAncestor: "#jp_container_" + i,
                size: {
                    width: cont_w + "px",
                    height: cont_h + "px"
                }
            });
        } else {
            $('#content_elements').append('<img class="images" title="' + b[i] + '" id="element' + i + '" style="z-index:' + (i+50) + vis + '" src="/_data/images/' + size + '/' + a[i] + '" />\n');
        }
    }   
    if(a.length > 1){
        var html_1 = '';
        html_1 += '<div id="active_left" class="pointer" onclick="prevImg();stopPlayer()">&nbsp;</div>\n';
        html_1 += '<div id="active_right" class="pointer" onclick="nextImg();stopPlayer()">&nbsp;</div>\n';
        $('#content').append(html_1);
        var new_h = cont_h-50;
        $('#active_left, #active_right').css('height',new_h + 'px');
    }

    $('#content_elements img').load(function() {
        recalcImgSize();
    });
    
    var html_2 = '';
    html_2 += '<div id="pager">\n';
    html_2 += '    <a class="pointer"><img src="/_files/img/first_i.png" /></a>\n';
    html_2 += '    <a class="pointer" onclick="prevImg();stopPlayer()" style="margin-right:15px;"><img src="/_files/img/prev.png" /></a>\n';
    html_2 += '    <a class="pointer" onclick="nextImg();stopPlayer()"><img src="/_files/img/next.png" /></a>\n';
    html_2 += '    <a class="pointer" onclick="lastImg();stopPlayer()"><img src="/_files/img/last.png" /></a>\n';
    html_2 += '    <span style="padding-left:20px;" id="pager_first"> 1 </span> of <span>' + a.length + '</span><span id="pager_label" style="padding-left:50px;">' + b[0] + '</span>\n';
    html_2 += '</div>\n';
    $('#page').append(html_2);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function stopPlayer(){
    $(".jplrfind").jPlayer("pause");
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function nextImg(){
    var next = $('#content_elements .images:visible, #content_elements .videos:visible').next();
    $('#content_elements .images:visible, #content_elements .videos:visible').fadeOut(500);
    if(next.length){
        next.fadeIn(500);
    } else {
        $('#content_elements .images, #content_elements .videos').first().fadeIn(500);
    }
    $('#active_right').css('display','none'); 
    window.setTimeout(renderPagerImg, 600);
    window.setTimeout(recalcImgSize, 600);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function prevImg(){
    var prev = $('#content_elements .images:visible, #content_elements .videos:visible').prev();
    $('#content_elements .images:visible, #content_elements .videos:visible').fadeOut(500);
    if(prev.length){
        prev.fadeIn(500);
    } else {
        $('#content_elements .images, #content_elements .videos').last().fadeIn(500);
    }
    $('#active_left').css('display','none'); 
    window.setTimeout(renderPagerImg, 600);
    window.setTimeout(recalcImgSize, 600);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function lastImg(){
    $('#content_elements .images,#content_elements .videos').fadeOut(500);
    $('#content_elements .images,#content_elements .videos').last().fadeIn(500);
    $('#active_right').css('display','none'); 
    window.setTimeout(renderPagerImg, 600);
    window.setTimeout(recalcImgSize, 600);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function firstImg(){
    $('#content_elements .images,#content_elements .videos').fadeOut(500);
    $('#content_elements .images,#content_elements .videos').first().fadeIn(500);
    $('#active_left').css('display','none'); 
    window.setTimeout(renderPagerImg, 600);
    window.setTimeout(recalcImgSize, 600);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function renderPagerImg(){
    $('#active_right').css('display','block'); 
    $('#active_left').css('display','block'); 

    // fwd-buttons
    var first = $('#pager a').first();
    if($('#content_elements .images,#content_elements .videos').first().css('display') == 'none'){ 
        first.children().first().attr('src','/_files/img/first.png');
        first.attr('onclick','firstImg();stopPlayer()');
    } else { 
        first.children().first().attr('src','/_files/img/first_i.png');
        first.removeAttr('onclick','firstImg();stopPlayer()');
    }
     // bwd-buttons
    var last = $('#pager a').last();
    if($('#content_elements .images,#content_elements .videos').last().css('display') == 'none'){ 
        last.children().first().attr('src','/_files/img/last.png');
        last.attr('onclick','lastImg();stopPlayer()');
    } else { 
        last.children().first().attr('src','/_files/img/last_i.png');
        last.removeAttr('onclick','lastImg();stopPlayer()');
    }


    // nrs
    var img_vis_first = $(".images:visible,.videos:visible").first().attr('id').match(/[\d]+$/);
    var img_plus = parseInt(img_vis_first)+1
    $('#pager_first').html(" " + img_plus + " ");
    // nrs
    var title_vis_first = $('#element' + img_vis_first).attr('title');
    $('#pager_label').html(" " + title_vis_first + " ");

}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function recalcImgSize(){
    var leftcol = 233;                                    // Linke Spalte plus Ränder (240+15+30)
    var cont_w = $('#content_elements .images:visible,#content_elements .videos:visible').width();
    var page_w = cont_w+leftcol;
    $('#content_elements').width(cont_w);
    $('#page').width(page_w);
    $('#active_left').css('width',(cont_w-200)/2); 
    $('#active_right').css('width',(cont_w-200)/2); 
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
function toggleDescription(that){
    var first_child = $(that).find(">:first-child");
    if(first_child.attr('src').match('_c')){
        first_child.attr('src' ,first_child.attr('src').replace('_c.png','_o.png')); 
        $(that).next().show('fast');
    } else {
        first_child.attr('src' ,first_child.attr('src').replace('_o.png','_c.png')); 
        $(that).next().hide('fast');        
   }
}
function submitPublicationsFilterEnter(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13){
       submitPublicationsFilter();
       return false;
   } else {
       return true;
   }    
}
function submitPublicationsFilter() {
    $('#pub_filter').submit();  
}
function resetPublicationsFilter(e) {
   $('#publications_filter').val(''); 
   $('#pub_filter').submit();
}
