		



var nl=String.fromCharCode(13);

var mapRDY = false;

var toolbarLoaded = 0;
var zoombarLoaded = 0;


var activeToolbarButton = 3;
var ToolbarButtonLocked = 0;

function setActiveButton( number )
{
	activeToolbarButton = number;
}

function getActiveButton()
{
	return activeToolbarButton;
}

function LockToolbarButtons()
{
	ToolbarButtonLocked = 1;
}

function UnLockToolbarButtons()
{
	ToolbarButtonLocked = 0;
}

function ToolbarButtonsLocked()
{
	return ToolbarButtonLocked;
}





function OpenDetailInfoPopUp(path){
	PopUp = 0;
	PopUp = window.open(path,"detail","width=300;,height=400;,directories=0,location=0,menubar=0,resizable=no,scrollbars=1,status=0,toolbar=0");
	PopUp.focus();
	if(PopUp.opener==null){
		PopUp.opener = self;
	}
}


function OpenDatatablePopUp(path){
	PopUp = 0;
	PopUp = window.open(path,"detail","width=300;,height=400;,directories=0,location=0,menubar=0,resizable=no,scrollbars=1,status=0,toolbar=0");
	PopUp.focus();
	if(PopUp.opener==null){
		PopUp.opener = self;
	}
}




function OpenPopUpDetail(ch_id){

		
	infopath = '?child_id='+ch_id+'';
	
	width = 0;
	height= 0;
	PopUp = 0;
	PopUp = window.open(infopath,"detail","width="+width+",height="+height+",directories=0,location=0,menubar=0,resizable=no,scrollbars=1,status=0,toolbar=0");
	PopUp.focus();
	if(PopUp.opener==null){
		PopUp.opener = self;
	}

}


function OpenPopUp(path){
	PopUp = 0;
	PopUp = window.open(path,"detail","width=0;,height=0;,directories=0,location=0,menubar=0,resizable=no,scrollbars=1,status=0,toolbar=0");
	PopUp.focus();
	if(PopUp.opener==null){
		PopUp.opener = self;
	}
}
	

var objTypeArray = null;

function MouseOverPoint( ob_id )
{

	highlight(ob_id, true);

	var resultframe = window.top.frames.TOURTORIAL.dataframe;

	if(document.all)
	{

		if( resultframe != null && resultframe.document.all["ob_"+ob_id] != null )
		{
			resultframe.document.all["ob_"+ob_id].focus();
			resultframe.document.all["ob_"+ob_id].blur();
		}

		//Das Stylesheet in der Ergebnissmenge wird geändert wenn man mit der Maus über ein Objekt kommt
		if( resultframe != null && resultframe.document.all["style_"+ob_id] != null )
		{
			resultframe.document.all["style_"+ob_id].className = "hdhighlight";
		}
		
	}
	else
	{
	
		if( resultframe != null )
		{
		
			if( resultframe.document.getElementById("ob_"+ob_id) )
			{
			
				resultframe.document.getElementById("ob_"+ob_id).focus();
				resultframe.document.getElementById("ob_"+ob_id).blur();
				
			}
			
		}

		if( resultframe != null )
		{
			if( resultframe.document.getElementById("style_"+ob_id) )
				resultframe.document.getElementById("style_"+ob_id).className = "hdhighlight";

		}
		
	}
	
}


function layerVis(doc, lyname, vis) 
{

	if (document.layers) {
		doc.layers[lyname].visibility = vis;
	}
	else if (document.all) {
			doc.all[lyname].style.visibility = vis;
	}
	else if (document.documentElement) {
		doc.getElementById(lyname).style.visibility = vis;
	}
}

function getLayerStyle(doc, lyname) {

	var l;
	if (document.layers) {
		if (l = doc.layers[lyname])
			return l;
		else
			return null;
	}
	else if (document.all) {
		if (l = doc.all[lyname])
			return l.style;
		else
			return null;
	}
	else if (document.documentElement) {
		if (l = doc.getElementById(lyname))
			return l;
		else
			return null;
	}
	else
		return null;
}


