TimerId = new Array();

function showMenu(id) {
  self.clearTimeout(TimerId[id]);
  menu = document.getElementById('submenu'  + id);
  menu.style.display = 'block';
}

function hideDelay(id) {
    menu = document.getElementById('submenu' + id);
    menu.style.display = 'none'; 
}
function hideMenu(id) {
   TimerId[id] = self.setTimeout("hideDelay(" + id + ")",100);
}

function popUp(URL) {
	
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300px,height=500px,left = 780,top = 250');");
}

function popUp1(URL) {
	
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420px,height=450px,left = 250,top = 250');");
}

function popUpKamer(URL) {
	
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500px,height=300px,left = 420,top = 290');");
}

 var urlAddress = "http://www.letstravel.nl";
 var pageName = "Lets Travel";

 function addToFavorites()
 {
  if (window.external)
  {
   window.external.AddFavorite(urlAddress,pageName)
  }
  else
  { 
   alert("Sorry! Je browser ondersteund deze functie niet.");
  }
 }

    
function setNewsLetter() {
	entries = document.getElementById('newslettercontents').getElementsByTagName('input');
	for (i=0;i<entries.length;i++) {
		if (entries[i].type == 'text') {
			entries[i].onfocus = function() {
				switch(this.name) {
					case 'name' : if(this.value == 'voornaam') this.value = ''; break;
					case 'surname' : if(this.value == 'achternaam') this.value = ''; break;
					case 'email' : if(this.value == 'email') this.value = ''; break;
				}
			}
			entries[i].onblur = function () {
				if (this.value == '') {
					switch(this.name) {
						case 'name' : this.value = 'voornaam'; break;
						case 'surname' : this.value = 'achternaam'; break;
						case 'email' : this.value = 'email'; break;
					}
				}
			}
		}
	}
}

function setZoekwoord() {
	entries = document.getElementById('zoekwoord').getElementsByTagName('input');
	for (i=0;i<entries.length;i++) {
		if (entries[i].type == 'text') {
			entries[i].onfocus = function() {
				switch(this.name) {
					case 'fulltext' :  this.value = ''; break;
				}
			}
			entries[i].onblur = function () {
				if (this.value == '') {
					switch(this.name) {
						case 'fulltext' :  break;
					}
				}
			}
		}
	}
}

function setBrochure() {
	entries = document.getElementById('brochure').getElementsByTagName('input');
	for (i=0;i<entries.length;i++) {
		if (entries[i].type == 'text') {
			entries[i].onfocus = function() {
				switch(this.name) {
					case 'name' : if(this.value == 'naam') this.value = ''; break;
					case 'street' : if(this.value == 'straat') this.value = ''; break;
					case 'postcode' : if(this.value == 'postcode') this.value = ''; break;
					case 'place' : if(this.value == 'woonplaats') this.value = ''; break;
					case 'email' : if(this.value == 'email') this.value = ''; break;
				}
			}
			entries[i].onblur = function () {
				if (this.value == '') {
					switch(this.name) {
						case 'name' : this.value = 'naam'; break;
						case 'street' : this.value = 'straat'; break;
						case 'postcode' : this.value = 'postcode'; break;
						case 'place' : this.value = 'woonplaats'; break;
						case 'email' : this.value = 'email'; break;
						
					}
				}
			}
		}
	}
}

function $(id) {
return document.getElementById(id);
}

function repopulateSelectBox(element, data) {
	 
	displayStyle = document.all?'block':'table-row';
	
	elementRow = $(element + 'Row');
	element = $(element);
	if (data) {
		elementRow.style.display = displayStyle; 
	} else {
		elementRow.style.display = 'none';
	}
	element.options.length = 0;
	for (i in data) {
		if (data[i].text.substr(0,1)=='-'){
			data[i].className = "mainsearchbold";
		}

		if (data[i].text.substr(0,2)=='- '){
			data[i].className = "mainsearchblue";
		}
		
		element.options[element.options.length] = data[i];
		
	}

}

