String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
}

function show_hide(thisObj,bVal, textVal)
{

  	styleObj=document.getElementById(thisObj).style;
  	bVal?( styleObj.display ='block'):(styleObj.display ='none');
	document.getElementById(thisObj).innerHTML = (textVal) ? textVal:"";

}



function emptyvalidation(entered)
{

	myval = entered.value.trim();	

		if (myval==null || myval=="")
		{return false;}
		else {return true;}

}

function validate_email(field)
{
	


	with (field)
	{
	apos=value.indexOf("@")
	dotpos=value.lastIndexOf(".")
	if (apos<1||dotpos-apos<2) 
	  {return false}
	else {return true}
	}
}

function validateForm(myForm)
{

	var bValidation = true;
	with (myForm){
		if(emptyvalidation(Name) == false){
			show_hide('txt_err', true, "Bitte Ihren Namen eingeben.");
			Name.focus();
			bValidation = false;
			return bValidation;
		}
		else show_hide('txt_err', false, "");		
		

		if (validate_email(EmailAdresse) == false) {

			show_hide('txt_err', true, "Bitte Ihre E-Mail Adresse eingeben.");
			EmailAdresse.focus(); 
			bValidation = false;
			return bValidation;
		}
		else show_hide('txt_err', false, "");		

		return bValidation;										
	}

}
