jQuery(document).ready(function(){

	if (GBrowserIsCompatible()) {
		geocoder = new GClientGeocoder();
		var mapOptions = {
			googleBarOptions : {
				style : "new"
			}
		}

		mapEsslingenLive = new GMap2(document.getElementById("mapEsslingenLive"));
        mapEsslingenLive.setUIToDefault();
		showAddress(addressEsslingenLive,mapEsslingenLive,14,'EsslingenLive','','/ftp/dokumente/Esslingen live_neu.pdf','/ftp/download/Wegbeschreibung_ES_live_Anfahrt.pdf','http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Ebershaldenstra%C3%9Fe+12,+73728+Esslingen+am+Neckar&sll=48.742641,9.312288&sspn=0.006396,0.027874&ie=UTF8&hq=&hnear=Ebershaldenstra%C3%9Fe+12,+73728+Esslingen+am+Neckar,+Esslingen,+Baden-W%C3%BCrttemberg&z=14');

		mapNeckarForum = new GMap2(document.getElementById("mapNeckarForum"));
        mapNeckarForum.setUIToDefault();
		showAddress(addressNeckarForum,mapNeckarForum,14,'Neckar Forum','neckarforum.png','/ftp/dokumente/Neckar Forum_Informationen.pdf','/ftp/download/Wegbeschreibung_Neckar_Forum.pdf','http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Hauffstra%C3%9Fe,+73728+Esslingen,+Deutschland&sll=48.742641,9.312288&sspn=0.008349,0.022724&ie=UTF8&hq=&hnear=Hauffstra%C3%9Fe,+73728+Esslingen+am+Neckar,+Esslingen,+Baden-W%C3%BCrttemberg&ll=48.74204,9.312651&spn=0.008349,0.022724&z=14');

		mapAltesRathaus = new GMap2(document.getElementById("mapAltesRathaus"));
        mapAltesRathaus.setUIToDefault();
		showAddress(addressAltesRathaus,mapAltesRathaus,14,'Altes Rathaus','altesrathaus.png','/ftp/dokumente/AltesRathaus_Informationen%20Kapazitaeten.pdf','/ftp/download/Wegbeschreibung_alle_Hallen_1.pdf','http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Rathausplatz+73728,+Esslingen+am+Neckar,+Esslingen&sll=48.74204,9.312651&sspn=0.008349,0.022724&ie=UTF8&hq=&hnear=Rathausplatz,+73728+Esslingen+am+Neckar,+Esslingen,+Baden-W%C3%BCrttemberg&ll=48.742323,9.307866&spn=0.008349,0.022724&z=14');

		mapZentrumZell = new GMap2(document.getElementById("mapZentrumZell"));
        mapZentrumZell.setUIToDefault();
		showAddress(addressZentrumZell,mapZentrumZell,14,'Zentrum Zell','zentrumzell.png','/ftp/dokumente/ZentrumZell-1_neu.pdf','/ftp/download/Wegbeschreibung_alle_Hallen_1.pdf','http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Alleenstra%C3%9Fe+1,+73730,+Esslingen&sll=48.742323,9.307866&sspn=0.008349,0.022724&g=Rathausplatz+73728,+Esslingen+am+Neckar,+Esslingen&ie=UTF8&hq=&hnear=Alleenstra%C3%9Fe+1,+Zell+73730+Esslingen+am+Neckar,+Esslingen,+Baden-W%C3%BCrttemberg&ll=48.723783,9.360695&spn=0.008352,0.022724&z=14');

		mapOsterfeldHalle = new GMap2(document.getElementById("mapOsterfeldHalle"));
        mapOsterfeldHalle.setUIToDefault();
		showAddress(addressOsterfeldHalle,mapOsterfeldHalle,14,'Osterfeldhalle Berkheim','osterfeldhalle.png','/ftp/dokumente/OsterfeldHalle_neu.pdf','/ftp/download/Wegbeschreibung_alle_Hallen_1.pdf','http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=K%C3%B6ngener+Stra%C3%9Fe+51,+73734,+Esslingen+am+Neckar&sll=48.723783,9.360695&sspn=0.008352,0.022724&ie=UTF8&hq=&hnear=K%C3%B6ngener+Stra%C3%9Fe+51,+Berkheim+73734+Esslingen+am+Neckar,+Esslingen,+Baden-W%C3%BCrttemberg&z=14');
	}

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
	
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});

