

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


function setCookie(c_name,value,expiredays)
{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }
	return xmlHttp;
}


function bijhoudenvb()
{
	xmlHttp = GetXmlHttpObject();
		if(xmlHttp == null)
		{
			alert("your browser doesn't support AJAX");
		}
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				document.getElementById("vp_right").innerHTML = xmlHttp.responseText;
				document.getElementById("vp_right").style.background = "none";	
			}
		};
		
		url = 'MainInclude/getnieuws.php';
		url = url + '?id=' + id;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	
}

function showcomments(id,ntype)
{
	//alert("reacties"+id);
	var nc= 'nieuwscomments'+id;

	 		
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			document.getElementById(nc).innerHTML = xmlHttp.responseText;
				
		}
	};
	
	url = 'include/getnewscomments.php';
	url = url + '?id=' + id;
	url = url + '&ntype=' + ntype;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
	

}

function openartikel(id)
{
		var art="nieuwsitem" +id
		document.getElementById(art).style.display="block";
}

function sluitartikel(id)
{
		var art="nieuwsitem" +id
		document.getElementById(art).style.display="none";
		
		var titel="titel" +id
		document.getElementById(titel).style.border="1px solid #99b2d4 ";
		document.getElementById(titel).style.background="#c5daf7";
		
}



function insertcomment(nieuwsid,userid,typecomment)
{
	var tekstinvoeg= "tekstinvoeg" + nieuwsid
	var tekst= document.getElementById(tekstinvoeg).value;
	
	var ct = "commentin"+nieuwsid;
	
	//alert("test");
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			document.getElementById(ct).innerHTML = xmlHttp.responseText;
			//alert(xmlHttp.responseText);
		}
	};
	
	url = 'include/insertcom.php';
	
	url = url + '?user_id=' + userid;
	url = url + '&nieuws_id=' + nieuwsid;
	url = url + '&tekst=' + tekst;
	url = url + '&type=' + typecomment;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
		
}

function plaatsreactie(blog_id,user_id,typecomment)
{
	var tekstinvoeg= "tekstinvoeg" + blog_id;
	var tekst= document.getElementById(tekstinvoeg).value;
	
	var blogr = "blogreageer"+blog_id;
	//alert("test");
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			document.getElementById( blogr ).innerHTML = xmlHttp.responseText;
			//alert(xmlHttp.responseText);
		}
	};
	
	url = 'include/insertcom.php';
	url = url + '?user_id=' + user_id;
	url = url + '&tekst=' + tekst;
	url = url + '&type=' + typecomment;
	url = url + '&blog_id=' + blog_id;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}


function changeItem(nr)
{
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("itemsbuitenland").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/changebuitenland.php';
	url = url + '?opschuifnr=' +nr;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function changePicItem(nr,fotovolgende,fotovorige,huidigenr)
{
	if(nr < huidigenr)
	{
		document.getElementById("fotobuitenland").innerHTML='<img src="externe-links/'+fotovorige+'.jpg"> </img>';
	}
	else
	{
		document.getElementById("fotobuitenland").innerHTML='<img src="externe-links/'+fotovolgende+'.jpg"> </img>';
	}
	document.getElementById("fotobuitenland").innerHTML='<img src="externe-links/'+fotovolgende+'.jpg"> </img>';
}

function checkUsername()
{
	//alert("test");
	var str = document.getElementById("screenname").value;
	//alert(str)
	//alert(document.getElementById("screenname").value);
	

	if(str.length < 5)
	{
		document.getElementById("fb_regis").innerHTML = '<p class="fail"> De login naam moet tenminste 6 tekens bevatten</p>';	
		return;
	}
	else
	{
		document.getElementById("fb_regis").innerHTML = '';		
	}

	var patt1 = /\W/g;
	var result = str.match(patt1);

	if(result)
	{
		document.getElementById("fb_regis").innerHTML = '<p class="fail"> De login mag enkel bestaan uit letters en cijfers.</p>';
		return;
	}

	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			if(xmlHttp.responseText == "false")
			{
				
				document.getElementById("fb_regis").innerHTML = '<p class="fail"> Deze gebruikersnaam is al bezet</p>';
				
			}
			else
			{
			
				document.getElementById("fb_regis").innerHTML = '<p class="succes">Goede keuze!</p> ';
		    }
		}
	};
	
	//alert(str);
	url = 'include/checkUsername.php';
	url = url + '?q=' + str;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function checkPassword()
{
	var pass1 = document.getElementById("pass").value;
	var pass2 = document.getElementById("pass_verif").value;
	
		//alert("in checkPassword");
	if(pass1.length < 1 || pass2.length < 1)
	{
	 //alert("pass1:"+pass1);
	 return false;
	 
 	}
 	
	if(pass1.length < 6 || pass2.length < 6)
	{
		document.getElementById("fb_regis").innerHTML = '<p class="fail">Het paswoord moet minstens 6 karakters bevatten</p>';
		return false;
	}
	if(pass1 != pass2)
	{
		document.getElementById("fb_regis").innerHTML = '<p class="fail"> Paswoorden zijn niet gelijk </p>';
		return false;
	}
	document.getElementById("fb_regis").innerHTML = "";
	return true;
}


