function pageView(id) {
	
	// haal de content op aan de hand van het id en vul deze voor de cell
	var content = '<a href="javascript:pageUp(1,0);"><img src="images/icons/up.png" class="icon_up" alt="Stuur naar boven" /></a><a href="javascript:pageDown(1,2);"><img src="images/icons/down.png" class="icon_down" alt="Stuur naar beneden" /></a>';
	rowAdd(id, content + "Rij");
}

function rowAdd(id, content) {
	
	var curTable = document.getElementById('table');
		
	var curRow = document.getElementById("row_" + id);
	curRow = curRow.rowIndex;

	var newRow = curTable.insertRow(curRow + 1);
	var newCell = newRow.insertCell(0);
	newRow.id = 'table_row_' + id;
	newRow.className = 'table_row_view';
	newCell.innerHTML = content;
	newCell.colSpan = 6;

	// fade het nieuwe element
	fade('table_row_' + id);
}


function pageEdit(id) {
	alert("Wijzig: " + id);
}

function pageDelete(id) {
	confirm("Verwijderen: " + id + "?");
}

function pageUp(id, higherPos) {
	alert("Omhoog d'r mee!");
}

function pageDown(id, lowerPos) {
	alert("Omlaag d'r mee!");
}

function parseSetActive() {
		
		// if the xmlhttp is sending the request
		if(xmlHttp.readyState == 2) {
			//var curImg = document.getElementById(imgId);
			//var curPath = curImg.getAttribute('src');
			//curImg.setAttribute('src','images/loader.gif');
		}
		// if xmlhttp returned that everything went ok
		else if(xmlHttp.readyState == 4) {
			// status = 200 = file found and ok!
			// just a default http "errorcode"
			if(xmlHttp.status == 200) {
				/*
					Wanneer de pagina wordt gevonden en alles ok is, doe dan het volgende:
					Hier kun je dus je eigen functies toevoegen
				*/
				//alert(xmlHttp.responseText);
			}
			// if file was not found, return a 404 erro
			else if (xmlHttp.status == 404) {
				alert("File not found!");
			}
			else {
				alert("Something else is wrong, server returned: ".xmlHttp.status);
			}
			
			//curImg.setAttribute('src',curPath);
		}		
}

function pageSetActiveN(id, imgId, rowid) {

	createXMLHttpRequest();
	
	// gebruik voor tests
	vars = "id="+ id +"&active=Y";

	// roep xmlhttp aan om de wijziging in de database door te voeren
	// open a connect, but nothing will be send at the moment!
	xmlHttp.open("POST", 'handlepage.php', true);

	// declare the "onreadystatechange"; in other words: when xmlhttp is sending a request the function (callBack) will be called
	xmlHttp.onreadystatechange = parseSetActive;

	// this content-type is only needed when sending through POST.
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	// now we're actually sending something to the url
	xmlHttp.send(vars);				

	// vervang de inactieve afbeelding door de loader
	
	// maak de afbeelding groen wanneer alles is doorgevoerd
	// en maak de tekst grijs ipv rood

	var destLink = document.getElementById('ahref_' + id);
	destLink.setAttribute('href', "javascript:pageSetActiveY(" + id + ",'Yact_" + id + "','" + rowid + "');");
	
	var destImg = document.getElementById(imgId);
	destImg.setAttribute('src','../res/icons/icon_Yactive.png');
	destImg.setAttribute('id','Yact_' + id);
	destImg.setAttribute('alt','Actief');
	destImg.blur();
	
	// zoek _inactive op en vervang dit door niks
	var destRow = document.getElementById('maintablerow' + rowid);
	//alert('row:' + destRow + ' maintablerow' + rowid);
	var destRowClass = destRow.getAttribute('class');
	var destRowClass = destRow.className; // for IE
	var destRowClassNew = destRowClass.replace(/_inactive/,'');
	
	destRow.setAttribute('class',destRowClassNew);
	destRow.className = destRowClassNew; // for IE
	
}

function pageSetActiveY(id, imgId, rowid) {

	createXMLHttpRequest();
	
	// gebruik voor tests
	vars = "id="+ id +"&active=N";

	// roep xmlhttp aan om de wijziging in de database door te voeren
	// open a connect, but nothing will be send at the moment!
	xmlHttp.open("POST", 'handlepage.php', true);

	// declare the "onreadystatechange"; in other words: when xmlhttp is sending a request the function (callBack) will be called
	xmlHttp.onreadystatechange = parseSetActive;

	// this content-type is only needed when sending through POST.
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	// now we're actually sending something to the url
	xmlHttp.send(vars);
	// vervang de actieve afbeelding door de loader
	
	// maak de afbeelding rood wanneer alles is doorgevoerd	
	// een maak de tekst rood ipv grijs
	var destLink = document.getElementById('ahref_' + id);
	destLink.setAttribute('href', "javascript:pageSetActiveN(" + id + ",'Nact_" + id + "','" + rowid + "');");
	
	var destImg = document.getElementById(imgId);
	destImg.setAttribute('src','../res/icons/icon_Nactive.png');
	destImg.setAttribute('id','Nact_' + id);
	destImg.setAttribute('alt','Niet actief');
	destImg.blur();

	// haal de class op, zodat we deze kunnen aanpassen 
	// zoek het einde op van de classnaam en voeg daar _inactive aan toe
	var destRow = document.getElementById('maintablerow' + rowid);
	var destRowClass = destRow.getAttribute('class');
	var destRowClass = destRow.className; // for IE
	var destRowClassNew = destRowClass + '_inactive';
	
	destRow.setAttribute('class',destRowClassNew);
	destRow.className = destRowClassNew; // for IE
}
