var error = "Following fields are not properly filled:\n";
var emailregex = new RegExp("^(([a-zA-Z0-9\\-\\.\\_]{2,})+)(\\@)(([a-zA-ZäÄöÖüÜ0-9\\-\\.]{3,})+)(\\.)([a-zA-Z]{2,4})$");

function $get(id)
{
	return document.getElementById(id);
}

function checkMailpost()
{
	var errors = "";
	if (document.getElementById('from') && document.sendpost.from.value == "")
	{
		errors += "- Your name\n";
	}

	if (document.getElementById('sendemail') && !emailregex.test(document.sendpost.sendemail.value))
	{
		if (document.sendpost.sendemail.value == "")
		{
			errors += "- Friend's E-mail\n";
		}
		else
		{
			errors += "- Friend's E-mail\n";
		}
	}

	if (document.sendpost.sendcomment.value == "")
	{
		errors += "- Your message\n";
	}

	if(errors)
    {
        alert(error+errors);
        return false;
    }

    else
    {
        return true;
    }
}

function checkComment()
{
	var errors ="";
	if (document.getElementById('author') && document.commentform.author.value == "")
	{
		errors += "- Your name!\n";
	}

	if (document.getElementById('email') && !emailregex.test(document.commentform.email.value))
	{
		if (document.commentform.email.value == "")
		{
			errors += "- Your email\n";
		}
		else
		{
			errors += "- Your email\n";
		}
	}

	if (document.commentform.comment.value == "")
	{
		errors += "- Your comment\n";
	}

	if(errors)
    {
        alert(error+errors);
        return false;
    }

    else
    {
        return true;
    }
}
function toggle(id)
{
	obj = document.getElementById(id);
	obj.style.display = (obj.style.display == 'block' ? 'none' : 'block');
	locked = 1;
	if (obj.style.display == 'none')
	{
		locked = 0;
	}
}

function sleep(id)
{

	if(t != 0)
	{
		clearTimeout(t);
	}
	if(locked==0){
		t = window.setTimeout("destroy('"+id+"')", 4000);
	}
}
function destroy(id)
{
	if(t != 0)
	{
		clearTimeout(t);
	}
	t = 0;

	obj = document.getElementById(id);
	obj.style.display='none';
}
