﻿

var highlightLayer=Array('basiseintrag','schatten','ho','hu','hl','hr');

var globalX1=-1;
var globalX2=-1;
var globalY1=-1;
var globalY2=-1;
var ScreenX=-1;
var ScreenY=-1;
var minx=-1;
var maxx=-1;
var lg='00';
var extraParams='';
var MOUSEOVER=0;
var MouseXStart=-1;
var MouseYStart=-1;

var MapWidth=440;
var MapHeight=440;

var BoxLeft=-1;
var BoxRight=-1;
var BoxTop=-1;
var BoxBottom=-1;

var MouseButtonDown=false;

var MouseX=-1;
var MouseY=-1;

var minX=-1;
var maxX=-1;
var minY=-1;
var maxY=-1;
var leftmargin=-1;
var topmargin=-1;

var MapUrl="";

var external=0;
var enable=1;

function initAll() {

	if (!external) {

		if (parent.document.getElementById('basiseintrag')!=null) {
			for (var j=0; j<highlightLayer.length; j++) {
				parent.document.body.removeChild(parent.document.getElementById(highlightLayer[j]));
			}
		}

		// basiseintrag
		var newDIV=parent.document.createElement("div");
		newDIV.id='basiseintrag';
		newDIV.style.position='absolute';
		newDIV.style.top='5px';
		newDIV.style.left='5px';
		newDIV.style.zIndex=20;
		newDIV.style.border='solid 1px';
		newDIV.style.visibility='hidden';
		newDIV.style.background='#ffffff';
		newDIV.style.width='614px';
		newDIV.style.height='210px';
		newDIV.onmouseover=function(){parent.myframe.setMouseOver(1);};
		newDIV.onmouseout=function(){parent.myframe.setMouseOver(0);};
		parent.document.body.appendChild(newDIV);

		// basisiframe
		var newIFRAME=parent.document.createElement("iframe");
		newIFRAME.id="basisiframe";
		newIFRAME.style.width=613;
		newIFRAME.style.height=210;
		newIFRAME.style.border='none';
		newIFRAME.src="/static/blank.html";
		newIFRAME.scrolling='no';
		newIFRAME.marginWidth=0;
		newIFRAME.marginHeight=0;
		newIFRAME.frameBorder=0;
		newIFRAME.onmouseover=function(){parent.myframe.setMouseOver(1);};
		newIFRAME.onmouseout=function(){parent.myframe.setMouseOver(0);};
		parent.document.getElementById('basiseintrag').appendChild(newIFRAME);

		// basisiframe-schatten
		newDIV=parent.document.createElement("div");
		newDIV.id='schatten';
		newDIV.style.position='absolute';
		newDIV.style.zIndex=19;
		newDIV.style.border='solid 1px';
		newDIV.style.visibility='hidden';
		newDIV.style.background='#000033';
		newDIV.style.width='614px';
		newDIV.style.height='210px';
		newDIV.style.top='5px';
		newDIV.style.left='5px';
		parent.document.body.appendChild(newDIV);



		// plus-eintrag
		newDIV=parent.document.createElement("div");
		newDIV.id='pluseintrag';
		newDIV.style.position='absolute';
		newDIV.style.top='5px';
		newDIV.style.left='5px';
		newDIV.style.zIndex=20;
		newDIV.style.border='solid 1px';
		newDIV.style.visibility='hidden';
		newDIV.style.background='#ffffff';
		newDIV.style.width='298px';
		newDIV.style.height='100px';
		newDIV.onmouseover=function(){parent.myframe.setMouseOver(1);};
		newDIV.onmouseout=function(){parent.myframe.setMouseOver(0);};
		parent.document.body.appendChild(newDIV);

		// plusiframe
		newIFRAME=parent.document.createElement("iframe");
		newIFRAME.id="plusiframe";
		newIFRAME.style.width=297;
		newIFRAME.style.height=100;
		newIFRAME.style.border='none';
		newIFRAME.src="/static/blank.html?sdfsdf";
		newIFRAME.scrolling='no';
		newIFRAME.marginWidth=0;
		newIFRAME.marginHeight=0;
		newIFRAME.frameBorder=0;
		newIFRAME.onmouseover=function(){parent.myframe.setMouseOver(1);};
		newIFRAME.onmouseout=function(){parent.myframe.setMouseOver(0);};
		parent.document.getElementById('pluseintrag').appendChild(newIFRAME);

		// plusiframe-schatten
		newDIV=parent.document.createElement("div");
		newDIV.id='plusschatten';
		newDIV.style.position='absolute';
		newDIV.style.zIndex=19;
		newDIV.style.border='solid 1px';
		newDIV.style.visibility='hidden';
		newDIV.style.background='#000033';
		newDIV.style.width='298px';
		newDIV.style.height='100px';
		newDIV.style.top='5px';
		newDIV.style.left='5px';
		parent.document.body.appendChild(newDIV);

		// info
		newDIV=parent.document.createElement("div");
		newDIV.id='info';
		newDIV.style.position='absolute';
		newDIV.style.zIndex=20;
		newDIV.style.border='solid 1px';
		newDIV.style.visibility='hidden';
		newDIV.style.background='#ffffcc';
		newDIV.style.width='191px';
		newDIV.style.top='5px';
		newDIV.style.left='5px';
		newDIV.onmouseover=function(){parent.myframe.setMouseOver(1);};
		newDIV.onmouseout=function(){parent.myframe.setMouseOver(0);};
		parent.document.body.appendChild(newDIV);


		// ho/hu/hl/hr
		for (var i=2; i<highlightLayer.length; i++) {
			newDIV=parent.document.createElement("div");
			newDIV.id=highlightLayer[i];
			newDIV.style.position='absolute';
			newDIV.style.zIndex=19;
			newDIV.style.visibility='hidden';
			newDIV.style.background='#ff0000';
			if (i<4) {
				newDIV.style.width='29px';
				newDIV.style.height='4px';
			} else {
				newDIV.style.width='4px';
				newDIV.style.height='29px';
			}
			newDIV.onmouseover=function(){parent.myframe.setMouseOver(1);};
			newDIV.onmouseout=function(){parent.myframe.setMouseOver(0);};
			newDIV.style.position='absolute';
			newDIV.style.top='5px';
			newDIV.style.left='5px';
			var newIMG=parent.document.createElement("img");
			newIMG.style.width='0px';
			newIMG.style.height='0px';
			newDIV.appendChild(newIMG);
			parent.document.body.appendChild(newDIV);
		}
		getFramePos();
		setInterval("hidebasiseintrag()",500);
	}
	try {
		if (document==parent.document) {
			alertDisabled();
			enable=0;
		}
	} catch (temp) {
	}
	implementNavBox();
	setMapSize(0,0,MapWidth,MapHeight,20,20);
}

