// This file holds the JavaScripts that will be used on the site.

// Open a new window.
var newWindow;
function win(url) {
	newwindow=window.open(url,'name','screenx=700. screeny=50, right=-700, top=50, height=400,width=400');
	newWindow.focus()
}

function nwin(url) {
	newwindow=window.open(url,'name','screenx=700. screeny=50, right=-700, top=50, width=900, height=600,');
	newWindow.focus()
}

// Check Guestbook form
function validForm(guest) {
	info = "";
	if (guest.name.value == "") {
		info += "\nName";
	}
	if(guest.comment.value == "") {
		info += "\nComments";
	}

	if (info != "") {
		info ="_____________________________\n" +
		"You failed to correctly fill in your:\n" +
		info + "\n_____________________________" +
		"\nPlease re-enter and submit again!";
		alert(info);
		return false;
	}
	else return true;
}

function textCounter(field, countfield, maxlimit) {
/*
* The input parameters are: the field name;
* field that holds the number of characters remaining;
* the max. numb. of characters.
*/
	if (field.value.length > maxlimit) // if the current length is more than allowed
		field.value =field.value.substring(0, maxlimit); // don't allow further input
	else
		countfield.value = maxlimit - field.value.length; // set the display field to remaining number
}


/*******************************************************
 These are the functions for the menu navigation.
*******************************************************/

window.onload = function () {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].className == 'label')
			x[i].onclick = clickNav;
	}
	closeNav();
	if (top.setNav)
		setNav(top.setNav,'currentPage');
}

function closeNav()
{
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].className == 'content')
			x[i].style.display = 'none';
	}
}

function clickNav(e)
{
	if (!e) var e = window.event;
	if (e.target) var tg = e.target;
	else if (e.srcElement) var tg = e.srcElement;
	while (tg.nodeName != 'DIV') // Safari GRRRRRRRRRR
		tg = tg.parentNode;
	var nextSib = tg.nextSibling;
	while (nextSib.nodeType != 1)
		nextSib = nextSib.nextSibling;
	var nextSibStatus = (nextSib.style.display == 'none') ? 'block' : 'none';
	nextSib.style.display = nextSibStatus;
}

function setNav(page,newID)
{
	var test = page.indexOf("#")+1;
	if (test)
		page = page.substring(0,test-1);
	var x = document.getElementsByTagName('a');
	var i;
	for (i=0;i<x.length;i++)
	{
		if (x[i].href == page)
		{
			x[i].id = newID;
			break;
		}
	}
	if (i < x.length && newID == 'currentPage')
	{
		var parDiv = x[i];
		while (parDiv.parentNode.tagName == 'DIV')
		{
			parDiv = parDiv.parentNode;
			parDiv.style.display = 'block';
		}
	}
}

/*******************************************************
 End menu script.
*******************************************************/

/*******************************************************
 Start scrolling script.
*******************************************************/

/*******************************************************
 End scrolling script.
*******************************************************/
