// 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)
{
    return ((s == null) || (s.length == 0))
}
//------------------------------------------------------------------------------------------------

function isFloat (s)

{
    var i;
    var decimalPointDelimiter = "."
    var seenDecimalPoint = false;

   if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return false;
      else return (isFloat.arguments[1] == true);

   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;
       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 get( ID ) {
	return	document.getElementById( ID );	
}
//---------------------------------------------------------------------------------------------------
function showDiv( ID ) {
	if( Div = get( ID ) ) {
		Div.style.display	=	"block";
	}
}
//---------------------------------------------------------------------------------------------------
function hideDiv( ID ) {
	if( Div = get( ID ) ) {
		Div.style.display	=	"none";	
	}
}
//---------------------------------------------------------------------------------------------------
