// JavaScript Document
//-----------------------------------------------------------------------------------------------
var defaultEmptyOK = false


function isInteger (s)
{

var i;

if (isEmpty(s))
    if (isInteger.arguments.length == 1) return defaultEmptyOK;
   else return (isInteger.arguments[1] == true);
   for (i = 0; i < s.length; i++)
    {
         // Check that current character is number.
         var c = s.charAt(i);
         if (!isDigit(c)) return false;
    }
// All characters are numbers.
return true;
}

//------------------------------------------------------------------------------------------------

// Returns true if character c is a digit
// (0 .. 9).

function isDigit (c)
{
    return ((c >= "0") && (c <= "9"));
}

//------------------------------------------------------------------------------------------------

function isEmpty(s)
{

var whitespace = new String(" ");

//   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
    {
      // We have a string with trailing blank(s)...
      var i = s.length - 1;       // Get length of string
      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }




    return ((s == null) || (s.length == 0))
}
//------------------------------------------------------------------------------------------------

function isFloat (s)

{
    var i;
    var decimalPointDelimiter = "."
	var decimalPointDelimiter2 = ","
    var seenDecimalPoint = false;

   if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return false;
      else return (isFloat.arguments[1] == true);

  if ((s == decimalPointDelimiter)||(s == decimalPointDelimiter2)) return false;
//   if (s == decimalPointDelimiter) return false;

   // Search through string's characters one by one
   // until we find a non-numeric character.
   // When we do, return false; if we don't, return true.

   for (i = 0; i < s.length; i++)
   {   
        // Check that current character is number.
       var c = s.charAt(i);

  //     if ( (c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
    if ( ((c == decimalPointDelimiter) || (c == decimalPointDelimiter2)) && !seenDecimalPoint) seenDecimalPoint = true;
       else if (!isDigit(c)) return false;
   }

   // All characters are numbers.
   return true;
}

//------------------------------------------------------------------------------------------------

// isNegativeInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer < 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

   if (isNegativeInteger.arguments.length > 1)
       secondArg = isNegativeInteger.arguments[1];

   // The next line is a bit byzantine.  What it means is:
   // a) s must be a signed integer, AND
   // b) one of the following must be true:
   //    i)  s is empty and we are supposed to return true for
   //        empty strings
   //    ii) this is a negative, not positive, number

   return (isSignedInteger(s, secondArg)
        && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );

}

//------------------------------------------------------------------------------------------------

// isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK])
// 
// isIntegerInRange returns true if string s is an integer 
// within the range of integer arguments a and b, inclusive.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.


function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
      else return (isIntegerInRange.arguments[1] == true);

   // Catch non-integer strings to avoid creating a NaN below,
   // which isn't available on JavaScript 1.0 for Windows.
   if (!isInteger(s, false)) return false;

   // Now, explicitly change the type to integer via parseInt
   // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
   // and JavaScript 1.1 and before (which doesn't).
   var num = parseInt (s);
   return ((num >= a) && (num <= b));
}

//------------------------------------------------------------------------------------------------

// isSignedFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is a signed or unsigned floating point 
// (real) number. First character is allowed to be + or -.
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isSignedInteger, then call isSignedFloat.
//

// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
      else return (isSignedFloat.arguments[1] == true);

   else {
       var startPos = 0;
       var secondArg = defaultEmptyOK;

       if (isSignedFloat.arguments.length > 1)
           secondArg = isSignedFloat.arguments[1];

       // skip leading + or -
       if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
          startPos = 1;    
       return (isFloat(s.substring(startPos, s.length), secondArg))
   }
}
//------------------------------------------------------------------------------------------------

// removes all spaces from a string

function trim (s)
{
    var iLen = s.length;
    var sOut = "";
    var chr = "";

    for (var i=0; i<iLen; i++)
    {
         chr = s.charAt (i); 
          if (chr!=" ")
         {
              sOut = sOut + chr; 
          }
    }
    return sOut;
}



//------------------------------------------------------------------------------------------------

function isAlphaNumeric(s)
{
  var validChars = "abcdefghijklmnopqrstuvwxyz0123456789";
  s = s.toLowerCase();
  
   for (var i = 0; i < s.length; i++) 
   {
     if (validChars.indexOf(s.charAt(i)) == -1)
     return false;
  }
  return true; 
  }
  
//---------------------------------------------------------------------------------------------------

function VerifeMail(adresse)
	{
	//adresse = document.form1.zugemail.value;
	var place = adresse.indexOf("@",1);
	var point = adresse.indexOf(".",place+1);
	if ((place > -1)&&(adresse.length >2)&&(point > 1))
		{
		return true;
		}
	else
		{
		return false;
		}
	}