function setMouseOver(a) {
	MOUSEOVER=a;
}
	

function implementNavBox() {
	var layernames=['l','r','b','t'];
	for (var i=0; i<layernames.length; i++) {
		document.write('<div id="'+layernames[i]+'" align="center" style="font-size:0; position:absolute; overflow:hidden; left:0; top:0; visibility:hidden;">');
		document.write('<img src="/static/pic/pixel.gif" width=2 height=2>');
		document.write('</div>');
	}
	document.write('<div id="ZoomIn" align="center" style="font-size:10; position:absolute; overflow:hidden; left:0; top:0; visibility:hidden;">');
	document.write('Vergrößern');
	document.write('</div>');
	document.write('<div id="ZoomOut" align="center" style="font-size:10; position:absolute; overflow:hidden; left:0; top:0; visibility:hidden;">');
	document.write('Verkleinern');
	document.write('</div>');
	document.write('<div id="Pan" align="center" style="font-size:10; position:absolute; overflow:hidden; left:0; top:0; visibility:hidden;">');
	document.write('Verschieben');
	document.write('</div>');
	document.onmousemove=MouseMoveOnMap;
	document.onmouseup=MouseUpOnMap;
	document.onmousedown=MouseDownOnMap;
}

function MouseMoveOnMap(e) {
	try {
		MouseX=event.clientX+document.body.scrollLeft-leftmargin;
		MouseY=event.clientY+document.body.scrollTop-topmargin;
	} catch (temp) {
		MouseX=e.clientX+document.body.scrollLeft-leftmargin;
		MouseY=e.clientY+document.body.scrollTop-topmargin;
	}
	var Status="";
	if (isInBox()) {
		if (MouseButtonDown) {
			drawBox();
		}
		var x;
		var y
		try {
			x=event.clientX+document.body.scrollLeft-leftmargin;
			y=event.clientY+document.body.scrollTop-topmargin;
		} catch (temp) {
			x=e.clientX+document.body.scrollLeft-leftmargin;
			y=e.clientY+document.body.scrollTop-topmargin;
		}
		Status= "Position in Pixel "+x;
		Status+=" / "+y;
		Status+=" - Position in Meter "+PixToMeterX(x);
		Status+=" / "+PixToMeterY(y);
		var width=globalX2-globalX1;
		Status+=" - Maßstab 1:"+Math.floor(3780*width/MapWidth);
	}
	if (window.status!=Status) {
		window.status=Status;
	}
	return false;
}

