function handleReisCode(objForm, domain)
{	
	newLocation = domain + "/" + objForm.reiscode.value + "/";
	document.reiscodeformulier.action = newLocation;
}


function openPopup(popupUrl, width, height)
{
	window.open(popupUrl, '', 'scrollbars=yes,menubar=yes,height='+width+',width='+height+',resizable=yes,toolbar=no,location=no,status=no');
}


function showElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	objElement.style.visibility = "visible";
	objElement.style.display = "block";
}

function hideElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	objElement.style.visibility = "hidden";
	objElement.style.display = "none";
}

function toggleElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	
	if ((objElement.style.visibility == "") || (objElement.style.visibility == "hidden"))
	{
		showElement(strElementID) 
	} else {
		hideElement(strElementID) 
	}
}


function toggleElementByCheckBox(strElementID, objCheckBox)
{
	if (objCheckBox.checked)
	{
		showElement(strElementID) 
	} else {
		hideElement(strElementID) 
	}
}


function setMainImage(newSource, mainimage)
{
	mainimage.src = newSource;
}

function setActivationArrow(idOfDiv) 
{
	// clean all backgrounds
	for (i=1;i <= 16; i++)
	{
		myDiv = document.getElementById('thumb'+ i);
		if ((myDiv != null) && (myDiv != "undefined"))
		{
			myDiv.style.background= "none";
		}
	}
	
	// set active
	objDiv = document.getElementById(idOfDiv);
	objDiv.style.background = "url(/images/bg_thumb_active.gif) no-repeat";

}


function hoverThumb(idOfDiv, state)
{
	objDiv = document.getElementById(idOfDiv);

	curBackground = objDiv.style.background;
	
	if (curBackground.indexOf("bg_thumb_active") > -1) {
		// do nothing
	} else if (state == "on") {
		objDiv.style.background = "url(/images/bg_thumb_hover.gif) no-repeat";
	} else {
		objDiv.style.background = "none";
	}	
}

function showNextDayGroup(groupNr)
{
	groupNr = groupNr + 1;
	showDayGroup(groupNr);
}

function showPreviousDayGroup(groupNr)
{
	groupNr = groupNr - 1;
	showDayGroup(groupNr);
}

function showDayGroup(groupNr)
{
	for (i=1; i <= nrOfDayGroups; i++)
	{
		divID = "daygroup"+ i;
		
		if (i == groupNr) {
			showElement(divID);
		} else {
			hideElement(divID);
		}
		
	}
	
}

var bSubmitted=false;

function checkForUnsaved(evt){
	if (document.forms.boekingcontrole && bSubmitted == false ){
		var alerttext = "";
		alerttext += "________________________________________________________________\n\n\n";
		alerttext += "Uw boeking is nog niet definitief!\n";
		alerttext += "Klik op \'Annuleren\' of \'Cancel\' en vervolgens op de \'Verstuur uw boeking\' knop om te bevestigen.\n";
		alerttext += "Klik op \'OK\' als u uw boeking daadwerkelijk wilt afbreken.\n\n";
		alerttext += "________________________________________________________________";
		
		if (evt) {
			evt.returnValue = alerttext;
		} else {
			event.returnValue = alerttext; //IE7
		}
	}
}

function handleSubmit() {
	bSubmitted = true;
	//return true;
}

