//---------------------------------------------------------------------
// File name:	general.js
// Description:	General javascript functions
// Author(s):	Piotr
// Version:		1.0 Copyright 2006 HDB-Alkmaar
//---------------------------------------------------------------------


//---------------------------------------------------------------------
// Function:	showDateNL
// Parameters:	None
// Returns:		Null
// Purpose:		Shows a date String in the document
// Author:		Piotr (TU Ron)
// Remarks:		-
//---------------------------------------------------------------------

function showDateNL() {
	var day = new Array(7);
	day[0] = "Zondag";
	day[1] = "maandag";
	day[2] = "Dinsdag";
	day[3] = "Woensdag";
	day[4] = "Donderdag";
	day[5] = "Vrijdag";
	day[6] = "Zaterdag";
	//
	var month = new Array(12);
	month[0] = "januari";
	month[1] = "februari";
	month[2] = "maart";
	month[3] = "april";
	month[4] = "mei";
	month[5] = "juni";
	month[6] = "juli";
	month[7] = "augustus";
	month[8] = "september";
	month[9] = "october";
	month[10] = "november";
	month[11] = "december";
	//
	var now = new Date;
	var day = day[now.getDay()];
	var month = month[now.getMonth()];
	var date = now.getDate();
	var year = now.getYear();
	if (year < 1900) {
		year += 1900;
	}
	document.write(day + " " + date + " " + month + " " + year);
}

//---------------------------------------------------------------------
// Function:    MM_openBrWindow
// Parameters:  String: The URL to open 
// 				String: The window name
//				String: Features 
// Returns:		Null
// Purpose:		Shows given reference in a new window
// Author:		Piotr
// Remarks:		The name of this function has to remain for pages 
//				edited in MMDW.
//---------------------------------------------------------------------

function MM_openBrWindow(anURL, windowName, features) {
  window.open(anURL, windowName, features);
}

//---------------------------------------------------------------------
// Function:	showRoute 
// Parameters:	none
// Returns:		null
// Purpose:		Shows the required route.
// Author:		Piotr
// Remarks:		For this to work:
//
//				The form should have a select box called 'routeSelect'
//				in a form 'routeForm'
//---------------------------------------------------------------------

function showRoute(){
	anId = document.routeForm.routeSelect.value;
	hideAllBut(anId, 'routeForm');
}

//---------------------------------------------------------------------
// Function:	showNextImage
// Parameters:	int:	total number of images
// Returns:		null
// Purpose:		Shows the next image.
// Author:		Piotr
// Remarks:		For this to work:
//
//				The form should have a form called 'photoshowForm'
//---------------------------------------------------------------------

var img_nr = 0;

function showNextImage(total) {
	img_nr = img_nr + 1;
	if (img_nr >= total) img_nr = 0;
	hideAllBut(img_nr, 'photoshowForm');
}

//---------------------------------------------------------------------
// Function:	showFormerImage
// Parameters:	int:	total number of images
// Returns:		null
// Purpose:		Shows the last image.
// Author:		Piotr
// Remarks:		For this to work:
//
//				The form should have a form called 'photoshowForm'
//---------------------------------------------------------------------

function showFormerImage(total) {
	img_nr = img_nr - 1;
	if (img_nr < 0) img_nr = total - 1;
	hideAllBut(img_nr, 'photoshowForm');
}

//---------------------------------------------------------------------
// Function:	hideAllBut
// Parameters:	int:	The element integer id that should be visible
//				Object: The form name
// Returns:		null
// Purpose:		Shows the document element with given id. Hides the 
//				others
// Author:		Piotr
// Remarks:		For this to work:
//
//				Only the elements that require show/hide should 
//				have a <span style="visibility: hidden;"></span> tag.
//
//				Pass id = -1 to hide all elements.
//---------------------------------------------------------------------

function hideAllBut(id, sFormName){
	if (document.getElementById && document.createTextNode){
		spans = document.getElementById(sFormName).getElementsByTagName('span');
		m = document.getElementById(sFormName);
		for (i = 0 ; i < spans.length ; i++){
			m.getElementsByTagName('span')[i].style.visibility='hidden';
		}
		if (id >= 0) {			
			m.getElementsByTagName('span')[id].style.visibility='visible';
		}
	}
}

//---------------------------------------------------------------------
// Function:	debugMsg
// Parameters:	String: The debug message
// Returns:		null
// Purpose:		Shows a debug message
// Author:		Piotr
// Remarks:		- 
//---------------------------------------------------------------------

function debugMsg(msg) {
	alert(msg);
}
