function setWidth() 
{
	//alert(document.getElementsByTagName('body')[0].clientWidth);
		
	width = (document.getElementsByTagName('body')[0].clientWidth - 300)
 	document.getElementById('content').style.width = width + 'px';
}

var xmlHttp;

function createXMLHttpRequest()
{
	if (window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest();
	}
}
	
function SnelprofileZoeken()
{
	if(document.snelzoeken.qpostcode.value == '')
	{
		alert('escriba su c&#0225;digo postal!');
		return false
	}
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("GET", "/ajax_zoeken.php?zip=" + document.snelzoeken.qpostcode.value + "&dist=" + document.snelzoeken.qafstand.value, true);
	xmlHttp.send(null);
}

function profileZoeken()
{
	if(document.zoeken.postcode.value == '')
	{
		alert('escriba su c&#0225;digo postal!');
		return false
	}
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("GET", "/ajax_zoeken.php?zip=" + document.zoeken.postcode.value + "&dist=" + document.zoeken.afstand.value + "&age1=" + document.zoeken.age1.value + "&age2=" + document.zoeken.age2.value + "&nude=" + document.zoeken.nude.value, true);
	xmlHttp.send(null);
}

function handleStateChange()
{
	if(xmlHttp.readyState == 1)
	{
		document.getElementById('content').innerHTML = '... thinking ...';
	}
	if(xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
	{
		if(xmlHttp.status == 200)
		{
			//var xmlData = xmlHttp.responseText;
			document.getElementById('content').innerHTML = xmlHttp.responseText;
		}
	}
}
function contact()
{
	createXMLHttpRequest();
	var naam = document.getElementById("mailnaam").value;
	var email = document.getElementById("mailemail").value;
	var bericht = document.getElementById("mailbericht").value;
	
	if ((document.getElementById("mailnaam").value.length==0) || (document.getElementById("mailnaam").value==null)) 
	{
		alert('escriba su nombre');
		return false;
	}
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
	{
		alert('correo electr&#0243;nico no v&#0225;lido');
		return false;
	}
	
	if ((document.getElementById("mailbericht").value.length==0) || (document.getElementById("mailbericht").value==null)) 
	{
		alert('no mensaje...');
		return false;
	}
			
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("GET", "/ajax_contact.php?naam=" + naam + "&email=" + email + "&bericht=" + bericht, true);
	xmlHttp.send(null);
}

function aanmelden()
{
	createXMLHttpRequest();
	var naam = document.getElementById("mailnaam").value;
	var email = document.getElementById("mailemail").value;
	var bericht = document.getElementById("mailbericht").value;
	var gsmnummer = document.getElementById("gsmnummer").value;
	var bestandsnaam = document.getElementById("bestandsnaam").value;
	
	if ((document.getElementById("mailnaam").value.length==0) || (document.getElementById("mailnaam").value==null)) 
	{
		alert('escriba su nombre');
		return false;
	}
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
	{
		alert('correo electr&#0243;nico no v&#0225;lido');
		return false;
	}
	
	if ((document.getElementById("mailbericht").value.length==0) || (document.getElementById("mailbericht").value==null)) 
	{
		alert('no mensaje');
		return false;
	}

	if ((document.getElementById("gsmnummer").value.length==0) || (document.getElementById("gsmnummer").value==null)) 
	{
		alert('escriba su n&#0250;mero de tel&#0233;fono m&#0225;vil!');
		return false;
	}
		
		
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("GET", "/ajax_aanmelden.php?naam=" + naam + "&email=" + email + "&bericht=" + bericht + "&gsmnummer=" + gsmnummer + "&bestandsnaam=" + bestandsnaam, true);
	xmlHttp.send(null);
}
	
function closeprofile(idnr)
{
	document.getElementById('profile' + idnr).innerHTML = '';
	document.getElementById('profile' + idnr).style.display = "none";
}
	
function showprofile(idnr)
{
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = function()	
	{
		if(xmlHttp.readyState == 1)
		{
			document.getElementById('profile' + idnr).innerHTML = '... thinking ...';
		}
		if(xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
		{
			if(xmlHttp.status == 200)
			{
				document.getElementById('profile' + idnr).style.display = "block";
				document.getElementById('profile' + idnr).innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET", "/overzicht/ajax_getprofile.php?id=" + idnr, true);
	xmlHttp.send(null);   
	//document.getElementById('profile' + idnr).style.display = "block";
}

