
    var knoten;
    var inhalt;
    var timer;

    function getDownload(id,level, fileName, callBack ){
      oMyDownload = window.document.createElement( "iframe" );
      oMyDownload.style.position = "absolute";
      oMyDownload.style.top = "-1000px";
      knoten = document.body.appendChild( oMyDownload );
      timer = setTimeout( function(){check4Download(id,level, callBack );}, 500 );
      oMyDownload.src = fileName;
    }

    function check4Download(id,level, callBack ) {
      try {
        var myContent = oMyDownload.contentWindow.document.body;
        if ( myContent.innerText )
          myContent = myContent.innerText;
        else myContent = myContent.innerHTML;
          callBack(id,level, myContent );
        clearTimeout(timer);
      }
      catch(e) {
        timer = setTimeout( function(){check4Download(id,level, callBack );}, 500 ); };
    }

    function showContent(id,level, content ) {
      inhalt = content.split(";");
      if(inhalt[0]=="-") {
        if(inhalt[1]!="") {
          start_adr[id] = inhalt[1];
          var formular = "form"+id;
          var adr_field = "toAddress"+id;
          document.forms[formular][adr_field].value=inhalt[1];
          if(inhalt[2]!="") {
            info_box_txt[id] = inhalt[2];
          }
          else {
            info_box_txt[id] = info_box_txt_stack[id];
          }
          lat[id] = "";
          long[id] = "";
        }
      }
      else {
        if((inhalt[0]!="") && (inhalt[1]!="")) {
          lat[id] = inhalt[0];
          long[id] = inhalt[1];
          var formular = "form"+id;
          var adr_field = "toAddress"+id;
          document.forms[formular][adr_field].value=lat[id]+","+long[id];
          if(inhalt[2]!="") {
            info_box_txt[id] = inhalt[2];
          }
          else {
            info_box_txt[id] = info_box_txt_stack[id];
          }
        }
      }
      //var ausgabe = "lon: "+lon+"<br>lat: "+lat;
      //document.getElementById("box").innerHTML=ausgabe;
      //document.body.removechild(knoten);
      n2m_load(id);
      if(level==0)
        reload_timer[id] = window.setTimeout("n2m_reload("+id+")",100000); //Daten wegen Mailabrufdauer nach 1,40 Min. nochmal nachladen
    }

    function n2m_reload(id) {
      clearTimeout(reload_timer[id]);
      //n2m_load(id);
      get_mail_data(id,1);

    }


    function get_mail_data(id,level) {
      getDownload(id,level, pop3url[id], showContent);
    }

    function start_timer(id) {
      info_box_txt_stack[id] = info_box_txt[id];
      sto[id] = window.setInterval("get_mail_data("+id+",0)",callint[id]*60000); //60000ms = 1 min
    }


    function set_icon(id) {

       icon_width_scaled[id] = Math.round(icon_width[id] * (icon_scale[id] /100));
       icon_height_scaled[id] = Math.round(icon_height[id] * (icon_scale[id] /100));

       myIcon[id] = new GIcon();
       myIcon[id].image = ownicon[id];
       myIcon[id].iconSize = new GSize(icon_width_scaled[id], icon_height_scaled[id]);   //berechnen
       myIcon[id].iconAnchor = new GPoint(Math.round(icon_width_scaled[id]/2), icon_height_scaled[id]);  //Verschiebung zu Geo Koordinate
       myIcon[id].infoWindowAnchor = new GPoint(Math.round(icon_width_scaled[id]/2), 2);  //Verschiebung zu Geo Koordinate
    }

    function n2m_load(id) {
      if(ownicon[id]!="")
        set_icon(id);

      if (GBrowserIsCompatible()) {
        var map_id = "map"+id;
        var dir_id = "directions"+id;

        map[id] = new GMap2(document.getElementById(map_id));
        if(map_type[id]==0)
          map[id].setMapType(G_NORMAL_MAP);
        else if(map_type[id]==1)
          map[id].setMapType(G_SATELLITE_MAP);
        else if(map_type[id]==2)
          map[id].setMapType(G_HYBRID_MAP);

        gdir[id] = new GDirections(map[id], document.getElementById(dir_id));

        geocoder = new GClientGeocoder();
        if(document.getElementById(map_id).style.width!="0px") {
          if(show_mapcontrol[id]==true) {
            if(mapcontrol_type[id]==0)
              map[id].addControl(new GSmallMapControl());
            else if(mapcontrol_type[id]==1)
              map[id].addControl(new GLargeMapControl());
            else if(mapcontrol_type[id]==2)
              map[id].addControl(new GSmallZoomControl());
            else if(mapcontrol_type[id]==3)
              map[id].addControl(new GScaleControl());
          }
          if(show_typecontrol[id]==true)
            map[id].addControl(new GMapTypeControl());
        }
        showAddress(id,start_adr[id], info_box_txt[id],show_info_box[id]);

      }

    }

    function setDirections(id,fromAddress, toAddress, locale) {
      gdir[id].load("from: " + fromAddress + " to: " + toAddress,
                { "locale": "de" });
    }

    function showAddress(id,address, popUpHtml, infobox) {
      if (geocoder) {
        if((long[id]!="") && (lat[id]!="")) {
          map[id].setCenter(new GLatLng(lat[id], long[id]), zoomlevel[id]);
          if(ownicon[id]!="") {
            markerOptions = { icon:myIcon[id] };
            var marker = new GMarker(new GLatLng(lat[id], long[id]),markerOptions);
          }
          else {
            var marker = new GMarker(new GLatLng(lat[id], long[id]));
          }

          map[id].addOverlay(marker);
          if(infobox)
            marker.openInfoWindowHtml(popUpHtml);

        }
        else {
          geocoder.getLatLng(
            address,
            function(point) {
              if (!point) {
                alert(address + " nicht gefunden");
              }
              else {
                map[id].setCenter(point, zoomlevel[id]);
                if(ownicon[id]!="") {
                  markerOptions = { icon:myIcon[id] };
                  var marker = new GMarker(point,markerOptions);
                }
                else
                  var marker = new GMarker(point);
                map[id].addOverlay(marker);
                if(infobox)
                  marker.openInfoWindowHtml(popUpHtml);
              }
            }
          );

        }

      }

    }
