var strictMode = 0;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isChrome  = (navigator.appVersion.indexOf("Chrome") != -1) ? true : false;
var isFF = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;

var browserVersion=parseFloat(navigator.appVersion);

// Browserspezifischer Abstand
var spacingBottom=0;
if (isIE) spacingBottom=22;
if (isChrome) spacingBottom=18;
if (isFF) spacingBottom=18;
if (isOpera) spacingBottom=0;

// CONTAINS =
Array.prototype.contains = function (elem) {
  var i;
  for (i = 0; i < this.length; i++) {
    if (this[i] == elem) {
      return i+1;
    }
  }

  return 0;
};

function getE(str) {
         return document.getElementById(str);
}

// ONRESIZE HANDLER
var resizeFunc = new Object();
window.onresize = function() {
  for (var funcName in resizeFunc)
    if (resizeFunc[funcName])
      eval(funcName+'()');

}
// ONSCROLL HANDLER
var scrollFunc = new Object();
window.onscroll = function() {
  for (var funcName in scrollFunc)
    if (scrollFunc[funcName])
      eval(funcName+'()');

}

var bottomBar = new Object();
bottomBar['user'] = new Object();
bottomBar['system'] = new Object();
function calcBarBottom(typ) {

         barPos=new Object();

         barPos.x = 1;
         barPos.w = 830-barPos.x;

         barPos.y = getFensterInfo('inner','height') - spacingBottom;

         if (typ=='system') {

            for (var i in bottomBar['user']) {
                 if (bottomBar['user'][i].visible) {
                    barPos.y -= bottomBar['user'][i].height;
                    barPos.x = bottomBar['user'][i].left;
                    barPos.w = bottomBar['user'][i].width;
                    break;
                 }
            }
         }
         return barPos;
}

function setBar(typ,name,doAdd,opt) {

           if (!doAdd && bottomBar[typ][name] === undefined) return 0;

         if (doAdd) {
            opt.visible=1;
            bottomBar[typ][name] = opt;
         } else {
           bottomBar[typ][name].visible = 0;
         }
         window.onresize();

}

var isSpacingBar = 0;
function checkSpacing () {

         if (!spacingBottom) return 0;

         var oHead = document.getElementsByTagName('BODY').item(0);

         isSpacingBar = 0;
         for (var m in bottomBar) {
           for (var i in bottomBar[m]) {
                 if (bottomBar[m][i].visible)
                    isSpacingBar=1;
           }
         }

         ele = getE('spaceBottom');
         if (ele == null) {

            if (isSpacingBar) {
              var oScript = document.createElement('DIV');
              oScript.setAttribute('id','spaceBottom');
              setStyle = 'height:'+spacingBottom+'px; z-index:9999995; position:fixed; background-color:rgba(255,255,255,.9);';
              oScript.setAttribute('style',setStyle);
              oScript.style.cssText = setStyle;

              oScript.style.width = '830px';
              oScript.style.left = '1px';
              oScript.style.top = (getFensterInfo('inner','height')-spacingBottom)+'px';

              oHead.appendChild(oScript);
            }

         } else {
           if (isSpacingBar) {
              ele.style.top = (getFensterInfo('inner','height')-spacingBottom)+'px';
           } else {
             clr = document.getElementById('spaceBottom'); clr.parentNode.removeChild(clr);
           }
         }


}


function cutString (str, mlen) {
   var cs = ' ...';
   if (str.length > mlen) str = str.substr(0,mlen-cs.length) + cs;
   return str;
}


function getFensterInfo(typ,richtung) {


//alert(1+'=' + document.documentElement.clientHeight+'\n2='+window.innerHeight+'\n3='+document.body.clientHeight);
 if (typ == 'inner') {
    if (document.documentElement) {  /*andere*/
      if (richtung=='height') return document.documentElement.clientHeight;
      if (richtung=='width') return document.documentElement.clientWidth;
     } else if (window.innerWidth) {  /*IE-strict*/
      if (richtung=='height') return window.innerHeight;
      if (richtung=='width') return window.innerWidth;
     } else {                  /*IE*/
      if (richtung=='height') return document.body.clientHeight;
      if (richtung=='width') return document.body.clientWidth;
     }
 }
 if (typ == 'total') {
    if (document.all && strictMode) { /*IE-strict*/
       if (richtung=='height') return document.documentElement.offsetHeight;
       if (richtung=='width') return document.documentElement.offsetWidth;
    } else if (document.all) { /*IE*/
       if (richtung=='height') return document.body.offsetHeight;
       if (richtung=='width') return document.body.offsetWidth;
     } else {   /*andere*/
       if (richtung=='height') return window.innerHeight;
       if (richtung=='width') return window.innerWidth;
    }
 }
 return -1;
}


 function ucfirst (str) {
    return str.charAt(0).toUpperCase() + str.substr(1);
}
function urlencode(str) {
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}

