
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'')
}

function newwindow(url)
{
  window.open(url,1,"resizable=yes, scrollbars=yes, location=no,top=5,left=5,width=800,height=800")
}


function getMap()
{
	if (navigator.appName == "Netscape")
        	return top.mainframe1.document.map;
	else
        	return top.mainframe1.map;
}

function clearselection()
{
	var map = getMap();
	map.getSelection().clear();
}

function zoomall()
{
	var map = getMap();
    if (map.isBusy())
	{
		map.Stop();
		map.Refresh();
	}else
	map.zoomOut();
}

function zoomin()
{
	var map = getMap();
    if (map.isBusy())
	{
	map.Stop();
	map.Refresh();
	}
    else
	map.zoomInMode();
}

function zoomout()
{
	var map = getMap();
    if (map.isBusy())
	{
	map.Stop();
	map.Refresh();
	}
    else
	map.zoomOutMode();
}

function zoompre()
{
	var map = getMap();
	map.zoomPrevious();
}

function ZoomScale()
{
    var map = getMap();
    map.zoomScaleDlg();
}


function meten()
{
	var map = getMap();
	map.viewDistance("m");
}

function zoomcoor()
{
	window.open("zoomcoor.html", "nieuw", "top=200,left=200,width=160,height=170");
}

function colofon()
{
	window.open("colofon.html", "nieuw4", "top=100,left=100,width=450,height=200");
}

function nota()
{
	window.open("colofon.html", "nieuw4", "top=200,left=200,width=31,height=210");
}

function voorschriften()
{
	window.open("voorschriften.html", "nieuw4", "width=700,height=500,scrollbars=yes,toolbar=yes,resizable=yes");
}

function zoomsel()
{
	var map = getMap();
	map.zoomSelected();
}

function zoompre()
{
	var map = getMap();
	map.zoomPrevious();
}



function verschuiven()
{
	var map = getMap();
	map.panMode();
}

function select()
{
	var map = getMap();
	map.setSelectionMode("Intersection");
    if (map.isBusy())
	{
	map.Stop();
	map.Refresh();
	}
    else
	map.selectMode();
}

function stop()
{
	var map = getMap();
 	map.Stop();
}


function printmap()
{
	clearselection()
	var map = getMap();
	alert("U kunt de kaart printen nadat u de paginaopmaak heeft bevestigd.");
	var pgsetup = map.pageSetupDlg();
    if (map.isBusy())
	{
	map.Stop();
	map.Refresh();
	}
    else
	map.printDlg();
}

function rapportwindow()
{
	var map = getMap();
	var sel = map.getSelection();
	if (sel.getNumObjects() < 1)
	{
		alert("Selecteer eerst een kilometerhok !");
		map.selectMode();
	}

	if (sel.getNumObjects() >= 1)
	{
		var objs = sel.getMapObjectsEx(null);
		var cntObjects = objs.size();
		var msg = "";
		var i;
		for (i = 0; i < cntObjects; i++)
		{
			var obj = objs.item(i);
			var key = obj.getKey();
			msg = msg + key +",";
		}
	rapporttxt="rapport/screening.asp?OBJ_KEYS="
	thewindow=window.open(rapporttxt+msg,"rapport","width=750,height=650,resizable=yes,scrollbars=yes")
	}
}

function MyFunction()
{
	var MyMap = getMap();
	if (MyMap.isBusy())
	setTimeout("MyFunction()", 100000);  
}


function zoom_street(straatnaam2)
{
	var map = getMap();
    if (map.isBusy())
	{
		map.Stop();
		map.Refresh();
	}else 
	{
		map.zoomGotoLocation("straatnaam", straatnaam2, 2000);
	}
}


function zoomgebouwen(waardeCombo)
{
	var map = getMap();
	map.zoomGotoLocation('Gebouwen',waardeCombo,2500);
}

function zoomlocatie(waardeCombo)
{
	var map = getMap();
	map.zoomGotoLocation('Locatie',waardeCombo,2500);
}

