$(document).ready(function(){
  $(".external,"
    +"a[href*='.pdf?'],a[href*='.PDF?'],"+"a[href*='.pdf#'],a[href*='.PDF#'],"
    +"a[href$='.pdf'],a[href$='.PDF']"
   ).attr("target","_blank");
});
////
/// cookies
//
function a_cookie_long(coo,val) {
  var t = new Date();
  var lange = t.getTime() + (99 * 365 * 24 * 60 * 60 * 1000);
  t.setTime(lange);
  document.cookie = coo+"="+val+"; expires=" + t.toGMTString();
  //a_d('c','set 99-year-cookie: '+coo+'='+val);
}
function a_cookie_session(coo,val) {
  document.cookie = coo+'='+encodeURI(val)+';';
  //a_d('c','set sessioncookie: '+coo+'='+encodeURI(val));
}
function a_cookie_get(coo) {
  if (document.cookie) {
    all_coo=document.cookie;
    expr = new RegExp(coo+'=([^;]+)','g');
    res = expr.exec(all_coo);
    if (res) {
      val=res[1];
      //a_d('c','find cookie: '+coo+'='+val);
      return decodeURI(val);
    } 
  }
  return '';
}
function a_cookie_delete(coo) {
  document.cookie = coo+"=; expires=0";
}

////
/// open and close elements by id
//
//open close or toggle tags by id
// 'v' 'c' 't' follow by ids
// numers are complieted with 'a_'.nr
function a_v() {
  state='o'; cookie_=false;
  arg=0; while (arg<arguments.length) {
    id=arguments[arg];
    cookie_=(arguments[arg].substr(0,4)=='coo_');
    //if (cookie_) {id=arguments[arg];}
    //else {id=arguments[arg];}
    if ((id=='o') || (id=='c') || (id=='t')) {
      state=id;
    } else if (document.getElementById(id)) {
      tag=document.getElementById(id);
      if (state=='t') {
        if (tag.style.display=='none') {state='o';}
        else {state='c';}
      }
      if (state=='o') {
        tag.style.display=a_v__display[id];
        //a_d('x','o '+id);
      } else {
        tag.style.display='none';
        //a_d('x','c '+id);
      }
      if (cookie_) {
        a_cookie_session(id,state);
      }
    }
    arg++;
  }
}

var a_v__display=Array();
a_v__display['coo_dot']='inline';
a_v__display['coo_all']='inline';
a_v__display['coo_dkey']='inline';
a_v__display['coo_dot']='inline';
a_v__display['coo_h2']='inline';
a_v__display['coo_h1']='inline';
a_v__display['coo_mkey']='inline';
a_v__display['coo_mkey_2']='inline';
a_v__display['coo_kkey']='inline';
a_v__display['coo_menu']='inline';