function urldecode(str) {
         if (str == null) return '';
         return unescape(str.replace(/\+/g, ' '));
}

        function tablesort(tbl_id, SE) {

         var REG = new RegExp("^(?:[0-9]+\-){"+SE+"}([0-9]+)(?:\-[0-9]+)*$");

         var tbl = document.getElementById(tbl_id);

         if (!tbl) { alert("Tabelle '" + tbl_id + "' nicht gefunden."); return 0; }

         // TBODY suchen
         for (tbX=0; tbX < tbl.childNodes.length; tbX++) {
                 if (tbl.childNodes[tbX].nodeName == "TBODY") {
                         var tbody = tbl.childNodes[tbX];
                         break;
                 }
         }
         if (!tbody) { alert("Keine Tabelle gefunden"); return 0; }

         var sCol=0; var offset=0; var aTr = null;

         for (var aCol = 0; aCol < tbody.childNodes.length; aCol++) {

                 aTr = tbody.childNodes[aCol];
                 if (aTr.nodeName != "TR" && aTr.nodeName != "TH") continue;

                 if (!aTr.getAttribute('SORT')) {
                         if (aTr.getAttribute('SORTLINE')) {
                           for (var aSM = 0; aSM < aTr.childNodes.length; aSM++) {
                               if (aSM==SE) { sClass = "akt"; } else { sClass=""; }
                               aTr.childNodes[aSM].className = sClass;
                           }
                         }
                         offset++;
                         continue;
                 }
                 var regErg = aTr.getAttribute('SORT').match(REG);

                 sCol = regErg[1];


                 if (tausche (tbody,aCol,sCol-1+offset)) aCol--;

         }
      }

      function tausche (par, n1,n2) {

                if (n1 == n2) return 0;

                var weg = par.replaceChild(par.childNodes[n2],par.childNodes[n1])
                if (n2 == par.childNodes.length) {
                   par.appendChild(weg);
                } else {
                   par.insertBefore(weg, par.childNodes[n2]);
                }
                return 1;
      }


function startYoutube(playerID) {

         /*
                 http://code.google.com/intl/de-DE/apis/youtube/js_api_reference.html
                 STATE: unstarted (-1), ended (0), paused (2), buffering (3), playing (1), video cued (5).

         */

         var player = document.getElementById(playerID);
         var state = player.getPlayerState();

         if (state == 3 || state == 1) {
            player.pauseVideo();
         } else {
            player.playVideo();
         }
}
function fixInput(element,typ,para1) {

 oldval = element.value;

 if (typ == "preis") {

       newval = parseDecimal(oldval,2,-1,0,0.99);

 } else if (typ == "zahl") {

       if (typeof para1 === 'undefined') para1 = 0;
       newval = parseDecimal(oldval,para1,-1);

 } else {
   newval = trim(oldval.replace(/[ ]{2,}/g, ' '));
 }

 element.value = newval;

 return 1;

}

function runde(x, n) {
  if (n < 1 || n > 14) return false;
  var e = Math.pow(10, n);
  var k = (Math.round(x * e) / e).toString();
  if (k.indexOf('.') == -1) k += '.';
  k += e.toString().substring(1);
  return k.substring(0, k.indexOf('.') + n+1);
}

 function addScript(url) {

          var oHead = document.getElementsByTagName('HEAD').item(0);
          var oScript= document.createElement('script');
          oScript.type = 'text/javascript';
          oScript.src=url;
          oHead.appendChild( oScript);
 }

 function uExec (url,uInput) {

          // Version 1.3, 27.3.2010, 13:$5
          // Umstellung von uInputID auf uInput

          // Version 1.2, 13.9.2008, 20:00
          // Neue Umsetzung mit optionaler uInputID welche ausgewertet als uInput übergeben wird

          var d=new Date()
          url += '&uExecTC=' + d.getTime();

          if (uInput) url += '&uInput=' + encodeURI(eval(uInput));

          var oHead = document.getElementsByTagName('HEAD').item(0);
          var oScript= document.createElement('script');
          oScript.type = 'text/javascript';
          oScript.src=url;
          oHead.appendChild( oScript);

 }


        function checkString(inputstr,needle) {
          if (!needle.length) { return 1; }
          var inputstr = inputstr.toLowerCase();
          var needle = needle.toLowerCase();
          var parts = needle.split(' ');
          for (p=0;p<parts.length; p++) {
               apart = parts[p];
               if (inputstr.indexOf(apart) == -1) { return 0; }
          }

          return 1;
        }

