var primary = new Array();
var alternate = new Array();
var alleMarkierungen = new Array();
var allMarkers = new Object();
var maxSymbols = 90;
var allSymbols = false;
var verschoben = false;
var xmin = -180;
var xmax = 180;
var ymin = -90;
var ymax = 90;
var xmitte = 0;
var ymitte = 0;
var randomVar = 0;
var clientwidth, clientheight, mapwidth, mapheight, size, msgwindow, X, Y;
var winlink = false;
var echolink = false;
var irlp = false;
var relay = false;
var aprs = false;
var dstar = false;
var pskmail = false;
var map1;
var positionen;
var initialized;
var TimeOutID;
var operation = 'query';
var start = 0;
var count = 40;
var logshowed = true;
var statusshowed = true;
var mapImageObject, mapLayerObject;
var logbuchtext;
var greyrow = false;
var serverKarte;

function makeTableRow(sym, call, Lat, Lng, Packet, ReportTime) {
  if (Lat < 0) {
    Lat = -Lat + ' S';
  } else {
    Lat = Lat + ' N';	
  }
  if (Lng < 0) {
    Lng = -Lng + ' W';
  } else {
    Lng = Lng + ' O';	
  }
  if (greyrow) {
    var col = "bgcolor=\"#cccccc\"";
    greyrow = false;
  } else {
    var col = "";
    greyrow = true;
  }
  var html = "<tr><td "+col+">"+sym+"</td><td "+col+"><span class=\"yacht_info_text_normal_bold\"><a href=\"javascript:void(map1.setCenter(new GLatLng("+alleMarkierungen[call].point.lat()+","+alleMarkierungen[call].point.lng()+"), 7));void(fensterOeffnen(new GLatLng("+alleMarkierungen[call].point.lat()+","+alleMarkierungen[call].point.lng()+"),'"+call+"'));\">"+call+"</a></span></td><td "+col+"><span class=\"yacht_info_text_normal_bold_rot\">"+ReportTime.replace(/\+/g, ' ')+"</span></td><td "+col+"><span class=\"yacht_info_text_normal_bold_blau\">"+Lat+"</span></td><td "+col+"><span class=\"yacht_info_text_normal_bold_blau\">"+Lng+"</span></td><td "+col+"><span class=\"yacht_info_text_normal\">"+Packet+"</span></td></tr>";
  return html;
}


function slideDown() {
  document.getElementById("logbook").style.height = 20;
  document.getElementById('logbook').style.top = clientheight - 43;
  logshowed = false;
  document.getElementById("logbookheadsyms").innerHTML = "<img src=\"/pictures/pfeilH.jpg\" onClick=\"slideUp();\">";

}

function slideDownPSK() {
  document.getElementById("pskstatus").style.height = 20;
  statusshowed = false;
  document.getElementById("pskstatusheadsyms").innerHTML = "<img src=\"/pictures/pfeilH.jpg\" onClick=\"slideUpPSK();\">";
}

function slideUpPSK() {
  document.getElementById('pskstatus').style.height = mapheight - 200;
  statusshowed = true;
  document.getElementById("pskstatusheadsyms").innerHTML = "<img src=\"/pictures/pfeilU.jpg\" onClick=\"slideDownPSK();\">";
}

function slideUp() {
  document.getElementById("logbook").style.height = 170;
  document.getElementById('logbook').style.top = clientheight - 193;
  logshowed = true;
  document.getElementById("logbookheadsyms").innerHTML = "<img src=\"/pictures/pfeilU.jpg\" onClick=\"slideDown();\">";
}

function ringOffen() {
  var fenster = window.open("../../html/home/popups/popup_ringsurf.html", "ringsurf", "width=568,height=121,resizable=no,alwaysRaised=yes");
}


function ShowCallsFound() {
  var mycall = document.getElementById("call").value;
  new Effect.Appear(document.getElementById('calldiv'));
  var updater = new Ajax.Updater('maindiv', '/php/findCall.php', {asynchronus: true, method: 'get', onComplete: showResponse, parameters: 'search=' + mycall});
  return false;
}

function showResponse(resp) {
  document.getElementById('maindiv').innerHTML = resp.responseText;
}

