function empty(o) {
	o.value = "";
}
// leave in page for way to customize layout of tooltip
// and avoid errors if onmouseovers/outs before page completely loaded
function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}

// preload images that will be displayed in tooltip
// put images to preload in this array
var preload_list = new Array("dot-com-btn.gif", "sm-duck.gif");
var path_to_images = "/images/";

if (document.images) {
	var image_list = new Array();
	for (var preload_counter=0; preload_counter<preload_list.length; preload_counter++) {
  	image_list[preload_counter] = new Image();
		image_list[preload_counter].src = path_to_images + preload_list[preload_counter];
  }
}

// variables for tooltip content
var tipRich = '<div class="tp1">This text is in a div with it\'s own class for different style specifications than the tooltip. </div>';
var tipImg = '<div style="text-align:center"><img src="/images/dot-com-btn.gif" width="176" height="30" alt="" border="0"></div>';
var tipImgTxt = '<img src="/images/sm-duck.gif" width="90" height="44" alt="" border="0"><div class="tp2">Images and text can go together in a tooltip.</div>';
var tipTerms = "If you plan to use our code, please follow our terms. Thank you.";




var weekdays = new Array("Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat.");
var weekdagen = new Array("zon","maa","din","woe","don","vrij","zat");
var months = new Array("januari", "februari", "maart", "april", "mei" ,"juni" ,"juli" ,"augustus" ,"september" ,"oktober" ,"november" ,"december");
var monthsEnglish = new Array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");

var cur = new Date();

function changeLanguage(language) {
	if (language == 'en') {
		months = monthsEnglish;
	}
}

function confirmLink(theLink, confirmMsg) {
    if (confirmMsg == '') {
        return true;
    }
    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&confirmed=1';
    }
    return is_confirmed;
}

function searchBoxWeekDay(day, month, elementId) {
	if (document.getElementById) {
		var theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	curCounter = cur.getDate() + cur.getMonth() * 31;
	dayCounter = day + month * 31;
	if (curCounter > dayCounter) {
		date = new Date(cur.getFullYear() + 1, month, day);
		theElement.innerHTML = "(" + weekdagen[date.getDay()] + ")";
	} else {
		date = new Date(cur.getFullYear(), month, day);
		theElement.innerHTML = "(" + weekdagen[date.getDay()] + ")";
	}
}

function disableOtherIfSelected(select, other, other2, changeColor) {
	if(other2 == undefined) other2 = null;
	if(changeColor == undefined) changeColor = false;
	if (select == null) return;
	if (changeColor) select.style.backgroundColor = '#FFFFFF';
	if (other  == null) return;
	if (select.selectedIndex > 0) {
		other.selectedIndex = 1;
		if (changeColor) other.style.backgroundColor = '#FFE9D1';
	}
	if (other2  == null) return;
	if (select.selectedIndex > 0) {
		other2.selectedIndex = 1;
		if (changeColor) other2.style.backgroundColor = '#FFE9D1';
	}
}

function checkRadio(thing) {
	thing.form.radiolocation.checked = false;
	thing.checked = true;
}

function selectRadioIndex(radio, index) {
	radio[index].checked = true;
}

function changeRadioLocation(aan, uit) {
	aan.style.backgroundColor = '#FFFFFF';

	uit.style.backgroundColor = '#FFE9D1';
	uit.selectedIndex = 1;
}

function clearInput(field, initialValue) {
	if (initialValue == "") {
		field.value = '';
	} else if (initialValue == field.value) {
		field.value = '';
	}
}

function checkCount(veld, aantal, volgende) {
	if(veld.value.length == aantal) {
		volgende.focus(); }
}

function fly(fileID, width, height, scroll) {
	if(scroll == undefined) scroll = 0;
	win = window.open(fileID , "fly", "menubar=0,scrollbars=" + scroll + ",toolbar=0,location=0,directories=0,status=0,resizable=1,width=" + width + ",height=" + height);
	win.resizeTo(width, height);
}

function show(elementId,type) {
	if (document.getElementById) {
		var theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	if (theElement.style) { theElement = theElement.style; }
	if (typeof(theElement.display) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { return; }

	type = 'inline';
	if(type == '' || navigator.appName == "Microsoft Internet Explorer")
	{
		type = 'inline';
	}

	theElement.display = type;


}

function hide(elementId) {
	if (document.getElementById) {
		var theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	if (theElement.style) { theElement = theElement.style; }
	if (typeof(theElement.display) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { return; }

	theElement.display = 'none';
}

function toggle(e) {
	var theElement = document.getElementById(e);
	if (theElement.style.display == "none")   {
		show(e);
	} else {
		hide(e);
	}
}

var min_year = 2004;
var max_year = 2006;

var weekday_showing              = false;
var dayofweek_returned_as_number = false;
var month_returned_as_number     = true;

if (min_year <= 400) {
	alert("Minimum year must be higher than 400 for this algorithm to work.");
}

function changeDays(numb, day, month, year) {
	mth = month[month.selectedIndex].value;
	now = new Date();
	yr = now.getYear();
	if (numb != 1) {
		numDays = numDaysIn(mth,yr);
		day.options.length = numDays;
		for (i=27;i<numDays;i++) {
			day.options[i].text = i+1;
		}
	}
	day = day.selectedIndex+1;
	if (weekday_showing) {
		dayofweek.selectedIndex = getWeekDay(mth,day,yr);
	}
}

function numDaysIn(mth,yr) {
	if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
	else if ((mth==1) && leapYear(yr)) return 29;
	else if (mth==1) return 28;
	else return 31;
}

function leapYear(yr) {
	if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
		return true;
	else
		return false;
}

function arr() {
	this.length=arr.arguments.length;
	for (n=0;n<arr.arguments.length;n++) {
		this[n] = arr.arguments[n];
	}
}

function getWeekDay(mth,day,yr) {
	first_day = firstDayOfYear(yr);
	for (num=0;num<mth;num++) {
		first_day += numDaysIn(num,yr);
	}
	first_day += day-1;
	return first_day%7;
}

function firstDayOfYear(yr) {
	diff = yr - 401;
	return parseInt((1 + diff + (diff / 4) - (diff / 100) + (diff / 400)) % 7);
}

function getFullYear(d) { // d is a date object
	yr = d.getYear();
	if (yr < 1000)
		yr+=1900;
	return yr;
}

function lightOn(o, c){
	if (document.getElementById || (document.all && !(document.getElementById))) {
		o.style.backgroundColor = c;
	}
}

function lightOff(o, c){
	if(document.getElementById || (document.all && !(document.getElementById))){
		o.style.backgroundColor = c;
	}
}