 //Browser Checking
if (navigator.userAgent.indexOf("MSIE") != -1 ) {
	//MSIE oder Netscape 6
	isIE = true;
	isNav = false;
	isNav6 = false;
} else if (document.getElementById&&!document.all){
	isIE = false;
	isNav = false;
	isNav6 = true;
} else {
	//  MSIE
	isIE = false;
	isNav = true;
	isNav6 = false;
}

// Create a DHTML layer
function createLayer(name, left, top, width, height, z, bgColor, visible, content) {
	  var layer;
	  if (isNav) {
		    parent.MapFrame.document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' bgColor=' + bgColor + ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
		    parent.MapFrame.document.writeln(content);
		    parent.MapFrame.document.writeln('</layer>');
		    layer = getLayer(name);
		    layer.width = width;
		    layer.height = height;
	  }

	  if (isIE||isNav6) {
    		parent.MapFrame.document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + 'z-index:' + z + ';' + 'background-color:' + bgColor + ';' + 'visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
		    parent.MapFrame.document.writeln(content);
    		parent.MapFrame.document.writeln('</div>');
			layer = getLayer(name);
		 }
	if (isNav6) {
	 	clipLayer(name, left, top, width+left, height+top);
	} else {
		clipLayer(name, 0, 0, width, height);
		 
	}
	
}


// Create a DHTML layer
function createLayer1(name, left, top, width, height, z, visible, content) {
	  var layer;
	  if (isNav) {
		    parent.MapFrame.document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height  + ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
		    parent.MapFrame.document.writeln(content);
		    parent.MapFrame.document.writeln('</layer>');
		    layer = getLayer(name);
		    layer.width = width;
		    layer.height = height;
	  }

	  if (isIE||isNav6) {
    		parent.MapFrame.document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + 'z-index:' + z + ';' + ';' + 'visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
		    parent.MapFrame.document.writeln(content);
    		parent.MapFrame.document.writeln('</div>');
			layer = getLayer(name);
		 }
	if (isNav6) {
	 	clipLayer(name, left, top, width+left, height+top);
	} else {
		clipLayer(name, 0, 0, width, height);
		 
	}
	
}


// Create a DHTML layer
function createScaleLayer(name, left, top, width, height, z, bgColor, visible, content) {
	  var layer;
	  if (isNav) {
		    parent.LayerFrame.document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' bgColor=' + bgColor + ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
		    parent.LayerFrame.document.writeln(content);
		    parent.LayerFrame.document.writeln('</layer>');
		    layer = getLayer(name);
		    layer.width = width;
		    layer.height = height;
	  }

	  if (isIE||isNav6) {
    		parent.LayerFrame.document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + 'z-index:' + z + ';' + 'background-color:' + bgColor + ';' + 'visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
		    parent.LayerFrame.document.writeln(content);
    		parent.LayerFrame.document.writeln('</div>');
			layer = getLayer(name);
		 }
	if (isNav6) {
	 	clipLayer(name, left, top, width+left, height+top);
	} else {
		clipLayer(name, 0, 0, width, height);
		 
	}
	
}
 
// get the layer object called "name"
function getLayer(name) {
	  if (isNav)
	    return(parent.MapFrame.document.layers[name]);
	 else if (isIE) {
	  	if ( eval('parent.MapFrame.document.all.' + name) != null) {
			layer = eval('parent.MapFrame.document.all.' + name + '.style');
			return(layer);
		} else 
			return(null);
	  }
	  else if (isNav6) {
	  		layer = eval('parent.MapFrame.document.getElementById("'+name+'").style');
			return(layer);
	 } else
	   return(null);
}

// toggle layer to visible
function showLayer(name) {		
  	var layer = getLayer(name);	
	if (layer != null) {
	  	if (isNav)
    		layer.visibility = "show";
	  	if (isIE||isNav6) 
   		 layer.visibility = "visible";
	}
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {		
	  var layer = getLayer(name);		
	  if (layer != null) {
		  if (isNav) {
			    layer.clip.left   = clipleft;
			    layer.clip.top    = cliptop;
		    	    layer.clip.right  = clipright;
			    layer.clip.bottom = clipbottom;
		  } else if (isNav6) {
			 //layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
			var newWidth = clipright - clipleft;
			var newHeight = clipbottom - cliptop;
			layer.height = newHeight;
			layer.width	= newWidth;
			layer.top	= cliptop  + "px";
			layer.left	= clipleft + "px";
			//layer.display= "none";
		  }	else {
		  	 layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
		  }  
	  }
}


// clip zoom box layer to mouse coords
function setClip() {	
	var tempX=startX;
	var tempY=startY;
	if (startX>x2) {
		zright=startX;
		zleft=x2;
	} else {
		zleft=startX;
		zright=x2;
	}
	if (startY>y2) {
		zbottom=startY;
		ztop=y2;
	} else {
		ztop=startY;
		zbottom=y2;
	}
	
	if ((startX != x2) && (startY != y2)) {
		var ovBoxSize = boxLineWidth;
		//clipLayer("Box",zleft,ztop,zright,zbottom);
		clipLayer("BoxTop",zleft,ztop,zright,ztop+ovBoxSize);
		clipLayer("BoxLeft",zleft,ztop,zleft+ovBoxSize,zbottom);
		clipLayer("BoxRight",zright-ovBoxSize,ztop,zright,zbottom);
		clipLayer("BoxBottom",zleft,zbottom-ovBoxSize,zright,zbottom);
	}
}


// move layer to x,y
function moveLayer(name, x, y) {		
  	var layer = getLayer(name);		
  	if (isNav)
    	layer.moveTo(x, y);
  	//if (document.all) {
	 else {
    	layer.left = x + "px";
   		layer.top  = y + "px";
  	}
}