function XMLLocation(data, responseCode) {
  var xml = GXml.parse(data);
  var ipInfo = xml.documentElement.getElementsByTagName("Hostip");
  var land = GXml.value(ipInfo[0].getElementsByTagName("countryName")[0]);
  var geocoder = new GClientGeocoder();
  geocoder.getLatLng(land, function(point) {if (point) {map1.setCenter(point, 7);primary[29]=true;primary[56]=true;primary[74]=true;primary[82]=true;primary[84]=true;primary[85]=true;loadMap();}});
}

function fensterOeffnen(punkt, callsign) {
  map1.openInfoWindowHtml(punkt, "<strong>" + callsign + "</strong><br><a href=\"javascript:void(showWindow('" + callsign + "'))\">Station Panel</a><br><a href=\"javascript:void(window.open('http://www.db0anf.de/app/aprs/stations/digiusermap-"+callsign+"', '', 'width=980,height=645'))\">Digi-User Map</a><br><a href=\"javascript:void(window.open('http://www.db0anf.de/app/aprs/stations/digiusage-"+callsign+"?sort=lastheard-d', '', 'width=980,height=580'))\">Used Digipeaters</a>");
}

function makeImgSrc(symbol) {
  var uri = "http://www.positionsreport.de/php/";
  var symbolNumber = symbol.charCodeAt(1);
  if (symbolNumber < 10) {
    symbolNumber = "00" + symbolNumber;
  } else if (symbolNumber < 100) {
    symbolNumber = "0" + symbolNumber;
  }
  symbolNumber = symbolNumber + ".gif";
  if (symbol.charAt(0) == "/") {
    uri = uri + "pri/";
  } else {
    uri = uri + "alt/";
  }
  return uri + symbolNumber;
}


function googleXMLDatei(data, responseCode) {
  var xml = GXml.parse(data);
  var allMarkers = alleMarkierungen;
  var counters = xml.documentElement.getElementsByTagName("count");
  var zahl = parseInt(counters[0].getAttribute("number"));
  var markers = xml.documentElement.getElementsByTagName("marker");
  for (var i = 0; i< markers.length; i++) {
    var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
    var rufzeichen = decodeURIComponent(markers[i].getAttribute("call"));
    if (allMarkers[rufzeichen] == undefined) {
      allMarkers[rufzeichen] = new positionMarker(point, decodeURIComponent(markers[i].getAttribute("icon")).replace(/\+/g, ' '), rufzeichen, "noCol");
      map1.addOverlay(allMarkers[rufzeichen]);
      //      GEvent.addDomListener(allMarkers[rufzeichen].clickable, 'click', markerClick);
      GEvent.addDomListener(allMarkers[rufzeichen].clickable, "mouseover", oeffneFenster);
    } else {
      allMarkers[rufzeichen].setPoint(point);
    }
    logbuchtext = logbuchtext + makeTableRow("<img src=\"http://www.pskmailreporter.de/php/getSymbol.php?sym=" + markers[i].getAttribute("icon") + "\">", rufzeichen, markers[i].getAttribute("lat"), markers[i].getAttribute("lng"), decodeURIComponent(markers[i].getAttribute("paket")).replace(/\+/g, ' '), decodeURIComponent(markers[i].getAttribute("time")));
  }
  if (zahl < count) {
    start = 0;
    document.getElementById('loadingdiv').style.visibility = "hidden";
    document.getElementById('loadingProgressDiv').style.visibility = "hidden";
    document.getElementById('loadingTextDiv').style.visibility = "hidden";
    document.getElementById('loadingProgressDiv').style.width = "0px";
    if (!initialized) {
      GEvent.addListener(map1, "moveend", function() {prepareLoadMap();});
      GEvent.addListener(map1, "zoomend", function(a,b) {if (a < b) {loadMap();}});
      initialized = true;
    }
    TimeOutID = window.setTimeout("loadMap()", 120000);
    document.getElementById('logbooktext').innerHTML = logbuchtext + "</table>";
  } else {
    start = start + zahl;
    var width = Math.round((start / positionen) * 150);
    document.getElementById('loadingProgressDiv').style.width = width + "px";
    var bounds = getBoundaries();
    GDownloadUrl("/php/googleSymbole1.php?symbols=" + encodeSymbols() + "&sw=" + bounds.getSouthWest().toUrlValue() + "&ne=" + bounds.getNorthEast().toUrlValue() + "&start=" + start + "&count=" + count, function(a,b) {googleXMLDatei(a,b);});
  }
}

