jQuery(function() { 
   link_animation();
   submenu();
   $('.thumb_fly').flyout({loadingSrc:'http://www.muenster-webdesign.net/images/site/ajax-loader.gif'});
 });

//Hintergrundgrafik für Navigation in den Cache laden
var navi_hintergrund;

var navi_hintergrund = new Image();
navi_hintergrund.src = "../images/site/button_aktive_background.png";

//Mail-Adresse dechiffrieren
function uncryptmail() {
	var fenster = window.open("mailto:post@muenster-webdesign.net");
	fenster.close();
}

//GoogleMaps

 var map;
 var gdir;
 var geocoder = null;
 var addressMarker;
 
 function karte_laden() {
  	window.onload=load;
	window.onunload=GUnload;
 }
 

    function load() {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
        setDirections("Münster", "Boverste Meer 20a, 48161 Münster", "de_DE");
      }
    }
    
    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Es konnte keine passende Adresse gefunden werden. Möglicherweise ist die Adresse noch sehr neu oder die angegebene Adresse ist falsch.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("Es ist ein Serverfehler aufgetreten bitte versuchen Sie es zu einem späteren Zeitpunkt noch einmal.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("Es ist ein unbekannter Fehler aufgetreten. Möglicherweise haben Sie keine Adresse eingegeben.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("Es ist ein unbekannter Fehler aufgetreten. Möglicherweise habe Sie keine Adresse eingegeben");
	   
	}

	function onGDirectionsLoad(){ 
          // Use this function to access information about the latest load()
          // results.

          // e.g.
	  // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}

//Info-Layer Ein- und Ausblenden


function openlayer(id) {
	jQuery("#additionaltext").toggle('slow');
}


//Farbanimation für Links
function link_animation() {
jQuery("#main a:not(.noanim), #topnav a, #footer a").hover(function() {
	  jQuery(this).stop(true).animate({ color: 'white' }, 180);
	  },
	  function() {jQuery(this).stop(true).animate({ color: "#aaaacc" }, 320);
	  });

jQuery("#nav_main a:not(.noanim)").hover(function() {
		jQuery(this).stop(true).animate({borderBottomColor: "#00FF00"}, 680);
		},
		function() {jQuery(this).stop(true).animate({borderBottomColor: "#333333"}, 400);
		});
}

//Submenü Ein- und Ausblenden

function submenu () {	
	jQuery("#nav_bar a:not(.noanim)").mouseenter(function() {
			// Ist ein Untermenü vorhanden?
			var displ = jQuery(this).next(".nav_sub").css("display");
			
			if (displ == "none") {
				jQuery(this).next(".nav_sub").css({'display':'block'});
				jQuery(this).addClass("current");
			}
			
	});
	
	jQuery("#nav_bar li:not(.noanim)").mouseleave(function() {
			  jQuery(".nav_sub").css({'display':'none'});
			  jQuery("#nav_bar a:not(.nav_sub)").removeClass("current");
	});
	
	
	//Teaser Ein- und Ausblenden
	
	jQuery(".sub_box a").mouseenter(function() {
			jQuery(this).next(".nav_sub_bdr").stop(true).animate({bottom: "0px"}, 450);
			/*jQuery(this).next(".nav_sub_bdr").children("p").css("display","block");*/
		});
	
	jQuery(".sub_box a").mouseleave(function() {
			jQuery(this).next(".nav_sub_bdr").stop(true).animate({bottom: "-40px"}, 450);
			/*jQuery(this).next(".nav_sub_bdr").children("p").fadeOut("fast");*/
		});		
}
 