function trim(str)
{ 
	while (str.substring(str.length-1,str.length)==' ')
	str = str.substring(0, str.length-1);

	while (str.substring(1,0)==' ')
	str = str.substring(1,str.length);

	return str;
}
function nachoben()
{
	//window.scrollTo(0,0); // nach oben - nur für IE
	document.body.scrollTop = 0; // nach oben - funktioniert überall außer NN4.x
	//document.body.scrollTop = document.body.scrollHeight - document.body.clientHeight; // nach unten - funktioniert überall außer NN4.x
}

function VerifeSuchFeld(event)
{
	if (event.keyCode==13)
	{
		SucheChk();
		return false;
	}
	
}

function SucheChk()
{
	var feld, sstr
	
		feld=document.suchform.suchen;
		sstr=feld.value;
		sstr=trim(sstr);

		if ((isEmpty(sstr)==true) || (sstr.length<3))
		{
    		alert("Sie sollen mindestens drei Buchstaben eingeben.");
    		feld.focus();
			return false;
		}
		else 
		{
			document.suchform.submit();
		}
}

function nWin(trg,param)
 { //v3.0
  var newWindow, trg, param
  newWindow = window.open(trg,"subWind", param);
  newWindow.focus();
}
function enableActiveX (containerID)
// Use it, improve it
// by Dirk Alban Adler // KLITSCHE.DE
{
	// No IE = no need to enable
    if (getInternetExplorerVersion () != -1)
    {
        // Get container
        var container = document.getElementById (containerID);
        // Get html in noscript 
        var html = container.innerHTML; 
        // Write html back to container
        container.innerHTML = html;
    }
}
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// Found at: 
// http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp
{
    var rv = -1; // Return value assumes failure
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re  = new RegExp ("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec (ua) != null)
        {
        	rv = parseFloat (RegExp.$1);
        }
    }
    return rv;
}
function checkSearch(Org, Lan) {
	Cat		=	document.getElementById( 'searchcat' ).value;
	Form	=	document.getElementById( 'searchForm' );
	Form.action	=	"default.asp?oid=" + Org + "&lid=" + Lan + "&navid=" + Cat;
	Form.submit();
	
}

  	function displayCorrect() {
		correctBorder( "NAVTD", "NAVBORDER" );
		correctBorder( "NAVTD02", "NAVBORDER02" );
		correctBorder( "NAVTD03", "NAVBORDER03" );
	}
	
	var TempHeight	=	0;

	function correctBorder( ID, Border ) {
		if( ( td = document.getElementById( ID ) ) && ( border = document.getElementsByName( Border ) ) ) {
			Height	=	parseInt( td.offsetHeight ) - 14;
			if( ID == "NAVTD02" ) {
				TempHeight	=	parseInt( border[ 0 ].style.height );
			}
			border[ 0 ].style.height	=	Height + "px";
			border[ 1 ].style.height	=	Height + "px";
		}
	}
	
	function recorrectBorder( ID, Border ) {
		if( ( td = document.getElementById( ID ) ) && ( border = document.getElementsByName( Border ) ) ) {
			Height	=	TempHeight;
			if( isNaN( Height )  ) {
				Height	=	parseInt( td.offsetHeight ) - 14;
			}
			border[ 0 ].style.height	=	Height + "px";
			border[ 1 ].style.height	=	Height + "px";
		}
	}
	
	// Zoom Div anzeigen, bzw. ausblenden
	function showZoom( id ) {
		div	=	document.getElementById( 'zoom' + id );
		if( div.style.display == "block" ) {
			div.style.display = "none";
		}
		else {
			div.style.display = "block";
		}
	}

	// Listeneintrag - Content ausblenden, Überschrift und Kurztext einblenden
	function TableAusblenden(table,headline,kurz)
	{
	document.getElementById(table).style.display = 'none';
	document.getElementById(kurz).style.display = 'block';
	document.getElementById(headline).onclick=function(){TableEinblenden(table,headline,kurz);};
	document.getElementById(headline).className='inact';
	recorrectBorder( "NAVTD02", "NAVBORDER02" );
	}
	// Listeneintrag - Content einblenden, Überschrift und Kurztext ausbleneden
	function TableEinblenden(table,headline,kurz)
	{
	alleAusblenden();
	document.getElementById(table).style.display = 'block';
	document.getElementById(kurz).style.display = 'none';
	document.getElementById(headline).onclick=function(){TableAusblenden(table,headline,kurz);};
	document.getElementById(headline).className='act';
	displayCorrect();
	}
	
	function alleAusblenden() {
		Counter = 0;
		while( ( d1 = document.getElementById( "content" + Counter ) ) && ( d2 = document.getElementById( "head" + Counter ) ) && ( d3 = document.getElementById( "short" + Counter ) ) ) {
			TableAusblenden( d1.id, d2.id, d3.id );
			Counter++;
		}
	}