function highlight(oid, b) {

	var doc = document;

	//Der Abschnitt setzt das ursprüngliche Stylesheet wieder zurück wenn man mit der Maus das Objekt verlässt
	if(! b )
	{

		var resultframe = window.top.frames.TOURTORIAL.dataframe;
		
		if( document.all )
		{
		
			if( resultframe != null && resultframe.document.all["style_"+oid] != null )
			{
				resultframe.document.all["style_"+oid].className = resultframe.getStyleSheetName();
			}
		
		}
		else
		{
			if( resultframe != null )
			{
				if( resultframe.document.getElementById("style_"+oid) )
					resultframe.document.getElementById("style_"+oid).className = resultframe.getStyleSheetName();
			}
		}
	
	}

	if( objTypeArray == null )
		return;
	

		switch (objTypeArray[oid]) {
			case "1":

				var stl_p = getLayerStyle(doc, 'p'+oid);
				if (stl_p == null)
				{
					return;
				}
				var stl_pointclickpane = getLayerStyle(doc, 'pointclickpane');
				var stl_h = getLayerStyle(doc, 'h');
				if (b) {
					stl_pointclickpane.zIndex = 1700;  
					doc.getElementById('h').style.left = doc.getElementById('p'+oid).style.left;
					doc.getElementById('h').style.top = doc.getElementById('p'+oid).style.top;
					
				}
				else {
					stl_pointclickpane.zIndex = 1400;  
				}
				//stl_h.visibility = (b ? 'visible' : 'hidden');
				
				doc.getElementById('h').style.visibility = (b ? 'visible' : 'hidden');
					
				break;
			case "2":

				var stl_h = getLayerStyle(doc, 'polygon_h'+oid);

				if( stl_h == null)
					return;
					
				doc.getElementById('polygon_h'+oid).style.visibility = (b ? 'visible' : 'hidden');
					
				break;
		}

}



var dir = '/tourtorial/grafiken/scroll/';


function scrollButton(name, srcfrag, zoomlevel, shift_x, shift_y) 
{

	scroll_frame = getElement(name);

	//var doc = jsincludestomap[name].document;
	doc = document;

	if( document.images.scroll != null )
		doc = document;
	else if( window.top.frames[name].document.images.scroll != null )
	{	

		doc = window.top.frames[name].document

	}
	else
		return;

	doc.images.scroll.src = dir+srcfrag;
	es = doc.forms.scroll.elements;
	es.zoomlevel.value = zoomlevel;
	es.recent_zoomlevel.value = zoomlevel;
	var mtes = jsincludestomap.map.document.forms.thisstatus.elements;

	es.x.value = parseInt(mtes.center_x.value) + shift_x;
	es.y.value = parseInt(mtes.center_y.value) + shift_y;
//alert(srcfrag);
	if (srcfrag == 'dummy_02.gif')
	{
		es.active.value = '0';
		scroll_frame.style.visibility = 'hidden';
	}
	else
	{
		es.active.value = '1';
		scroll_frame.style.visibility = 'visible';
	}

}

function is_alt(ens, eie) {
	return eie.altKey;
}

function is_shift(ens, eie) {
	return eie.shiftKey;
}



function getNavigatorElement()
{

	var navigator;
	
	if( document.all )
	{
		navigator = document.all.navigator;
	}
	else
	{
		navigator = document.getElementById("generalmap");
	}

	return navigator;

}

function setNavigatorStatus( status )
{

	var navigator = getElement('generalmap');

	if( status == 1 )
		navigator.style.visibility = 'visible';
	else
		navigator.style.visibility = 'hidden';

}


var navigator_orig_width = 116;
var navigator_orig_height = 100;


function changeNavigatorSize( factor )
{


	var mynavigator = getElement('generalmap');

	mynavigator.style.width = navigator_orig_width / factor;
	mynavigator.style.height = navigator_orig_height / factor;				

		

	window.top.frames.TOURTORIAL.navigator.updateGeneralMapSize( factor );
	
	window.top.document.forms.reloade.elements.generalmap_factor.value = factor;
	window.top.document.forms.thisstatus.elements.generalmap_factor.value = factor;
	window.top.document.forms.requestzoom.elements.generalmap_factor.value = factor;

}




