		function fillstars(scoreElement, score){
			for(i=1;i<=5;i++){
			    document.getElementById("star"+scoreElement+i).src="/images/star_off.png";
			}
			for(i=1;i<=parseInt(score);i++){
			    document.getElementById("star"+scoreElement+i).src="/images/star_on.png";
			}
			document.getElementById(scoreElement).value=score;
		}

		function removestars(scoreElement){
			for(i=1;i<=5;i++){
			    document.getElementById("star"+scoreElement+i).src="/images/star_off.png";
			}
			if(getValue(scoreElement)!=0){
				for(i=1;i<=parseInt(getValue(scoreElement));i++){
				    document.getElementById("star"+scoreElement+i).src="/images/star_on.png";
				}
			}
		}

		function showstars(scoreElement, score){
			for(i=1;i<=5;i++){
			    document.getElementById("star"+scoreElement+i).src="/images/star_off.png";
			}
			for(i=1;i<=parseInt(score);i++){
			    document.getElementById("star"+scoreElement+i).src="/images/star_on.png";
			}
		}
		
		function getValue(elemName) {
		  var myType = document.getElementById(elemName).type;
		  if (myType == 'checkbox') {
			if (document.getElementById(elemName).checked) {
				return "1";
			} else {
				return "0";
			}
		  }
		  if (myType == 'password' || myType == 'text' || myType == 'hidden' || myType == 'textarea')
			return(document.getElementById(elemName).value);
		  if (myType == 'select-one')
			return document.getElementById(elemName).options[document.getElementById(elemName).selectedIndex].value;
		  return(document.getElementById(elemName).value);
		}



$(function() {	

	$("#search").each(function() {
	
		$(".text", this).css("color", "#c7cab3").focus(function() {
			
			$(this).css("color", "#444f03");
			if($(this).val() == 'Vul hier een zoekwoord in...') {
				$(this).val('');
			}
			if($.browser.msie)
				$("#tooltip").show();
			else
				$("#tooltip").fadeIn();
		
		}).blur(function() {
		
			if($(this).val() == '') {
				$(this).css("color", "#c7cab3");
				$(this).val('Vul hier een zoekwoord in...');
			}
			if($.browser.msie)
				$("#tooltip").hide();
			else
				$("#tooltip").fadeOut();
		
		});
	
	});
	
	if($.browser.msie && parseInt($.browser.version) == 6)
		$(":submit, li, .hotels a").hover(function() {
		
			$(this).addClass("hover");
		
		}, function() {
		
			$(this).removeClass("hover");
		
		});
	else
		$("#nav > li > span > a").hover(function() {
		
			$(this).parent().parent().addClass("hover");
		
		}, function() {
		
			$(this).parent().parent().removeClass("hover");
		
		});
		
	$("select").parent().form();
	
	$(".date").datepicker({
		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
		monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
		dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
		dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
		dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
		dateFormat: 'dd-mm-yy',
		firstDay: 1,
		prevText: '&laquo; Vorige',
		prevStatus: 'Bekijk de vorige maand',
		nextText: 'Volgende &raquo;',
		nextStatus: 'Bekijk de volgende maand'
	});	
	$('#start-date').bind(
		'dpClosed',
		function(e, selectedDates)
		{
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#end-date').dpSetStartDate(d.addDays(1).asString());
			}
		}
	);
	$('#end-date').bind(
		'dpClosed',
		function(e, selectedDates)
		{
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#start-date').dpSetEndDate(d.addDays(-1).asString());
			}
		}
	);

	
	$(".fancybox a").fancybox({
		transitionIn: 'elastic',
		transitionOut: 'elastic'
	});

	$('#doReview').click(function() {
	  $('#reviewbox').show('slow');
	});
	
	
	/* filter steden */
	$('#filter_steden').keyup(function() {
		var ajaxUrl = '/filterSteden.php';	
				
		var country = jQuery('#country').val();
		var filter_steden = jQuery('#filter_steden').val();
				
		// hide old div
		jQuery("#resultaten").hide();
				
		// show new div
		jQuery("#resultaten_ajax")  	
		.load(ajaxUrl, 'country=' +country+ '&keyword=' +filter_steden);
	})
	
	/* filter hotels */
	$('#filter_keyword').keyup(function() {
		sendRequestSearch();
	}); 
	$('#minrate').keyup(function() {
		sendRequestSearch();
	}); 
	$('#maxrate').keyup(function() {
		sendRequestSearch();
	}); 
	$('#reset_filters').click(function() {
		jQuery('#filter_keyword').val('');
		jQuery('#minrate').val('');
		jQuery('#maxrate').val('');
		jQuery('#hotelStars').val('');
		
		
		$("#starhotelStars1").attr("src","/images/star_off.png");
		$("#starhotelStars2").attr("src","/images/star_off.png");
		$("#starhotelStars3").attr("src","/images/star_off.png");
		$("#starhotelStars4").attr("src","/images/star_off.png");
		$("#starhotelStars5").attr("src","/images/star_off.png");
		
		sendRequestSearch();
	}); 
	$('#score').click(function() {
		sendRequestSearch();
	}); 
		
	function sendRequestSearch ($) {
		var ajaxUrl = '/filterHotels.php';	
				
		var country = jQuery('#country').val();
		var city = jQuery('#city').val();
		var keyword = jQuery('#filter_keyword').val();
		var sterren = jQuery('#hotelStars').val();
		var minrate = jQuery('#minrate').val();
		var maxrate = jQuery('#maxrate').val();
				
		// hide old div
		jQuery("#resultaten").hide();
				
		// show new div
		jQuery("#resultaten_ajax")  
		.load(ajaxUrl, 'country=' +country+ '&city=' +city+ '&keyword='+keyword+ '&class=' +sterren+ '&minrate=' +minrate+ '&maxrate=' +maxrate); 
	}
});
