function openAGB() {
	agbwin = window.open('http://www.elitepartner.de/km/agb.do','AGBPopup','width=435,height=500,top=50,left=150,scrollbars=yes,status=no,toolbar=no,resizable=yes,location=no');
	if (agbwin.mainwin == null) agbwin.mainwin = self;
	agbwin.focus();
}
function openPrivacyTerms() {
	privacywin = window.open('http://www.elitepartner.de/km/datenschutz.do','PrivacyTermsPopup','width=435,height=500,top=50,left=150,scrollbars=yes,status=no,toolbar=no,resizable=yes,location=no');
	if (privacywin.mainwin == null) privacywin.mainwin = self;
	privacywin.focus();
}
function emailCheck(str) {
     var a = false;
     var res = false;
     if(typeof(RegExp) == 'function') {
         var b = new RegExp('abc');
         if(b.test('abc') == true){a = true;}
     }
     if(a == true) {
         reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                           '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                           '(\\.)([a-zA-Z]{2,4})$');
         res = (reg.test(str));
     } else {
        res = (str.search('@') >= 1 &&
             str.lastIndexOf('.') > str.search('@') &&
             str.lastIndexOf('.') >= str.length-5);
     }
     return(res);
 }

function validateForm(){
    var valid = true;
    var error_text = document.getElementById("ep_error_text");
    error_text.style.display = "none";
	var email_input = document.getElementById("ep_email");
    var error_email = document.getElementById("ep_error_email");
    error_email.style.display = "none";
    var email_label = document.getElementById("ep_email_label");
	if (email_input.value == null || email_input.value == "" || emailCheck(email_input.value) == false){
        email_label.className = "ep_error";
        email_input.className = "ep_error_input";
		email_input.focus();
        error_email.style.display = "block";
        error_text.style.display = "block";
		valid = false;
	} else {
        email_label.className = "";
        email_input.className = "";
    }
    var gender = document.getElementById("ep_gender");
    var gender_label = document.getElementById("ep_gender_label");
    if (gender.options.value == "u" || gender.value == "u") {
        gender.className = "ep_error_input";
        gender_label.className = "ep_error";
        error_text.style.display = "block";
		valid = false;
    } else {
        gender.className = "";
        gender_label.className = "";
    }
    var agb_cb = document.getElementById("ep_agb");
    var error_agb = document.getElementById("ep_error_agb");
    error_agb.style.display = "none";
    if (agb_cb.checked == 0) {
        agb_cb.className = "ep_error_cb";
        error_text.style.display = "block";
        error_agb.style.display = "block";
		valid = false;
    } else {
        agb_cb.className = "";
    }
	return valid;
 }
