/*  #####################################################
**  Domain:    www.lenggries.de
**  Datei:     googleMaps.js
**  Funktion:  JavaScript Code für Googlemaps

**  Erstellt:  04.11.2008

**  Autor:     Axel Güldner
**  copyright: infomax websolutions GmbH
##################################################### */


$(window).load(function(){
    //Overlaykarte verstecken
    //$("#CONT_googleMaps").hide();    

    //Legendenpunkte verstecken
    //$("#CONT_googleMaps #mapLegend ul").children("li.firstLayer").children("ul.secondLayer").toggle();
});

$(document).ready(function(){

	//Init Maps
	if (window.initmapSmall) initmapSmall();
	//if (window.initmapLarge) initmapLarge();
	
	$("#CONT_googleMaps").css("margin","1em 0 0 0");
		 

    //OverlayKarte öffnen und schließen
    $("*[rel='mapOpener']").click(function(){
        if(!$("#CONT_googleMaps").hasClass("activeMap")){
            $("#CONT_googleMaps").toggleClass("activeMap");            
            $("#CONT_keyvisual").slideUp("slow",function(){
                $("#CONT_googleMaps").slideDown("slow", function(){
                	if(!$.browser.msie)$("#CONT_googleMaps").curvycorner({tl: { radius: 10 }, tr: { radius: 10 }, bl: { radius: 10 }, br: { radius: 10 }, antiAlias: true, autoPad: true});
                	$("#CONT_googleMaps").css("margin","2em 0 2em 0");
                	initmapLarge();
                });                
            });
        }else{
          $("#CONT_googleMaps").slideUp("slow",function(){
                $("#CONT_keyvisual").slideDown("slow",function(){					
                    $("#CONT_googleMaps").toggleClass("activeMap");                    
                });
            });
        }
    });


    //Legendpunkte öffnen und schließen
    $("#CONT_googleMaps #mapLegend ul").children("li.firstLayer").children("a").click(function(){
        $(this).parent().children("ul.secondLayer").animate({height:"toggle", opacity:"toggle"});
    });


    //Marker setzen
    $("#CONT_googleMaps #mapLegend ul").children("li.firstLayer").children("ul.secondLayer").children("li").click(function(){
        $(this).toggleClass("active");
        if($(this).hasClass("active"))UpdateSearch($(this).attr("id").substr(7), 'set');
		else UpdateSearch($(this).attr("id").substr(7), 'unset');
    });


});
  
window.onunload = function(){
	//GoogleMaps Unload
	if (window.GUnload) {
		GUnload();
	}
}	