function MouseUpOnMap(e) {
	MouseButtonDown=false;
	showMode("ZoomIn",false);
	showMode("ZoomOut",false);
	showMode("Pan",false);
	showBox(false);
	try {
		MouseX=event.clientX+document.body.scrollLeft-leftmargin;
		MouseY=event.clientY+document.body.scrollTop-topmargin;
	} catch (temp) {
		MouseX=e.clientX+document.body.scrollLeft-leftmargin;
		MouseY=e.clientY+document.body.scrollTop-topmargin;
	}
	if (isInBox()&&!MOUSEOVER) {
		if (MouseMode()==0)	{
			// hier pan-funktion einf�gen
			var merker=0;
			for (var i=0; i<document.getElementsByName('mymap')[0].areas.length; i++) {
				var coords=document.getElementsByName('mymap')[0].areas[i].coords;
				var co=coords.split(",");
				if (MouseX>=co[0]&&MouseX<=co[2]&&MouseY>=co[1]&&MouseY<=co[3]&&merker==0) {
					merker=1;
					eval(document.getElementsByName('mymap')[0].areas[i].href.substring(11));
				}
			}
			if (merker==0) {
				MoveAbsolute(MouseX-minX,MouseY-minY);
			}
		}
		if (MouseMode()>0) {
			// hier zoom-in-funktion einf�gen
			ZoomTo(BoxLeft-minX,BoxBottom-minY,BoxRight-minX,BoxTop-minY);
		}
		if (MouseMode()==-1) {
			// hier zoom-out-funktion einf�gen
			Zoom(Math.abs((BoxRight-BoxLeft) /(maxX-minX)));
		}
		return false;
	}
	return true;
}

function MouseDownOnMap(e) {
	MouseButtonDown=true;
	if(document.images['Map'].complete==true) {
		try {
			MouseXStart=event.clientX+document.body.scrollLeft-leftmargin;
			MouseYStart=event.clientY+document.body.scrollTop-topmargin;
		} catch (temp) {
			MouseXStart=e.clientX+document.body.scrollLeft-leftmargin;
			MouseYStart=e.clientY+document.body.scrollTop-topmargin;
		}
		MouseX=MouseXStart;
		MouseY=MouseYStart;
		if (isInBox()) {
			drawBox();
			showBox(true);
		}
		return true;
	} else {
		MouseButtonDown=false;
		return false;
	}
}

