
Joms.RoutingControll.prototype.drawForm = function()
{
	this.formElCont.style.position = 'relative';
	// create routing tab
	var html = '';

	html += '<form id="'+this.id +'Form" class="routingCtrlForm">';
		html += '<div id="'+this.id +'DestList"></div>';
		html += '<div style="display: block;" class="routingCtrlDestinationControlls">';
			html += '<a href="#" id="'+this.id +'AddDest">I18N_ROUTING_ADD</a>'
			html += ', <a href="#" id="'+this.id +'ReverseDest">I18N_ROUTING_REVERSE</a>';
			html += ', <a href="#" id="'+this.id +'Reset">I18N_ROUTING_DELETE</a>';
		html += '</div>';

		html += '<div style="display: block;" class="routingCtrlCriteriumControlls">';
			html += '<select id="'+this.id +'Criterium" class="routingCtrlCriteriumSelect">';
			html += '</select>';
			html += '<br/>';
			html += '<input type="checkbox" value="1" id="'+this.id +'Param" class="routingCtrlCriteriumCheckBox" checked="1" /> <span id="'+this.id +'ParamText">využít placené úseky</span>';
			html += '<br/>';
			html += '<input id="'+this.id+'SearchButton" tabindex="999" class="routingCtrlSearchRouteButton" type="submit" value="I18N_ROUTING_SEARCH" />';

		html += '</div>';


	html += '</form>';
	this.formElCont.innerHTML = html;
};


// hook handlers

function jomsErrorHandler(type, id, objName, message) {
	if (JomsLocal) debug(type, id, objName, message);
}

function jomsMapChanged() {
	var sel = gid('mapSelect');
	if (sel == null) 
		return;
	
	var mapId = app.map.getCurrentMap();
	for (var i=0; i < sel.options.length; i++) {
		if (sel.options[i].value == mapId) {
			sel.selectedIndex = i;
			return;
		} 
	}
}

function showNetmapMapLink(baseUrl) {
	if (baseUrl) {
		var link = baseUrl;
		if (this.query && this.query.createUrlParams) {
			link += '?' + app.query.createUrlParams();
		}
		app.msg(link);
	} else {
		app.msg(app.createMapLink());
	}
}

function repairMapSize(size, fullscreen) 
{	
	var headerEl = gid('netmapHeader');
	var footerEl = gid('netmapFooter');
	var menuEl = gid('mapMenu');
	var pageEnvEl = gid('pageEnvelope');		
	
	var netmapAreaLeft = 20;
	var netmapAreaTop = 0;
	var netmapAreaRight = 20;
	var netmapAreaBottom = 30;
	var netmapMapWidthReduce = 30;
	
	if (!NG_mapborder) {
		netmapAreaLeft = 0;
		netmapAreaTop = 0;
		netmapAreaRight = 0;
		netmapAreaBottom = 3;
		netmapMapWidthReduce = 0;
		gid('interfaceEnvelope').style.padding = 0;
		gid('mapBorderElement').style.border = 0;
	}

	if (NG_fullscreen) {
		headerEl.style.display = "none";
		footerEl.style.display = "none";
		if (NG_InterfaceWidth > 0) {
			pageEnvEl.style.width = size.width + "px";
			pageEnvEl.style.margin = "0";
		}
		netmapAreaTop = 0;
	} else {
		headerEl.style.display = "block";
		headerEl.style.height = NG_HeaderHeight + "px";
		footerEl.style.display = "block";
		footerEl.style.height = NG_FooterHeight + "px";
		
		if (NG_InterfaceWidth > 0) {
			pageEnvEl.style.width = NG_InterfaceWidth + 'px';
			pageEnvEl.style.margin = "0 auto";  
		}
		netmapAreaTop = NG_HeaderHeight;
		netmapAreaBottom += NG_FooterHeight;
	}
	
	if (NG_MenuVisible) {
		netmapAreaTop += NG_MapMenuHeight;
		menuEl.style.display = "block";
	} else {
		netmapAreaTop -= 5;
		menuEl.style.display = "none";
	}
	
	var interfaceWidth = netmapAreaLeft + netmapAreaRight;
	var interfaceHeight = netmapAreaTop + netmapAreaBottom;  
	
	var mapHeight;
	var mapWidth;
	var pageHeight = size.height - (interfaceHeight);
	
	if (NG_InterfaceWidth > 0 && !NG_fullscreen) {
		mapWidth = NG_InterfaceWidth;
	} else {
		mapWidth = size.width;
	}
	
	if (NG_TabsVisible) {
		mapWidth = mapWidth - (NG_TabsWidth + 40);	
		gid('netmapTabContainer').style.display = "block";
	} else {
		mapWidth = mapWidth - netmapMapWidthReduce;
		gid('netmapTabContainer').style.display = "none";
	}
	
	var hpEl = gid('heightProfile');
	var hpElB = gid('heightProfileBorder');
	if (!NG_RouteProfileVisible) {
	 	mapHeight = size.height - interfaceHeight;
		hpElB.style.display = 'none';			
	} else {
		mapHeight = size.height - (interfaceHeight + 5 + NG_RouteProfileHeight); 
		hpEl.style.width = mapWidth + 'px';
		hpEl.style.height = NG_RouteProfileHeight + 'px';
		hpElB.style.display = 'block';
	}
	
	this.mapHeight = mapHeight;
	this.mapWidth = mapWidth;

	var peEl = gid('interfaceEnvelope');

	peEl.style.height = (size.height - interfaceHeight) + 35 + 'px';
	
	var tabEl = gid('netmapTabContainer');
	tabEl.style.height = (size.height - interfaceHeight) + 10 + 'px';
	 
}

function switchTabs()
{
	if (NG_TabsVisible) {
		tabs.hide();
	} else {
		tabs.show();
	}
	
	return false;
}

function switchFullscreen() 
{
	if (NG_fullscreen) {
		// show header
		NG_fullscreen = false;
		app.repairMapSize();
	} else {
		NG_fullscreen = true;
		app.repairMapSize();
	}
	
	return false;
}

function switchMeasurementTool()
{
	if (ctrlDistanceMeasurement.visible) {
		ctrlDistanceMeasurement.hide();
	} else {
		ctrlDistanceMeasurement.show();
	}
}

function switchGpsTool()
{
	if (ctrlGps.visible) {
		ctrlGps.hide();
	} else {
		ctrlGps.show();
	}
}

function mapSelectChange() {
	var sel = gid('mapSelect');
	var mapId = sel.options[sel.selectedIndex].value;
	if (mapId != '') {
		app.changeMap(mapId);
	}
}