// JavaScript Document
// tools.js
// Toolbar-Funktionen

/*var toolName = new Array('Zoom In', //1
						'Zoom Out', //2
						'Pan');		//3
var toolDetail = new Array('Vergrößern des angezeigten Kartenausschnitts', 	//1
						'Verkleinern des angezeigten Kartenausschnitts', 	//2
						'Verschieben des angezeigten Kartenausschnitts');	//3
*/

function addMaptools() {
	var content = "<table class='tools'>";
	content += "<tr>";
	/* alternativ Button beinhaltet Schrift
	if (useZOOMIN) {	
		content += "<td>";		
		content += "<button name='ZOOMIN2' type='button' class='toolbutton' alt='Herauszoomen' onMousedown='parent.UPGMainF.clickMaptool(\"ZOOMOUT\",true);'>";
		content += "<img src='images/mActionZoomIn.png' height='22'>";
		content += "Hineinzoomen</button>";
		content += "</td>";		
	}*/
	if (useZOOMIN) {
		content += "<td>";
		content += "<img id='ZOOMIN' src='images/mActionZoomIn.png' height='22' class='toolbutton' title='Vergrößern' onmousedown='parent.UPGMainF.clickMaptool(\"ZOOMIN\",true);'>";
		//content += "</td><td class='tool'>";		
		//content += "Vergrößern";
		content += "</td>";
	}
	if (useZOOMOUT) {
		content += "<td>";	
		content += "<img id='ZOOMOUT' src='images/mActionZoomOut.png' height='22' class='toolbutton' title='Verkleinern' onmousedown='parent.UPGMainF.clickMaptool(\"ZOOMOUT\",true);'>";
		//content += "</td><td class='tool'>";
		//content += "Verkleinern";
		content += "</td>";
	}	
	if (useZOOMFULL) {
		content += "<td>";	
		content += "<img id='ZOOMOUT' src='images/mActionZoomFullExtent.png' height='22' class='toolbutton' title='Auf Gesamtansicht zoomen' onmousedown='parent.UPGMainF.clickMaptool(\"ZOOMFULL\",false);'>";
		//content += "</td><td class='tool'>";
		//content += "Auf alles zoomen";
		content += "</td>";
	}		
	if (usePAN) {
		content += "<td>";
		content += "<img id='PAN' src='images/mActionPan.png' height='22' class='toolbutton' title='Verschieben' onmousedown='parent.UPGMainF.clickMaptool(\"PAN\",true);'>";		
		//content += "</td><td class='tool'>";		
		//content += "Verschieben";
		content += "</td>";
	}
	if (useIDENTIFY) {
		content += "<td>";	
		content += "<img id='IDENTIFY' src='images/mActionIdentify.png' height='22' class='toolbutton' title='Info' onmousedown='parent.UPGMainF.clickMaptool(\"IDENTIFY\",true);'>";		
		//content += "</td><td class='tool'>";
		//content += "Info";
		content += "</td>";
	}
	if (useMEASURE) {
		content += "<td>";	
		content += "<img id='MEASURELIN' src='images/mActionMeasure.png' height='22' class='toolbutton' title='Strecke messen' onmousedown='parent.UPGMainF.clickMaptool(\"MEASURELIN\",true);'>";		
		//content += "</td><td class='tool'>";
		//content += "Strecke messen";
		content += "</td>";
	}	
	if (usePRINT) {
		content += "<td>";	
		content += "<img id='PRINT' src='images/mActionFilePrint.png' height='22' class='toolbutton' title='Drucken' onmousedown='parent.UPGMainF.clickMaptool(\"PRINT\", false);'>";		
		//content += "</td><td class='tool'>";
		//content += "Drucken";
		content += "</td>";
	}
	if ((useTOGGLEREF)||(useTOGGLELEG)) {
		content += "<td>";
		content += "<img src='images/separator.png' height='22'>";
		content += "</td>";
	}
	//toggle-buttons
	if (useTOGGLEREF) {
		content += "<td>";	
		content += "<img id='TOGGLEREF' src='images/mActionToggleOverview.png' height='22' class='togglebutton' title='Übersichtskarte ein-/ausblenden' onmousedown='toggleVisibility(\"boxReference\");'>";
		//content += "</td><td class='tool'>";
		//content += "Drucken";
		content += "</td>";
	}
	if (useTOGGLELEG) {
		content += "<td>";	
		content += "<img id='TOGGLELEG' src='images/mActionToggleLegend.png' height='22' class='togglebutton' title='Zeichenerklärung ein-/ausblenden' onmousedown='toggleVisibility(\"boxLegend\");'>";		
		//content += "</td><td class='tool'>";
		//content += "Drucken";
		content += "</td>";
	}
	if ((useHELP)||(useIMPRINT)) {
		content += "<td>";
		content += "<img src='images/separator.png' height='22' ondblclick='toggleDebug();'>";
		content += "</td>";
	}
	if (useHELP) {
		content += "<td>";	
		content += "<img id='HELP' src='images/mActionHelp.png' height='22' class='toolbutton' title='Hilfe / Benutzerhandbuch' onmousedown='showHelp();'>";		
		//content += "</td><td class='tool'>";
		//content += "Hilfe";
		content += "</td>";
	}	
	if (useIMPRINT) {
		content += "<td>";	
		content += "<img id='IMPRESSUM' src='images/mActionImprint.png' height='22' class='toolbutton' title='Impressum' onmousedown='showImprint();'>";		
		//content += "</td><td class='tool'>";
		//content += "Hilfe";
		content += "</td>";
	}	
	content += "</tr>";	
	content += "</table>";
	document.writeln(content);
	//setIcon(maptoolMode, true);
}