function getDisplayStatus (objektID,status) {
         var obj = document.getElementById(objektID);
         if (!obj) return -1;
         if (obj.style.display == "block") return 1;
         if (obj.style.display == "none") return 0;
}


function changeDisplayStatus (objektID,status) {
         var obj = document.getElementById(objektID);
         if (!obj) return 0;
         if (status == 2 && obj.style.display == "block") status = 0;
         if (status == 2 && obj.style.display == "none") status = 1;
         if (status == 2) status = 0;
         if (status == 0) obj.style.display = "none";
         if (status == 1) obj.style.display = "block";
         return status;
}



function switchDisplay (obj, status, styp) {

        // Ersatz für changeDisplayStatus (14.09.08) (C) BUDZE
        // Neu, auch Übergabe von direktem Objekt
        if (typeof obj != 'object') {
           obj = document.getElementById(obj);
        }

        if (!obj) return -1;

        if (isIE || !styp) styp = "block";
        var modi = new Array("none",styp);

        if (status == true) status=1;
        if (status == false) status=0;

        // automatischer Wechsel
        if (status == 2) {
          if (obj.style.display == modi[0]) {
            status = 1;
          } else {
            status = 0;
          }
        }
        obj.style.display = modi[status];
        return status;
}

function fadeOpacity(obj,setOp,stepOp,destOp,stepW,exec) {

         //var obj = document.getElementById(objektID);

         obj.style.filter = 'Alpha(opacity='+setOp+')';
         obj.style.opacity = setOp/100;

         // Einblenden, falls noch nicht...
         if (obj.style.display =='none') switchDisplay(obj,1);

         if (setOp == destOp) { eval(exec); return 1; }
         window.setTimeout(function() { fadeOpacity(obj,setOp+stepOp,stepOp,destOp,stepW,exec); }, stepW);

}

var innerMessageStatus = 0;
function innerMessage(msg,sekunden,buttons) {

         if (innerMessageStatus) remInnerMessage();
         var max_sek = 120;

         if (sekunden===0) sekunden = max_sek;
         if (typeof sekunden === 'undefined') sekunden = 10;
         if (typeof buttons === 'undefined') buttons = new Array();

         var oHead = document.getElementsByTagName('BODY').item(0);

         var oScript = document.createElement('DIV');
         oScript.setAttribute('id','imsgBG');

         oScript.style.left = '0px';
         oScript.style.top = '0px';
         oScript.style.width = '100%';
         oScript.style.height = '100%';

         oHead.appendChild(oScript);

         var oScriptF = document.createElement('DIV');
         oScriptF.setAttribute('id','imsgFRAME');

         oScriptF.style.left = '100px';
         oScriptF.style.top = '300px';
         oScriptF.style.width = '500px';

         if (sekunden < max_sek) {
                 var bmsg = 'dieser Hinweis schließt sich in '+sekunden+' Sekunden';
                 window.setTimeout('remInnerMessage()',(sekunden*1000));
         } else if (buttons.length) {
                 var bmsg = 'abbrechen';
         } else  {
                 var bmsg = 'Meldung schließen';
         }

         oScriptF.innerHTML = msg + '<br>';

         closeFunc = function(){ remInnerMessage(); };
         // Buttons
         for (var n=0; n < buttons.length; n++) {
                  var oScriptB = document.createElement('BUTTON');
                  btnClick = buttons[n][0];

                  oScriptB.onclick = buttons[n][0];
                  oScriptB.innerHTML = buttons[n][1];
                  oScriptF.appendChild(oScriptB);

         }
         // schließen

         var oScript3 = document.createElement('BUTTON');
         oScript3.setAttribute('id','imsgCLOSE');
         oScript3.setAttribute('title','Meldung schließen!');
         oScript3.onclick = closeFunc
         oScript3.innerHTML = bmsg;
         oScriptF.appendChild(oScript3);


         oHead.appendChild(oScriptF);

         fadeOpacity(getE('imsgBG'),0,10,80,25);


         getE('imsgCLOSE').focus();

         innerMessageStatus = 1;


}
function remInnerMessage() {

         if (!innerMessageStatus) return 0;
         clr = document.getElementById('imsgFRAME');  clr.parentNode.removeChild(clr);
         clr = document.getElementById('imsgBG'); clr.parentNode.removeChild(clr);
         innerMessageStatus = 0;
}