function oeffneFenster(evt) {
  var rufzeichen = this.id;
  return map1.openInfoWindowHtml(alleMarkierungen[String(rufzeichen)].point, "<strong>" + rufzeichen + "</strong><br><a href=\"javascript:void(showWindow('" + rufzeichen + "'))\">Station Panel</a><br><a href=\"javascript:void(window.open('http://www.db0anf.de/app/aprs/stations/digiusermap-"+rufzeichen+"', '', 'width=980,height=645'))\">Digi-User Map</a><br><a href=\"javascript:void(window.open('http://www.db0anf.de/app/aprs/stations/digiusage-"+rufzeichen+"?sort=lastheard-d', '', 'width=980,height=580'))\">Used Digipeaters</a>");
}

function prepareLoadMap(){
  if (verschoben) {
    alleMarkierungen = new Array();
    map1.clearOverlays();
  }
  verschoben = !verschoben;
  loadMap();
} 

function getBoundaries() {
  var karte = map1;
  var hoehe = (karte.getBounds().getNorthEast().lat() - karte.getBounds().getSouthWest().lat()) / 2;
  if (karte.getBounds().getNorthEast().lng() < karte.getBounds().getSouthWest().lng()) {
    var breite = (360 + karte.getBounds().getNorthEast().lng() - karte.getBounds().getSouthWest().lng()) / 2; 
  } else {
    var breite = (karte.getBounds().getNorthEast().lng() - karte.getBounds().getSouthWest().lng()) / 2;
  }
  var sw = new GLatLng(karte.getBounds().getSouthWest().lat(), karte.getBounds().getSouthWest().lng(), false);
  var ne = new GLatLng(karte.getBounds().getNorthEast().lat(), karte.getBounds().getNorthEast().lng(), false);
  return new GLatLngBounds(sw, ne);
}

function showWindow(myquery) {
  ogcquery = 'http://www.positionsreport.de/php/getCallInfo.php?MyCallSign=' + myquery;
  if (msgwindow != null) {
    if (msgwindow.closed) {
      msgwindow = null;
    } else {
      msgwindow.document.open();
    }
  } 
  if (msgwindow == null) {
    msgwindow = window.open(ogcquery, '', 'width=980,height=580,resizable=no,scrollbars=no') ;
  } else {
    msgwindow.location = ogcquery;
  } 
  msgwindow.focus();
  return true;
}

function markerClick(evt) {
  return  showWindow(this.id);
}

function loadPage() {
  window.onresize = resizeMap;
  resizeMap();
  initialize();
  map1 = new GMap2(document.getElementById("googleMapDiv"));
  map1.setCenter(new GLatLng(0, 0), 3);
  serverKarte = new GMap2(document.getElementById("logbookmap"));
  serverKarte.setCenter(new GLatLng(0, 0), 3);
  addCustomMaps(serverKarte);
  serverKarte.setMapType(seamap);
  serverKarte.addControl(new GSmallMapControl());
  serverKarte.enableScrollWheelZoom();
  globalKarte = map1;
  map1.addMapType(G_PHYSICAL_MAP);
  addCustomMaps(map1);
  map1.setMapType(seamap);
  map1.addControl(new GLargeMapControl());
  map1.addControl(new GScaleControl());
  map1.addControl(new GMapTypeControl());
  map1.addControl(new ShowMousePositionControl());
  map1.enableScrollWheelZoom();
  map1.setCenter(new GLatLng(0,0), 2);
  globalKarte.openInfoWindowHtml(new GLatLng(0, 0), "<table><tr><td><img src=\"http://www.intermar-yachttrack.de/OpenSeaMap-Logo135x135.png\" height=\"70\" width=\"70\"></td><td>Bitte unterst&uuml;tzen Sie das <a href=\"http://www.openseamap.org\">OpenSeaMap</a> Projekt<br>Zeichnen Sie Hafenpläne und teilen Sie Ihre Erfahrung<br>Diese Karte ist mit Hilfe des <a href=\"http://www.openseamap.org\">OpenSeaMap</a> Projektes erstellt worden</td></tr></table>");
  loadMap();
}