function setIcon(theTool,active) {
	if (active) {
    	parent.UPGMainF.document.getElementById(theTool).style.borderColor="#BB6688";	
    	parent.UPGMainF.document.getElementById(theTool).style.borderWidth="2px";
    	parent.UPGMainF.document.getElementById(theTool).style.margin="0px";		    	    	
    } else {
		parent.UPGMainF.document.getElementById(theTool).style.borderColor="#AABBDD";
    	parent.UPGMainF.document.getElementById(theTool).style.borderWidth="1px";		
    	parent.UPGMainF.document.getElementById(theTool).style.margin="1px";		    	
	}
}

function clickMaptool(clickedTool, isModeTool) {
	if (isModeTool) {
		setIcon(maptoolMode, false);
		if (maptoolMode=='MEASURELIN') {
			stopPlineTool();
		} else if (maptoolMode=='PAN') {
			disableDragMap();
		}		
		maptoolMode = clickedTool;
		setIcon(maptoolMode, true);
		parent.window.document.status=clickedTool;
	}
	switch(clickedTool) {
	//zoom in
	case 'ZOOMIN':
		setCursor('crosshair');
		break;
	//zoom out
	case 'ZOOMOUT':
		setCursor('crosshair');
		break;
	//zoom out
	case 'ZOOMFULL':
		//setCursor('crosshair');
		ms_zoomToExtent(themeMinX, themeMinY, themeMaxX, themeMaxY)
		break;		
	//pan		
	case 'PAN':
		setCursor('move');
		startDragMap();
		break;
	//Info/Ganglinie		
	case 'IDENTIFY':
		setCursor('pointer');
		break;
	//Linienmessung		
	case 'MEASURELIN':
		setCursor('crosshair');
		break;		
	//Drucken		
	case 'PRINT':
		setIcon(clickedTool, true);	
		openPrintForm();		
		setIcon(clickedTool, false);			
		break;		
	default:
		alert('kein gültiges Map-Tool');
	};
}

// Öffnen des Drucken-Dialogs
function openPrintForm() {
	var url = "print.htm";
	var pWin = window.open( url,"printWin","width=650,height=280,menubar=no,resizable=no,status=no,toolbar=0");
	pWin.focus();
}


