// Maak verbinding
function makeAjax () {
	var xmlHttp;
	
	try {

		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
		return xmlHttp;
	}
	catch (e) {
	  
	  // Internet Explorer
		try {
		
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			return xmlHttp;
		}
		catch (e) {
		
			try {
		  
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			}
			catch (e) {
		
				alert("Uw browser ondersteund geen AJAX.");
				return false;
			}
		}
	}
}


// Pagina voor fotoboek
function fetchPage(path, id, page) {
	
	xmlHttpConn = makeAjax();
	
	
	xmlHttpConn.onreadystatechange = function() {
		
		if(xmlHttpConn.readyState == 4) {
			
			// input verkrijgen
			values = xmlHttpConn.responseText;
			
			document.getElementById('content').innerHTML = values;
			
			return false;
		}
	}
	
	
	xmlHttpConn.open("GET", path + "imm_ajax.php?id=" + id + "&page=" + page, true);
	
	xmlHttpConn.send(null);
}


// Afbeelding voor fotoboek
function fetchImage(path, id) {
	
	xmlHttpImage = makeAjax();
	
	
	xmlHttpImage.onreadystatechange = function() {
		
		if(xmlHttpImage.readyState == 4) {
		
			// input verkrijgen
			values = xmlHttpImage.responseText;
		
			document.getElementById('imageimage').innerHTML = values;
			
			return false;
		}
	}
	
	
	xmlHttpImage.open("GET", path + "imm_ajax.php?image=" + id, true);

	xmlHttpImage.send(null);
}


// Headers ophalen
function fetchHeaders (path, catid, sectionid, page, current, year) {
	
	//document.getElementById('headers').innerHTML = '<img src="' + path + 'system/loading.gif" alt="" title="" />';
	
	xmlHttpConn = makeAjax();
	
	xmlHttpConn.onreadystatechange = function() {
		
		if(xmlHttpConn.readyState == 4) {
			
			// input verkrijgen
			values = xmlHttpConn.responseText;
			
			document.getElementById('headers').innerHTML = values;
				
			return false;
		}
	}
	
	
	xmlHttpConn.open("GET", path + "cms_headers_ajax.php?sectionid=" + sectionid + "&catid=" + catid + "&page=" + page + "&current=" + current + "&year=" + year, true);
	
	xmlHttpConn.send(null);
}

