 /* JavaScript-Funktionen
  * @version       3.00
  * @revision      $Revision: 001 $
  * @lastmodified  $Date: 2007-08-18 16:03:42 +0200 (Sa, 18 Aug 2007) $
  * @author        M. Overkamp
  * @copyright     Copyright 2004-2008 GISWORKS
  *
  * @package       ruhrsite metropoleruhr
  * @subpackage    public
  *
  */

  /** E-Mail-Adressen vor Robots schützen */
  function decode(text1, text2) {
    document.write('<a href="' + 'mailto:' + text1 + '@' + text2 + '">' + text1 + '@' + text2 + '<\/a>');
  }


  function UnCryptMailto(s, shift) {
  	var n=0;
  	var r="";
  	for(var i=0;i<s.length;i++) {
  		n=s.charCodeAt(i);
  		if (n>=8364) {n = 128;}
  		r += String.fromCharCode(n-(shift));
  	}
  	return r;
  }
  function linkTo_UnCryptMailto(s, shift)	{
  	location.href=UnCryptMailto(s, shift);
  }


  /**        */
  function pop(url, name, weite, hoehe) {
    var hoehepop = hoehe + 40;
    var weitepop = weite + 20;
    var fenster;
    name = "Profil";
    fenster = window.open(url,name,"resizable=yes,scrollbars=yes,width="+weitepop+",height="+hoehepop+",screenX=10,screenY=10,left=10,top=10");
    //fenster = window.open(url, name, "resizable=yes,scrollbars=yes,width="+weitepop+",height="+hoehepop+",");
    if (fenster != null)
    if (fenster.closed);
    fenster.focus();
  }


  /** Ermitteln und Anzeigen der noch verbleibenden Anzahl an Zeichen in einem Feld */
  function Rest_Zeichen(form, max_laenge, anzeige) {
  	var ErlaubteAnzahl = max_laenge;

  	Laenge = form.value.length;
  	if(Laenge > ErlaubteAnzahl) {
  	  form.value = form.value.substring(0,ErlaubteAnzahl);
  	  RestlicheZeichen = 0;
  	} else {
  		RestlicheZeichen = ErlaubteAnzahl - Laenge;
  	}
  	anzeige.value = RestlicheZeichen;
  }



  /** E-Mail-Adresse auf gewisse Regeln &uuml;berpr&uuml;fen wird von function ok() aufgerufen */
  function check_email(str) {
    var at = "@";
		var dot = ".";
		var lat = str.indexOf(at);
		var lstr = str.length;
		var ldot = str.indexOf(dot);
		if (str.indexOf(at) == -1){ return false;}
		if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr){ return false;}
		if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr){ return false;}
		if (str.indexOf(at,(lat+1)) != -1){	return false;}
		if (str.substring(lat-1,lat) == dot || str.substring(lat+1,lat+2) == dot){ return false;}
		if (str.indexOf(dot,(lat+2)) == -1){ return false;}
		if (str.indexOf(" ") != -1){ return false;}

 		return true;
	}


	// Koordinaten darauf prüfen, dass nur Ziffern 0 - 9 eingetragen sind
  	function check_koordinate(koordinate) {
      var length = koordinate.length;
      var aChar;
      for(var i = 0; i != length; i++) {
        aChar = koordinate.substring(i, i + 1)
        if(aChar < "0" || aChar > "9") {
          return false;
        }
      }
      return true;
    }

    // Rechtswert auf innerhalb Boundingbox prüfen
    // metropoleruhr Hochwert zwischen 5675000 und 5744000
    function check_rechtswert(koordinate) {
      if(koordinate < 2520000 || koordinate > 2639000) {
        return false;
      }
      return true;
    }

    // Hochwert auf innerhalb Boundingbox prüfen
    // metropoleruhr Hochwert zwischen 5675000 und 5744000
    function check_hochwert(koordinate) {
      if(koordinate < 5675000 || koordinate > 5744000) {
        return false;
      }
      return true;
    }