function DocDetailOnOff (url)
{
document.location.href = url;
//document.body.scrollTop = document.body.scrollHeight - document.body.clientHeight;
}

function DCDownload(url, lan)
{
			var height = 100
			var iLeft = 0;
			//alert(iLeft);
			var iTop  = 0 ;
			var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ;
			sOptions += ",width=" + '200' ;
			sOptions += ",height=" + height ;
			sOptions += ",left=" + iLeft ;
			sOptions += ",top=" + iTop ;
			document.location.href = url + lan;
		//	var PopUpFenster = window.open(url, 'DCDownload', sOptions ) ;
		//	PopUpFenster.opener = self;
}

function DCDocDownload(url, lan)
{
			var height = 100
			var iLeft = 0;
			//alert(iLeft);
			var iTop  = 0 ;
			var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ;
			sOptions += ",width=" + '200' ;
			sOptions += ",height=" + height ;
			sOptions += ",left=" + iLeft ;
			sOptions += ",top=" + iTop ;
			document.location.href = url + lan;
		//	var PopUpFenster = window.open(url, 'DCDownload', sOptions ) ;
		//	PopUpFenster.opener = self;
}

// Formularchecker auch gleich mit rein
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_validateForm() { //v4.0
  var mailfailure = false;
  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; feld = val; if ((val=val.value)!="") {
	  feld.style.backgroundColor = '#FFFFFF';
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) { errors+='- '+nm+' must contain an e-mail address.\n'; mailfailure = true; feld.style.backgroundColor = '#FFEEEE'; }
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') { errors += '- '+nm+' is required.\n'; feld.style.backgroundColor = '#FFEEEE'; } }
  } if (errors) { if( mailfailure ) { alert(FormFailure+"\n"+EmailFailure); } else { alert(FormFailure); } }
  document.MM_returnValue = (errors == '');
}
// --- Flash aktivieren ----------------------------------------------------------------------------------
function enableActiveX (containerID)
// Use it, improve it
// by Dirk Alban Adler // KLITSCHE.DE
{
	// No IE = no need to enable
    if (getInternetExplorerVersion () != -1)
    {
        // Get container
        var container = document.getElementById (containerID);
        // Get html in noscript 
        var html = container.innerHTML; 
        // Write html back to container
        container.innerHTML = html;
    }
}
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// Found at: 
// http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp
{
    var rv = -1; // Return value assumes failure
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re  = new RegExp ("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec (ua) != null)
        {
        	rv = parseFloat (RegExp.$1);
        }
    }
    return rv;
}
var PrintContent	=	"";
// Öffnet eine Seite zum Druck und aktiviert den Druck dort auch sofort
function getPrint() {
	try {
		PrintWin.close();
	}
	catch( e ) { }
	var	PrintWin	=	window.open( "/druckversion.asp", "", "width=610,height=400,resizable=no,menubar=no,status=no" );
	if( Div = document.getElementById( "MIDDLE" ) ) {
		PrintContent	=	Div.innerHTML;
	}
}
function getPrintContent() {
	return	PrintContent;	
}
function get( ID ) {
	return document.getElementById( ID );	
}

function changePic(bildnummer) {
	document.getElementById ('startPic').src = '/pics/Bildgalerie/Galeriebild' + bildnummer + '.jpg';
}
var	CurrentVisibleDiv	=	null
function showDiv( ID ) {
	if( CurrentVisibleDiv != null ) {
		if( Div = get( CurrentVisibleDiv ) ) {
			Div.style.display	=	"none";
		}
	}
	if( Div = get( ID ) ) {
		CurrentVisibleDiv	=	ID;
		Div.style.display	=	"";	
	}
}

function switchDisplay( element ) {
	if( Obj = get( "historie" + element ) ) {
		if( Obj.style.display == 'none' ) {
			Obj.style.display = 'block';
		
			for ( i=1; i <= 10; i++ ) {
				if( T_Obj = get( "historie" + i ) ) {
					if( T_Obj != Obj ) {
						T_Obj.style.display = 'none';
					}
				}
			}
		}
		else {
			Obj.style.display = 'block';
		}
	}
}