function $()
{
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++)
	{
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}
var xmlhttp = false;

function getHTTPReq(url,destinationid)
{
	if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
	else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
	if (xmlhttp)
	{
		xmlhttp.open("GET",url,true);
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState==4)
			{
				if (xmlhttp.status==200) { $(destinationid).innerHTML = xmlhttp.responseText; }
				else { $(destinationid).innerHTML = 'Er is iets fout gegaan!'; }
			}
		}
		if (window.XMLHttpRequest) { xmlhttp.send(null); }
		else if (window.ActiveXObject) { xmlhttp.send(); }
	}
}

function setCountry()
{
	getHTTPReq('http://www.vakantieverblijfhuren.nl/ajax.php?setcountry','dcountry');
}

function setRegion()
{
	var country = $('country').value;
	getHTTPReq('http://www.vakantieverblijfhuren.nl/ajax.php?country='+country+'&region','dregion');
	$('city').disabled=true;
	setTimeout("showResult()", 400);
}

function setCity()
{
	var country = $('country').value;
	var region = $('region').value;
	getHTTPReq('http://www.vakantieverblijfhuren.nl/ajax.php?country='+country+'&region='+region,'dcity');
	setTimeout("showResult()", 400);
}

function showResult()
{
	var index = 1;
	var country = ($('country')) ? $('country').value : '';
	var region = ($('region')) ? $('region').value : '';
	var city = ($('city')) ? $('city').value : '';
	getHTTPReq('http://www.vakantieverblijfhuren.nl/ajax.php?list&index='+index+'&country='+country+'&region='+region+'&city='+city+'&type='+$('type').value+'&person='+$('person').value,'result');
}
window.onload=setCountry;

var ajax = new Array();

function getCityList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_city').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'http://www.vakantieverblijfhuren.nl/getCities.php?countryCode='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCities(index)
{
	var obj = document.getElementById('dhtmlgoodies_city');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}


function getSubCategoryList(sel)
{
	var category = sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_subcategory').options.length = 0;	// Empty city select box
	if(category.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'http://www.vakantieverblijfhuren.nl/getSubCategories.php?category='+category;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSubCategories(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createSubCategories(index)
{
	var obj = document.getElementById('dhtmlgoodies_subcategory');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}	