var akt_bl;
var akt_sorte;
var cookie = new CJL_CookieUtil("spritbarometer", 144000, "/");

function initResult()
{
  akt_bl = "none";
  akt_sorte = "none";
  if (cookie.cookieExists())
  {
    akt_bl=cookie.getSubValue("bl");
    setBlStyle();
    akt_sorte=cookie.getSubValue("sorte");
    setSorteStyle();
  }
  showResult();
}

function showResult()
{
  document.getElementById('top3_ergebnis').innerHTML=document.getElementById("top3_" + akt_bl + "_" + akt_sorte).innerHTML;
}

function bundesland(bl)
{
  resetBlStyle();
  akt_bl = bl;
  showResult();
  setBlStyle();
  cookie.setSubValue("bl", akt_bl);
}

function spritsorte(sorte)
{
  resetSorteStyle();
  akt_sorte = sorte;
  showResult();
  setSorteStyle();
  cookie.setSubValue("sorte", akt_sorte);
}

function resetStyle(element)
{
  document.getElementById(element).className="";
}

function setStyle(element)
{
  document.getElementById(element).className="current";
}

function resetBlStyle()
{
  if (akt_bl != "none")
  {
    resetStyle("bl_" + akt_bl);
  }
}

function setBlStyle()
{
  if (akt_bl != "none")
  {
    setStyle("bl_" + akt_bl);
  }
}

function resetSorteStyle()
{
  if (akt_sorte != "none")
  {
    resetStyle("sorte_" + akt_sorte);
  }
}

function setSorteStyle()
{
  if (akt_sorte != "none")
  {
    setStyle("sorte_" + akt_sorte);
  }
}

function showMap($lat, $lng) 
{
  if (GBrowserIsCompatible()) 
  {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng($lat, $lng), 16);
    map.addControl(new GSmallMapControl());
    var ZapfIcon = new GIcon();
    ZapfIcon.image = "/media/zapf.png";
    ZapfIcon.iconSize = new GSize(32, 32);
    ZapfIcon.iconAnchor = new GPoint(16, 32);
    ZapfIcon.clickable = false;
    markerOptions = { icon:ZapfIcon };
    map.addOverlay(new GMarker(new GLatLng($lat, $lng), markerOptions));
  }
}

function addBookmark(b,c)
{
  if (window.sidebar)
  {
    window.sidebar.addPanel(b,c,'');
  }
  else if (window.opera)
  {
    var a=document.createElement("A");
    a.rel="sidebar";
    a.target="_search";
    a.title=b;
    a.href=c;
    a.click();
  }
  else if (document.all)
  {
    window.external.AddFavorite(c,b);
  }
}