function zoomBoom_punt(waardeCombo)
{
	var map = getMap();
	map.zoomGotoLocation('Boom_punt',waardeCombo,2500);
}

function zoomadres2(waardeCombo)
{
	// var map = getMap();
	// map.zoomGotoLocation('Adres',waardeCombo,1500);
	var map = getMap();
    if (map.isBusy())
	{
		map.Stop();
		map.Refresh();
	}else 
	{
		map.zoomGotoLocation('Adres',waardeCombo,1500);
	}
}


var Tijd;
function zoomadres(straatnaam)
{
	var map = getMap();
	zoomadres2(straatnaam);
 	Tijd = setInterval("iup();", 300);
}


var i=0;
function iup()
{
  i += 1;
  if (i > 10)
  {
     redlinelayerWillem();
     clearInterval(Tijd);
	 i = 0;
  }
}


function redlinelayerWillem()
{
	var map = getMap();
    map.createLayer('redline','redline');
   var code = map.getLastError().getCode();
	map.getMapLayer('redline').removeAllObjects();
	map.getMapLayer('redline').setPriority(0.1);
	map.getMapLayer('redline').setSelectability(false);
	var width = map.getWidth("M");
	var height = map.getHeight("M");
	var centerx = map.getLon()
	var centery = map.getLat()
	var tdnpointx = (centerx - (0.4905*width))
    var tdnpointy = (centery - (0.492*height))
	var tdnsetup = map.getRedlineSetup();
	tdnsetup.getFillAttr().setColor(71);
	tdnsetup.getFillAttr().setStyle("Diagonal45");
	tdnsetup.getLineAttr().setColor(71);
	var redlinelayer = map.getMapLayer('redline');
	var tdnobject = redlinelayer.createMapObject("","","");
	var tdnpoint = map.createObject("MGPoint");
	tdnpoint.setX(centerx);
	tdnpoint.setY(centery);
	tdnobject.addCirclePrimitive(tdnpoint,false,8,"m",2000);
}


function layerToggle(name)
{   
    var map = getMap();
    var layer = map.getMapLayer(name);
   
    if (layer == null)
        alert("layer not found.");    
    else
        layer.setVisibility(!layer.getVisibility());
        
    map.refresh();
} 

function groupToggle()
{	var map = getMap();
	var MapLayerGroup = map.getMapLayerGroup('Plattegrond');

	if(MapLayerGroup == null)
		alert("layergroup not found.");
	else
		MapLayerGroup.setVisibility(!MapLayerGroup.getVisibility());
		map.refresh();
}

function zoekgebouwen() 
{ 	
	window.open("gebouwen.asp", "nieuw", "width=400,height=100, left=210, top=320,scrollbars=no,toolbar=no,resizable=yes");
}

function zoeklocatie() 
{ 	
	window.open("locatie.asp", "nieuw", "width=400,height=100, left=210, top=320,scrollbars=no,toolbar=no,resizable=yes");
}

function zoekadres() 
{ 	
	window.open("adres.asp", "nieuw", "width=500,height=200, left=210, top=320,scrollbars=no,toolbar=no,resizable=yes");
}

function monumentenroute()
{
	window.open("monumenten.asp","nieuw", "width=200, height=200, left=202, top=305, scrollbars=no, toolbar=no, resizable=yes");
}

function disclaimer()
{
	window.open("disclaimer.html","nieuw", "width=1000, height=650, left=1, top=1, scrollbars=auto, toolbar=yes, resizable=yes");
}

function zoekboom() 
{ 	
	window.open("boom.asp", "nieuw", "width=500,height=200, left=210, top=320,scrollbars=no,toolbar=no,resizable=yes");
}

function closeFunc(){if(lw){lw.close();lw=null;}}

function plannennieuw()
{
	var map = getMap();
	
	var MapLayerGroup = map.getMapLayerGroup('Bestemmingsplannen_nieuw');
	if(MapLayerGroup == null)
	alert("layergroup not found.");
	else
	MapLayerGroup.setVisibility(!MapLayerGroup.getVisibility());

	map.refresh();  
}
