
function getMap()
{
	if (navigator.appName == "Netscape")
		return parent.mapframe.document.map;
	else
		return parent.MyMapFrame.MyMap;
}



function gotoLocation(index)
{
	var map = getMap();
   	
   	if (index == 1)
        map.zoomScale(498116.226816,298703.746769, 11000);

   	if (index == 2)
        map.zoomScale(500199.611843,296281.862935, 12000);
		
	if (index == 3)
        map.zoomScale(500995.902447,302576.940577, 20000);	
		
	if (index == 4)
        map.zoomScale(502738.732992,299984.462469, 55400);		
        
        if (index == 5)
        map.zoomScale(487732.556350,273668.543575, 30000);
        
}

function help(lang)
{	
    window.open('help_'+lang+'.pdf')
}

function layersView_on_off()
{
   var lvWidth = getMap().LayersViewWidth;
   if(lvWidth == 220)
   	getMap().LayersViewWidth = 0;
   else
   {
   	getMap().LayersViewWidth = 220;
   }
}

function FindArea()
{
    // Digitize polyline
    if (navigator.appName == "Netscape")
      getMap().digitizePolygonEx(parent.MyMapFrame.document.obs);
    else
      getMap().digitizePolygon();
}

function polygonSel()
{
   var MyMap = parent.MyMapFrame.document.MyMap;
   var MapScale = MyMap.getScale();
   {
	   parent.MyMapFrame.document.MyMap.selectPolygonMode();
   }
}

function radiusSel()
{
   var MyMap = parent.MyMapFrame.document.MyMap;
   var MapScale = MyMap.getScale();
   {
	   top.MyMapFrame.document.MyMap.selectRadiusMode();
   }
}

function withinSel()
{
   var MyMap = parent.MyMapFrame.document.MyMap;
   var MapScale = MyMap.getScale();
   {
   	parent.MyMapFrame.document.MyMap.selectWithinDlg();
   }
}

function clearSelection()
{
   var MyMap = parent.MyMapFrame.document.MyMap;
   var MyMapSel = MyMap.getSelection();
   MyMapSel.clear();
}

function waterpipes_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);

	map.getMapLayerGroup("FRAVEITA").setVisibility(false);
	map.getMapLayerGroup("VATNSVEITA").setVisibility(true);
	map.getMapLayerGroup("RAFVEITA").setVisibility(false);
	map.getMapLayer("Lokar").setVisibility(true);
	map.getMapLayer("Brunahanar").setVisibility(true);
	map.getMapLayer("Geymir").setVisibility(true);
	map.getMapLayer("Vatnslagnir").setVisibility(true);
	
	map.setAutoRefresh(true);
	map.refresh();
}

function sewerpipes_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);
	
	map.getMapLayerGroup("FRAVEITA").setVisibility(true);
	map.getMapLayerGroup("VATNSVEITA").setVisibility(false);
	map.getMapLayerGroup("RAFVEITA").setVisibility(false);
	map.getMapLayer("Brunnar").setVisibility(true);
	map.getMapLayer("Nidurfoll").setVisibility(true);
	map.getMapLayer("Fraveita").setVisibility(true);
	
	map.setAutoRefresh(true);
	map.refresh();
 }

function warmwaterpipes_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);

	map.getMapLayerGroup("FRAVEITA").setVisibility(false);
	map.getMapLayerGroup("VATNSVEITA").setVisibility(false);
	map.getMapLayerGroup("RAFVEITA").setVisibility(false);

	map.setAutoRefresh(true);
	map.refresh();
 }
 
 function electricity_layer()
 {
 	var map = getMap();
 	map.setAutoRefresh(false);
 
 	map.getMapLayerGroup("FRAVEITA").setVisibility(false);
	map.getMapLayerGroup("VATNSVEITA").setVisibility(false);
 	map.getMapLayerGroup("RAFVEITA").setVisibility(true);
  	map.getMapLayer("Lightposts").setVisibility(true);
  	map.getMapLayer("Distribution_Box").setVisibility(true);
 	map.getMapLayer("Transformers").setVisibility(true);
	map.getMapLayer("ELECTRICITYLINE").setVisibility(true);
	
 	map.setAutoRefresh(true);
 	map.refresh();
 }

 function telephone_layer()
 {
 	var map = getMap();
 	map.setAutoRefresh(false);
 
 	map.getMapLayerGroup("SIMAVEITA").setVisibility(true);
 	map.getMapLayerGroup("RAFVEITA").setVisibility(false);
 	map.getMapLayer("Simalagnir").setVisibility(true);
	map.getMapLayer("Simap").setVisibility(true);
 	map.getMapLayerGroup("FRAVEITA").setVisibility(false);
	map.getMapLayerGroup("VATNSVEITA").setVisibility(false);
 
 	map.setAutoRefresh(true);
 	map.refresh();
 } 
 
