function si(q,y)
{
	q.src=y;
}

var u = null;
var ux = null
var _z = false;
var _zx = false;
function ed(a,b)
{
	
	if (u!=null)
	{
		Element.hide(u);
		Element.removeClassName(ux, 'lchecked');
	}
	ux = $(b);
	u = $(a);
	Element.show(u);
	Element.addClassName(ux, 'lchecked');
}

		function legenda()
		{
			window.open('/legenda.php','legenda','width=450px,height=690px,scrollbars=1');
			return false;
		}
function mail(naam,tld,subject)
{
	location.href = "mailto:"+naam+"@"+tld+"?subject="+subject;
}	

function login()
{
	if ($('gebruiker').value.length == 0)
	return;
	if ($('ww').value.length == 0)
	return;	
		var pars = "gebruiker="+$('gebruiker').value+"&ww="+$('ww').value;
		
		var myAjax = new Ajax.Request(
			'index.php?p=leden', 
			{
				method: 'post', 
				parameters: pars, 
				onComplete: function(resp) { if (resp.responseText=="OK") { top.location.href='?p=leden'; } else { alert(resp.responseText); }; }
			});			
	
}
var myAjax = null;
function stopLoad()
{
	
	myAjax.transport.abort();
	myAjax = null;
	stn.om.Clear();
}
function wwvergeten()
{
	if ($('em').value.length == 0)
	{
		return;
	}
		var pars = Form.serialize('wvf')+"&wwv=1";
		
		var myAjax = new Ajax.Request(
			'index.php?p=leden', 
			{
				method: 'post', 
				parameters: pars, 
				onComplete: function(resp) { if (resp.responseText=="OK") { alert('Er is een email verzonden met nieuwe logingegevens naar het opgegeven email adres'); Element.hide($('wvd')); } else { alert(resp.responseText); }; }
			});		
	
}
var popOut = null;
function popOutInfoDiv()
{
	var w = 1024;
	var h = 768;
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 550
	var popH = 500;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	
			
		

	popOut=window.open('','popOut','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
	var tmp = popOut.document;
	tmp.write('<html><head><title>Stichting Trekkershutten Nederland</title>');
	tmp.write('<link rel="stylesheet" href="styles.css">');
	tmp.write('</head><body><div class=\'\' id=\'infoDiv\'  name=\'infoDiv\' style="padding:0px; margin:0px;"');
	tmp.write(document.getElementById('infoDiv').innerHTML+'</div>');
	tmp.write('</body></html>');
	tmp.close();
	document.getElementById('infoDiv').style.display='none';	

}
var evOut = null;
function popEvenement(eid)
{
	var w = 1024;
	var h = 768;
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 400
	var popH = 290;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		
	evOut=window.open('/evenement.php?h='+eid,'evOut','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
}

var reOut = null;
function popReservering(eid)
{
	var w = 1024;
	var h = 768;
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 600
	var popH = 750;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		
	reOut=window.open('/reserveer.php?i='+eid,'reOut','scrollbars=yes, width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
}

var hutOut = null;
function hutInfo(hut)
{
	var w = 1024;
	var h = 768;
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 400
	var popH = 170;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;	
	hutOut=window.open('/hut.php?h='+hut,'hutOut','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
}
		function get_keycode(ev)
		{
		    if (ev.keyCode)
		    {
		        return ev.keyCode;
		    }
		    else
		    {
		        return ev.which;
		    }
		}
		
		function blockchar(wat,ev,code)
		{
			if (!ev) ev = window.event;
			var keyCode = get_keycode(ev)
		
			if (keyCode==code)
			return false;
			
			if (keyCode==8)
			return true;
			
			var wat = String.fromCharCode(keyCode);
			
			if (code=="getalstrict")
			code = /([0-9])/;	
			
			if (code=="getal")
			code = /([0-9\.\,\-])/;
			if (!code.test(wat))
			return false;	
			
			return true;	
		}		
function popLidInfo(content)
{
	
	var w = 1024;
	var h = 768;
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 300
	var popH = 150;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;				
		

	gOut=window.open('','gOut','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
	
	var tmp = gOut.document;
	tmp.write('<html><head><title>Locatie informatie</title>');
	tmp.write('<link rel="stylesheet" href="styles.css">');
	tmp.write('</head><body style=\'padding:4px;\'><div class=\'cDiv\' id=\'infoDiv\'  name=\'infoDiv\' style="padding:0px; margin:0px;">');
	tmp.write(content+'</div>');
	tmp.write('</body></html>');
	tmp.close();
	

}

function showInfoDiv(lid)
{
//	_tooltip.style.visibility="hidden"
	if (myAjax!=null)
	{
		stopLoad();
	}
  // om = new OverlayMessage(document.getElementById('map'));      
  stn.om.Set("<font style='font-size:12px;'>...<br/><br/><img align=absmiddle src='images/indicator_big.gif'/><br/><br/><a class='rood' href='#' onClick=\"stopLoad();\">Stop</a></font>");
	urchinTracker("/lidinfo/"+lid); 	
	var pars = "lid="+lid;
	myAjax = new Ajax.Request(
			"/index.php?p=zoek", 
			{
				method: 'post', 
				parameters: pars, 
				onComplete: verwerkInfo
			});

}
function verwerkInfo(resp)
{
	if (resp.responseText.length == 0)
		return;
	
	if (resp.responseText == "ERR")
	{
		stopLoad();
		alert('Fout bij het ophalen van locatie gegevens!');
		return;
	}
	if (popOut!=null)
	if (popOut.closed)
		popOut = null;
	
	if (popOut!=null)
	{
		popOut.document.getElementById('infoDiv').innerHTML = resp.responseText;
		if (window.focus) 
			popOut.focus();

	} else {
		document.getElementById('infoDiv').innerHTML = resp.responseText;
		document.getElementById('infoDiv').style.display='';	
	}
	myAjax = null;
	stn.om.Clear();	
	
}
function toggleBezet(wat,datum)
{
	if (wat.className.indexOf("bezOver") == -1)
	{	
		wat.className = 'bezOver';
		wat.title='Geen trekkershutten vrij';
	} else {
		wat.className = '';
		wat.title='';
	}
	
		var pars = "setBezet="+datum;
		
		var myAjax = new Ajax.Request(
			'index.php?p=leden', 
			{
				method: 'post', 
				parameters: pars, 
				onComplete: function(resp) { if (resp.responseText=="OK") {  } else { alert(resp.responseText); }; }
			});				
	
}
function bezetOver(wat)
{
	if (wat.className.indexOf("bezOver") != -1)
		return;	
		
	if (wat.className.indexOf("bezet") == -1)
	{
		wat.className = 'bezet';
		
	}
}
function bezetOut(wat)
{
	if (wat.className.indexOf("bezOver") != -1)
		return;
	
	if (wat.className.indexOf("bezet") != -1)
	{
			wat.className = '';
	}	
}

function nextMaand(wan)
{
	getCalendar(wan);
}
function prevMaand(wan)
{
	getCalendar(wan);
}

function getCalendar(wan)
{
	var pars = "getBezet="+wan;
	var myAjax = new Ajax.Updater(
			'calender', 
			'index.php?p=leden', 
			{
				method: 'post', 
				parameters: pars
			});
	
}

function getCalendar2(wan,lid)
{
	var pars = "getCal="+wan+"&lid="+lid;
	var myAjax = new Ajax.Updater(
			'cale', 
			'/index.php?p=zoek', 
			{
				method: 'post', 
				parameters: pars
			});
	
}

function saveEvenement(wan)
{
		var pars = "setEvenement="+$('evenement').value+"&datum="+wan;
		
		var myAjax = new Ajax.Request(
			'index.php?p=leden', 
			{
				method: 'post', 
				parameters: pars, 
				onComplete: function(resp) { if (resp.responseText=="OK") { alert("Evenement(en) opgeslagen"); } else { alert(resp.responseText); }; }
			});		
	
}

function meerInfo(lid)
{

//	document.getElementById('calDiv').style.display='';
	document.getElementById('infoDiv').style.display='';
	
}


var cs = "land";
var csl = "landl";
function switchCtrl(naar,wat)
{
	if (cs == "zoeken" && naar != "zoeken")
		Element.hide($('zoekDiv'));
	if (naar == "zoeken")
	{
		if (_z)
			Element.show($('zoekDiv'));
		if ($('infoDiv').style.display=='')
			Element.hide($('infoDiv'));
	}
	Element.hide($(cs));
	Element.removeClassName($(csl), 'activeTab');
	csl = wat;
	cs = naar;
	Element.addClassName($(wat), 'activeTab');
	Element.show($(naar));
	urchinTracker("/Zoek_een_hut.html/"+naar); 	
	
}



function zoek()
{
	var zt = $('zoekTekst').value;
	if (zt.length==0)
	{
		return;
	}
	$('zoekRes').innerHTML = "<div align=center style='margin-top:200px;'><img src='/images/indicator_big.gif' ><br/>...</div>";
	Element.show($('zoekDiv'));
	_z = true;
	
		pars = "zoek="+escape(zt);
		urchinTracker("/Zoek_een_hut.html/zoek/"+escape(zt)); 
		var myAjax = new Ajax.Updater(
			'zoekRes', 
			"?p=zoek", 
			{
				method: 'post', 
				parameters: pars
			});	
	
	
}

function getUitgebreid()
{
	if (_zx)
	{
		
		Element.show($('zoekDiv'));
		return;
	}
	// zoekUitgebreid
	$('zoekRes').innerHTML = "<div align=center style='margin-top:200px;'><img src='/images/indicator_big.gif' ></div>";
	Element.show($('zoekDiv'));
	_z = true;
	_zx = true;
		var pars = "zoekUitgebreid=1";
		urchinTracker("/Zoek_een_hut.html/uitgebreidzoeken/"); 
		var myAjax = new Ajax.Updater(
			'zoekRes', 
			"?p=zoek", 
			{
				method: 'post', 
				parameters: pars
			});		
}
function zoekUitgebreid()
{
	
	_z = true;
		var pars = Form.serialize($('zform'));
		if (pars == "0")
			return;
		pars += "&zoekUit=1";
		$('zoekRes').innerHTML = "<div align=center style='margin-top:200px;'><img src='/images/indicator_big.gif' ><br/>...</div>";
		var myAjax = new Ajax.Updater(
			'zoekRes', 
			"?p=zoek", 
			{
				method: 'post', 
				parameters: pars
			});		
}
var zoekX=null;
function hideZoek()
{
	if (zoekX!=null)
	{
		zoekX[0].clearMarkers();
	}
}


function zoekKaart()
{
//	var zt = $('zoekTekst').value;
//	if (zt.length==0)
//	{
		//return;
	//}	
	
		
		stn.downloadUrl("hutten.php?uzoek=1&a="+Math.random(), function(xml, responseCode) {
		
		zoekX[0].clearMarkers();
			
       for (x=1;x<=4;x++)
       {
       	if (stn.landen[x])
       	{
       		stn.hideLand(x);
       	}
       }			
			

			
		 
		  var hutten = xml.getElementsByTagName("hut");
		  
		  for (var i = 0; i < hutten.length; i++) { 
			var l = parseInt(hutten[i].getAttribute("l"));
		    switch (l)
		    {
		    	case 1:
					  		zoekX[1].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.small.NL,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[2].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.med.NL,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[3].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.big.NL,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
		    		break;
		    	case 2:
					  		zoekX[1].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.small.BE,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[2].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.med.BE,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[3].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.big.BE,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
		    		break;
		    	case 3:
					  		zoekX[1].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.small.NL,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[2].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.med.NL,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[3].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.big.NL,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
		    		break;
		    	case 4:
					  		zoekX[1].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.small.LU,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[2].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.med.LU,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
					  		zoekX[3].push(stn.createMarker(new google.maps.LatLng(parseFloat(hutten[i].getAttribute("lat")), parseFloat(hutten[i].getAttribute("lng"))), stn.icons.big.LU,hutten[i].getAttribute("b"),hutten[i].getAttribute("i")));
		    		break;    		    		    		
		    }

		  }
		  
		       
		 // google.maps.event.addListener(zoekX[0], 'loaded', function(){
		       

      	
       

       
	       zoekX[0].addMarkers(zoekX[1],6,8);
	       zoekX[0].addMarkers(zoekX[2],9,14);
	       zoekX[0].addMarkers(zoekX[3],15,18);
	       // zoekX[0].refresh();        
	       zoekX[0].show();
	       
       
       Element.hide($('zoekDiv'));
		        
		});			
	
}
/*
function test()
{
	downloadRoute('test.xml');
	
}
function LoadGPXFileIntoGoogleMap(filename)
{
 		om.Set("<font style='font-size:12px;'><?=getVal('map_draw_route')?><br/><br/><img align=absmiddle src='/images/indicator_big.gif'/><br/><br/></font>");
		if (fietsroutes[filename])
		{
			fietsroutes[filename].AddTrackpointsToMap();
			
			om.Clear();	
		} else { 
			window.setTimeout('downloadRoute(\''+filename+'\')',10);
		}
}
		
function downloadRoute(filename)
{

		GDownloadUrl(filename, function(data, responseCode) {
					
				  var xml = GXml.parse(data);
							parser = new GPXParser(xml, map);
							parser.SetTrackColour("#0000ff");					     // Set the track line colour
							parser.SetTrackWidth(5);							     // Set the track line width
							parser.SetMinTrackPointDelta(0.001);				     // Set the minimum distance between track points
						// parser.CenterAndZoom(xml, G_SATELLITE_MAP); // Center and Zoom the map over all the points.
							
							fietsroutes[filename] = parser;
							
							parser.AddTrackpointsToMap();						     // Add the trackpoints				
		 // parser.AddWaypointsToMap();						         // Add the waypoints
							 om.Clear();			
				});
}
*/