//menu
var menu = null;
function init_menu()
{
	menu = document.getElementById('menu');
	var li = menu.getElementsByTagName('li'), i = li.length;
	while (i--) li[i].onmouseover = showMenu;
	menu.onmouseout = timeout;
	menu.onmouseover = cleartimer;
}

var timer = null;
function timeout()
{
	timer = setTimeout('hideMenus(menu, null)', 1000);
}

function cleartimer()
{
	if (timer)
	{
		clearTimeout(timer);
		timer = null;
	}
}

function showMenu()
{
	var ul = this.parentNode;
	while (ul)
	{
		if (ul.tagName.toLowerCase() == 'ul')
		{
			hideMenus(ul, this);
			break;
		}

		ul = ul.parentNode;
	}

	ul = this.firstChild;
	while (ul)
	{
		if (ul.nodeType == 1 && ul.tagName.toLowerCase() == 'ul')
		{
			ul.style.display = 'block';
			ul.style.visibility = ''; // necessary for IE
			break;
		}

		ul = ul.nextSibling;
	}
}

function hideMenus(level, skipli)
{
	var stack = [level], i = 0, li, j, el, tag;
	do
	{
		li = stack[i].childNodes, j = li.length;
		while (j--)
		{
			el = li[j];
			if (el.nodeType == 1 && el != skipli)
			{
				tag = el.tagName.toLowerCase();
				if (tag == 'li')
				{
					stack[i++] = el;
				}
				else if (tag == 'ul' && el.style.display == 'block')
				{
					stack[i++] = el;
					el.style.display = 'none';
					el.style.visibility = 'hidden'; // necessary for IE
				}
			}
		}
	}
	while (i--);
}

//copy
if (window.Event)   
  document.captureEvents(Event.MOUSEUP);   
 function nocontextmenu()    
{  
 event.cancelBubble = true  
 event.returnValue = false;  
  return false;  
}  
 function norightclick(e)   
{  
 if (window.Event)   
 {  
  if (e.which == 2 || e.which == 3)  
   return false;  
 }  
 else  
  if (event.button == 2 || event.button == 3)  
  {  
   event.cancelBubble = true  
   event.returnValue = false;  
   return false;  
  }  
 }  
 document.oncontextmenu = nocontextmenu;   
document.onmousedown = norightclick;

//validate
function validateForm()
{

//check if name is empty
if (document.emailform.elements['name'].value == "")
{
alert("Insert a name to continue.");
document.emailform.elements['name'].focus();
return(false);
}

//check if email is empty
if (document.emailform.elements['email'].value == "")
{
alert("Insert a e-mail adres to continue.");
document.emailform.elements['email'].focus();
return(false);
}
//check if email is correct
if (!checkEmail(document.emailform.elements['email'].value))
{
alert("Insert a correct e-mail adres to continue.");
document.emailform.elements['email'].focus();
return(false);
} 
//check if comment is empty
if (document.emailform.elements['comment'].value == "")
{
alert("insert a comment to continue.");
document.emailform.elements['comment'].focus();
return(false);
}

}

// email check
function checkEmail(emailAddress) {

var foundAtSymbol = 0;
var foundDot = 0;
var md;

// Go through each character in the email address.
for (var x=0; x<emailAddress.length - 1; x++) {
md = emailAddress.substr(x, 1);

// Is the character an @ symbol?
if (md == '@') foundAtSymbol++;

// Count how many dots there are after the @ symbol.
if (md == '.' && foundAtSymbol == 1) foundDot++;
};

// Is there only one @ symbol, and are there more than one dots?
if (foundDot > 0 && foundAtSymbol == 1) {
return true;
} else {
return false;
};};
