/*
ACHTUNG ORIGINALDATEI BEFINDET SICH HIER: originalvalidateForm.js
*/
function validate(f,cerror,cnorm,ctext){
	vret = true;
	for(i = f.length-1;i>=0;i--){
		returnor = true;
		if(f[i].getAttribute("needed") != null){
			if(f[i].type == "text" || f[i].type == "textarea" ){
				if(f[i].value == ""){
					//f[i].style.border = "1px solid "+cerror;
					//f[i].parentNode.parentNode.style.color = cerror;
					
					if(returnor){
						f[i].focus();
					}
					returnor = false;
				}else{
					//f[i].style.border = "1px solid "+cnorm;
					//f[i].parentNode.parentNode.style.color = ctext;
				}
				
				if(f[i].getAttribute("needed") == "email" && f[i].value.search("@") == -1){
					//f[i].style.border = "1px solid "+cerror;
					//f[i].parentNode.parentNode.style.color = cerror;
					
					if(returnor){
						f[i].focus();
					}
					returnor = false;
				}
				
				if(f[i].getAttribute("needed") == "date"){
					try{
						var year = f[i].value.split(".")[2];
						var month = f[i].value.split(".")[1];
						var day = f[i].value.split(".")[0];
						
						if(year < 1900){
							if(returnor){
								f[i].focus();
							}
							returnor = false;
						}else if(!(month >= 1 && month <= 12)){
							if(returnor){
								f[i].focus();
							}
							returnor = false;
						}else if(!(day >= 1 && day <= 31)){
							if(returnor){
								f[i].focus();
							}
							returnor = false;
						}else if(
								 (month==4 
							   || month==6
							   || month==9
							   || month==11)
							   && day > 30
								 ){
							if(returnor){
								f[i].focus();
							}
							returnor = false;
						}else if(
								 (month==4 
							   || month==6
							   || month==9
							   || month==11)
							   && day > 30
								 ){
							if(returnor){
								f[i].focus();
							}
							returnor = false;
						}else if(month==2){
							schaltjahr = false;
							if(year%4==0){
								if(year%100!=0||year%400==0){
									schaltjahr=true
								}
							}
							if(schaltjahr){
								if(day>29){
									if(returnor){
										f[i].focus();
									}
									returnor = false;
								}
							}else{
								if(day>28){
									if(returnor){
										f[i].focus();
									}
									returnor = false;
								}
							}
						}
						
					}catch(x){
						if(returnor){
							f[i].focus();
						}
						returnor = false;
					}
					
					if(returnor == false){
						//f[i].style.border = "1px solid "+cerror;
						//f[i].parentNode.parentNode.style.color = cerror;
						
					}
					
				}
				
			}else{
				if(!f[i].checked){
					f[i].parentNode.style.color = cerror;
					if(returnor){
						f[i].focus();
					}
					returnor = false
				}else{
					f[i].parentNode.style.color = ctext;
				}
			}
			if(returnor){
				f[i].style.border = "1px solid "+cnorm;
				f[i].style.backgroundColor = "#ffffff";
			}else{
				f[i].style.border = "1px solid "+cerror;
				f[i].style.backgroundColor = "#f2e6ed";
				vret = false;
			}
		}
	}
	
	
	return vret;
}