function zoekvriend(obj)
{
	var namepiece= obj.value;
	
	//if(namepiece.length > 2)
	{
	
	//alert(namepiece);
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("resultset").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/findfriend.php';
	url = url + '?namepiece=' + namepiece;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
	}
}

function voegvriendtoe(id1,id2)
{

	//alert(namepiece);
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("resultset").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/addfriend.php';
	url = url + '?id1=' + id1;
	url = url + '&id2=' + id2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function changetwit()
{
	var twit = document.getElementById("twitinput").value;
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("twitter").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/addtwit.php';
	url = url + '?twit=' + twit;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function volgendefriends(id,pg)
{
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("profielfriends").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/friendsnext.php';
	url = url + '?pg=' + pg;
	url = url + '&id=' + id;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function voegberichttoe(voorwie,vanwie)
{
	var text =document.getElementById("textbericht").value;
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("addbericht").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/toevoegenbericht.php';
	url = url + '?voorwie=' + voorwie;
	url = url + '&vanwie=' + vanwie;
	url = url + '&b_type=' + 2;
	url = url + '&text=' + text;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function privebericht(voorwie,vanwie)
{
	var text =document.getElementById("textbericht2").value;
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("addbericht2").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/toevoegenbericht.php';
	url = url + '?voorwie=' + voorwie;
	url = url + '&vanwie=' + vanwie;
	url = url + '&b_type=' + 1;
	url = url + '&text=' + text;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function deletebericht(id)
{
	
	var div= "bericht"+id;
	alert(" Bent u zeker dat u dit wilt verwijderen?");
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById(div).innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/deletebericht.php';
	url = url + '?id=' + id;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function chose(id,nr)
{
	var inputstuk= "spelerplaats"+id;
	var plaats= document.getElementById(inputstuk).value;
	var inputdiv= "inputdiv"+id;
	//alert(plaats);
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			
			document.getElementById(inputdiv).innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/kiezenspelers.php';
	url = url + '?id=' + id;
	url = url + '&plaats=' + plaats;
	url = url + '&nr=' + nr;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
	
}


function clearnewbericht()
{
	var s=1
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			
			//alert( "testing:"+ xmlHttp.responseText);
			
		}
	};
	
	url = 'include/clearnewbericht.php';
	url += '?s='+ s;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}

function zoekclub(obj)
{
	var namepiece= obj.value;
	
	//if(namepiece.length > 2)
	{
	
	//alert(namepiece);
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("your browser doesn't support AJAX");
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			//alert(xmlHttp.responseText);
			document.getElementById("resultset").innerHTML = xmlHttp.responseText;
			
		}
	};
	
	url = 'include/zoekclub.php';
	url = url + '?namepiece=' + namepiece;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
	}
}


function showselect(nr)
{
	
	if(nr == 1)
	{
		
		document.getElementById("puntenenkel").style.display = "block";
		document.getElementById("puntendubbel").style.display = "none";
		document.getElementById("puntenveteranen").style.display = "none";
			
		document.getElementById("gemengdcheck").checked =false;
		document.getElementById("gemengdcheck").disabled = true;
		
	}
	
	if(nr == 2)
	{
		document.getElementById("puntendubbel").style.display = "block";
		document.getElementById("puntenenkel").style.display = "none";
		document.getElementById("puntenveteranen").style.display = "none";
		
		document.getElementById("gemengdcheck").disabled = false;
	}
	
	if(nr == 3)
	{
		document.getElementById("puntenveteranen").style.display = "block";
		document.getElementById("puntenenkel").style.display = "none";
		document.getElementById("puntendubbel").style.display = "none";
		
		document.getElementById("gemengdcheck").checked =false;
		document.getElementById("gemengdcheck").disabled = true;
	
		
	}
	
	if(nr == 4)
	{
		document.getElementById("enkel").disabled = false;
		document.getElementById("dubbel").disabled = false;
		document.getElementById("puntenveteranen").style.display = "none";
	}
	
	
	
}








