function si(q,y)
{
	q.src=y;
}

var u = null;
var ux = null
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;
	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'));      
  om.Set("<font style='font-size:12px;'>Bezig met ophalen locatie gegevens...<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;
	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='';
	
}