function repopulatePlaatsPerRegio(element, value) {
	if (value==0) { repopulateSelectBox(element, plaatsenPerLand['id' + $ ('land').value] );
	} else { data = plaatsenPerRegio['id' + value]; 

	displayStyle = document.all?'block':'table-row';
	
	elementRow = $(element + 'Row');
	element = $(element);
	if (data) {
		elementRow.style.display = displayStyle; 
	} else {
		elementRow.style.display = 'none';
	}
	element.options.length = 0;
	for (i in data) {
		if (data[i].text.substr(0,1)=='-'){
			data[i].className = "mainsearchbold";
		}

		if (data[i].text.substr(0,2)=='- '){
			data[i].className = "mainsearchblue";
		}
		
		element.options[element.options.length] = data[i];
		
	}

	}
}

function populateCaption(id) {

	caption = $("mainsearchcaption");
    if(id == '12' || id == '16' || id == '15' || id == '5' || id == '27'){
	caption.innerHTML = 'Type';
	}
	if(id == '4' || id == '26'){
	caption.innerHTML = 'Thema';
	}
}
function selectsLoader(categorie, land, subcategorie, regio, plaats, personen, duur ) {
	if(categorie)
	{
		populateCaption(categorie);
	}
	repopulateSelectBox('subcategorie',subcatPerCat['id' + categorie]);
	$('subcategorie').value = subcategorie

	repopulateSelectBox('regio',regiosPerLand['id' + land]);
	$('regio').value = regio

	if(regio){
		repopulateSelectBox('plaats',plaatsenPerRegio['id' + regio]);
		$('plaats').value = plaats
	}else{
		repopulateSelectBox('plaats',plaatsenPerLand['id' + land]);
		$('plaats').value = plaats	
	}
	
}

var clickCount = 0;
function addClick(){
	
        clickCount++;
		
}
function goBack(){
        window.history.go(- clickCount - 1);
}


//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear){
  var DaysInMonth = 31;
  if (WhichMonth == "4" || WhichMonth == "6" || WhichMonth == "9" || WhichMonth == "11") DaysInMonth = 30;
  if (WhichMonth == "2" && (WhichYear/4) != Math.floor(WhichYear/4)) DaysInMonth = 28;
  if (WhichMonth == "2" && (WhichYear/4) == Math.floor(WhichYear/4)) DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which){
  DaysObject = eval("document.bookingform." + Which + "day");
  MonthObject = eval("document.bookingform." + Which + "month");
  YearObject = eval("document.bookingform." + Which + "year");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
//  DaysObject.options.length=DaysForThisSelection;
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection){
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++){
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection){
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++){
      NewOption = new Option(DaysObject.options.length + 1);
//      DaysObject.add(NewOption);// Only IE
      DaysObject.options[DaysObject.options.length] = NewOption;
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which){
	DaysObject = eval("document.bookingform." + Which + "day");
	MonthObject = eval("document.bookingform." + Which + "month");
	YearObject = eval("document.bookingform." + Which + "year");

	YearObject[0].selected = true;
	MonthObject[NowMonth].selected = true;

	ChangeOptionDays(Which);

	DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead){
  line = "";
  for (i=0; i<YearsAhead; i++)
  {
    line += "<OPTION>";
    line += NowYear + i;
  }
  return line;
}

function showTypeComment() {
	comment = document.getElementById('typecomment');
	comment.style.display = 'block';
	document.getElementById("resultoutline").style.top="-51px";
}
function hideTypeComment() {
	comment = document.getElementById('typecomment'); 
	comment.style.display = 'none';
	document.getElementById("resultoutline").style.top="0";
	
}

function showCountryComment() {
	comment = document.getElementById('countrycomment');
	comment.style.display = 'block';
	document.getElementById("resultoutline").style.top="-51px";
}
function hideCountryComment() {
	comment = document.getElementById('countrycomment'); 
	comment.style.display = 'none';
	document.getElementById("resultoutline").style.top="0";
}

function confirmOptIn() {
	return confirm("Het streven van Lets Travel is om 1x per maand een digitale nieuwsbrief met aantrekkelijke aanbiedingen en een overzicht van nieuwe arrangementen te versturen. Wenst u deze nieuwsbrief te ontvangen, klik dan op ok. Hiermee geeft u Lets Travel toestemming om de nieuwsbrief aan u te versturen.");
}