/*
               function stepFlyAni(flyID,steps,step,speed,from_x,to_x,from_y,to_y,from_w,to_w,from_h,to_h,doRem) {



                        if (step > steps) {
                           switchDisplay(flyID,0);
                           if (doRem) {
                              clr = document.getElementById(flyID); clr.parentNode.removeChild(clr);
                           }
                           return 1;
                        }

                        var element = document.getElementById(flyID);

                        element.style.left = (from_x + Math.ceil(step*(to_x-from_x)/(steps+1)))+'px';
                        element.style.top = (from_y + Math.ceil(step*(to_y-from_y)/(steps+1)))+'px';
                        element.style.width = (from_w + Math.ceil(step*(to_w-from_w)/(steps+1)))+'px';
                        element.style.height = (from_h + Math.ceil(step*(to_h-from_h)/(steps+1)))+'px';

                        setTimeout('stepFlyAni(\"'+flyID+'\",'+steps+','+(step+1)+', '+speed+', '+from_x+', '+to_x+', '+from_y+', '+to_y+', '+from_w+', '+to_w+', '+from_h+', '+to_h+', '+doRem+');',speed);

               }
*/
/*
               function doFlyAni (flyID,toID,steps,speed,doRem) {

                        var pos1 = getPosition(document.getElementById(flyID));
                        var pos2 = getPosition(document.getElementById(toID));

                        //if (getCookie('DC_USER') == 1)
                        stepFlyAni(flyID,steps,0,speed,pos1.x,pos2.x,pos1.y,pos2.y,pos1.w,pos2.w,pos1.h,pos2.h,doRem);
               }
*/



function convert2bool(val) {
         if (val==0 || val=='') return 0;
         return 1;
}

function turnbool(val) {
         if (val) return 0;
         return 1;
}

function isIdent (str1,str2) {
         if (str1==str2) return 1;
         return 0;
}

function trim(s) {
         while (s.substring(0,1) == ' ')
                s = s.substring(1,s.length);
         while (s.substring(s.length-1,s.length) == ' ')
                s = s.substring(0,s.length-1);
         return s;
}

function getPosition (element,respectFixed) {

         // FIX: 19.1.2011, 10:45
         // Bei position Fixed (muss in STYLE, nicht in der CSS angegeben werden)
         // wird das Scrolltop addiert (Opera macht das alleine!!)
         // FIX: 23.3.2009, 10:00
         // IE7 Bug mit Strict (elem.offsetTop is NULL)

         // FIX: 28.8.2008, 14:30
         // Keine Negativen Offsets (Opera Bug)

         position=new Object();

         if (typeof element !== 'object') return position;

         if (typeof respectFixed === 'undefined') respectFixed = 0;


         position.p = getStyleVal(element,'position');

         position.z = getStyleVal(element,'zIndex');


         position.y = 0;
         position.x = 0;

         scrollY = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
         scrollX = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);

         var elem=element,tagname='',x=0,y=0;
         while ((typeof(elem)=='object')&& elem != null &&(typeof(elem.tagName)!='undefined')) {

                 var pt = getStyleVal(elem,'position');
                 if (pt == 'fixed' || pt == 'absolute') position.p=pt;

                 position.z = Math.max(position.z,getStyleVal(elem,'zIndex'));

                 position.y += Math.max(0,elem.offsetTop);
                 position.x += Math.max(0,elem.offsetLeft);

                 tagname=elem.tagName.toUpperCase();
                 if (tagname=='BODY')
                         elem=0;
                 if (typeof(elem)=='object' && typeof(elem.offsetParent)=='object')
                         elem=elem.offsetParent;
         }

         if (position.p == 'fixed') {


         /* mit OPERA Version 11 teilweise noch ProblemE
            if (!isOpera) {
         */
            position.y += scrollY;
            position.x += scrollX;


            if (respectFixed) {
                position.ya = position.y;
                position.xa = position.x;

                position.y -= scrollY;
                position.x -= scrollX;
            }
         }


         position.h=element.offsetHeight;
         position.w=element.offsetWidth;

         return position;
}