function setMapSize(x,y,w,h,l,t) {
	minX=x;
	maxX=x+w;
	minY=y;
	maxY=y+h;
	leftmargin=l;
	topmargin=t;
}

function setMapUrl(url) {
	MapUrl=url;
}

function isInBox() {
	if (MouseX<minX) {
		return false;
	}
	if (MouseX>maxX) {
		return false;
	}
	if (MouseY<minY) {
		return false;
	}
	if (MouseY>maxY) {
		return false;
	}
	return true;
}

function drawBox() {
	AdjustBoxHeight();
	var LineWidth=1;
	var Color="#ff0000";
	var layer='';
	if (MouseMode()==0) {
		Color="#000000";
		layer=document.getElementById('Pan').style;
		showMode("ZoomIn",false);
		showMode("ZoomOut",false);
		showMode("Pan",true);
	}
	if (MouseMode()>0) {
		Color="#ff0000";
		if (MouseMode()>1) {
			Color="#00ff00";
		}
		layer=document.getElementById('ZoomIn').style;
		showMode("ZoomIn",true);
		showMode("ZoomOut",false);
		showMode("Pan",false);
	}
	if (MouseMode()==-1) {
		Color="#0000ff";
		layer=document.getElementById('ZoomOut').style;
		showMode("ZoomIn",false);
		showMode("ZoomOut",true);
		showMode("Pan",false);
	}
	if (layer!=null) {
		layer.top	= BoxTop+topmargin;
		layer.left	= BoxRight+leftmargin;
		layer.backgroundColor="#ffff00";
	}
	layer=document.getElementById('t').style;
	if (layer!=null) {
		layer.backgroundColor=Color;
		layer.height=LineWidth;
		layer.width	= BoxRight-BoxLeft;
		layer.top	=(BoxTop+topmargin)+"px";
		layer.left	=(BoxLeft+leftmargin)+"px";
	}
	layer=document.getElementById('b').style;
	if (layer!=null) {
		layer.backgroundColor=Color;
		layer.height=LineWidth;
		layer.width	= BoxRight-BoxLeft;
		layer.top	=(BoxBottom+topmargin)+"px";
		layer.left	=(BoxLeft+leftmargin)+"px";
	}
	layer=document.getElementById('r').style;
	if (layer!=null) {
		layer.backgroundColor=Color;
		layer.height=BoxBottom-BoxTop;
		layer.width	= LineWidth;
		layer.top	=(BoxTop+topmargin)+"px";
		layer.left	=(BoxRight+leftmargin)+"px";
	}
	layer=document.getElementById('l').style;
	if (layer!=null) {
		layer.backgroundColor=Color;
		layer.height=BoxBottom-BoxTop;
		layer.width	= LineWidth;
		layer.top	=(BoxTop+topmargin)+"px";
		layer.left	=(BoxLeft+leftmargin)+"px";
	}
}

function showMode(mode,show) {
	var layer=document.getElementById(mode).style;
	if (layer!=null) {
		if (show) {
			layer.visibility="visible";
		} else {
			layer.visibility="hidden";
			layer.top	= 0;
			layer.left	= 0;
		}
	}
}

function showBox(show) {
	var layernames=['l','r','b','t'];
	for (var i=0; i<layernames.length; i ++) {
		var layer=document.getElementById(layernames[i]).style;
		if (layer!=null) {
			if (show) {
				layer.visibility="visible";
			} else {
				layer.visibility="hidden";
				layer.height=0;
				layer.width	= 0;
				layer.top	= 0;
				layer.left	= 0;
			}
		}
	}
}

function MouseMode() {
	if (Math.abs(MouseXStart-MouseX)<5 && Math.abs(MouseYStart-MouseY)<5) {
		// verschieben
		return 0;
	} else {
		if (MouseXStart<MouseX) {
			if (MouseYStart<MouseY) {
				// vergr��ern mit freiem Rechteck, beginnend am Klickpunkt
				return 2;
			} else {
				// vergr��ern mit Rechteck mit festem Kantenverh�ltnis, Klickpunkt im Zentrum
				return 1;
			}
		} else {
			// verkleinern mit Rechteck mit festem Kantenverh�ltnis, Klickpunkt im Zentrum
			return -1;
		}
	}
	return 0;
}

