var w = false;

$(document).ready(function() {
  $("a[href$=.pdf]").click(function(e) { openPDFWin($(this).attr("href")); e.preventDefault(); });
  $("a[href^=http://]").attr("target", "_blank");
  $("body #right div.text:not(body.download #right div.text)").jScrollPane({dragMaxHeight: 50, scrollbarWidth: 30});
  
  $("a.editable").click(function() {
    edit(current_path, $(this).closest("div.grid_1, div.grid_2").attr("id")); e.preventDefault();
  });
});

function openPDFWin(url) {
  window.open(url, '', 'resizable');
}

function edit(page, region) {
  if (!w || w.closed) {
    w = window.open("/edit.php?page=" + page + "&id=" + region, "popup", "width=685,height=680");
  } else {
    w.focus();
  }
}