function getStyleVal(obj,value){
                 if (obj.currentStyle){
                         return obj.currentStyle[value];
                 } else if (window.getComputedStyle) {
                         var objStyle = window.getComputedStyle(obj, "");
                         return objStyle.getPropertyValue(value);
                 } else {
                         return '-1'
                 }
}


function changeEnabledVal (objektID,status) {
         var obj = document.getElementById(objektID);
         if (!obj) return 0;
         if (status == 0) obj.disabled = true;
         if (status == 1) obj.disabled = false;
         return status;
}

function changeClass (objektID,classname) {
         var obj = document.getElementById(objektID);
         obj.className=classname;
}

function checkBoxes(formname,name,val) {
         var objs = document.forms[formname].elements;

         for (var i = 0; i < objs.length; i++) {
         if (typeof name === 'undefined' || !name.length || name == objs[i].getAttribute('name'))
             objs[i].checked = val;
         }
}

function checkAll(formname,tagval,val) {
         var objs = document.forms[formname].elements;

         for (var i = 0; i < objs.length; i++) {
         if (objs[i].getAttribute('tag') == tagval)
             objs[i].checked = val;
         }
}

function countChecked(formname, name) {
         var objs = document.forms[formname].elements;

         var cnt=0;
         for (var i = 0; i < objs.length; i++) {
             if (objs[i].checked) {
                 if (typeof name === 'undefined' || name == objs[i].getAttribute('name'))
                         cnt++;
             }
         }
         return cnt;
}




function JSGetSwfVer(i) {
        if (navigator.plugins != null && navigator.plugins.length > 0) {
                if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                        var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                      var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                        descArray = flashDescription.split(" ");
                        tempArrayMajor = descArray[2].split(".");
                        versionMajor = tempArrayMajor[0];
                        versionMinor = tempArrayMajor[1];
                        if ( descArray[3] != "" ) {
                                tempArrayMinor = descArray[3].split("r");
                        } else {
                                tempArrayMinor = descArray[4].split("r");
                        }
                      versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
              } else {
                        flashVer = -1;
                }
        }
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
        else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
        else {

                flashVer = -1;
        }
        return flashVer;
}

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
        reqVer = parseFloat(reqMajorVer + "." + reqRevision);
        for (i=25;i>0;i--) {
                if (isIE && isWin && !isOpera) {
                        versionStr = VBGetSwfVer(i);
                } else {
                        versionStr = JSGetSwfVer(i);
                }
                if (versionStr == -1 ) {
                        return false;
                } else if (versionStr != 0) {
                        if(isIE && isWin && !isOpera) {
                                tempArray         = versionStr.split(" ");
                                tempString        = tempArray[1];
                                versionArray      = tempString.split(",");
                        } else {
                                versionArray      = versionStr.split(".");
                        }
                        versionMajor      = versionArray[0];
                        versionMinor      = versionArray[1];
                        versionRevision   = versionArray[2];

                        versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
                        versionNum        = parseFloat(versionString);
                        if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                                return true;
                        } else {
                                return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
                        }
                }
        }
}

function aTrim(s) {

  v = h = '';
  c = s;

  while (c.substring(0,1) == ' ') {
    v += c.substring(0,1);
    c = c.substring(1,c.length);
  }
  while (c.substring(c.length-1,c.length) == ' ') {
    h += c.substring(c.length-1,c.length);
    c = c.substring(0,c.length-1);
  }
  return new Array(v,c,h);
}