function mainplan_on_off()
{
	var map = getMap();
	var layer = map.getMapLayerGroup("ADALSKIPULAG");
	if (layer == null)
		alert ("Ašalskipulag layer not found");
	else
	{
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	map.refresh();
}

function highfly_on_off(which_fly)
{
	var map = getMap();
	var layergroup = map.getMapLayerGroup("LOFTMYNDIR");
	if (layergroup == null)
		alert ("Loftmyndir layer not found");
	else
	{
		var layer = map.getMapLayer(which_fly)
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	map.refresh();
}

function sveitafj_on_off(which_fly)
{
	var map = getMap();
	var layergroup = map.getMapLayerGroup("STADIR");
	if (layergroup == null)
		alert ("Stadir layer not found");
	else
	{
		var layer = map.getMapLayer(which_fly)
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	map.refresh();
}

function localplan_on_off()
{
	var map = getMap();
	var layer = map.getMapLayerGroup("DEILISKIPULAG");
	if (layer == null)
		alert ("Deiliskipulag layer not found");
	else
	{
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	map.refresh();
}

function streets_info_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);
		
	map.getMapLayerGroup("VEGMANNVIRKI").setVisibility(true);
	map.getMapLayerGroup("SLITLOG").setVisibility(false);
	map.getMapLayer("Gotur - Grunnframkv").setVisibility(false);
	
	map.setAutoRefresh(true);
	map.refresh();
}

function streets_construction_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);
	
	map.getMapLayer("Gotur - Grunnframkv").setVisibility(true);
	map.getMapLayerGroup("SLITLOG").setVisibility(false);
	
	map.setAutoRefresh(true);
	map.refresh();
}

function streets_paving_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);
	
	map.getMapLayerGroup("VEGMANNVIRKI").setVisibility(true);
	map.getMapLayerGroup("SLITLOG").setVisibility(true);
	map.getMapLayer("Gotur - Grunnframkv").setVisibility(false);
	
	map.setAutoRefresh(true);
	map.refresh();
}

function streets_paving_layerToggle(layerName)
{
	var map = getMap();
	map.setAutoRefresh(false);
	
	var layer = map.getMapLayer(layerName)
	var isLayerOn = layer.getVisibility();
	if (isLayerOn == true)
		layer.setVisibility(false); 
	else
	{
		layer.setVisibility(true);
	}
	
	map.setAutoRefresh(true);
	map.refresh();
}

function service_on_off(which_service)
{
	var map = getMap();
	var layergroup = map.getMapLayerGroup("THJONUSTA");
	if (layergroup == null)
		alert ("THJONUSTA layer not found");
	else
	{
		var layer = map.getMapLayer(which_service)
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	map.refresh();
}

function service_on_off1(which_service )
{
	var map = getMap();
	var layergroup = map.getMapLayerGroup("THJONUSTA");
	if (layergroup == null)
		alert ("THJONUSTA layer not found");
	else
	{
		var layer = map.getMapLayer(which_service )
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	map.refresh();
}


function service_and_path_on_off(path, service)
{
	var map = getMap();
	map.setAutoRefresh(false);
	var layergroup = map.getMapLayer("Vegir");
	if (layergroup == null)
		alert ("Vegir layer not found");
	else
	{
		var layer = map.getMapLayer(path)
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	
	var layergroup = map.getMapLayerGroup("THJONUSTA");
	if (layergroup == null)
		alert ("THJONUSTA layer not found");
	else
	{
		var layer = map.getMapLayer(service)
		var isLayerOn = layer.getVisibility();
		if (isLayerOn == true)
			layer.setVisibility(false); 
		else
		{
			layer.setVisibility(true);
		}
	}
	

	map.setAutoRefresh(true);	
	map.refresh();
}

function area_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);
		
	map.getMapLayerGroup("VEGMANNVIRKI").setVisibility(true);
	map.getMapLayerGroup("SLITLOG").setVisibility(false);
	map.getMapLayer("Gotur - Grunnframkv").setVisibility(false);
		
	map.setAutoRefresh(true);
	map.refresh();
}

function service_layer()
{
	var map = getMap();
	map.setAutoRefresh(false);
		
	map.getMapLayerGroup("VATNSVEITA").setVisibility(true);
	map.getMapLayerGroup("FRAVEITA").setVisibility(true);
	map.getMapLayer("Lokar og brunahanar").setVisibility(false);
	map.getMapLayer("Vatnslagnir").setVisibility(false);
	map.getMapLayer("Brunnar").setVisibility(false);
	map.getMapLayer("Nidurfoll").setVisibility(false);
	map.getMapLayer("Fraveita").setVisibility(false);
		
	map.setAutoRefresh(true);
	map.refresh();
}