function MoveAbsolute(xp,yp) {
	var xm=PixToMeterX(xp);
	var ym=PixToMeterY(yp);

	var x1=globalX1;
	var x2=globalX2;
	var y1=globalY1;
	var y2=globalY2;

	var width=x2-x1;
	var height=y2-y1;

	x1=Math.floor(xm-width/2);
	x2=Math.floor(xm+width/2);
	y1=Math.floor(ym-height/2);
	y2=Math.floor(ym+height/2);

	if (enable) {
		setExtent(x1,y1,x2,y2);
		AdjustScales();
		UpdateMap();
	} else {
		alertDisabled();
	}
}

function ZoomTo(xp1,yp1,xp2,yp2) {
	var xm1=PixToMeterX(xp1);
	var ym1=PixToMeterY(yp1);
	var xm2=PixToMeterX(xp2);
	var ym2=PixToMeterY(yp2);
	if (enable) {
		setExtent(xm1,ym1,xm2,ym2);
		AdjustScales();

		UpdateMap();
	} else {
		alertDisabled();
	}
}

function Zoom(factor) {
	var x1=globalX1;
	var x2=globalX2;
	var y1=globalY1;
	var y2=globalY2;
	var width=x2-x1;
	var height=y2-y1;

	var widthnew=0;
	var heightnew=0;
	if (factor!=0) {
		widthnew=width/factor;
		heightnew=height/factor;
	}
	x1+=(width-widthnew)/2;
	x2 -=(width-widthnew)/2;
	y1+=(height-heightnew)/2;
	y2 -=(height-heightnew)/2;

	if (enable) {
		if (x2-x1 < 1000000) {
			setExtent(x1,y1,x2,y2);
			AdjustScales();
			UpdateMap();
		}
	} else {
		alertDisabled();
	}
}

function AdjustBoxHeight() {
	if (MouseMode()==2) {
		// Klickpunkt in der linken, unteren Ecke des Rechtecks
		BoxLeft=Math.min(MouseX,MouseXStart);
		BoxRight=Math.max(MouseX,MouseXStart);
		BoxTop=Math.min(MouseY,MouseYStart);
		BoxBottom=Math.max(MouseY,MouseYStart);
	} else {
		// Klickpunkt im Zentrum des Rechtecks
		BoxLeft=Math.min(MouseX,2*MouseXStart-MouseX);
		BoxRight=Math.max(MouseX,2*MouseXStart-MouseX);
		BoxTop=Math.min(MouseY,2*MouseYStart-MouseY);
		BoxBottom=Math.max(MouseY,2*MouseYStart-MouseY);
	}
	BoxLeft=Math.max(minX,BoxLeft);
	BoxRight=Math.max(minX,BoxRight);
	BoxBottom=Math.max(minY,BoxBottom);
	BoxTop=Math.max(minY,BoxTop);

	BoxLeft=Math.min(MapWidth+minX,BoxLeft);
	BoxRight=Math.min(MapWidth+minX,BoxRight);
	BoxBottom=Math.min(MapHeight+minY,BoxBottom);
	BoxTop=Math.min(MapHeight+minY,BoxTop);

	if (MouseMode()!=2) {
		// Seitenverh�lnis der Karte beibehalten
		var w=BoxRight-BoxLeft;
		var h=BoxBottom-BoxTop;
		var dh=h-w*MapHeight/MapWidth;
		BoxTop+=dh/2;
		BoxBottom-=dh/2;
	}
}

