// ******************************************************
// Deze functie regeld alles omtrend het navigeren op de 
// pagina deze check of het in een frame geladen moet worden
// of er een popup geladen moet worden enz enz
// ****************************************************** 
// gotoURL :: arguments[0]	= (STRING)  "URL" (URL waar de link naartoe wijst)
// gotoURL :: arguments[1]	= (STRING)  "TARGET" (Kijkt of er een nieuw venster geopend dient te worden)
// gotoURL :: arguments[2]	= (BOOLEAN) "POP_UP" (true is een Pop-UP, false niet (alleen in combinatie met de TARGET))
	function gotoURL() {
		var anker = "";
		var URL = arguments[0];
		var TARGET = arguments[1];
		var POP_UP = arguments[2];
		var databank = self.location.href.search( "Databank" );
		
		var path = "";
		if (databank >= 0) {
			layout = parent.layout;
			path = "../../";
		}		
		
	// Wijzig de statistieken
	//	if (window.parent.frames['statsFrame']) {
	//		window.parent.frames['statsFrame'].location.href = "default_stats.php" + URL + "&actie=hits";
	//	} else if (window.parent.parent.frames['statsFrame']) {
	//		window.parent.parent.frames['statsFrame'].location.href = "default_stats.php" + URL + "&actie=hits";
	//	}
		
		if ((window.location.href.indexOf("default_inhoud.php") >= 0) && (URL.indexOf("http://") == -1) && (URL.indexOf("&layout=") >= 0) && (URL.indexOf("&slayout=") == -1) && (window.location.href.indexOf("&layout=") == -1) && (window.name != "inhoud_frame")) {
			window.location.href = path + "default_layout.php" + URL;
		} else {
			var inhoudFrame = window.frames['inhoud_frame'];
			
		// Laad in hetzelfde frame
			if (TARGET == "_self") {
				if ((URL.indexOf("http://") >= 0) || (URL.indexOf("ftp://") >= 0)) {
					if (inhoudFrame) {
						inhoudFrame.location.href = URL;
					} else {
						location.href = URL;
					}
				} else if (URL.indexOf("&layout=") >= 0) {
					var temp = URL.split("&");
						temp[0] = temp[0].split("=");
						temp[1] = temp[1].split("=");
						temp[2] = temp[2].split("=");
					// Kijk voor het anker
						if (temp[2][1].search("#") >= 0) {
							var test = temp[2][1].split("#");
							anker = test[1];
							temp[2][1] = test[0];
						}
						if (URL.search("actie") >= 0) {
							temp[3] = temp[3].split("=");
						} else if (URL.search("hc") >= 0) {
							temp[3] = temp[3].split("=");
							temp[4] = temp[4].split("=");
							temp[5] = temp[5].split("=");
						} else {
							temp[3] = new Array("", "");
						}
						
				// Zet de variabelen goed voor het inloggen (leg de locatie vast)
				// Kijk of er naar een ander layout gegaan moet worden
					if (temp[1][1] == "zelfdelayout") {
						URL = URL.replace("zelfdelayout", layout);
					} else {
						if (layout != temp[1][1]) {
							if (self.name == "mainFrame") { 
								location.href = path + "default_layout.php" + URL;
							} else {
								parent.location.href = path + "default_layout.php" + URL;
							}
						} else {
							layout = temp[1][1];
						}
					}
					if (parent.pagina) {
						parent.pagina = temp[2][1];
					} else {
						pagina = temp[2][1];
					}
						
				// Kijk of het een beveiligde pagina is
					if ((beveiligdePagina(temp[2][1])) && (URL.search("actie=ok") < 0) ) {
						window.frames['downloadFrame'].location.href = path + "default_extranet_login.php" + URL + "&target=" + TARGET + "&popup=" + POP_UP;
					} else {
						var inhoudFiguur = document.getElementById('inhoud');
						if (inhoudFrame) {
							inhoudFrame.location.href = path + "default_inhoud.php" + URL;
						} else if (self.name == "inhoud_frame") {
							window.location.href = path + "default_inhoud.php" + URL;
						} else if (inhoudFiguur) {
							inhoudFiguur.innerHTML = stripAreas(parent.document.getElementById(pagina).value);
							doPaginaScript( temp[2][1] );
							wisselFiguur( temp[2][1] );
							activeerObject( temp[2][1] );
							hoverActief( temp[2][1] );
							klok();
							teller( tellerwaarde );
						// kijk of er naar een anker gesprongen moet worden
							if (anker != "") {
								location.href = "#" + anker;
							} else {
								location.href = "#cs_topfornoframe";
							}
						} else {
							if (databank >= 0)
							{
								parent.location.href = path + "default_inhoud.php" + URL;
							}
							else
							{
								location.href = path + "default_layout.php" + URL;
							}
						}
					}
				} else {
					var temp = URL.split( "#" );
					var tURL = path + "default_inhoud.php" + temp[0] + "&slayout=" + layout;
					if ( temp[1] ) {
						tURL += "#" + temp[1];
					}
					if (self.name == "inhoud_frame") {
						parent.location.href = tURL;
					} else {
						location.href = tURL;
					}
				}
		// Download een file uit het archief
			} else if ((TARGET == "_archief") || (TARGET.search("figuur") >= 0)) {
				if (TARGET == "_archief") {
					window.frames['downloadFrame'].location.href = path + "default_download.php?bestand=" + URL;
				} else if (TARGET.search("figuur") >= 0) {
					if (document.getElementById(TARGET)) {
						document.getElementById(TARGET).src = URL;
					} else {
						parent.document.getElementById(TARGET).src = URL;
					}
				}
		// Laad in een nieuw scherm
			} else {
				var temp = URL.split("&pagina=");
					
			// Kijk of het een beveiligde pagina is
				if ((URL.indexOf("&pagina=") >= 0) && (beveiligdePagina(temp[1])) && (URL.search("actie=ok") < 0) ) {
					window.frames['downloadFrame'].location.href = path + "default_extranet_login.php" + URL + "&target=" + TARGET + "&popup=" + POP_UP;
				} else {
					if ((URL.indexOf("http://") >= 0) || (URL.indexOf("mailto:") >= 0)) {
						rURL = URL;
					} else if (URL.indexOf("&layout=") >= 0) {
						rURL = path + "default_layout.php" + URL; 
					} else if (URL.indexOf("&pagina=") >= 0) { 
						rURL = path + "default_inhoud.php" + URL; 
					} else if (URL.indexOf("klanten/klant_") >= 0) {
						rURL = path + "default_image.php?image=" + URL + "&klant=" + klantId;
					}
					
					if (POP_UP) {
						var d = new Date();
						var windowID = d.getHours() + "" + d.getMinutes() + "" + d.getSeconds();

						if (rURL.indexOf("http://") >= 0) {
							var breedte = screen.availWidth - 50;
							var hoogte = screen.availHeight - 150;
							var scherm = window.open(rURL, "pop_up" + windowID, "status=no, menu=no, width=" + breedte + ", height=" + hoogte + ", left=" + ((screen.availWidth - breedte) / 2) + ", top=" + ((screen.availHeight - hoogte) / 2) + ", scrollbars=yes");
						} else if (URL.indexOf("&layout=") >= 0) {
							var scherm = window.open(rURL + "&popup=ja", "pop_up" + windowID, "status=no, menu=no, width=750, height=600, left=100px, top=100px, scrollbars=yes, resizable=yes");
						} else {
							var scherm = window.open(rURL + "&layout=" + layout + "&popup=ja", "pop_up" + windowID, "status=no, menu=no, width=750, height=600, left=100px, top=100px, scrollbars=yes, resizable=yes");
						}
					} else {
						var props = "location=1, menubar=1, toolbar=1, status=1, scrollbars=1, width=" + screen.availWidth + ", height=" + screen.availHeight + ", left=0, top=0";
						if ((URL.indexOf("http://") >= 0) || (URL.indexOf("mailto") >= 0)) {
							window.open(rURL, "newScherm" + windowID, props);
						} else if ((URL.indexOf("&pagina=") >= 0) && (URL.indexOf("&layout=") < 0)) {
							window.open(rURL + "&layout=" + layout, "newScherm" + windowID, props);
						} else if ((URL.indexOf("&pagina=") >= 0) && (URL.indexOf("&layout=") >= 0)) {
							window.open(rURL, "newScherm" + windowID, props);
						}
					}
				}
			}
		}
	}
	