function ajaxLoader(url,id) {
		document.getElementById(id).innerHTML = '<img src="img/loader.gif" alt="loader" style="margin: 50px;" />'
		if (document.getElementById) {
		el = document.getElementById(id);
			var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
			}
			if (x)
				{
			x.onreadystatechange = function()
					{
				if (x.readyState == 4 && x.status == 200)
						{
						el = document.getElementById(id);
						el.innerHTML = x.responseText;
					}
					}
				/* Het gedoe met de timestamp is nodig omdat IE7 anders de cache gebruikt, en dat is behalve onhandig ook gewoon ONTZETTEND STOM. Rotmicrosoft! */
				var date = new Date();
				var timestamp = date.getTime();
				if (url.indexOf('?')==-1)
					url=url+"?rotmicrosoft="+timestamp;
				else
					url=url+"&rotmicrosoft="+timestamp;
				/* Zonder IE7 hadden we dit deel dus kunnen overslaan... */
				x.open("GET", url, true);
				x.send(null);
				}
}

function laadRegelsVoorReageren(id) {
	ajaxLoader("php/laadinhoud.php?type=regelsvoorreageren&id="+id,"foto");
}

function laadLinks() {
	ajaxLoader("php/laadinhoud.php?type=links","foto");
	ajaxLoader("php/laadinhoud.php?type=linksuitleg","tekst");
	ajaxLoader("php/laadinhoud.php?type=niets","menu");
}

function laadMaandArchieven() {
	ajaxLoader("php/laadinhoud.php?type=maandarchieven","foto");
	ajaxLoader("php/laadinhoud.php?type=maandarchievenuitleg","tekst");
	ajaxLoader("php/laadinhoud.php?type=niets","menu");
}

function laadAlbums() {
	ajaxLoader("php/laadinhoud.php?type=albums","foto");
	ajaxLoader("php/laadinhoud.php?type=albumsuitleg","tekst");
	ajaxLoader("php/laadinhoud.php?type=niets","menu");
}

function printOver() {
	ajaxLoader("php/laadinhoud.php?type=overfoto","foto");
	ajaxLoader("php/laadinhoud.php?type=over&id=over","tekst");
	ajaxLoader("php/laadinhoud.php?type=overmenu","menu");
}

function laadfoto(id) {
	ajaxLoader("php/laadinhoud.php?id="+id+"&type=foto","foto");
}

function laadexif(id) {
	ajaxLoader("php/laadinhoud.php?id="+id+"&type=exif","tekst");
}

function laadovertekst(id) {
	ajaxLoader("php/laadinhoud.php?id="+id+"&type=over","tekst");
}

function laadtekst(id) {
	ajaxLoader("php/laadinhoud.php?id="+id+"&type=tekst","tekst");
}

function laadreacties(id) {
	ajaxLoader("php/laadinhoud.php?id="+id+"&type=reacties","tekst");
}

function laadmenu(id) {
	ajaxLoader("php/laadinhoud.php?id="+id+"&type=menu","menu");
}
		
function laadalles(id) {
	laadfoto(id);
	laadtekst(id);
	laadmenu(id);
}

function initialiseer(id) {
	laadalles(id);
	laadThumbnails('nu');
}

function laadThumbnails(query,maand,jaar) { /* Let op: Variabele 'maand' wordt door albumfunctie als album gebruikt */
	if (query=='maand'){
		if (maand==null)
			maand='1';
		if (jaar==null)
			jaar='2008';
		urlparam = "type=maand&maand="+maand+"&jaar="+jaar;
	}
	if (query=='album'){
		if (maand==null)
			maand='1';
		urlparam = "type=album&album="+maand;
	}
	if (query=='nu') {
		urlparam = "type=nu";
	}
	ajaxLoader("php/laadthumbnails.php?"+urlparam,"thumbnails");
	
}




/* TABBLADEN */
function allemaalinactief() {
	var lis = document.getElementsByTagName('li');
		for(var i = 0; i < lis.length; i++) {
			lis[i].className = 'unselected';
		}
}

function maakactief(obj) {
	allemaalinactief();
	document.getElementById(obj).className="selected";
}







   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
	  
      http_request.open('POST', url, true);
      http_request.onreadystatechange = alertContents;
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=iso-8859-1");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
	idtje = document.getElementById('id').value;
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			idtje = document.getElementById('id').value;
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('tekst').innerHTML = result;          
         } else {
            alert('There was a problem with the request.');
         }
      }
	  laadmenu(idtje);
   }
   
   function get(obj) {
		naam=document.getElementById("naam").value;
		email=document.getElementById("email").value;
		website=document.getElementById("website").value;
		reactie=document.getElementById("reactie").value;
		onthoud=document.getElementById("onthoud").checked;
	if ( naam=="") {
		alert("Vul alsjeblieft je naam in!");
		return false;
	}
	if ( reactie=="" ) {
		alert("Vul alsjeblieft een reactie in!");
		return false;
	}
	
	
	var poststr = "naam=" + encodeURI( naam ) +
                    "&email=" + encodeURI( email ) +
					"&id=" + encodeURI( document.getElementById("id").value ) +
					"&website=" + encodeURI( website ) +
					"&reactie=" + escape( reactie ) +
					"&onthoud=" + encodeURI( onthoud );
      makePOSTRequest('php/verwerkform.php', poststr);
   }
