function trim (str) {

                                var c = "";
                                var trim_left = 0;
                                var trim_right = 0;
                                for (var i = 0; i < str.length; i++) {
                                                                c = str.charAt(i);
                                                                if (c == ' ' || c == '\t') {
                                                                                                trim_left++;
                                                                }
                                                                else {
                                                                                                break;
                                                                }
                                }
                                for (var i = str.length - 1; i >= 0; i--) {
                                                                c = str.charAt(i);
                                                                if (c == ' ' || c == '\t') {
                                                                                                trim_right++;
                                                                }
                                                                else {
                                                                                                break;
                                                                }
                                }
                                return str.substr(trim_left, str.length - (trim_left + trim_right));
}

function checkEmailForm(){

        var fm=document.sendMailForm ;

        if (trim (fm.NAME.value) == '') {
                 alert ("Bitte geben Sie Ihren Namen ein."+"\nDer Eintrag wurde nicht gespeichert.");
                 fm.NAME.focus();
                return false;
        }
        if (trim (fm.EMAIL.value) == '') {
                 alert ("Bitte geben Sie Ihre Email ein."+"\nDer Eintrag wurde nicht gespeichert.");
                 fm.EMAIL.focus();
                return false;
        }else{
                   if(!chkmail(trim (fm.EMAIL.value))){

                        alert ("Bitte überprüfen Sie das Format Ihrer Email."+"\nDer Eintrag wurde nicht gespeichert.");
                fm.EMAIL.focus();
                return false;
                   }

                }
				
		if (trim (fm.FRAGEN.value) == '') {
                 alert ("Bitte geben Sie eine Nachricht ein."+"\nDer Eintrag wurde nicht gespeichert.");
                 fm.FRAGEN.focus();
                return false;
        }

                return true;
}

function chkmail(mail) {
                        var str = mail;
                        return        (null == str.match(/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/)) &&
                                        (null != str.match(/^.+@\[?[a-zA-Z0-9\._\-]+\]?$/)) &&
                                        (null != str.match(/\.([a-zA-Z]{2,3}$)|([0-9]{1,3}\]?$)/));
}