var overzichturl = "http%3A%2F%2Fwww.duwo.nl%2Fsmartsite.dws%3Fid%3D123%26style%3D1%26aanbodcode%3DAANBODDELFT%26result%3D1000%26soort%3DInstemming";
var entryurls = new Array();
var origurls = new Array();

function process(i)
{
	// laadt de overzichtstabel:
	$("#test").load("proxy.php?url=" + entryurls[i] + " #tab-content",
					"",
					
					// als de tabel geladen is, maak een lijst met de links naar de instemmingspaginas:
					function (responseText, textStatus, XMLHttpRequest)
					{
					$("#test #photo-para dl *:nth-child(odd)").remove();
					$("#test #photo-para dl *:nth-child(3)").remove();
					$("#test #photo-para dl *:nth-child(3)").remove();
					$("#test #photo-para dl *:nth-child(3)").remove();
					
					$("#test #photo-para a").remove();
					
					$("#test #photo-para dl").wrap("<a href=\"http://www.duwo.nl" + origurls[i] + "\"></a>");
					
					var basics = $("#test #photo-para a");
					
					$("body").append(basics);
					
					var dates = $("#test table[title=Divers]");
					$(dates).find("tr:first").remove();
					
					$("body").append(dates);
					
					var specs = $("#test table[title=Woning]");
					$(specs).find("tr:first").remove();
					$("body").append(specs);
					
					var info = $("#content-para p");
					
					$("body").append(info);
					
					$("#test #tab-content").remove();
					
					i++;
					if (i < entryurls.length) process(i);
					});
	
}; // end function

$(document).ready(function(){
				  
				  // laadt de overzichtstabel:
				  $("#test").load("proxy.php?url=" + overzichturl + " #result-table tbody",
								  "",
								  
								  // als de tabel geladen is, maak een lijst met de links naar de instemmingspaginas:
								  function (responseText, textStatus, XMLHttpRequest)
								  { 
									  // verwijder de header van de tabel:
									  $("#test tr:first").remove();
									  
									  // verzamel de links in entryurls array:
									  var links = $("#test a");
									  
									  for (var i=0; i < links.length; i++)
									  {
								  
										  var u = $(links[i]).attr("href");
										  origurls.push(u);
								  
										  u =  escape(u);
								  
										  // haal de eerste slash eraf:
										  u = u.substr(1);
										  
										  // voeg http://www.duwo.nl/ toe aan het begin:
										  u = 'http%3A%2F%2Fwww.duwo.nl%2F' + u;
										  
										  // voeg de encoded url toe aan de array:
										  entryurls.push(u);
									  }
									  
									  // html tabel opruimen:
									  $("#test tbody").remove();
									  
									  // sorteer de array:
									  entryurls.sort();
									  entryurls.reverse();
								      origurls.sort();
									  origurls.reverse();
								  
								  
									  process(0);

								  });
				  
				  });


