
// browsererkennung (wird im moment nur bei drag&drop für erkennung vom ie verwendet)
userAgent = navigator.userAgent.toLowerCase();
isIE = ((userAgent.indexOf("msie") != -1) && (userAgent.indexOf("opera") == -1));
isOpera = (userAgent.indexOf("opera") != -1);
isMac = (userAgent.indexOf("mac") != -1);
isMacIE = (isIE && isMac);
isWinIE = (isIE && !isMac);
isSafari = (userAgent.indexOf("safari") != -1);
isGecko = (navigator.product == "Gecko" && !isSafari);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function show_subnavi(caller, welches, was, pos_setzen) {
  welches=welches.split(",");
  for (var i=0; i<welches.length; i++) {
    if (document.getElementById("subnavi"+welches[i])) {
      var subnavi=document.getElementById("subnavi"+welches[i]);
      if (pos_setzen && i==welches.length-1) {
        var pos=get_pos(caller);
        if (i==0) {
          subnavi.style.left=pos['x']-5;
          subnavi.style.top=pos['y']+13;
        } else {
          subnavi.style.left=pos['x']+150;
          subnavi.style.top=pos['y']-7;
        }
      }
      subnavi.style.visibility=was;
    }
  }
}

function get_pos(which_div) {
  var y_start=0;
  var positionen=new Array();
  document.body ? y_scrollposition=document.body.scrollTop+y_start : y_scrollposition=window.pageYOffset+y_start;
  // die x-position definieren
  var aktuelles=which_div;
  var x_position=0;
  while(aktuelles!=null) {
    x_position+=aktuelles.offsetLeft;
    aktuelles=aktuelles.offsetParent;
  }
  positionen['x']=x_position;
  // die y-position definieren
  var aktuelles=which_div;
  var y_position=y_start;
  while(aktuelles!=null) {
    y_position+=aktuelles.offsetTop;
    aktuelles=aktuelles.offsetParent;
  }
  positionen['y']=y_position;
  return positionen;
}

function scroll_to(scroll_position) {
  var y=0; if (window.pageYOffset) { window.pageYOffset=scroll_position; }
  else if (document.body) { document.body.scrollTop=scroll_position; }
}

function change_prop(form, field, new_value, submit, question) {
  if (submit) {
    if (question.length>1) { var eingabe; eingabe=confirm(question); }
    else { var eingabe=true; }
    if (eingabe) {
      if (document.getElementById('scrollposition')) {
        var scroll_position;
        if (window.pageYOffset) { scroll_position=window.pageYOffset; }
        else if (document.body) { scroll_position=document.body.scrollTop; }
        else { scroll_position='x'; }
        change_prop(form, 'scrollposition', scroll_position, false, '');
      }
      document.getElementById(field).value=new_value; document.getElementById(form).submit();
    }
  } else { document.getElementById(field).value=new_value; }
}

function change_language(which, page) {
  var language_id=which.options[which.selectedIndex].value;
  if (document.getElementById('pageform')) {
    if (document.getElementById('screen')) {
      change_prop('pageform', 'screen', 'new_language_id|'+language_id, true, '');
    } else {
      location.href=page+"&new_language_id="+language_id;
    }
  } else {
    location.href=page+"&new_language_id="+language_id;
  }
}

function predefined_input_focus(was, bezeichnung) {
  if (was.value==bezeichnung) { was.value=""; }
}

function predefined_input_blur(was, bezeichnung) {
  if (was.value=="" || was.value==" " || was.value=="  " || was.value=="   ") { was.value=bezeichnung; }
}

function show_images(welcher) {
  if (document.getElementById(welcher)) {
    var bildleiste=document.getElementById(welcher);
    if (bildleiste.style.display=="block") {
      bildleiste.style.display="none";
    } else {
      bildleiste.style.display="block";
    }
  }
}