function selectAllIcons() {
  if (allSymbols) {
    alleMarkierungen = new Array();
    map1.clearOverlays();
    allSymbols = false;
    document.getElementById('allSelector').src = "../../../pictures/allIcons.gif";
  } else {
    allSymbols = true;
    document.getElementById('allSelector').src = "../../../pictures/allIconsx.gif";
  }
  loadMap();
}

function encodeSymbols() {
  var symbole = '';
  for (var i = 0; i <= maxSymbols; i++) {
    if (primary[i]) {
      if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
      symbole = symbole + encodeURIComponent('/' + String.fromCharCode(i + 33));
    }
    if (alternate[i]) {
      if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
      symbole = symbole + encodeURIComponent('\\' + String.fromCharCode(i + 33));
    }
  }
  if (echolink) {
    if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
    symbole = symbole + 'E0';
  }
  if (irlp) {
    if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
    symbole = symbole + 'I0';
  }
  if (relay) {
    if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
    symbole = symbole + 'R0';
  }
  if (aprs) {
    if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
    symbole = symbole + encodeURIComponent('I&');
  }
  if (dstar) {
    if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
    symbole = symbole + encodeURIComponent('D&');
  }
  if (pskmail) {
    if (!(symbole == '')) {
  	symbole = symbole + ',';
      }
    symbole = symbole + encodeURIComponent('P&');
  }
  if (winlink) {
    symbole = symbole + '&winlink=true';
  } else {
    symbole = symbole + '&winlink=false';
  }
  if (allSymbols) {
    symbole = symbole + '&allSymbols=true';
  } else {
    symbole = symbole + '&allSymbols=false';
  }
  return symbole;
}

function setCount(data, responseCode) {
  var xml = GXml.parse(data);
  var counters = xml.documentElement.getElementsByTagName("zaehler");
  positionen = parseInt(counters[0].getAttribute("number"));
  var bounds = getBoundaries();
  GDownloadUrl("/php/googleSymbole1.php?symbols=" + encodeSymbols() + "&sw=" + bounds.getSouthWest().toUrlValue() + "&ne=" + bounds.getNorthEast().toUrlValue() + "&start=" + start + "&count=" + count, function(a,b) {googleXMLDatei(a,b);});
  logbuchtext = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  greyrow = false;
}

function setGating(data, responseCode) {
  serverKarte.clearOverlays();
  var xml = GXml.parse(data); 
  var markers = xml.documentElement.getElementsByTagName("marker");
  var server = decodeURIComponent(markers[0].getAttribute("server"));
  var call =  decodeURIComponent(markers[0].getAttribute("call"));
  var servericon = decodeURIComponent(markers[0].getAttribute("servericon")).replace(/\+/g, ' ');
  var callicon = decodeURIComponent(markers[0].getAttribute("callicon")).replace(/\+/g, ' ');
  var serverpoint = new GLatLng(parseFloat(markers[0].getAttribute("serverlat")), parseFloat(markers[0].getAttribute("serverlon")));
  var callpoint = new GLatLng(parseFloat(markers[0].getAttribute("callat")), parseFloat(markers[0].getAttribute("calllon")));
  var lastpoint = new GLatLng(parseFloat(markers[0].getAttribute("lastposlat")), parseFloat(markers[0].getAttribute("lastposlng")));
  var servermarker = new positionMarker(serverpoint, servericon, server, "noCol");
  var lastmarker = new positionMarker(lastpoint, decodeURIComponent(markers[0].getAttribute("lastposicon")).replace(/\+/g, ' '), decodeURIComponent(markers[0].getAttribute("lastposcall")), "noCol");
  serverKarte.addOverlay(lastmarker);
  serverKarte.addOverlay(servermarker);
  serverKarte.setCenter(serverpoint, 3);
  var htmlWindow = new HTMLOverlay(serverpoint, "<span class=\"fliesstext\">GATING <a href=\"javascript:void(map1.setCenter(new GLatLng("+callpoint.lat()+","+callpoint.lng()+"), 7));void(fensterOeffnen(new GLatLng("+callpoint.lat()+","+callpoint.lng()+"),'"+call+"'));\">" + call + "</a></span>");
  serverKarte.addOverlay(htmlWindow);
  var htmlWindow2 = new HTMLOverlay(lastpoint, "<span class=\"fliesstext\"><a href=\"javascript:void(map1.setCenter(new GLatLng("+lastpoint.lat()+","+lastpoint.lng()+"), 7));void(fensterOeffnen(new GLatLng("+lastpoint.lat()+","+lastpoint.lng()+"),'"+decodeURIComponent(markers[0].getAttribute("lastposcall"))+"'));\">Position Report</a></span>");
  serverKarte.addOverlay(htmlWindow2);
  //  serverKarte.openInfoWindow(serverpoint, "GATING <a href=\"javascript:void(map1.setCenter(new GLatLng("+callpoint.lat()+","+callpoint.lng()+"), 7));void(fensterOeffnen(new GLatLng("+callpoint.lat()+","+callpoint.lng()+"),'"+call+"'));\">" + call + "</a>");
}