function setExtent(x1,y1,x2,y2) {
	x1=Math.floor(x1);
	x2=Math.floor(x2);
	y1=Math.floor(y1);
	y2=Math.floor(y2);

	var altx1=x1;
	var altx2=x2;
	var alty1=y1;
	var alty2=y2;

	if (isNaN(x1)||isNaN(x2)||isNaN(y1)||isNaN(y2)) {
		document.history.go(-1);
	}
	if (x1>x2) {
		x=x2;
		x2=x1;
		x1=x;
	}
	if (x1==x2) {
		x2=x1+1000;
	}
	globalX1=Math.floor(x1);
	globalX2=Math.floor(x2);
	if (y1>y2) {
		y=y2;
		y2=y1;
		y1=y;
	}
	if (y1==y2) {
		y2=y1+1000;
		history.go(-1);
	}
	globalY1=Math.floor(y1);
	globalY2=Math.floor(y2);
}

function MoveRelative(fx,fy) {
	var x1=globalX1;
	var x2=globalX2;
	var y1=globalY1;
	var y2=globalY2;
	width=x2-x1;
	height=y2-y1;
	x1+=width*fx;
	x2+=width*fx;
	y1+=height*fy;
	y2+=height*fy;
	setExtent(x1,y1,x2,y2);
	AdjustScales();
	UpdateMap();
}

function PixToMeterX(x) {
	var x1=globalX1;
	var x2=globalX2;
	var width=x2-x1;
	x=x1+x*width/MapWidth;
	return Math.floor(x);
}

function PixToMeterY(y) {
	y=MapHeight-y;
	var y1=globalY1;
	var y2=globalY2;
	var height=y2-y1;
	y=y1+y*height/MapHeight;
	return Math.floor(y);
}

function AdjustScales() {
	var x1=globalX1;
	var x2=globalX2;
	var y1=globalY1;
	var y2=globalY2;

	var w=x2-x1;
	var h=y2-y1;
	var ScaleX=w/MapWidth;
	var ScaleY=h/MapHeight;
	if (ScaleX<ScaleY) {
		var wbef=x2-x1;
		var wnew=wbef*ScaleY/ScaleX;
		x1+=(wbef-wnew)/2;
		x2=x1+wnew;
	} else {
		var hbef=y2-y1;
		var hnew=hbef*ScaleX/ScaleY;
		y1+=(hbef-hnew)/2;
		y2=y1+hnew;
	}

	setExtent(x1,y1,x2,y2);
}

function UpdateMap() {
	var x1=globalX1;
	var x2=globalX2;
	var y1=globalY1;
	var y2=globalY2;
	var MapLink='iframe.pl?';
	MapLink+="x1="+x1;
	MapLink+="&x2="+x2;
	MapLink+="&y1="+y1;
	MapLink+="&y2="+y2;
	MapLink+=extraParams;
	document.location.href=MapLink;
}

function info(firma,area_i,cox,coy) {
	parent.document.getElementById('info').innerHTML=unescape(firma);
	var co=Array(cox,coy);
	if (area_i>-1) {
		var coords=document.getElementsByName('mymap')[0].areas[area_i].coords;
		co=coords.split(",");
	}
	var x=Number(co[0]);
	if (x+220>maxx) {
		x=maxx-220;
	}
	x+=ScreenX;
	var y=Number(co[1]);
	if (y+30>MapHeight) {
		y=MapHeight-30;
	}
	y+=ScreenY;
	parent.document.getElementById('info').style.left=x;
	parent.document.getElementById('info').style.top=y;
	parent.document.getElementById('info').style.visibility='visible';
	MOUSEOVER=1;
}