var toolArray = new Array(	'generalmap',
										'generalmapselector',
										'fullscreenbox',
										'toolbar',
										'dataframe',
										'up',
										'down',
										'left',
										'right'
									);

var toolStatusArray = new Array();										
var toolStatus = 'visible';

var timer_is_set = 0;
var time_out_timer = 0;
var time_to_wait_till_visible = 1000;

function hideTourtorialTools()
{

	if( toolStatus == 'hidden' ) 
		return;
	else
		toolStatus = 'hidden';
		
	//toolStatusArray = new Array();
	
	timer_is_set = 1;
	
	counter = toolArray.length;

	for( var tool = 0; tool < counter; tool++ )
	{
		var frame = getElement( toolArray[tool] );
		
		if( frame )
		{
		
			if( toolStatusArray[toolArray[tool]] == null )
			{
				var tmp = new Array();
				tmp['visibility'] = frame.style.visibility;
				tmp['filter'] = frame.style.filter;
				tmp['opacity'] = frame.style.opacity;

				toolStatusArray[toolArray[tool]] = tmp;
			}
			
			
			frame.style.visibility = 'hidden';
			frame.style.filter = 'Alpha(opacity=0)';
			frame.style.opacity = '.0';

		}
		
	}
	
	clearTimeout( time_out_timer );
	time_out_timer = setTimeout( "updateTimer()", time_to_wait_till_visible );
	
}

function showTourtorialTools()
{

	toolStatus = 'visible';
	
	counter = toolArray.length;

	for( var tool = 0; tool < counter; tool++ )
	{
		var frame = getElement( toolArray[tool] );

		if( frame )
		{		
			frame.style.visibility = toolStatusArray[toolArray[tool]]['visibility'];
			
			for( var i = 0; i < ( toolStatusArray[toolArray[tool]]['opacity'] * 100 ); i+= 5 )
			{
				setTimeout( "smoothing( '" + toolArray[tool] + "', " + i + " )", time_to_wait_till_visible + i * 5 );
			}
		}
		
	}

}

function updateTimer()
{
	timer_is_set = 0;
}

function smoothing( name, value )
{

	if( toolStatus == 'hidden' ) 
		return;
	
	if( timer_is_set == 1 )
		return;
		
	var frame = getElement( name );

	frame.style.filter = 'Alpha(opacity='+value+')';
	frame.style.opacity = ( value / 100 );
			
}



	var zoom_image_0 = '/tourtorial/grafiken/zoombar/zoombar_erster_02.gif';
	var zoom_image_1 = '/tourtorial/grafiken/zoombar/zoombar_gerade_05.gif';
	var zoom_image_2 = '/tourtorial/grafiken/zoombar/zoom_ungerade_05.gif';
	var zoom_image_3 = '/tourtorial/grafiken/zoombar/zoombar_gerade_06.gif';
	var zoom_image_4 = '/tourtorial/grafiken/zoombar/zoom_ungerade_06.gif';
	var zoom_image_5 = '/tourtorial/grafiken/zoombar/zoombar_gerade_07.gif';
	var zoom_image_6 = '/tourtorial/grafiken/zoombar/zoom_ungerade_07.gif';
	var zoom_image_7 = '/tourtorial/grafiken/zoombar/zoombar_letzter_gerade_03.gif';	

	function resetZoombarIcons()
	{


		if( window.document.images.zoom0 != null )
			window.document.images.zoom0.src = zoom_image_0;
		if( window.document.images.zoom1 != null )
			window.document.images.zoom1.src = zoom_image_1;
		if( window.document.images.zoom2 != null )
			window.document.images.zoom2.src = zoom_image_2;
		if( window.document.images.zoom3 != null )
			window.document.images.zoom3.src = zoom_image_3;
		if( window.document.images.zoom4 != null )
			window.document.images.zoom4.src = zoom_image_4;
		if( window.document.images.zoom5 != null )
			window.document.images.zoom5.src = zoom_image_5;
		if( window.document.images.zoom6 != null )
			window.document.images.zoom6.src = zoom_image_6;
		if( window.document.images.zoom7 != null )
			window.document.images.zoom7.src = zoom_image_7;	
			
	}
	
	

	var zoom_image_0_aktiv = '/tourtorial/grafiken/zoombar/zoombar_erster_aktiv_03.gif';
	var zoom_image_1_aktiv = '/tourtorial/grafiken/zoombar/zoombar_aktiv_16.gif';
	var zoom_image_2_aktiv = '/tourtorial/grafiken/zoombar/zoombar_aktiv_20.gif';
	var zoom_image_3_aktiv = '/tourtorial/grafiken/zoombar/zoombar_aktiv_21.gif';
	var zoom_image_4_aktiv = '/tourtorial/grafiken/zoombar/zoombar_aktiv_22.gif';
	var zoom_image_5_aktiv = '/tourtorial/grafiken/zoombar/zoombar_aktiv_23.gif';
	var zoom_image_6_aktiv = '/tourtorial/grafiken/zoombar/zoombar_aktiv_24.gif';
	var zoom_image_7_aktiv = '/tourtorial/grafiken/zoombar/zoombar_letzter_aktiv_03.gif';