function loadMap() {
  var symbole = '';
  window.clearTimeout(TimeOutID);
  start = 0;
  resizeMap();
 
  randomVar = randomVar + 1;

  var bounds = getBoundaries();
  document.getElementById('loadingdiv').style.visibility = "visible";
  document.getElementById('loadingProgressDiv').style.visibility = "visible";
  document.getElementById('loadingTextDiv').style.visibility = "visible";
  GDownloadUrl("/php/pskServer.php", function(a,b) {document.getElementById('pskstatustext').innerHTML = a;document.getElementById('pskstatustext').style.height = mapheight - 221; document.getElementById('messagelist').style.height = ((mapheight - 220) / 3) - 20; document.getElementById('serverlist').style.height = ((mapheight - 220) *(2/3)) - 12; document.getElementById('gatinglist').style.height = ((mapheight - 220) *(2/3)) - 12;});
  GDownloadUrl("/php/lastgating.php", function(a,b) {setGating(a,b);});
  GDownloadUrl("/php/googleSymbole1.php?symbols=" + encodeSymbols() + "&sw=" + bounds.getSouthWest().toUrlValue() + "&ne=" + bounds.getNorthEast().toUrlValue() + "&getCount=1", function(a,b) {setCount(a,b);});
  return true;
}
 
function resizeMap() {
  if (document.body.clientWidth != null) {
    // microsoft version
    clientwidth = document.body.clientWidth;
    clientheight = document.body.clientHeight; 
  } else {
    // netscape version
    clientwidth = (window.innerWidth -16);
    clientheight = window.innerHeight; 
  }

  mapwidth = clientwidth - 60;
  mapheight = clientheight - 95;
  
  document.getElementById('googleMapDiv').style.width = mapwidth;
  document.getElementById('googleMapDiv').style.height = mapheight;
  document.getElementById('logbook').style.width = mapwidth - 2;
  document.getElementById('pskstatus').style.left = mapwidth - 265;
  if (statusshowed) {
    document.getElementById('pskstatus').style.height = mapheight - 200;
  } else {
    document.getElementById('pskstatus').style.height = 20;
  }
  if (document.getElementById('messagelist') != null) {
    document.getElementById('pskstatustext').style.height = mapheight - 221;
    document.getElementById('messagelist').style.height = ((mapheight - 220) / 3) - 20; 
    document.getElementById('serverlist').style.height = ((mapheight - 220) *(2/3)) - 12;
    document.getElementById('gatinglist').style.height = ((mapheight - 220) *(2/3)) - 12;

  }
  if (logshowed) {
    document.getElementById('logbook').style.top = clientheight - 193;
  } else {
    document.getElementById('logbook').style.top = clientheight - 43;
  }
  //  document.getElementById('logbookheadtext').style.width = mapwidth - 42;
  //document.getElementById('logbookheadtext2').style.width = mapwidth - 42;
  document.getElementById('logbookheadsyms').style.left = mapwidth - 27;
  if (mapwidth < 1000) {
    document.getElementById('logbooktext').style.width = ((mapwidth - 303)/3)-1;
    document.getElementById('logbookheadtext2').style.left = (mapwidth - 303)/3;
    document.getElementById('logbooktext2').style.left = (mapwidth - 303)/3;
    document.getElementById('logbooktext2').style.width = 2*(mapwidth - 303)/3;
  } else {
    document.getElementById('logbooktext').style.width = mapwidth - 892;
    document.getElementById('logbookheadtext2').style.left = mapwidth - 891;
    document.getElementById('logbooktext2').style.left = mapwidth - 891; 
    document.getElementById('logbooktext2').style.width = 588;
  }
  document.getElementById('logbookmap').style.left = mapwidth - 303;
  document.getElementById('logbookmaptitle').style.left = mapwidth - 303;
}