function b(kdnr,area_i,plus,cox,coy) {
	hidebasiseintrag()
	var co=Array(cox, coy);
	if (area_i>-1) {
		co=getAreaCoords(area_i);
	}
	var x=ScreenX+co[0]-80;
	var layername='basiseintrag';
	var shadowname='schatten';
	highlightLayer=Array('basiseintrag','schatten','ho','hu','hl','hr');
	if (plus) {
		layername='pluseintrag';
		shadowname='plusschatten';
		parent.document.getElementById('plusiframe').src='//www.city-map.de/city/basisiframe/'+kdnr+lg+'.html';
		if (x+298>maxx) {
			x=maxx-298;
		}
		highlightLayer=Array('pluseintrag','plusschatten','ho','hu','hl','hr');
	} else {
		parent.document.getElementById('basisiframe').src='//www.city-map.de/city/basisiframe/'+kdnr+lg+'.html';
		if (x+614>maxx) {
			x=maxx-614;
		}
	}
	if (x<minx) {
		x=minx;
	}
	var y=ScreenY+co[1]+50;
	if (co[1]>MapHeight/2+50) {
		y-=(MapHeight/2+25);
	}
	parent.document.getElementById(layername).style.left=x;
	parent.document.getElementById(layername).style.top=y;
	parent.document.getElementById(shadowname).style.left=x+7;
	parent.document.getElementById(shadowname).style.top=y+8;
	icon_highlight(area_i);
	return false;
}

function getAreaCoords(area_i) {
	var coords=document.getElementsByName('mymap')[0].areas[area_i].coords;
	var co=coords.split(",");
	for (var i=0; i<3; i++) {
		co[i]=Number(co[i]);
	}
	return co;
}

function icon_highlight(area_i) {
	var start=0;
	var area_test=''+area_i;
	if (area_test&&area_test.match(/,/)) {
		area_i=area_i.replace(/[0-9]{9},/,'');
		area_i=Number(area_i);
		start=2;
	}
	if (area_test) {
		var co=Array(0,0,0,0);
		if (area_i>-1) {
			co=getAreaCoords(area_i);
		}
		var l=2;
		if (co[2]-co[0]>10) {
			parent.document.getElementById('ho').style.left=co[0]+ScreenX+17;
			parent.document.getElementById('ho').style.top=co[1]+ScreenY+17;
			parent.document.getElementById('hu').style.left=co[0]+ScreenX+17;
			parent.document.getElementById('hu').style.top=co[1]+ScreenY+42;
			parent.document.getElementById('hl').style.left=co[0]+ScreenX+17;
			parent.document.getElementById('hl').style.top=co[1]+ScreenY+17;
			parent.document.getElementById('hr').style.left=co[0]+ScreenX+42;
			parent.document.getElementById('hr').style.top=co[1]+ScreenY+17;
			l=highlightLayer.length;
		} else if (start==2) {
			parent.document.getElementById('ho').style.left=co[0]+ScreenX+10;
			parent.document.getElementById('ho').style.top=co[1]+ScreenY+22;
			parent.document.getElementById('hu').style.left=co[0]+ScreenX+10;
			parent.document.getElementById('hu').style.top=co[1]+ScreenY+22;
			parent.document.getElementById('hl').style.left=co[0]+ScreenX+22;
			parent.document.getElementById('hl').style.top=co[1]+ScreenY+11;
			parent.document.getElementById('hr').style.left=co[0]+ScreenX+22;
			parent.document.getElementById('hr').style.top=co[1]+ScreenY+11;
			l=highlightLayer.length;
		} else {
			for (i=start; i<highlightLayer.length; i++) {
				parent.document.getElementById(highlightLayer[i]).style.visibility='hidden';
			}
		}

		for (i=start; i<l; i++) {
			parent.document.getElementById(highlightLayer[i]).style.visibility='visible';
		}
	} else {
		for (i=start; i<highlightLayer.length; i++) {
			parent.document.getElementById(highlightLayer[i]).style.visibility='hidden';
		}
	}
}

