function hideErrorMessages()
{
	document.getElementById('errorNameEmpty').style.visibility = 'hidden';
	document.getElementById('errorEmailEmpty').style.visibility = 'hidden';
	document.getElementById('errorEmailInvalid').style.visibility = 'hidden';
	document.getElementById('errorMessageEmpty').style.visibility = 'hidden';
}

function validateContactForm()
{
	var honeypot = document.getElementById('importantInput').value;
	if(honeypot != "") {
		document.location = "contact.php?messageSent=true";
		return false;
	}
	hideErrorMessages()
	var formIsOk = true;
	var name = document.getElementById('realname').value;
	var email = document.getElementById('email').value;
	var message = document.getElementById('message').value;
	if(name == "" || name == "name")
	{
		document.getElementById('errorNameEmpty').style.visibility = 'visible';
		formIsOk = false;
	}
	if(email == "" || email == "e-mail")
	{
		document.getElementById('errorEmailEmpty').style.visibility = 'visible';
		formIsOk = false;
	}
	if(email != "" && email != "e-mail" && !ValidateEmail(email))
	{
		document.getElementById('errorEmailInvalid').style.visibility = 'visible';
		formIsOk = false;
	}
	if(message == "" || message == "mitteilung")
	{
		document.getElementById('errorMessageEmpty').style.visibility = 'visible';
		formIsOk = false;
	}
	return formIsOk;
}

function ValidateEmail(email)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return reg.test(email);
}

function validateEmailForm(hideFormObjectsOnSuccess){
	var honeypot = document.getElementById('importantInput').value;
	if(honeypot != "") {
		document.location = "contact.php?messageSent=true";
		return false;
	}
	var emailObj = document.getElementById('mce-EMAIL');
	var errorMessageObj = document.getElementById('mce-error-response');
	if(emailObj != null && errorMessageObj != null)
	{
		if(emailObj.value == '' || emailObj.value == 'e-mail')
		{
			errorMessageObj.innerHTML = 'Bitte E-Mailadresse ausf&uuml;llen.'
			errorMessageObj.style.visibility = '';
			return false;
		}
		else if(!ValidateEmail(emailObj.value))
		{
			errorMessageObj.innerHTML = 'Bitte eine g&uuml;ltige E-Mailadresse eingeben.'
			errorMessageObj.style.visibility = '';
			return false;
		}
	}
	errorMessageObj.innerHTML = '';
	if(hideFormObjectsOnSuccess)
	{
		document.getElementById('mce-EMAIL').style.visibility = 'hidden';
		document.getElementById('mc-embedded-subscribe').style.visibility = 'hidden';
	}
	return true;
}

function printContactForm(contactEmail, returnUrl){
document.write(
'<p>',
		'Wenn Sie Fragen zu unserem Angebot oder ein anderes Anliegen haben, rufen Sie uns gerne an oder benutzen das unten stehende Formular.',
		'</p>',
		'<form action="/system-cgi/formmail.pl" method="POST">',
		'	<input type=hidden name="recipient" value="' + contactEmail + '" />',
		'	<input type="hidden" name="subject" value="nordenglueck.de - Kontakt">',
		'	<input type="hidden" name="redirect" value="' + returnUrl + '">',
		'	<input type="hidden" name="required" value="realname,email,message"> ',
		'	<div class="inputElements">',
		'	<span class="formError" id="errorNameEmpty">Bitte Name ausf&uuml;llen</span>',
		'	<br />',
		'	<input type="text" onfocus="setFocus(this,\'name\');" onblur="unSetFocus(this,\'name\')" onmouseover="setHover(this);" onmouseout="unSetHover(this);" class="textinputEmpty" value="name" id="realname" name="realname" size="20" value="" style="width: 220px" maxlength="100" />',
		'	</div>',
		'	<div class="inputElements">',
		'	<span class="formError" id="errorEmailEmpty">Bitte Ihre E-Mail-Adresse eingeben</span><span class="formError" id="errorEmailInvalid">Bitte eine g&uuml;ltige Adresse ausf&uuml;llen</span>',
		'	<br />',
		'	<input type="text" onfocus="setFocus(this,\'e-mail\');" onblur="unSetFocus(this,\'e-mail\')" onmouseover="setHover(this);" onmouseout="unSetHover(this);" class="textinputEmpty" id="email" name="email" size="20" value="e-mail" style="width: 220px" maxlength="100" />',
		'	</div>',
		'	<div class="inputElements">',
		'	<span class="formError" id="errorMessageEmpty">Bitte eine Mitteilung ausf&uuml;llen</span>',
		'	<br />',
		'	<textarea onfocus="setFocus(this,\'mitteilung\');" onblur="unSetFocus(this,\'mitteilung\')" onmouseover="setHover(this);" onmouseout="unSetHover(this);" class="textinputEmpty" id="message" name="message" style="width: 330px; height: 150px;">mitteilung</textarea>',
		'	<textarea class="importantInput" id="importantInput" name="importantInput"></textarea>',
		'	</div>',
		'	<div class="inputElements">',
		'	<input type="submit" class="btn" onclick="return validateContactForm();" onmouseover="setHover(this);" onmouseout="unSetHover(this);" value="mitteilung absenden" name="Submit" />',
		'	</div>',
		'</form>');
}

function printEmailForm() {
document.write(
'<div id="mc_embed_signup">',
' <form action="http://crmundmarke.us1.list-manage.com/subscribe/post?u=31fad08b481ebe1eede44ea7a&amp;id=94f8d39bb3" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">',
'   <input type="text" onfocus="setFocus(this,\'e-mail\');" onblur="unSetFocus(this,\'e-mail\')" onmouseover="setHover(this);" onmouseout="unSetHover(this);" class="textinputEmpty" value="e-mail" name="EMAIL" class="required email" id="mce-EMAIL" style="width: 70%;" />',
'	<textarea class="importantInput" id="importantInput" name="importantInput"></textarea>',
'  <div id="mce-responses">',
'   <div class="formError" style="margin-top: -45px; width: 340px;visibility:hidden;" id="mce-error-response"></div>',
'   <div class="response" id="mce-success-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;position: relative;top: -1.5em;z-index: 1;width: 80%;background: #;color: #529214;"></div>',
'  </div>',
'  <input type="submit" value="senden" onclick="return validateEmailForm(true);" name="subscribe" onmouseover="setHover(this);" onmouseout="unSetHover(this);" id="mc-embedded-subscribe" class="btn" style="margin-top: 5px;">',
' </form>',
'</div>');
}

function setFocus(obj, standardText) {
	obj.className = 'textinput';
	if(obj.value == standardText)
		obj.value = '';
}
function unSetFocus(obj,standardText) {
	if(obj.value == '' || obj.value == standardText) {
		obj.className = 'textinputEmpty';
		obj.value = standardText;
	}
}
function setHover(obj){
	obj.style.borderColor = '#e997c1';
}

function unSetHover(obj){
	obj.style.borderColor = '#ccc';
}