function checkEmail (strng) {
var ret=true;
if (strng == "") {
   ret = false;
}
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       ret = false;
    }
    else {
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          ret = false;
       }
    }
return ret;    
}

var strKlassenName = "novalidate";
function formValidating(objForm){
//alert($(".si_highlight_validate").css("background-color"));
var u1sercolor=$(".si_highlight_validate").css("background-color");//"#ff6666";
var strPattern = eval("/"+strKlassenName+"/");
	  var blnSend = true;
		  for(var i=0; i<objForm.elements.length; i++){

			var objElement = objForm.elements[i];
				if (objElement.type=="text" || objElement.type=="password" || objElement.type=="textarea" ){
				var gr_match1=objElement.value;
				var illegalChars1= /[\(\)\<\>\\\"\[\]]/
				if (gr_match1.match(illegalChars1))  {objElement.style.backgroundColor = u1sercolor; blnSend = false;} else objElement.style.backgroundColor = "";
				}

				if (objElement.type=="text" || objElement.type=="password" )
						if(objElement.className.search(strPattern) == -1){
								if(objElement.value.length <= 3) {
								objElement.style.backgroundColor = u1sercolor; blnSend = false;
								} else if(objElement.value.length >= 3) {
								objElement.style.backgroundColor = "";
								}
								
								if (objElement.name.search("telefonnummer") >=0){
										
										if (objElement.value.length>7) objElement.style.backgroundColor = ""; else {objElement.style.backgroundColor = u1sercolor; blnSend = false;}
								}
								
								if (objElement.name.search("email") >=0){
								var valid=objElement.value;
								if (checkEmail(objElement.value)==true) objElement.style.backgroundColor = ""; else {objElement.style.backgroundColor = u1sercolor; blnSend = false;}
								}
		
							var gr_match=objElement.value;
							var illegalChars= /[\(\)\<\>\\\"\[\]]/
							if (gr_match.match(illegalChars))  {objElement.style.backgroundColor = u1sercolor; blnSend = false;} else if (blnSend == true) objElement.style.backgroundColor = "";
		
				}
				if (objElement.type=="checkbox" )
				if(objElement.className.search(strPattern) == -1){
				  if(objElement.checked == false) {
					objElement.parentNode.style.backgroundColor = u1sercolor; blnSend = false;
				  } else if(objElement.checked == true) {
					objElement.parentNode.style.backgroundColor = "";
				  }
				}

				if (objElement.type=="radio" )
				if(objElement.className.search(strPattern) == -1){
					var boolRadio = false; 
					for(var z=0; z<objForm.elements[objElement.name].length; z++){
						if (objForm.elements[objElement.name][z].checked) {boolRadio = true; }
					}
				  if(boolRadio == false) {
					objElement.parentNode.style.backgroundColor = u1sercolor; blnSend = false;
				  } else if(boolRadio == true) {
					objElement.parentNode.style.backgroundColor = "";
				  }
				}
		  }
		//if (objForm.name=="formID" && ($("#security_pw").val() != $("#ignore_security_pw").val())) {blnSend = false; $("#security_pw").css("background-color","#FF404E"); $("#ignore_security_pw").css("background-color","#FF404E");}

	  return blnSend;
}


$(document).ready(function(){
	
	$(".plugin_kontaktformular input").click( function() {
		$(this).css("background-color","");
		$(this).parent().css("background-color","");
	 } );
	$(".plugin_kontaktformular input").keyup( function() {
		$(this).css("background-color","");
	 } );
	
	
	$("#kontaktform").submit( function() {
		//alert("test");
	  return formValidating(document.getElementById("kontaktform"));
	 } );
});