function hidebasiseintrag() {
	if (parent.document.getElementById('basiseintrag').style.visibility=='visible'&&MOUSEOVER==0) {
		parent.document.getElementById('basisiframe').src='/static/blank.html';
		for (var i=0; i<highlightLayer.length; i++) {
			parent.document.getElementById(highlightLayer[i]).style.visibility='hidden';
		}
	}
	if (parent.document.getElementById('pluseintrag').style.visibility=='visible'&&MOUSEOVER==0) {
		parent.document.getElementById('plusiframe').src='/static/blank.html';
		for (var i=0; i<highlightLayer.length; i++) {
			parent.document.getElementById(highlightLayer[i]).style.visibility='hidden';
		}
	}
	if (parent.document.getElementById('info').style.visibility=='visible'&&MOUSEOVER==0) {
		parent.document.getElementById('info').style.visibility='hidden';
	}
}

function saveMap(xFeld,yFeld,widthFeld,mapForm,multikunde) {
	var mapwidth=globalX2-globalX1;
	var mapheight=globalY2-globalY1;
	parent.document.getElementsByName(xFeld)[0].value=globalX1+mapwidth/2;
	parent.document.getElementsByName(yFeld)[0].value=globalY1+mapheight/2;
	var neuWidth=globalX2-globalX1;
	if (neuWidth<100) {
		neuWidth=100;
	}
	if (multikunde) {
		parent.document.getElementsByName('kundennummer')[0].value=multikunde;
	}
	parent.document.getElementsByName(widthFeld)[0].value=neuWidth;
	if (mapForm) {
		parent.document.getElementById(mapForm).submit();
	}
}

function getFramePos() {
	var myTarget=parent.document.getElementsByName('myframe')[0];
	var gety=0;
	var getx=0;
	while (myTarget!=parent.document.body && myTarget!=parent.document.mainAreaContent) {
		gety+=myTarget.offsetTop;
		getx+=myTarget.offsetLeft;
		myTarget=myTarget.offsetParent;
	}
	ScreenX=getx;
	ScreenY=gety;
}

function multisubmit(doit) {
	if (doit) {
		var multikunde=document.kundenform.multikunde.value;
		if (multikunde) {
			var temp=multikunde.split(/,/);
			multikunde=temp[0];
			var area_i=temp[1];
			extraParams+='&multikunde='+multikunde
			var co=getAreaCoords(area_i);
			MoveAbsolute(co[0]+11,co[1]+11);
		}
	} else {
		extraParams=extraParams.replace(/&multikunde=[0-9]{9}/,'');
		UpdateMap();
	}
}

function alertDisabled() {
	alert('This applet was brought to you by www.city-map.de.\nThe page you are looking at has not been authorized to use the city-map applet.\nIf you consider this an error please contact webmaster@city-map.de');
}

function routePrint(imgsrc) {
	if (imgsrc) {
		try {
			parent.bottomMapFrame.focus();
			parent.bottomMapFrame.document.printPreview.src=imgsrc;
			var done=0;
			for (var i=0; i<=100000; i++) {
				if ( parent.bottomMapFrame.document.images['printPreview'].complete == true && done == 0 ) {
					parent.bottomMapFrame.print();
					done=1;
				}
			}
		} catch(temp) {
			parent.document.printPreview.src='/mapserver/'+imgsrc;
			var done=0;
			for (var i=0; i<=100000; i++) {
				if ( parent.document.images['printPreview'].complete == true && done == 0 ) {
					parent.focus();
					parent.print();
					done=1;
				}
			}
		}
		
	} else {
		parent.focus();
		parent.print();
	}
}

function toggleView(test) {
	if (extraParams.indexOf('&sat=1')!=-1) {
		extraParams=extraParams.replace(/\&sat=1/,'');
		if (test) {
			document.getElementById('toggleLuftbild').className='togglePassiv';
			document.getElementById('toggleKarte').className='toggleAktiv';
		}
	} else {
		extraParams+='&sat=1';
		if (test) {
			document.getElementById('toggleLuftbild').className='toggleAktiv';
			document.getElementById('toggleKarte').className='togglePassiv';
		}
	}
	UpdateMap();
}