function initialize() {
  new Effect.Opacity('loadingdiv', {duration:0.0, from:0.7, to:0.7});
  initialized = false;
  for (var i = 0; i <= maxSymbols; i++) {
    primary[i] = false;
    alternate[i] = false;
  }
  allSymbols = true;
}

function symClick(icon) {
  var table = icon.substring(0,3);
  var symStr = icon.substring(4,7);
  var symbol = parseInt(symStr, 10);
  if (icon == 'echolink') {
    var image = document.getElementById('echolink_icon_01');
    if (echolink) {
      image.src ="../../pictures/home/echolink_icons/echolink_icon_01.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/echolink_icon_aktiv_01.jpg";
    }
    echolink = !echolink;
  } else if (icon == 'irlp') {
    var image = document.getElementById('echolink_icon_02');
    if (irlp) {
      image.src ="../../pictures/home/echolink_icons/irlp_icon_02.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/irlp_icon_activ_02.jpg";
    }
    irlp = !irlp;
  } else if (icon == 'relay') {
    var image = document.getElementById('echolink_icon_03');
    if (relay) {
      image.src ="../../pictures/home/echolink_icons/relay_icon_03.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/relay_icon_activ_03.jpg";
    }
    relay = !relay;
  } else if (icon == 'winlink') {
    var image = document.getElementById('winlink_icon_01');
    if (winlink) {
      image.src ="../../pictures/home/winlink_icons/winlink_icon_01.jpg";
    } else {
      image.src ="../../pictures/home/winlink_icons/winlink_icon_aktiv_01.jpg";
    }
    winlink = !winlink;
  } else if (icon == 'aprs') {
    var image = document.getElementById('echolink_icon_04');
    if (aprs) {
      image.src ="../../pictures/home/echolink_icons/i_inakt.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/i_akt.jpg";
    }
    aprs = !aprs;
  } else if (icon == 'dstar') {
    var image = document.getElementById('echolink_icon_05');
    if (dstar) {
      image.src ="../../pictures/home/echolink_icons/d_inakt.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/d_akt.jpg";
    }
    dstar = !dstar;
  } else if (icon == 'pskmail') {
    var image = document.getElementById('echolink_icon_06');
    if (pskmail) {
      image.src ="../../pictures/home/echolink_icons/p_inakt.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/p_akt.jpg";
    }
    pskmail = !pskmail;
  } else {
    var image = document.getElementById(icon);
    if (table == 'pri') {
      if (primary[symbol]) {
	image.src = '../../../pictures/home/aprs_icons/aprs_icons_inaktiv/' + icon + '.jpg';
      } else {
	image.src = '../../../pictures/home/aprs_icons/aprs_icons_aktiv/' + icon + '.jpg';
      }
      primary[symbol] = !primary[symbol];
    } else {
      if (alternate[symbol]) {
	image.src = '../../../pictures/home/aprs_icons/aprs_icons_inaktiv/' + icon + '.jpg';
      } else {
	image.src = '../../../pictures/home/aprs_icons/aprs_icons_aktiv/' + icon + '.jpg';
      }
      alternate[symbol] = !alternate[symbol];
    }
  }
  loadMap();
}

function resetIcons() {
  var pri;
  var alt;
  var icon;
  var image;
  alleMarkierungen = new Array();
  map1.clearOverlays();
  allSymbols = false;
  document.getElementById('allSelector').src = "../../../pictures/allIcons.gif";
  for (var i = 0; i <= maxSymbols; i++) {
    primary[i] = false;
    alternate[i] = false;
    icon = eval(i);
    if (i < 10) {
      icon = '0' + icon; 
    }
    if (i < 100) {
      icon = '0' + icon;
    }
    pri = 'pri_' + icon;
    alt = 'alt_' + icon;
    image = document.getElementById(pri);
    image.src = '../../../pictures/home/aprs_icons/aprs_icons_inaktiv/' + pri + '.jpg';
    image = document.getElementById(alt);
    image.src = '../../../pictures/home/aprs_icons/aprs_icons_inaktiv/' + alt + '.jpg';
  }
}

