/* On double click show publication linkings. Using jQuery. 03.11.2009 by ibex, mod 26.12.2009 */
$(document).ready( function() {
  /* Show link on dblclick */
  //var lipubl =$("li.publ[id]");
  var lipubl =$("span.minpubl");
  lipubl.dblclick(function() {
    var elPubl = $(this).parent();
    var idPubl = $(elPubl).attr("id");
    var ref = window.location.href;
    //remove existing #
    var ref = ref.substr(0, (ref.indexOf("#") != -1) ? ref.indexOf("#") : ref.length) + "#" + idPubl;
    //remove /edit of edit phase
    ref = ref.replace(/\/edit/,"");
    var refSite = ref.replace(/http:\/\/csvi-ms.net\/(..\/)?/i,"/en/");
      alert("Link:\n" + ref + "\n\n" +
      "HTML:\n<a href=\"" + ref +"\" title=\""+$(this).text() +"\">[" + idPubl + "]</a>\n\n" +
      "HTML site:\n<a href=\"" + refSite +"\" title=\""+$(this).text() +"\">[" + idPubl + "]</a>\n\n" +
      "HTML page:\n<a href=\"" + "#" + idPubl +"\" title=\""+$(this).text() +"\">[" + idPubl + "]</a>\n\n" +
      "BBCode:\n[url=" + ref + "][" + idPubl + "][/url]\n\n" +
      "BBCode medium:\n" + $(this).find("em").text() + " [url=" + ref + "][" + idPubl + "][/url]\n\n" +
      "BBCode full:\n" + $(this).text() + " [url=" + ref + "][" + idPubl + "][/url]");
  })
});

/* Add Google Schoolar. Using jQuery. 26.12.2009 by ibex */
$(document).ready( function() {
  $("li.publ").each( function (i) {
    var q = "http://scholar.google.com/scholar?as_q=%22"  + $(this).find("em.publtitle").text().replace(/ /g, "+") + "%22&as_sauthors=" + $(this).find("span.publauthors").text().split(" ", 1)[0];
    $(this).find("span.miscinfo").append(" <a class=\"small\" href=\"" + q + "\" title=\"Click to search Google Scholar for this entry\">Google Scholar</a>");
    // not requiered: &btnG=Search+Scholar&as_epq=&as_oq=&as_eq=&as_occt=any
  });
});

/* Collapse/Expand all Using jQuery. 25.12.2009 by ibex */
function toggle_expand_all() {
  /*$('.content .collapsible:first').css("color","red");*/
  if ($('.content .collapsible:first').hasClass('collapsed')) {
    $('.content .collapsible').removeClass('collapsed');
  } else {
    $('.content .collapsible').addClass('collapsed');
  }
  /*No load by default of link*/
  return false;
}