var gdir;
var mapUebersicht;
var mapEsslingenLive;
var mapNeckarForum;
var mapAltesRathaus;
var mapZentrumZell;
var mapOsterfeldHalle;
var addressUebersicht='Ebershaldenstra&szlig;e 12, 73728 Esslingen, Deutschland';
var addressEsslingenLive='Ebershaldenstra&szlig;e 12, 73728 Esslingen, Deutschland';
var addressNeckarForum='Hauffstra&szlig;e, 73728 Esslingen, Deutschland';
var addressAltesRathaus='Rathausplatz, 73728 Esslingen, Deutschland';
var addressZentrumZell='Alleenstra&szlig;e 1, 73730 Esslingen, Deutschland';
var addressOsterfeldHalle='K&ouml;ngener Stra&szlig;e 51, 73734 Esslingen, Deutschland';

/* Funktionen */
function handleErrors() {
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("Adresse existiert nicht (evtl. mit Latitude und Longitude versuchen)!\n Fehler: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
		alert("Adresse wurde nicht gefungen (evtl. mit Latitude und Longitude versuchen)!\n Fehler: " + gdir.getStatus().code);
	
	else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		alert("Adresse vollständig angeben!\n Fehler: " + gdir.getStatus().code);
	
	else if (gdir.getStatus().code == G_GEO_BAD_KEY)
		alert("Google Maps API Key nicht gültig! Bitte nicht kopieren! Key kann auf http://www.google.com/apis/maps/signup.html beantragt werden! \n Fehler: " + gdir.getStatus().code);
	
	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		alert("Fehler bei der Berechnung. Bitte nochmal versuchen!\n Fehler: " + gdir.getStatus().code);
	
	else alert("Unbekannter Fehler!\n Fehler: " + gdir.getStatus().code);

}

function onGDirectionsLoad() {
}

function showAddress(address,map,zoom,title,image,infolink,printlink,googleLink) {
	if (geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					map.setCenter(point, zoom);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					var myHtml='<span class="popup">';
					myHtml+='<img src="esslingenlive.png" width="125" height="31" class="logo" />';
					myHtml+='<p>';
					if (image)
						myHtml+='<img src="'+image+'" width="75" height="59" class="bild" />';
					if (title != 'EsslingenLive')
						myHtml+='<h1>'+title+'</h1>';
					myHtml+=address.replace(/,/g, "<br />")+'</p>';
					myHtml+='<br /><a href="'+googleLink+'" target="_blank">Routenplaner</a>';
					if (infolink)
						myHtml+=' | <a href="'+infolink+'" target="_blank">Info</a>';
					if (printlink)
						myHtml+=' | <a href="'+printlink+'" target="_blank">Drucken</a>';
					myHtml+='</span>';
					map.openInfoWindowHtml(point,myHtml);
					GEvent.addListener(marker, "click", function() {
						map.openInfoWindowHtml(point, myHtml);
					});
				}
			}
		);
	}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function hp_openAlbumpic(myUrl,width,height) { 
  window.open(myUrl,'','scrollbars=no,resizable=no,width='+width+',height='+height);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,mytitle,myclass,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { mytitle=val.title,nm=val.name; myclass=val.className; if(!mytitle) mytitle=nm; 
    var myobj=MM_findObj(nm);
    if (myobj.style.backgroundColor='#ffcccc') {
      myobj.style.backgroundColor='';
    }
    if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) {
          var myobj=MM_findObj(nm);
          myobj.style.backgroundColor='#ffcccc';
          errors+='- '+mytitle+' muss eine gültige e-Mail Adresse enthalten.\n';
        }
      } else if (test.indexOf('isLength')!=-1) { 
        p=test.indexOf(':');
        min=test.substring(9,p); max=test.substring(p+1);
        if (val.length<min || val.length>max) {
          var myobj=MM_findObj(nm);
          myobj.style.backgroundColor='#ffcccc';
          errors+='- '+mytitle+' muss zwischen '+min+' und '+max+' Zeichen lang sein.\n';
        }
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) {
          var myobj=MM_findObj(nm);
          myobj.style.backgroundColor='#ffcccc';
          errors+='- '+mytitle+' muss eine Nummer enthalten.\n';
        }
        if (test.indexOf('inRange') != -1) {
          p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) { 
            var myobj=MM_findObj(nm);
            myobj.style.backgroundColor='#ffcccc';
            errors+='- '+mytitle+' muss eine Nummer zwischen '+min+' und '+max+'enthalten.\n';
          }
        } 
      } } else if (test.charAt(0) == 'R') {
       var myobj=MM_findObj(nm);
       myobj.style.backgroundColor='#ffcccc';
       errors += '- '+mytitle+' ist ein Pflichtfeld.\n'; 
      }
      }
  } if (errors) alert('Folgende Fehler sind aufgetreten:\n'+errors);
  document.MM_returnValue = (errors == '');
}







