function SHARED_init()
	{
	if(window.XMLHttpRequest) 
		{
		var xmlHTTP = new XMLHttpRequest();
		} 
	else if(window.ActiveXObject) 
			{
			var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
			}	
	if(xmlHTTP)
		{
		return xmlHTTP;	
		}
	else
		{
		return false;	
		}
	}
	
function SHARED_isIE(){
	if(document.all){
		return true;	
	}	
	else{
		return false;	
	}
}

function SHARED_makeRequest(src_file,method,vars)
	{
	if(xmlHTTP=SHARED_init())
		{
		var postvars=vars;
		xmlHTTP.open(method,src_file,true);
		xmlHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHTTP.send(postvars);
		xmlHTTP.onreadystatechange=function()
			{
			if(xmlHTTP.readyState==4)
				{
				//
				//alert(xmlHTTP.responseText.toString());
				addMarkers(xmlHTTP.responseText.toString());
				//return xmlHTTP.responseText.toString();
				//document.getElementById(target_id).innerHTML=xmlHTTP.responseText;
				}
			}
		}	
	}
	
function SHARED_emptyElement(elem){
	if(elem){
		for(var i=0;i<elem.childNodes.length;i++){
			var tmp=elem.childNodes[i];
			elem.removeChild(tmp);
			
			
		}		
	}	
}

//imageviewer
// JavaScript Document
//get window width and height
function getWindowSize(mode)
	{
	if(document.body && document.body.offsetHeight)
		{
		avail_height=parseInt(document.body.offsetHeight);
		avail_width=parseInt(document.body.offsetWidth);
		}
	if(window.innerHeight)
		{
		avail_height=parseInt(window.innerHeight);
		avail_width=parseInt(window.innerWidth);
		}	
	if(mode=="width")
		{
		return avail_width;
		}
	if(mode=="height")
		{
		return avail_height;
		}
	}
	
function setHeight(){
	if(document.getElementById("contentContainer")){
		var tmp = document.getElementById("contentContainer");
		if(tmp.offsetHeight && tmp.offsetHeight-20<getWindowSize("height")){
			tmp.style.height = 	getWindowSize("height")-20+"px";	
		}
		
	}	
}

var imgArray=new Array();
var imgId=0;
	
function showZoomImage(src,title,width,height)
	{
	if(document.getElementById('modImgZoom'))
		{
		document.getElementsByTagName("body")[0].removeChild(document.getElementById('modImgZoom'));
		}
	if(document.getElementById('modBgMask'))
		{
		document.getElementsByTagName("body")[0].removeChild(document.getElementById('modBgMask'));
		}
	
	var avail_width=getWindowSize("width");
	var avail_height=getWindowSize("height");
		
	//scale img for smaller displays
	var space=0;
	if((avail_height-space)<height)
		{
		width=(avail_height-space)*width/height;
		height=avail_height-space;
		}
		
	//parent div
	var modImgZoom=document.createElement("div");
	modImgZoom.id="modImgZoom";
	modImgZoom.style.width=width+10+"px";
	modImgZoom.style.height=height+10+"px";
	
	//img
	var zoomImg=document.createElement("img");
	zoomImg.id="zoomImg";
	zoomImg.src=src;
	zoomImg.alt="";
	zoomImg.onclick=function(){
		showZoomImage("shared/images/sachsen.jpg","",550,403);			
	}
	zoomImg.style.width=(width)+"px";
	zoomImg.style.height=(height)+"px";
	zoomImg.style.border="1px solid #666666";
	
	
	modImgZoom.style.top=(getWindowSize('height')-parseInt(modImgZoom.style.height))/3+"px";
	modImgZoom.style.left=(getWindowSize('width')-parseInt(modImgZoom.style.width))/2+"px";
	//modImgZoom.style.top=(1000-parseInt(modImgZoom.style.height))/3+"px";
	modImgZoom.style.left=(1000-parseInt(modImgZoom.style.width))/2+"px";
	
	
	//close
	var closeImg=document.createElement("img");
	closeImg.id="modCloseImg";
	closeImg.src="shared/images/close.gif";
	closeImg.alt="Schließen";
	closeImg.title="Schließen";
	closeImg.onclick=new Function("document.getElementsByTagName('body')[0].removeChild(this.parentNode);document.getElementsByTagName('body')[0].removeChild(document.getElementById('modBgMask'))");
	
	var previousImg=document.createElement("img");
	previousImg.id="modPreviousImg";
	previousImg.src="shared/images/previous.gif";
	previousImg.alt="Vorheriges Bild";
	previousImg.title="Vorheriges Bild";
	previousImg.onclick=new Function("loadImage('previous')");
	previousImg.style.cursor="pointer";
	previousImg.style.verticalAlign="middle";
		
	var nextImg=document.createElement("img");
	nextImg.id="modNextImg";
	nextImg.src="shared/images/next.gif";
	nextImg.alt="Nächstes Bild";
	nextImg.title="Nächstes Bild";
	nextImg.onclick=new Function("loadImage('next')");
	nextImg.style.cursor="pointer";
	nextImg.style.verticalAlign="middle";
	
	var imgCounter=document.createElement("span");
	imgCounter.id="imgCounter";
	imgCounter.appendChild(document.createTextNode((imgId+1)+" / "+imgArray.length));
	imgCounter.style.fontSize="11px";
	
	imgTitle=document.createTextNode(title);
	
	var mask=document.createElement("div");
	mask.id="modBgMask";
	document.getElementsByTagName("body")[0].appendChild(mask);
	//show
	document.getElementsByTagName("body")[0].appendChild(modImgZoom);
	
	//fade=window.setInterval("fadeIn("+width+","+height+",50)",10);
	document.getElementById("modImgZoom").appendChild(zoomImg);
	document.getElementById("modImgZoom").appendChild(closeImg);
	//document.getElementById("modImgZoom").appendChild(previousImg);
	//document.getElementById("modImgZoom").appendChild(imgCounter);
	//document.getElementById("modImgZoom").appendChild(nextImg);
	document.getElementById("modImgZoom").appendChild(imgTitle);
	
	return false;
	}
	
function setElementTitle(element,title){
	if(document.getElementById(element)){
		document.getElementById(element).title = title;	
	}	
}
	
function loadImage(mode)
	{
	
	if(document.getElementById("modImgZoom") && document.getElementById("zoomImg"))
		{
		if(mode=="next"){
			if(imgId<imgArray.length-1){
				imgId++;	
			}
			else{
				imgId=0;	
			}
			
		}
			
		if(mode=="previous"){
			if(imgId>0){
				imgId--;	
			}
			else{
				imgId=imgArray.length-1;	
			}
			
		}
		document.getElementById("imgCounter").innerHTML=(imgId+1)+" / "+imgArray.length;
		document.getElementById("zoomImg").src=imgArray[imgId];	
		}
	}
	
