<!--


var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var popup;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows" 
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}



function checkform ( form )
{

  if (form.city.value == "") {
		
    	alert( "Vul een stad in a.u.b." );
   
    	return false;
		
  }

  if (form.arr_day.value == form.dep_day.value && form.arr_month.value == form.dep_month.value) {
    	
	alert( "Aankomst en vertrek kan niet op dezelfde dag zijn. Vul een andere vertrek datum in a.u.b." );
   	
   	return false;
		
  }
	showhide('loadingHome'); showhide('frmSearch');
	return document.forms[0].submit();
}

function writePopup( page )
{
	if( page == "" ) return;
	
	popup = window.open(page, 'window','crollbars=no,toolbar=no,resizable=yes,directories=no,menubar=no,location=no,status=no,width=1,height=1,left=0,top=0');
	 id = setTimeout("countdown()",4000);	
} 

function countdown()
{
	popup.close();
}
	
function setLocationIframe( url, from )
{
	//url = 'http://www.nu.nl';
	
	//document.loadIframe.src= url;
	//var a = document.frames('loadIframe');	
	document.getElementById(from).src=url; 
}




function sortBy( sort_value ) 
{
	document.sort.sort_by.value = sort_value;
	document.sort.submit();
}


//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.search." + Which + "day");
  MonthObject = eval("document.search." + Which + "month");
  YearObject = eval("document.search." + 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.search." + Which + "day");
	MonthObject = eval("document.search." + Which + "month");
	YearObject = eval("document.search." + 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;
}

//hide show functionality
function showhide(layerID){

  if(document.getElementById)
    layerObj = document.getElementById(layerID);
  else if(document.all)
    layerObj = document.all[layerID];
  else
    layerObj = null;
  if(layerObj)
  {
    display = layerObj.style.display;
    layerObj.style.display = (!display || display == 'block') ?
'none' : 'block';
  }
}