function changeZoomlevelIcon( lvl )
{

	switch( lvl )
	{



		case 0:
			if( window.document.images.zoom0 )
				window.document.images.zoom0.src = zoom_image_0_aktiv;
			break;
		case 1:
			if( window.document.images.zoom1 )
				window.document.images.zoom1.src = zoom_image_1_aktiv;
			break;
		case 2:
			if( window.document.images.zoom2 )
				window.document.images.zoom2.src = zoom_image_2_aktiv;
			break;
		case 3:
			if( window.document.images.zoom3 )
				window.document.images.zoom3.src = zoom_image_3_aktiv;
			break;
		case 4:
			if( window.document.images.zoom4 )
				window.document.images.zoom4.src = zoom_image_4_aktiv;
			break;
		case 5:
			if( window.document.images.zoom5 )
				window.document.images.zoom5.src = zoom_image_5_aktiv;
			break;
		case 6:
			if( window.document.images.zoom6 )
				window.document.images.zoom6.src = zoom_image_6_aktiv;
			break;
		case 7:
			if( window.document.images.zoom7 )
				window.document.images.zoom7.src = zoom_image_7_aktiv;
			break;
	}

}
	
	
function changeZoomlevel( lvl )
{

	if (window.innerWidth)
	{
		mapsizex = innerWidth;
		mapsizey = innerHeight;	
	}
	else if (document.body && document.body.offsetWidth)
	{
		mapsizex = parent.map.document.body.offsetWidth;
		mapsizey = parent.map.document.body.offsetHeight;	
	}


	document.forms.requestzoom.elements.mapsizex.value = mapsizex;
	document.forms.requestzoom.elements.mapsizey.value = mapsizey;

	if( lvl == 1 && document.forms.requestzoom.elements.recent_zoomlevel.value == 0 )
	{

		document.forms.requestzoom.elements.x.value = document.forms.requestzoom.elements.mapwidth.value / 2;
		document.forms.requestzoom.elements.y.value = document.forms.requestzoom.elements.mapheight.value / 2;

	}
	else
	{

		document.forms.requestzoom.elements.x.value = document.forms.thisstatus.elements.center_x.value;
		document.forms.requestzoom.elements.y.value = document.forms.thisstatus.elements.center_y.value;

	}

	document.forms.requestzoom.elements.zoomlevel.value = lvl;
	document.forms.requestzoom.submit();


}
	