function changeImg(name, source) {
  name.src = source;
  return true;
}

function closediv(divToClose) {
  new Effect.Fade(divToClose);
  return true;
}

function aktualisiereDiv(path) {
  var icon;
  var pri;
  var alt;
  var image;
  if (path == 'aprs_div.html') {
    for (var i = 0; i <= maxSymbols; i++) {
      icon = eval(i);
      if (i < 10) {
        icon = '0' + icon; 
      }
      if (i < 100) {
        icon = '0' + icon;
      }
      pri = 'pri_' + icon;
      alt = 'alt_' + icon;
      if (primary[i]) {
        image = document.getElementById(pri);
        image.src = '../../../pictures/home/aprs_icons/aprs_icons_aktiv/' + pri + '.jpg';        
      } else {
        image = document.getElementById(pri);
        image.src = '../../../pictures/home/aprs_icons/aprs_icons_inaktiv/' + pri + '.jpg';
      }
      if (alternate[i]) {
        image = document.getElementById(alt);
        image.src = '../../../pictures/home/aprs_icons/aprs_icons_aktiv/' + alt + '.jpg';      
      } else {
        image = document.getElementById(alt);
        image.src = '../../../pictures/home/aprs_icons/aprs_icons_inaktiv/' + alt + '.jpg';
      }
    }     
    if (allSymbols) {
      document.getElementById('allSelector').src = "../../../pictures/allIconsx.gif";
    } else {
      document.getElementById('allSelector').src = "../../../pictures/allIcons.gif";
    }
  } else if (path == 'winlink_div.html') {
    var image = document.getElementById('winlink_icon_01');
    if (winlink) {
      image.src ="../../pictures/home/winlink_icons/winlink_icon_aktiv_01.jpg";
    } else {
      image.src ="../../pictures/home/winlink_icons/winlink_icon_01.jpg";
    }
  } else if (path == 'relay_div.html') {
    var image = document.getElementById('echolink_icon_01');
    if (echolink) {
      image.src ="../../pictures/home/echolink_icons/echolink_icon_aktiv_01.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/echolink_icon_01.jpg";
    }
    var image = document.getElementById('echolink_icon_02');
    if (irlp) {
      image.src ="../../pictures/home/echolink_icons/irlp_icon_activ_02.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/irlp_icon_02.jpg";
    }
    var image = document.getElementById('echolink_icon_03');
    if (relay) {
      image.src ="../../pictures/home/echolink_icons/relay_icon_activ_03.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/relay_icon_03.jpg";
    }
    var image = document.getElementById('echolink_icon_04');
    if (aprs) {
      image.src ="../../pictures/home/echolink_icons/i_akt.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/i_inakt.jpg";
    }
    var image = document.getElementById('echolink_icon_05');
    if (dstar) {
      image.src ="../../pictures/home/echolink_icons/d_akt.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/d_inakt.jpg";
    }
    var image = document.getElementById('echolink_icon_06');
    if (pskmail) {
      image.src ="../../pictures/home/echolink_icons/p_akt.jpg";
    } else {
      image.src ="../../pictures/home/echolink_icons/p_inakt.jpg";
    }
  }
}

function loadInDiv(updateDiv, path) {
  var updater = new Ajax.Updater(updateDiv, path, {asynchronus: false, method: 'get'});
  setTimeout("aktualisiereDiv(\'"+path+"\')", 100);
}

function loadDiv(updateDiv, path, frameDiv, handleDiv) {
  var updater = new Ajax.Updater(updateDiv, path, {asynchronus: false, method: 'get'});
  new Effect.Appear(frameDiv);
  new Draggable(frameDiv, {handle: handleDiv});
}

function loadCall() {
  var updater = new Ajax.Updater('callmain', '../../php/findCall_new.php', {asynchronus: false, method: 'get', parameters: 'search=' + document.getElementById("call").value});
}

function loadWinLinkCall() {
  var updater = new Ajax.Updater('callmain', '../../php/findCall_new.php', {asynchronus: false, method: 'get', parameters: 'search=' + document.getElementById("winCall").value + '&winlink=1'});
}

function loadRelayCall() {
  var updater = new Ajax.Updater('callmain', '../../php/findCall_new.php', {asynchronus: false, method: 'get', parameters: 'search=' + document.getElementById("relayCall").value + '&echolink=1'});
}

