
/* Javascript fix for Safari's and Operas inability to link to named anchors
 * (or ids of elements) inside elements with  style="overflow:auto"  set
 *
 *  based on the script by Geoff Stearns ( geoff @ deconcept.com )
 *  slightly modified by Haymo Hinz      ( hinz@hrz.uni-marburg.de )
 *
 * see http://blog.deconcept.com/code/overflowsafari/overflowsafari.html
 * for more information
 *
 */


// Browserswitch for Safari or Opera
var sfr = false, opr = false;

function checksUA () {
  var UA = navigator.userAgent;
  if (UA.indexOf("Safari")>=0) sfr = true;
  if (UA.indexOf("Opera")>=0) opr = true;
} checksUA ();

// the id of the element with overflow: auto set, in this case the div
var targBox = "liste";

function initAnchors() {
  if (document.getElementById) {
    var atags = document.getElementsByTagName("A");
    for (var i=0;i<atags.length;i++) {
      var ca = atags[i];
      if (ca.href.indexOf("#") > -1) {
        ca.onclick = function() {
          scrollDivToAnchor(this.href.split("#")[1]);
          // to prevent scrolling of whole page in Opera
          /* if (opr) return false;  */
} } } } }

function scrollDivToAnchor(a) {
  // with targBox only
  if (document.getElementById(targBox)) {
    var b = document.getElementById(targBox);
    // offset correction for Opera
    var boT = b.offsetTop;  //   (opr) ?  0 :
    // MUST be anchors with additional id in Opera

    b.scrollTop = document.getElementById(a).offsetTop - boT;
    if (opr) document.body.scrollTop = 0;
  }
  // alternately, if your elements are not nested within other nodes inside
  // the box, you could use document.getElementById(a).parentNode.scrollTop
  // that way you wouldn't need to specify the id of the scrollable box
}

if (sfr || opr) {                                // Opera Browser included
  window.onload = initAnchors;
}

function pdf(x) {
  var xWin = window.open('',x,'top=20,left=50,width=800,height=600,resizable=1')
  xWin.focus();
}
function oWin(x) {
  var xWin = window.open('',x,'top=20,left=50,width=900,height=600,menubar=1,toolbar=1,location=1,resizable=1,scrollbars=1')
  xWin.focus();
}


function oWin (url,setting) {
  var frm = "extern"+setting, feat = "left=200,top=100,width=600,height=500";
  switch(setting) {
    case 1:
      feat = "left=110,top=40,width=500,height=450";
      feat += ",toolbar=no";
      feat += ",scrollbars=no";
      feat += ",menubar=no";
      feat += ",location=no";
      feat += ",resizable=yes";
      break;
     case 2:
      feat = "left=30,top=30,width=520,height=360"; // bildfenster-fenster
      feat += ",toolbar=no";
      feat += ",scrollbars=yes";
      feat += ",menubar=no";
      feat += ",location=no";
      feat += ",resizable=yes";
      break;
    default:
      break;
  } var Fenster = window.open(url,frm,feat);
  Fenster.focus();
}

// --- Macromedia --------------------------------------

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' die E-Mail-Adresse erscheint fehlerhaft.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' Bitte nur Ziffern notieren.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Zahl zwischen '+min+' und '+max+' enthalten.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' bitte noch ausfüllen.\n'; }
  } if (errors) alert('Etwas fehlt noch:\n\n'+errors);
  document.MM_returnValue = (errors == '');
}