function parseDecimal (input,komma,standard,extMode,minVal,maxVal,einheit) {
  if (typeof komma === 'undefined') komma = 2;
  if (typeof einheit === 'undefined') einheit = '';
  if (typeof standard === 'undefined'){
         if (typeof minVal != 'undefined') standard = Math.max(minVal,0);
         if (typeof maxVal != 'undefined') standard = Math.min(maxVal,standard);
  }
  if (typeof extMode === 'undefined') extMode = 0;

  // Trim String
  // Inhalt besteht nur noch aus Zahlen und Punkten
  // Das letzte Zeichen kann kein Punkt sein
  input = input.replace(/^[^\d\.,]*?((\-(?=\d))?[\d\.,]*\d).*$/, '$1');
  input = input.replace(/^([\.,].*)$/, '0$1');

  var input_alt = input;
  var isNeg = 0;
  var isErr = 0;
  input = input.replace(/^\-(.*)$/, '$1');
  if (input != input_alt) isNeg = 1;

  var regErg = input.match(/^(\d{0,3}?)([\.,])?(\d{0,3}?)([\.,])?(\d+)$/);
  if (!regErg) {
    isErr = 1;
  } else {
    var z3 = regErg[1];
    var t2 = regErg[2];
    var z2 = regErg[3];
    var t1 = regErg[4];
    var z1 = regErg[5];

    if (typeof z3 === 'undefined') z3 = '';
    if (typeof t2 === 'undefined') t2 = '';
    if (typeof z2 === 'undefined') z2 = '';
    if (typeof t1 === 'undefined') t1 = '';
    if (typeof z1 === 'undefined') z1 = '';

    var wert=0;
    if (!t1.length) {
      //Blanke Zahl
      wert += parseFloat(z1);
    } else if (((t1 != t2) && t2.length) || (t1 != t2 && (z1.length != 3 || komma >= 3))) {
      //mit Nachkomma
      if (z3.length && z2.length != 3) {
        isErr = 1;
      } else {
        wert += parseFloat(0+'.'+z1);
        if (z2.length) wert += parseFloat(z2);
        if (z3.length) wert += parseFloat(z3)*1000;
      }
    } else {
      // 2 gleiche Trennzeichen
      if ((z3.length && z2.length != 3) || (z2.length && z1.length != 3)) {
        isErr = 1;
      } else {
        wert += parseFloat(z1);
        if (z2.length) wert += parseFloat(z2)*1000;
        if (z3.length) wert += parseFloat(z3)*1000*1000;
      }
    }
  }

  if (isNeg) wert *= -1;

  if (wert != standard) {
     if (typeof minVal != 'undefined') wert = Math.max(minVal,wert);
     if (typeof maxVal != 'undefined') wert = Math.min(maxVal,wert);
  }
  if (isErr) wert = standard;

  // ist numerisch?
  if (String(wert).match(/^[\-]?[\d\.]+$/)) {
    if (extMode) return number_format(wert,komma,',','.')+einheit;
    return number_format(wert,komma,'.','');
  }
  return wert;
}

function number_format(number, decimals, sym_dezimal, sym_tausend) {
  var n = !isFinite(+number) ? 0 : +number,
  prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
  sep = (typeof sym_tausend === 'undefined') ? '.' : sym_tausend, dec = (typeof sym_dezimal === 'undefined') ? ',' : sym_dezimal,
  s = '',
  toFixedFix = function (n, prec) { var k = Math.pow(10, prec); return '' + Math.round(n * k) / k; };

  s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');

  if (s[0].length > 3)
    s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);

  if ((s[1] || '').length < prec) {
     s[1] = s[1] || '';
     s[1] += new Array(prec - s[1].length + 1).join('0');
  }
  return s.join(dec);
}

function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

//setCookie('test',Math.random())


