/************************************************************************
*  Standard-Java-Scripts                                                *
*  Stand:  20.9.2003                                                    *
************************************************************************/

function displayId(o,ok){	
	obj = document.getElementById(o)
	if ((ok==1)||(ok==0)) {
		if (ok==1)
			obj.style.display='inline';
		else
			obj.style.display='none';
	}
	else {
		if (obj.style.display=='none')
			obj.style.display='inline';
		else
			obj.style.display='none';
	}
}

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;

  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return foundObj;
}

// * Dependencies *
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

////////////////////////////////////////////////////////////////////
//                                                                //
//  openWindow                                                    //
//                                                                //
//  (c) 2003 MBL - Medienagentur Bärbel Laszczyk                  //
//                                                                //
//  Parameter:                                                    //
//  URL - relativer oder absoluter Pfad                           //
//  typ - popup - Fenster ohne Schnickschnack                     //
//      - scroll - popup aber scrollbars                          //
//      - normal - Normales Fenster mit allem                     //
//      - String - individuelle Einstellungen                     //
//   left, top - Position in Pixel von links, bzw. oben           //
//   width, height - Breite, bzw. Höhe des Fensters in Pixel      //
//                                                                //
////////////////////////////////////////////////////////////////////


var Win=0;
function openWindow(URL, typ, name, left, top, width, height)
{
  var parameter = '';
  if (typ=='popup')
  	parameter = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no';
  else if (typ=='scroll')
  	parameter = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no';
  else if (typ=='normal')
  	parameter = 'toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes';
	else parameter = typ;
  if(!width)  width = Math.floor(screen.width/2);
  if(!height) height= Math.floor(screen.height/2);
  if(!left)   left  = Math.floor((screen.width - width)/2);
  if(!top)    top   = Math.floor((screen.height - height)/2);
  if (!name) name = 'Win';
  if(Win)
  {
    if(!Win.closed) Win.close();
  }
  // alert(left+' - '+top+' - '+width+' - '+height+' - '+name);
  Win = open(URL, name, parameter + ',width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function Format(num,stellen){
   //alert(num);
   num = num.toString();
   var ret = '';
   if (num.indexOf('.')>0) {
      var pos = num.indexOf('.');
      var voll = parseInt(num.substr(0,pos));
      var rest = num.substr(pos+1,num.length);
      var restnum = parseInt(rest);
      //alert(num+' - '+voll+' - '+rest+' - '+restnum);
      var max1 = 0;
      for (var i=0; i<stellen;i++) {
         max1 += Math.pow(10,i)*9
      }
      //alert('Max1: ' + max1);
      var max2 = Math.pow(10,(stellen-1));
      //alert('Max2: ' + max2);
      if (restnum>max1) {
         rest = rest.toString();
         //alert(rest + ' - ' + rest.length);
         var v1 = rest.substr(0,stellen);
         var v2 = rest.substr(stellen,rest.length);
         //alert(v1 + ' - ' + v2);
         var nachkomma = Math.round(parseFloat(v1 + '.' + v2));
         //alert(nachkomma);
         ret = voll + '.' + nachkomma;
      }
      else if (restnum < max2) {
         ret = voll + '.' + rest;
         for (var i=1;i<(stellen-rest.length+1);i++) {
            ret += '0';
         }
      }
      else {
         ret = voll + '.' + rest;
      }
      //alert(ret);
   }
   else {
      ret = num + '.';
      for (var i=1;i<=stellen;i++) {
         ret += '0';
         //alert(num+' - '+i+' - '+stellen+' - '+ret);
      }
   }
   //alert(ret);
   return ret;
}


