// JavaScript Document

//Textfeld auf 500 Buchstaben begrenzen -----------------------------------------------------------------------------
 function CheckTA(feld)
 {
 var max=500, textinhalt;
 //textfeld = document.getElementByName('Beschreibung');
 textinhalt=feld.value;

 if (textinhalt.length >= max)
 {
 feld.value=textinhalt.substring(0,max);
 alert("Maximale Anzahl von Zeichen ("+max+") erreicht!");
 }
 //document.getElementById('zeichenanzahl').innerHTML = "Zeichen "+ textinhalt.length +" von "+max;
 document.getElementById('zeichenanzahl').innerHTML = "Zeichen "+ textinhalt.length;
}
//Eycatcher mit Effect erscheinen lassen -----------------------------------------------------------------------------
function showpics(anzahl) {

 Effect.SlideDown("pic1");
 window.setTimeout("Effect.SlideDown('pic2')", 1000);
 window.setTimeout("Effect.SlideDown('pic3')", 2000);

}
// Bildergalerie -Bild wechseln -----------------------------------------------------------------------------
function change_pic(picname) {
 obj = document.getElementById('bigpic');
 obj.src = "images/stories/iproplan/referenzen/"+ picname;
 alert(picname);

}


//Google Maps Scripte -----------------------------------------------------------------------------
//Karte anzeigen -----------------------------------------------------------------------------
var map = null;
var geocoder = null;

function showmap(mymap,x,y,z,setmarker,maptype) {
var z = Number(z);

document.getElementById(mymap).style.display = "block";

if (GBrowserIsCompatible())
 {
 map = new GMap2(document.getElementById(mymap));
 map.addControl(new GSmallMapControl());
 map.addControl(new GMapTypeControl());
 map.setCenter(new GLatLng(x,y),z);

 //Kartentyp setzen
if(maptype == 'sat') map.setMapType(G_SATELLITE_MAP);
 else if(maptype == 'hybrid') map.setMapType(G_HYBRID_MAP);
 else if(maptype == 'earth') map.setMapType(G_SATELLITE_3D_MAP);
 else map.setMapType(G_NORMAL_MAP);

 //Evtl. Marker gleich mit setzen
 if(setmarker == 'yes') {
 showMarker(x,y);
 //var point01 = new GMarker(new GLatLng(x,y));
 //map.addOverlay(point01);
 }

 }

}

//Marker setzen (funktioniert noch nicht)
function showMarker(x,y) {
 // Create our "tiny" marker icon
 var blueIcon = new GIcon(G_DEFAULT_ICON);
 blueIcon.image = "http://ggz-zschopau.de/img/pin-icon.png";

blueIcon.shadow = false;
// Set up our GMarkerOptions object
 markerOptions = { icon:blueIcon };
 //var point01 = new GMarker(new GLatLng(x,y), markerOptions);

 var point = new GLatLng(x,y);
 var marker = new GMarker(point);

 map.addOverlay(marker);
}

//Adresse suchen und anzeigen
function showAddress(address) {

geocoder = new GClientGeocoder();

 if (geocoder) {

 geocoder.getLatLng(
 address,
function(point) {
 if (!point) {
 alert(address + " kann ich nicht finden!");
 } else {
 //alert(address + ', ' +point.lat() + ' / ' + point.lng());
showPoint(point.lat(), point.lng());

}
}
 );
 }
}



function showPoint(x, y) {
var point = new GLatLng(x, y);
//toString(point);

 var marker = new GMarker(point, {icon:G_DEFAULT_ICON, draggable: true});
 trackMarkers = true;
 map.setCenter(point);
map.addOverlay(marker);

 window.document.forms[0].lat.value = point.lat();
 window.document.forms[0].lng.value = point.lng();
 GEvent.addListener(marker, "dragstart", function() {});
 GEvent.addListener(marker, "dragend", function() {
 var neu = marker.getPoint();
 //document.getElementById("message").innerHTML = center.toString();
 window.document.forms[0].lat.value = neu.lat();
 window.document.forms[0].lng.value = neu.lng();
 });
} 
//Schriftgröße ändern
var prefsLoaded = false;
var defaultFontSize = 75;
var currentFontSize = defaultFontSize;

//Schriftgröße zurücksetzen
function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);

}
//Schriftgröße Vergrößer/verkleinern
function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

	if(currentFontSize > 100){
		currentFontSize = 100;
	}else if(currentFontSize < 60){
		currentFontSize = 60;
	}
	setFontSize(currentFontSize);
}
function setFontSize(fontSize){
	var stObj = document.getElementById('content');
	var tagobj = document.getElementsByTagName("h2")[0];
	document.body.style.fontSize = fontSize + '%';
	//stObj.style.fontSize = fontSize + '%';
	//tagobj.style.fontSize = fontSize + '%';	
	//alert (document.body.style.fontSize);
}
	 
//Sprungmenü
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// JavaScript Document