﻿var stepTime = 10 ;
var stepSize = 5 ;
var maxHeight = 222 ;
var minHeight = 0 ;
function blubb( elementName )
{
    var element = document.getElementById(elementName);
    if(element.style.height == '')
      element.style.height = maxHeight + 'px';
    if(element.style.height == maxHeight + 'px')
    {
      peng( elementName , false) ;
    }
    else if(element.style.height == minHeight + 'px')
    {
      peng( elementName , true) ;
    }
}
function peng(elementName, up)
{
    var element = document.getElementById(elementName);
    var actualHeight = Number(element.style.height.replace('px',''));
    var newHeight = 0;
    if( up )
    {
      newHeight = actualHeight + stepSize;
    }
    else
    {
      newHeight = actualHeight - stepSize;
    }
    if(newHeight < maxHeight  && newHeight > minHeight)
    {
      element.style.height = newHeight + 'px';
      SetOpacity(element,newHeight);
      setTimeout('peng("'+elementName+'", '+up+')', stepTime);
    }
    else
    {
      if(up)
      {
        element.style.height = maxHeight + 'px';
        SetOpacity(element,maxHeight);
      }
      else
      {
        element.style.height = minHeight + 'px';
        SetOpacity(element,minHeight);
      }
    }
}
function SetOpacity(element , value )
{
  element.style.filter="alpha(opacity=" + (value * 100 / maxHeight) + ")"; 
  element.style.opacity  = (value / maxHeight);
}

function jump (select) {
for (i = 0; i < select.length; ++i) {
 if (select.options[i].selected == true) {
       self.location.href = select.options[i].value;
  }
}
}

function load(mapID, msgID, coord1, coord2, text) {
  if (GBrowserIsCompatible()) {
    var tempmap = new GMap2(document.getElementById(mapID));
    // Links oben Pfeile und "+" und "-" Tasten
    tempmap.addControl(new GSmallMapControl());
    // Rechts oben Tasten "Karte", "Satelit", "Hybrid"
    tempmap.addControl(new GMapTypeControl());
    // Geodaten werden unter Karte angezeigt,
    // Bei Verschieben wird Zentrum immer wieder neu angegeben
    GEvent.addListener(tempmap, "moveend", function() {
     var center = tempmap.getCenter();
      document.getElementById(msgID).innerHTML = "<div style=\"font-family: Verdana,Arial; font-size:12px;\">Kartenmitte (Breite, Länge in °): "+center.toString()+"</div>";
    });
    
    // Breite,Länge
    var tempcenter = new GLatLng(coord1,coord2);
    // Zoomstufe: 1 Überblick... 15 Lupe
    tempmap.setCenter(tempcenter, 13);    
    // Textfenster mit fortlaufendem Text an Koordinaten geheftet
    // HTML-Formatierung möglich
    tempmap.openInfoWindowHtml(tempmap.getCenter(),"<div style=\"font-family: Verdana,Arial; font-size:12px;\">"+ text +"</div>");
    
     // verschiebbarer Marker
     var tempmarker = new GMarker(tempcenter, {draggable: true});
     
    GEvent.addListener(tempmarker, "dragstart", function() {
      tempmap.closeInfoWindow();
    });
    
    GEvent.addListener(tempmarker, "dragend", function() {
      tempmarker.openInfoWindowHtml("<div style=\"font-family: Verdana,Arial; font-size:12px;\"><b>Aktuelle Position (Breite, Länge)</b><br>"+tempmarker.getPoint().toString()+"</div>");
    });
    tempmap.addOverlay(tempmarker);
  }
}
/** Klappmechanismus für Inhaltsbereich **/
  $(document).ready(function ()
  {
    $("#inhalt .az_block").each(function (index, htmlObject)
    {
      new openCloseZeug({
        initialOpen: ($(htmlObject).hasClass('init_open')),
        // appendAsFirst: true,
        // beforeOpenFunction: function () {  },
        // beforeCloseFunction: function () {  },
        jDomParent: $(htmlObject).find(".az_kopf"),
        jDomToggleContainer: $(htmlObject).find(".az_inhalt"),
        cssClass: "az_Link",
        // jDomParentForClass: $(htmlObject).parent(".box-name"),
        // textOpen: "",
        // textClose: "",
        // parentCloseClass: "",
        // parentOpenClass: "",
        imgSrcOpen: "/symbole/open.png",
        imgSrcClose: "/symbole/close.png"
      });
    });

    $("#randspalte div.mBox:not(.last,#servicebox)").has("h3").addClass("az_box");
    $("#randspalte .az_box").each(function (index, htmlObject)
    {
        new openCloseZeug({
            initialOpen: ($(htmlObject).hasClass('init_open')),
            // appendAsFirst: true,
            // beforeOpenFunction: function () {  },
            // beforeCloseFunction: function () {  },
            jDomParent: $(htmlObject).find("h3"),
            jDomParentIsClickable: true,
            jDomToggleContainer: $(htmlObject).find(".az_inhalt"),
            cssClass: "az_Link",
            // jDomParentForClass: $(htmlObject).parent(".box-name"),
            // textOpen: "",
            // textClose: "",
            parentCloseClass: "az_box_close",
            parentOpenClass: "az_box_open",
            imgSrcOpen: "/symbole/az_pfeil_gruen_unten.png",
            imgSrcClose: "/symbole/az_pfeil_gruen_oben.png"
        });
    });
    $("#randspalte .az_box:first").not(".init_open, .init_close").find("h3:first").click();
    $("#randspalte h2").next(".az_box:not(.init_open, .init_close)").not(":first").find("h3:first").click();
    // Symbol für externer Link
    var extAnchor = $("a[href^='http'], a[href^='https']").not("#lbCenter a, #lbBottomContainer a, a[href*='www.landratsamt-pirna.de']");
    // var extDownload = $("a.extern");
    $(extAnchor).not("a:has(img)").append('<img alt="" src="/symbole/link_neues_fenster.gif" width="12" height="7" class="info_img" />');
    // var anchors = $.merge(extAnchor, extDownload);
    var anchors = extAnchor
    // anchors = jQuery.unique(anchors);
    $(anchors).attr("title", "Link öffnet in neuem Fenster");
    $(anchors).click(function ()
    {
        window.open(this.href);
        return false;
    });
  });
/** Klappmechanismus für Randspalte **/
