// JavaScript Document
function checkNewsletterInput(obj, type) {
	if(type == 'focus'){
		if(obj.value == 'Vul uw e-mail adres hier in')
			obj.value = '';
	}
	else if(type == 'blur') {
		if(obj.value == '')
			obj.value = 'Vul uw e-mail adres hier in';
	}
}


function checkInput(inputfield,initvalue,comparevalue){
	if(comparevalue){
		if(inputfield.value == ''){
			if(comparevalue != 'Wachtwoord') inputfield.value = comparevalue;
		}
	}
	else{
		if(inputfield.value == 'Wachtwoord'){
			inputfield.value = '';
			replaceT(inputfield);
		}
		else if(inputfield.value == initvalue){
			inputfield.value = '';
		}
	}
}
function replaceT(obj){
	var newO=document.createElement('input');
	newO.setAttribute('type','password');
	newO.setAttribute('id',obj.getAttribute('id'));
	newO.setAttribute('name',obj.getAttribute('name'));
	newO.setAttribute('class','text');
	newO.className = 'text';
	obj.parentNode.replaceChild(newO,obj);
	setTimeout("document.getElementById('"+obj.getAttribute('id')+"').focus();",10);
}







var HotelFinder = Class.create({
	initialize: function(type) {
		this.strAjaxUrl = '/includes/ajax/hotelfinder.php';
		switch (type) {
			case 'business': 
				this.loadCities('business');
				break;
			case 'party': 
				this.loadCities('party');
				break;
			default: 
				this.loadCountries();
				this.loadCities();
		}		
	},
	loadCountries: function() {
		new Ajax.Updater('country-list', this.strAjaxUrl, {
			method:'post',
			parameters: {action: 'countries'},
			evalScripts:'true'
		});
		new Ajax.Updater('hotel-list', this.strAjaxUrl, {
			method:'post',
			parameters: {action: 'hotels'},
			evalScripts:'true'
		});
	},
	loadCities: function(type) {
		switch (type) {
			case 'business': 
				new Ajax.Updater('city-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'cities_business'},
					evalScripts:'true'
				});
				new Ajax.Updater('hotel-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'hotels_business'},
					evalScripts:'true'
				});
				new Ajax.Updater('facilities-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'business_facilities'},
					evalScripts:'true'
				});
				break;
			case 'party': 
				new Ajax.Updater('city-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'cities_party'},
					evalScripts:'true'
				});
				new Ajax.Updater('hotel-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'hotels_party'},
					evalScripts:'true'
				});
				new Ajax.Updater('facilities-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'party_facilities'},
					evalScripts:'true'
				});
				break;
			default: 
				new Ajax.Updater('city-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'cities', country: $F('country-list')},
					evalScripts:'true'
				});
				new Ajax.Updater('hotel-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'hotels', country: $F('country-list')},
					evalScripts:'true'
				});
		}		


	},
	loadHotels: function(type) {
		switch (type) {
			case 'business': 
				new Ajax.Updater('hotel-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'hotels_business', city: $F('city-list')},
					evalScripts:'true'
				});
				break;
			case 'party': 
				new Ajax.Updater('hotel-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'hotels_party', city: $F('city-list')},
					evalScripts:'true'
				});
				break;
			default: 
				new Ajax.Updater('hotel-list', this.strAjaxUrl, {
					method:'post',
					parameters: {action: 'hotels', city: $F('city-list')},
					evalScripts:'true'
				});
		}		
	}
});
