
function doTerrysCallback(initiator,Jval,init_select,url) {

	// if a selector is set back to 'unselected', treat as if selector one level up were changed
	if (initiator=='wijn' && $("#kies_wijn").val()=='')
	{
		initiator = 'wijnhuis';
		Jval = $('#kies_wijnhuis').val();
	}
	
	if (initiator=='wijnhuis' && $("#kies_wijnhuis").val()=='')
	{
		initiator = 'streek';
		Jval = $('#kies_streek').val();
	}
	
	if (initiator=='streek' && $("#kies_streek").val()=='')
	{
		initiator = 'land';
		Jval = $('#kies_land').val();
	}
	
/*
// items to update
   var items = [];
   if (	initiator=='land')
     items = ['streek', 'wijnhuis', 'wijn'];
   else if (initiator=='streek')
	 items = ['wijnhuis', 'wijn'];
   else if (initiator=='wijnhuis')
	 items = ['wijn'];
	  

$.each(items,function() {
    // create local variable to hold the item so we can use it in the callback of the ajax request
    var	item = this;
	// do ajax request to get new HTML
	$.get(url+'inc/pop_'+item+'.php', {value:Jval, type:initiator, init_select:init_select}, function(data) {
																			 
        // store HTML
		$("#"+item+"_label").html(data);
		
		// re-attach onchange event
		if (item=='streek') {
		  $("#kies_"+item).change(function() {
		    doTerrysCallback(item,$(this).val(),'',url);
		  });
		}
	});
 });
*/  

// show selected page
	showLoader();
	$.get(url+'zoek_redirect.php', {value:Jval, type:initiator}, function(data) {
		if(data.indexOf('http') != -1) window.location = data;
		else alert(data);	
	});
}


function open_tagcloud() {
	$('#flashintro').hide();
	$('#row1_content').show();
}

function showLoader() {
	$("#loader").fadeIn('250');
}
function hideLoader() {
	$("#loader").fadeOut('100');
}

function doTerrysShowResult(initiator,Jval,url) {
	showLoader();
	
	$.get(url+'zoek_redirect.php', {value:Jval, type:initiator}, function(data) {
		if(data.indexOf('http') != -1) {
			window.location = data;
		} else {
			alert(data);	
		}
		
	});
}

function showMore(swoosh, swish) {
	$("#"+swoosh).slideUp(200, function() {
		window.setTimeout('$("#'+swish+'").slideDown(800);',100);
	});
}
function showLess(swoosh, swish) {
	$("#"+swoosh).slideUp(200, function() {
		window.setTimeout('$("#'+swish+'").slideDown(800);',100);
	});
}


function makeRequest(url, tag) { 
	var http_request = false;
	
	
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Er kon geen verbinding worden gemaakt.\nProbeer het later nog eens.'); 
		return false;
	}

	http_request.onreadystatechange = function() { alertContents(http_request, tag); };
	http_request.open('GET', url, true);
	http_request.send(null);

}

function alertContents(http_request, tag) {

	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var results = http_request.responseText;
			getObject(tag).innerHTML = results;
			if(tag == 'blokgroot') {
				Effect.toggle('blokgroot','blinddown');
			}			
		} else {
			alert('Niet alles ging goed.\nProbeer het nog eens.');
		}
	}

}

function getObject(name) {
	var ns4 = (document.layers) ? true : false;
	var w3c = (document.getElementById) ? true : false;
	var ie4 = (document.all) ? true : false;
	
	if (ns4) return eval('document.' + name);
	if (w3c) return document.getElementById(name);
	if (ie4) return eval('document.all.' + name);
	return false;
}

function writeCookie() {
	var today = new Date();
	var the_date = new Date("December 31, 2023");
	var the_cookie_date = the_date.toGMTString();
	var the_cookie = "res="+ screen.width +"x"+ screen.height;
	var the_cookie = the_cookie + ";expires=" + the_cookie_date;
	document.cookie=the_cookie;
}

function toggle(obj1) {
	var change = document.getElementById(obj1);
	
	if ( change.style.display != 'none' ) {
		change.style.display = 'none';
	}
	else {
		change.style.display = '';
	}

}


function toggleOn(obj1) {
	var change = document.getElementById(obj1);
	change.style.display = '';
}
function toggleOff(obj1) {
	var change = document.getElementById(obj1);
	change.style.display = 'none';
}

function popup(url, w, h) {
	window.open(url,'popup','height='+h+', width='+w+', menubar=no, status=yes, scrollbars=yes, resizable=yes, toolbar=yes, location=no');		
}

function wb_select(land, streek, huis) {

	$("ul.landensublist")
		.not("[id=strekenlist_"+land+"]")
		.not("[id=huizenlist_"+streek+"]")
		.not("[id=wijnenlist_"+huis+"]")
		.slideUp(200, function() {});
	
	window.setTimeout("$(\"#strekenlist_"+land+"\").slideDown(400); $(\"#huizenlist_"+streek+"\").slideDown(400); $(\"#wijnenlist_"+huis+"\").slideDown(400);",1);
}