var aantalreizengevondentekst, aantalreizengevondentimeout
function filterHolidays(cr, c, ht, hp) {
	if (aantalreizengevondentekst == null) { 
		aantalreizengevondentekst = $("div.aantalreizengevonden").text() 
	}
	var filtertext

	if (cr > 0) {
		// reset the clicked continent/region list item, and its child list items
		$("li.cr" + cr + " > a, li.cr > ul > li > a").removeClass("ghosted");
		// ghost the other list items -- fadeTo is not used because of anti-aliasing issues in IE
		$("li.ht > a, li.cr:not(.cr" + cr + ") > a, li.cr:not(.cr" + cr + ") > ul > li > a").addClass("ghosted");

		if (c == null) {
			// show the clicked continent/region holiday
			$("div.cr" + cr + ", h1.cr" + cr).slideDown("slow");
		}
		// hide the other holidays
		$("div.reis-box:not(.cr" + cr + "), h1:not(.cr" + cr + ")").slideUp("slow");

		if ($("div.cr" + cr).length > 1) {
			filtertext = " Nu worden alleen de " + $("div.cr" + cr).length + " reizen naar '" + $("li.cr" + cr + " > a").text() + "' getoond."
		} else {
			filtertext = " Nu wordt alleen de reis naar '" + $("li.cr" + cr + " > a").text() + "' getoond."
		}
	} 
	
	if (c > 0) {
		// reset the clicked country list item
		$("li.c" + c + " > a").removeClass("ghosted");

		// ghost the other list items
		$("li.ht > a, li.c:not(.c" + c + ") > a").addClass("ghosted");

		// show the clicked country holidays
		$("div.c" + c + ", h1.cr" + cr).slideDown("slow");
		// hide the other holidays
		$("div.reis-box:not(.c" + c + ")").slideUp("slow");
		
		if ($("div.c" + c).length > 1) {
			filtertext = " Nu worden alleen de " + $("div.c" + c).length + " reizen naar '" + $("li.c" + c + " > a").text() + "' getoond."
		} else {
			filtertext = " Nu wordt alleen de reis naar '" + $("li.c" + c + " > a").text() + "' getoond."
		}
	} 
		
	if (ht > 0) {
		// reset the clicked holidaytype list item
		$("li.ht" + ht + " > a").removeClass("ghosted");
		// ghost the other list items
		$("li.cr > a, li.c > a, li.ht:not(.ht" + ht + ") > a").addClass("ghosted");
		
		// hide the other holidays and the continent/region titles
		$("div.reis-box:not(.ht" + ht + "), h1.cr").slideUp("slow");
		// show the clicked holidaytype holidays
		$("div.ht" + ht).slideDown("slow");

		if ($("div.ht" + ht).length > 1) {
			filtertext = " Nu worden alleen de " + $("div.ht" + ht).length + " reizen met het vervoertype '" + $("li.ht" + ht + " > a").text() + "' getoond."
		} else {
			filtertext = " Nu wordt alleen de reis met het vervoertype '" + $("li.ht" + ht + " > a").text() + "' getoond."
		}
	} 

	if (hp >= 0) {
		// reset the clicked price-range list item
		$("li.hp" + hp + " > a").removeClass("ghosted");
		// ghost the other list items
		$("li.cr > a, li.c > a, li.ht > a, li.hp:not(.hp" + hp + ") > a").addClass("ghosted");
		
		// hide the other holidays and the continent/region titles
		$("div.reis-box:not(.hp" + hp + "), h1.cr").slideUp("slow");
		// show the clicked holidaytype holidays
		$("div.hp" + hp).slideDown("slow");

		if ($("div.hp" + hp).length > 1) {
			filtertext = " Nu worden alleen de " + $("div.hp" + hp).length + " reizen met een prijs " + $("li.hp" + hp + " > a").text() + " getoond."
		} else {
			filtertext = " Nu wordt alleen de reis met een prijs " + $("li.hp" + hp + " > a").text() + " getoond."
		}
	} 

//window.console.log("null");	

	clearTimeout(aantalreizengevondentimeout);
	$("div.aantalreizengevonden").stop();

	if (cr == null && ht == null && hp == null) {
		// reset all continent/region list items
		$("a").removeClass("ghosted");

		// show all holidays
		$("div.reis-box, h1.cr").slideDown("slow");
 
		$("div.aantalreizengevonden").html(aantalreizengevondentekst)
	
		//$("div.aantalreizengevonden").animate({ backgroundColor: "#ffa" }, 1000)
		//aantalreizengevondentimeout = setTimeout('$("div.aantalreizengevonden").animate({ backgroundColor: "#F5F7F9"}, 7500)',2500);
	} else {
		filtertext += "<br/><a href='javascript:void(0)' onclick='filterHolidays()'>Toon alle "+ $("span.totaalaantalreizen").text() + " reizen</a>"
		//$("div.aantalreizengevonden").html(aantalreizengevondentekst + filtertext)
		$("div.aantalreizengevonden").html(filtertext)
	
		//$("div.aantalreizengevonden").animate({ backgroundColor: "#ffa" }, 1000)
		//aantalreizengevondentimeout = setTimeout('$("div.aantalreizengevonden").animate({ backgroundColor: "#F5F7F9"}, 7500)',2500);
	}
//window.console.log("end");		
	//window.console.log("function filterHolidays() finished") 

	return false;
}