function setCookie(name,value) {
       if (typeof value === 'undefined') {
         // löschen
         document.cookie = name+ '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
       } else {
         // beschreiben
         document.cookie = name+'='+value+';';
       }
}


               function moveObjectStep(eFly,steps,step,speed,from_x,to_x,from_y,to_y,from_w,to_w,from_h,to_h,method,filter,methodP) {

                        if (step > steps) {

                           if (method =='remove') {
                              switchDisplay(eFly,0);
                              eFly.parentNode.removeChild(eFly);
                           } else if (method =='fadeout') {
                              eFly.style.filter = 'Alpha(opacity=100)';
                              eFly.style.opacity = 1;
                              switchDisplay(eFly,0);
                           } else if (method =='reset') {
                             fadeOpacity(eFly,0,10,100,25);
                             eFly.style.position = methodP.p;
                             if (isNaN(methodP.z)) {
                                 eFly.style.zIndex = 0;
                             } else {
                                 eFly.style.zIndex = methodP.z;
                             }
                             if (methodP.p != 'static') {
                                eFly.style.position = methodP.p;
                                eFly.style.left = methodP.x+'px';
                                eFly.style.top = methodP.y+'px';
                                eFly.style.width = methodP.w+'px';
                                eFly.style.height = methodP.h+'px';
                             } else {
                               eFly.style.left = '0px'; eFly.style.top = '0px';
                               eFly.style.width = ''; eFly.style.height = '';
                             }

                           }

                           return 1;
                        }
                        var progress = 1-(steps-step)/steps;

                        var offset_x = 0;
                        var offset_y = 0;
                        if (typeof methodP.scrollTop == 'number') {
                                 offset_y = Math.max(document.body.scrollTop,document.documentElement.scrollTop) - methodP.scrollTop;
                        }

                        eFly.style.left = (offset_x + from_x+(to_x-from_x)*progress)+'px'
                        eFly.style.top = (offset_y + from_y+(to_y-from_y)*progress)+'px'

                        if (filter.chSize) {
                         eFly.style.width = (from_w+(to_w-from_w)*progress)+'px'
                         eFly.style.height = (from_h+(to_h-from_h)*progress)+'px'
                        }

                        if (filter.fadeOut) {
                         eFly.style.filter = 'Alpha(opacity='+Math.round((1-progress)*100)+')';
                         eFly.style.opacity = 1-progress;
                        }

                        window.setTimeout(function() { moveObjectStep(eFly,steps,step+1,speed,from_x,to_x,from_y,to_y,from_w,to_w,from_h,to_h,method,filter,methodP); }, speed);



               }


               function moveObject (eFly,eTo,steps,speed,method) {

                         // vorrausschauend:
                         // Elemente die bisher STATIC sind, sollten RELATIV fliegen.

                        // fadeout - Objekt anschließend ausblenden
                        // reset - Objekt anschließend wieder an Ursprung einblenden
                        // rem - Objekt anschließend löschen

                        // FEHLERHAFT:
                        //if (typeof eFly != 'object') { alert('FLY-E nicht gefunden'); return position; }
                        //if (typeof eTo != 'object') { alert('FLY-TO nicht gefunden'); return position; }


                        mOM = new Array('fadeout','reset','remove');
                        if (!mOM.contains(method)) method = 'fadeout';

                        var filter = new Object();
                        filter.chSize=1;
                        filter.fadeOut=1;

                        var methodP = new Object();
                        methodP=getPosition(eFly,1);

                        var posFly = getPosition(eFly,1);

                        var rFix2 = 0;
                        if (posFly.p=='fixed') rFix2 = 1;

                        var posTo = getPosition(eTo,rFix2);

                        if (posFly.p == 'fixed' && posTo.p != 'fixed') {
                                 // Flug von Fix zu non-fixed
                                 eFly.style.position = 'absolute';

                                 posFly.x=posFly.xa; posFly.y=posFly.ya; //absolutwerte Laden

                        }

                        if (posTo.p == 'fixed' && posFly.p != 'fixed') {
                                 methodP.scrollTop = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
                        }

                        var from_x = posFly.x;
                        var from_y = posFly.y;

                        var to_x = posTo.x;
                        var to_y = posTo.y;

                        var from_w = posFly.w;
                        var from_h = posFly.h;

                        var to_w = posTo.w;
                        var to_h = posTo.h;

                        if (posFly.p =='static') {
                                 posFly.p = eFly.style.position = 'relative';
                        }

                        if (posFly.p == 'relative') {

                                 offset_x = parseFloat(getStyleVal(eFly,'left'));
                                 offset_y = parseFloat(getStyleVal(eFly,'top'));
                                 if (isNaN(offset_x)) offset_x = 0;
                                 if (isNaN(offset_y)) offset_y = 0;

                                 methodP.x = offset_x;
                                 methodP.y = offset_y;


                                 to_x -= (from_x - offset_x);
                                 to_y -= (from_y - offset_y);



                                 from_x = offset_x; //+ aktueller Offset
                                 from_y = offset_y;

                                 filter.chSize=0;
                        }


                        if (!filter.chSize) {
                                 // ZEntrieren
                                 to_x += Math.round((to_w-from_w)/2);
                                 to_y += Math.round((to_h-from_h)/2);
                        }

                        eFly.style.zIndex  = 100000000;

                        //alert('X: '+from_x+' Y: '+from_y+' (' + posFly.p+ ')\n\nX: '+to_x+' Y: '+to_y+' (' + posTo.p+ ')');


                        moveObjectStep(eFly,steps,0,Math.round(speed/steps),from_x,to_x,from_y,to_y,from_w,to_w,from_h,to_h,method,filter,methodP);
               }
