
<!--


// nützliche allgemeine JavaScript-Functionen



// --- AJAX-Funktionen Start -------------------------------------------


function createXmlHttpReqObj()
{
	var resObj = null;	
	
	try
	{
		resObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(Error)
	{
		try
		{
			resObj = new ActiveXObject("MSXML2.XMLHTTP");
		}
		catch(Error)
		{
			try
			{
				resObj = new XMLHttpRequest();
			}
			catch(Error)
			{
				alert('Erzeugung des XMLHttpRequestObjekts ist nicht möglich');
			}
		}
	}
	
	return resObj;
	
}



// --- AJAX-Funktionen Ende -------------------------------------------


	function openWin(ziel,breit,hoch,behave)
		{
		NewWindow = window.open(ziel,"Stationsinfo","width="+breit+",height="+hoch+","+behave+"");
		}

	function toggleIcon(dataID, iconID, iconState)
		{
		//alert(iconID + '_' + iconState + '.gif');
		document.getElementById(dataID + '_' + iconID).src = 'mobjects/' + iconID + '_' + iconState + '.gif';
		}

	function toggleBtnIcon(dataID, iconID, iconState)
		{
		//alert(dataID + '_' + iconID + '_' + iconState);
		document.getElementById(dataID + '_' + iconID).style.backgroundImage = 'url(mobjects/' + iconID + '_' + iconState + '.gif)';
		//background-image:url(mobjects/icon_filter_g.gif);
		}



var currValuesOK = false;
function checkcurrvalue(id, title, aktval, minval, maxval)
// auch auf NaN prüfen!
//20030723: focus() bei fehlermeldungen auskommentiert wg schleife
{
	//alert('Checking ' + title + ': ' + aktval + '/' + minval + '/' + maxval);

	//kommapos = aktval.indexOf(',');
	//alert('kommapos = ' + kommapos);

	if (isNaN(aktval.replace(/,/,'.')) == true)
	{
		currValuesOK = false;
		alert('Bitte geben Sie für ' + title + ' einen Betrag ein! (Formatbeispiel: nnn,nn)');
		//document.getElementById(id).focus();
	}
	/*
	elseif (aktval.indexOf(',') < 1)
	{
		currValuesOK = false;
		alert('Bitte geben Sie für ' + title + ' einen Betrag mit 2 Nachkomastellen ein! (Formatbeispiel: nnn,nn)');
		//document.getElementById(id).focus();
	}
	*/
	else
	{
		aktval2 = parseFloat(aktval.replace(/,/,'.'));
		minval2 = parseFloat(minval.replace(/,/,'.'));
		maxval2 = parseFloat(maxval.replace(/,/,'.'));
		//alert('parsed: ' + aktval2 + '/' + minval2 + '/' + maxval2);

		if (aktval2 < minval2) 
		{
			currValuesOK = false;
			alert('Der Wert für ' + title + ' muss mindestens ' + minval + ' betragen!');
			//document.getElementById(id).focus();
			//document.getElementById(id).focus();
		}
		else
		{
			currValuesOK = true;
		}

		if (aktval2 > maxval2)
		{
			currValuesOK = false;
			alert('Der Wert für ' + title + ' darf höchstens ' + maxval + ' betragen!');
			//document.getElementById(id).focus();
		}
		else
		{
			currValuesOK = true;
		}
	}
}
function checkCurrValuesStatus()
{
	//alert('currValuesOK = ' + currValuesOK);
	return currValuesOK;
}


function toggleButtons(that)
//wird auf jeder seite benötigt, um bei änderungen in formfields 
//ein abspeichern der form zu erzwingen, disabled nextstep-button 
{ //if (document.getElementById(that).defaultChecked != document.getElementById(that).checked)
	{
		//alert(that);
		//alert(document.getElementById(that).defaultChecked);
		//alert(document.getElementById(that).checked);
		//alert('submit');
		document.getElementById('submitForm').disabled='';
		//alert('save');
		document.getElementById('goNextStep').disabled='disabled';
	}
}


function toggle2Ta(ta_x, ta_y)
//wird in tarifgruppen.asp eingesetzt um zwischen zwei checkboxen zu toggeln
//von denen nur eine gewählt werden darf. radiobuttons werden nicht eingesetzt, weil 
//sonst die submit-auswertung nicht mehr als schleife laufen kann
{
	if (document.getElementById(ta_x).checked = true) 
	{
		document.getElementById(ta_y).checked = false;
	}
	else if (document.getElementById(ta_y).checked = true) 
	{
		document.getElementById(ta_x).checked = false;
	}
}


function toggleMin1Ta(ta_x, ta_y)
//wird in tarifarten_indiv.asp eingesetzt um zwischen zwei checkboxen zu toggeln
//von denen mindestens eine gewählt werden muss. radiobuttons werden nicht eingesetzt, weil 
//sonst die submit-auswertung nicht mehr als schleife laufen kann
{
	if (document.getElementById(ta_x).checked == false) 
	{
		document.getElementById(ta_y).checked = true;
	}
	/*
	if (document.getElementById(ta_y).checked == false) 
	{
		document.getElementById(ta_x).checked = true;
	}
	*/
}


//--- Start MAILADRESSEN-Checker -------------------------------------------------------------------------


  function isDigit( ch )
  {
    if ( (ch >= '0') && (ch <= '9') )
      return true;
    else
      return false;
  }


  function isAlpha( ch )
  {
    if ( ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) )
      return true;
    else
      return false;
  }


  function isAlnum( ch )
  {
    if ( isAlpha( ch ) || isDigit( ch ) )
      return true;
    else
      return false;
  }


  function notIn( str1, str2 )
  {
    var i = 0;
    var j = str2.length;
    for( ; i<j; i++ )
    {
      var str3 =  str2.charAt(i);
      if( str1.indexOf( str3 ) != -1 )
        return false;
    }
    return true;
  }


  function checkUsername( username, mustBeQuoted )
  {
    var i = 0;
    var j = username.length;
    if ( username.charAt(0) != '"' )
    {
      if ( (username.charAt(0) <  ' ') || (username.charAt(0) >  '~')
            || !notIn( mustBeQuoted, username.charAt(0) ) )
        return false;
      for( i=1; i<j; i++ )
      {
        if ( ( (username.charAt(i) < ' ') || (username.charAt(i) >  '~')
              || !notIn ( mustBeQuoted, username.charAt(i) ) )
             && ( username.charAt(i-1) != '\\' ) )
          return false;
      }
    }
    else
    {
      if ( username.charAt( j-1 ) != '"' )
        return false;
      for( i=1; i<j-1; i++ )
      {
        if ( ( (username.charAt(i) == '\n') || (username.charAt(i) == '\r')
              || (username.charAt(i) == '\"') )
            && (username.charAt(i-1) != '\\') )
          return false;
      }

    }
    return true;
  }


  function checkNr ( nr )
  {
    var i=0;
    var j=nr.length;

    if( j < 1 )
      return false;

    for( ; i<j; i++ )
      if( ( nr.charAt(i) < '0' ) || ( nr.charAt(i) > '9' ) )
        return false;

    return true;
  }


  function checkIpnr( ipnr )
  {
    var iL=0;
    var iC=0;
    var i=0;
    var sNr = "";

    for( ; i< ipnr.length; i++ )
    {
      if ( ipnr.charAt(i) == '.' )
      {
        if ( !iL || (iL> 3) || parseInt( sNr,10 ) > 255 )
          return false;
        iC++;
        iL = 0;
        sNr = "";
        continue;
      }
      if ( isDigit ( ipnr.charAt(i) ) )
      {
        iL++;
        sNr = sNr + ipnr.charAt(i);
        continue;
      }
      return false;
    }

    if ( parseInt( sNr,10 ) > 255 )
      return false;
    if ( ( (iC==3) && (iL>=1) && (iL<=3) ) || ( (iC==4) && (!iL) )  )
      return true;
    else
      return false;
  }


  function checkFqdn( fqdn )
  {
    var iL=0;
    var iC=0;
    var i=fqdn.length-1;

    if ( (fqdn.charAt(0) == '.') || (fqdn.charAt(0) == '-') )
      return false;
    if ( fqdn.charAt(i) == '.' )
      i=i-1;

    for( ; i>=0; i-- )
    {
      if ( fqdn.charAt(i) == '.' )
      {
        if ( iL < 2 && iC < 2 )
          return false;
        if ( fqdn.charAt(i-1) == '-' )
          return false;
        iC++;
        iL = 0;
        continue;
      }
      if ( isAlnum ( fqdn.charAt(i) ) )
      {
        iL++;
        continue;
      }
      if ( fqdn.charAt(i) == '-' )
      {
        if ( !iL )
          return false;
        iL++;
        continue;
      }
      return false;
    }

    if ( !iC || ( iL == 1 && iC < 2 ) || ( !iL && iC==1 ) ) {
      return false;
    }

    return true;

  }


  function checkHostname( hostname )
  {
    if ( hostname.charAt(0) == '[' )
    {
      if ( hostname.charAt(hostname.length-1) != ']' )
        return false;
      var ipnr = hostname.substring( 1, hostname.length -1 );
        return checkIpnr( ipnr );
    }

    if ( hostname.charAt(0) == '#' )
    {
      var nr = hostname.substring( 1, hostname.length );
        return checkNr( nr );
    }

    return checkFqdn( hostname );
  }


  function checkEmailAdr( address )
  {
    var status = true;
    var username = "";
    var hostname = "";

    if ( address.length < 8 )
      return false;

    var seperate = address.lastIndexOf("@");
    if ( seperate == -1 )
      return false;

    username = address.substring(0, seperate );
    if ( ! checkUsername( username, "<>()[],;:@\" " ) )
      return false;

    hostname = address.substring(seperate+1, address.length );
    if ( ! checkHostname( hostname ) )
      return false;

    return true;
  }


  function checkEmail( email, allowFullname )
  {
    var existFullname = false;
    var status = true;
    var fullname = "";
    var adress = "";
    if ( email.length < 8 )
      return false;
    var emailBegin = email.indexOf("<");
    var emailEnd = email.lastIndexOf(">");

    if ( (emailBegin == -1) && (emailEnd == -1) )
      return checkEmailAdr( email );

    if ( ( (emailBegin == -1) && (emailEnd != -1) )
        || ( (emailBegin != -1) && (emailEnd == -1) ) )
      return false;

    adress = email.substring( emailBegin+1, emailEnd );

    if ( ! checkEmailAdr( adress ) )
      return false;

    if ( email.length == adress.length + 2 )
      return true;
    else
      if ( ! allowFullname )
        return false;

    if ( emailEnd == email.length - 1 )
    {
      if ( emailBegin == 0 )
        return true;
      if ( email.charAt( emailBegin -1 ) != ' ' )
        return false;
      fullname = email.substring( 0, emailBegin-1 );
      return checkUsername ( fullname, "<>()[],;:@\"" );
    }

    return false ;

  }



//--- Ende MAILADRESSEN-Checker -------------------------------------------------------------------------


//-->

