function fixpix()
{
	if (document.getElementById('newsfp') && document.getElementById('newsfp').getElementsByTagName('img')[0])
	{
		var newspic = document.getElementById('newsfp').getElementsByTagName('img')[0];
		
		if (newspic.width  > 204 || !newspic.width)
		{
			newspic.width = '204';
		}
		newspic.style.visibility = 'visible';
	}
}

if (document.getElementById('bread').innerHTML.length < 10)
{
	var tijd_datum = new Date();
	var dagn = tijd_datum.getDay();
	var dag = tijd_datum.getDate(); 
	var maand = tijd_datum.getMonth();
	var jaar = tijd_datum.getFullYear();
	var uur = tijd_datum.getHours();
	var minuten = tijd_datum.getMinutes();
	if (minuten < 10)
	{
		minuten = '0' + minuten;
	}
	var maandarray = new Array('januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december');
	var dagarray = new Array('zondag','maandag','dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag');
	
	document.getElementById('bread').innerHTML = "Het is nu " + dagarray[dagn]+" "+dag+" "+maandarray[maand]+" "+jaar+" &nbsp;"+uur+":"+minuten+" uur"; 
}

// XML
function getHTTPObject() {
    var xmlhttp = false;

    
 	if (window.ActiveXObject)
 	{
     	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 	}
 	else
    {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}

function xml2div(vid,vfunc,vvars,run) { // requires vid=div id, vfunc = function, vvars=vars
	var xmlhttp = getHTTPObject();
	xmlhttp.open("GET", "/engine.php?func="+vfunc+"&vars="+escape(vvars),true); // Open verbinding via GET, via deze URL en communiceer asynchroon
	xmlhttp.onreadystatechange = function()  { 
    	if (xmlhttp.readyState == 4) 
    	{
        	document.getElementById(vid).innerHTML = xmlhttp.responseText; // geef de data weer in een dialoogvenster
   			if (run != '')
   			{
	   			eval(run);
   			}       
    	}
    }
	xmlhttp.send(null) // Verstuur de request
}

if (document.getElementById('newsr'))
{
	var nlinks = document.getElementById('newsr').getElementsByTagName('a');
	for (i = 0; i < nlinks.length - 1; i++)
	{
		nlinks[i].onclick = function ()
		{
			var nid = this.id.substr(3,this.id.length);
			xml2div('newsl', 'fpnews', 'id='+nid,'fixpix()');
			return false;
		}
	}
}

if (document.getElementById('links'))
{
	var hids = document.getElementById('links').getElementsByTagName('span');
	var cid = new Array();
	for (i = 0; i < hids.length; i++)
	{
		hids[i].style.display = 'none';
		
		cid[i] = hids[i].id.substr(5,hids[i].id.length);
		
		if (document.getElementById('meer' + cid[i]))
		{
			document.getElementById('meer' + cid[i]).innerHTML = 'meer &raquo;';
			document.getElementById('meer' + cid[i]).onclick = function ()
			{
				if (document.getElementById('links' + this.id.substr(4,this.id.length)).style.display == 'none')
				{
					document.getElementById('links' + this.id.substr(4,this.id.length)).style.display = 'block';
					this.innerHTML = '&laquo; verbergen';
				}
				else
				{
					document.getElementById('links' + this.id.substr(4,this.id.length)).style.display = 'none';
					this.innerHTML = 'meer &raquo;';
				}
				return false;
			}
		}
	}
}

if (document.getElementById("hulp"))
{
	var hulps = document.getElementById("hulp").getElementsByTagName("div");
	for (i = 0; i < hulps.length; i++)
	{
		hulps[i].onmouseover = function()
		{
			this.oldbg = this.style.backgroundColor;
			this.style.backgroundColor = '#EEEEEE';
			this.style.cursor = 'pointer';
			this.title = 'Klik voor meer informatie';
		}
	
		hulps[i].onmouseout = function()
		{
			this.style.backgroundColor = this.oldbg;
		}
		
		hulps[i].onclick = function()
		{
			var thid = this.id.substr(3,this.id.length);
			if (this.innerHTML.indexOf('hm11121') != -1)
			{
				this.oldinner = this.innerHTML;
				xml2div(this.id, 'hulp', 'id='+thid,'');
				
			}
			else
			{
				this.innerHTML = this.oldinner;

			}
			
		}
		
	}
}

if (document.getElementById("addr"))
{
	var hulps = document.getElementById("addr").getElementsByTagName("div");
	for (i = 0; i < hulps.length; i++)
	{
		hulps[i].onmouseover = function()
		{
			this.oldbg = this.style.backgroundColor;
			this.style.backgroundColor = '#EEEEEE';
			this.style.cursor = 'pointer';
			this.title = 'Klik voor meer informatie';
		}
	
		hulps[i].onmouseout = function()
		{
			this.style.backgroundColor = this.oldbg;
		}
		
		hulps[i].onclick = function()
		{
			var thid = this.id.substr(3,this.id.length);
			
			if (this.innerHTML.indexOf('hm11121') != -1)
			{
				xml2div(this.id, 'addr', 'id='+thid,'domap('+thid+',\'\')');
				return false;
			}
		}
	}
}



if (document.getElementById("newstab"))
{
	var nhulps = document.getElementById("newstab").getElementsByTagName("tr");
	for (i = 0; i < nhulps.length; i++)
	{
		nhulps[i].onmouseover = function()
		{
			this.oldbg = this.style.backgroundColor;
			this.style.backgroundColor = '#EEEEEE';
			this.style.cursor = 'pointer';
		}
		nhulps[i].onmouseout = function()
		{
			this.style.backgroundColor = this.oldbg;
		}
		nhulps[i].onclick = function()
		{
			document.location.href = this.getElementsByTagName('a')[0].href;
			return false;
		}
	}
}

if (document.getElementById("vragen"))
{
	var vnhulps = document.getElementById("vragen").getElementsByTagName("tr");
	for (i = 0; i < vnhulps.length; i++)
	{
		vnhulps[i].onmouseover = function()
		{
			this.oldbg = this.style.backgroundColor;
			this.style.backgroundColor = '#EEEEEE';
			this.style.cursor = 'pointer';
		}
		vnhulps[i].onmouseout = function()
		{
			this.style.backgroundColor = this.oldbg;
		}


		vnhulps[i].onclick = function()
		{
			var thid = this.id.substr(3,this.id.length);
			if (this.innerHTML.indexOf('hm11121') != -1)
			{
				this.oldinner = this.getElementsByTagName('td')[1].innerHTML;
				xml2div('vr'+thid, 'vraag', 'id='+thid,'');
				
			}
			else
			{
				this.getElementsByTagName('td')[1].innerHTML = this.oldinner;

			}
			return false;
		}
	}
}



if (document.getElementById("results"))
{
	var rnhulps = document.getElementById("results").getElementsByTagName("a");
	for (i = 0; i < rnhulps.length; i++)
	{
		rnhulps[i].onmouseover = function()
		{
			this.oldbg = this.style.backgroundColor;
			this.style.backgroundColor = '#EEEEEE';
			this.style.cursor = 'pointer';
		}
		rnhulps[i].onmouseout = function()
		{
			this.style.backgroundColor = this.oldbg;
		}
		rnhulps[i].onclick = function()
		{
			document.location.href = this.getElementsByTagName('a')[0].href;
			return false;
		}
	}
}


if (document.getElementById('map'))
{
	load();
}

function domap(id, oud)
{
	if (document.getElementById('map' + id))
	{
		var geo = document.getElementById('map' + id).innerHTML;
		var mapx = new GMap2(document.getElementById("map" + id));
		mapx.addControl(new GSmallZoomControl());
		mapx.addControl(new GMapTypeControl());
		var pointx = new GLatLng(parseFloat(geo.split(',')[0]),parseFloat(geo.split(',')[1]));
		mapx.setCenter(pointx, 14);	
		var markerx = new GMarker(pointx);
		mapx.addOverlay(markerx);	
	}
}

fixpix();