﻿function Bookmark(url, title)
{
    if (navigator.userAgent.indexOf("Firefox") != -1)
        alert("Druk op de knoppen [Ctrl] en [D] om deze pagina aan uw favorieten toe te voegen. \r\n\r\nUw browser zal dan een bladwzijer aanmaken.\r\n");
    else
        window.external.AddFavorite(url, title);       
}

function ShowHideMail()
{
	var mailElement = document.getElementById("mail");

	if (mailElement.style.display == "none") mailElement.style.display = "block";
	else mailElement.style.display = "none";
}

function MailGotFocus(element, text)
{
	if (element.value == text)
	{
		element.value = "";
		element.style.color = "#666";
	}
}

function MailLostFocus(element, text)
{
	if (element.value == "")
	{
		element.value = text;
		element.style.color = "#999";
	}
}

function SetBackgroundColorToError(element)
{
	element.style.color = "#FFF";
	element.style.backgroundColor = "#FF766F";
}

function SetBackgroundColorToNormal(element)
{
	element.style.backgroundColor = "#FFF";
	element.style.color = "#666";
}

function ValidateElement(element, fieldType, showError)
{
	if (typeof showError == "undefined") showError = false;
	var emailPattern = new RegExp("[A-Z0-9._-]{2,}@[A-Z0-9._-]{2,}\\.[A-Z]{2,3}", "i");

	switch(fieldType)
	{
		case "name":
			if (element.value.length < 3 || element.value.indexOf("Vul hier") > -1)
			{
				if (showError) SetBackgroundColorToError(element);
				return false;
			}
			else
			{
				SetBackgroundColorToNormal(element);
				return true;
			}
			break;
		case "email":
			if (!element.value.match(emailPattern))
			{
				if (showError) SetBackgroundColorToError(element);
				return false;
			}
			else
			{
				SetBackgroundColorToNormal(element);
				return true;
			}
			break;
	}
	
	return false;
}

function ValidateEmailForm(form)
{
	valid = true;

	if (!ValidateElement(document.getElementById("txtName"), "name", true)) valid = false;
	if (!ValidateElement(document.getElementById("txtEmail"), "email", true)) valid = false;
	if (!ValidateElement(document.getElementById("txtFriendName"), "name", true)) valid = false;
	if (!ValidateElement(document.getElementById("txtFriendEmail"), "email", true)) valid = false;

	if (valid) form.submit();
}

var currentTab;
var currentContent;

function ShowContent(tab, div)
{
    if (currentContent != null)
        currentContent.style.display = "none";
        
    if (currentTab != null)
        currentTab.className = "none";        

    currentTab = tab;
    currentTab.className = "selected";        
    currentContent = document.getElementById(div);
    currentContent.style.display = "";
}

function hideOldBrowser()
{
    document.frmHide.submit();
}