var zoom_plus = '/tourtorial/grafiken/toolbar/zoom_in_02.gif';
var zoom_minus = '/tourtorial/grafiken/toolbar/zoom_out_02.gif';
var neutral_but = '/tourtorial/grafiken/toolbar/pfeil_02.gif';
var new_point = '/tourtorial/grafiken/toolbar/';
var move_point = '/tourtorial/grafiken/toolbar/';
var delete_point = '/tourtorial/grafiken/toolbar/';
var drawzoom_plus = '/tourtorial/grafiken/toolbar/3_drag_zoom_02.gif';
var enhance_point = '/tourtorial/grafiken/toolbar/';
var new_polygon_part = '/tourtorial/grafiken/toolbar/'
var planer_add = '/tourtorial/grafiken/toolbar/';
var planer_delete = '/tourtorial/grafiken/toolbar/';

function resetToolbarButtons()
{

	layerVis(document, 'zoomclickpane', 'hidden');
	layerVis(document, 'zoomoutclickpane', 'hidden');
	layerVis(document, 'pointclickpane', 'hidden');
	layerVis(document, 'addpointclickpane', 'hidden');
	layerVis(document, 'movepointclickpane', 'hidden');
	layerVis(document, 'delpointclickpane', 'hidden');
	layerVis(document, 'zoomdrawpane', 'hidden');
	layerVis(document, 'newpolygonpartclickpane', 'hidden');

	
	if( document.images.zoom_plus != null )
		document.images.zoom_plus.src = zoom_plus;

	if( document.images.z != null )
		document.images.z.src = zoom_minus;

	if( document.images.neutral_button != null )
		document.images.neutral_button.src = neutral_but;

	if( document.images.new_point != null )
		document.images.new_point.src = new_point;

	if( document.images.move_point != null )
		document.images.move_point.src = move_point;

	if( document.images.delete_point != null )
		document.images.delete_point.src = delete_point;

	if( document.images.draw_zoom_plus != null )
	{
		document.images.draw_zoom_plus.src = drawzoom_plus;
		if( restoreZoomDrawPane != null )
			restoreZoomDrawPane();
		
	}	

	if( document.images.enhance_point != null )
		document.images.enhance_point.src = enhance_point;
		
	if( document.images.new_polygon_part != null )
		document.images.new_polygon_part.src = new_polygon_part;
		
	if( document.images.planer_add != null )
		document.images.planer_add.src = planer_add;

	if( document.images.planer_delete != null )
		document.images.planer_delete.src = planer_delete;
		
		
}


function tt_ButtonZoomInClicked() 
{

	if( ToolbarButtonsLocked() )
		return;
		
	resetToolbarButtons();

	var zoom_plus_active = '/tourtorial/grafiken/toolbar/zoom_in_aktiv_02.gif';

	document.body.style.cursor="default";


	
	document.body.style.cursor="pointer";	
	layerVis(document, 'zoomclickpane', 'visible');
	
	window.document.images.zoom_plus.src = zoom_plus_active;
	setActiveButton( 1 );
	
}


function tt_ButtonZoomOutClicked() 
{

	if( ToolbarButtonsLocked() )
		return;
		
	var zoom_minus_active = '/tourtorial/grafiken/toolbar/zoom_out_aktiv.gif';

	resetToolbarButtons();


	thisstatus_es = document.forms.thisstatus.elements;

	if (thisstatus_es.zoomlevel_weaker.value == '00') 
		return;


	document.body.style.cursor="pointer";	
	layerVis(document, 'zoomoutclickpane', 'visible');

	window.document.images.z.src = zoom_minus_active;
	setActiveButton( 2 );


}


function tt_ButtonNeutralClicked() 
{

	if( ToolbarButtonsLocked() )
		return;
		
	resetToolbarButtons();
	
	var neutral_active = '/tourtorial/grafiken/toolbar/pfeil_aktiv_02.gif'
	
	
	document.body.style.cursor="default";
	
	
	document.body.style.cursor="help";	
	layerVis(document, 'pointclickpane', 'visible');
	
	document.images.neutral_button.src = neutral_active;
	setActiveButton( 3 );
	
}


