<!--

function checkValues(theForm)
{
	var formConfig = getFormularConfig(theForm);	
	return checkFields (formConfig);
}	

function getFormularConfig (theForm) {
	
	//alert ("Formular:" + theForm.name);
	var ret;
	
	if (theForm.name == 'GesuchAuftrag') {
	    
	    ret = getFormularConfigKaufgesuch(theForm);
	    return ret.concat(getFormularConfigKunde(theForm));
	}	
	else if (theForm.name == 'ImmoVermittlung') {
		ret = getFormularConfigVermittlung(theForm);
		return ret.concat(getFormularConfigKunde(theForm));	
	}	
	else if (theForm.name == 'OnlinePlattformInserat') {
        ret = getFormularConfigOnlinePlattformInserat(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }  	
	else if (theForm.name == 'PaketAuftrag') {
        ret = getFormularConfigPaketAuftrag(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }   	
    else if (theForm.name == 'IIM NachrichtAgrar') {
        ret = getFormularConfigAgrarFeedback(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }    
	else if (theForm.name == 'IIM ObjektAnfrage') {
        ret = getFormularConfigFeedback(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }    
	else if (theForm.name == 'IIM NachrichtHotel') {
        ret = getFormularConfigFeedbackHotel(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }    
	else if (theForm.name == 'IIM AnfrageCampingplatz') {
        ret = getFormularConfigFeedbackCampingplatz(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }    
	else if (theForm.name == 'Antiquitaetenanfrage') {
        ret = getFormularConfigAntiquitaetenanfrage(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }  
	else if (theForm.name == 'Antiquitaeteninserat') {
        ret = getFormularConfigAntiquitaeteninserat(theForm);
        return ret.concat(getFormularConfigKunde(theForm));    
    }
	else {
		alert("Standardformularpruefung!");	
		return getFormularConfigKaufgesuch(theForm);
	}			
}	

function setTopic(theForm)
{
	theForm.Topic.value = document.referrer;
	theForm.JS_CHECK.value = "True";
}


function checkFields (Testfeld) {
        
    //alert ("Objekte: " + Testfeld.length);
    //Hier wird fuer alle Felder von Leertest ueberprueft, ob sie leer sind
    for (var i = 0; i < Testfeld.length; i++) {
       	//alert("I:" + i + "\nObjekttyp:" + Testfeld[i]["feld"].name + "\nChecktyp:" + Testfeld[i]["feld"].type);
        try { 
        			         		        		
        		// Text, Textarea, File
						if (Testfeld[i]["feld"].type=='text'||Testfeld[i]["feld"].type=='textarea'||Testfeld[i]["feld"].type=='file') {														
							
							if (Testfeld[i]["feld"].value=="") {
								alert( Testfeld[i]["text"] );
								smartforms_setSelection(Testfeld[i]["feld"], 0, 0, 'frEnd');
                Testfeld[i]["feld"].focus();  
								return false;
			 				} 
			 				else {
			 					if (/kd_email/.test(Testfeld[i]["feld"].name)) {				          
				          
				          var mailcheck = checkmail(Testfeld[i]["feld"].value);	
				          //alert("Emailpruefung: " + mailcheck);
				          if (!mailcheck) {
				          	if ( Testfeld[i]["text2"].type != 'undefined') {
				          		alert( Testfeld[i]["text2"] );
				          	}
				          	else {
				          		alert( "eMail-Adresse bitte richtig eingeben!" );
				          	}		
				          	smartforms_setSelection(Testfeld[i]["feld"], 0, 0, 'frEnd');
				          	Testfeld[i]["feld"].focus();
				          	return false;	
				          }					          			        			 					
				 				} 									 				
							}					 					
						}
			  
						// Radio
						else if (Testfeld[i]["feld"].type=='radio') {
							var radiogroup = Testfeld[Testfeld[i]["feld"].name];
					        var itemchecked = false;
					        for(var j = 0 ; j < radiogroup.length ; ++j) {
										if(radiogroup[j].checked) {
											itemchecked = true;
											break;
										}
					        }
					        if(!itemchecked) { 
										//alert( Testfeld[i]["text"] );
		                Testfeld[i]["feld"].focus();  
										return false;
					        }
					        else {
					 					//alert(Testfeld[i]["feld"].name + " -> (" + Testfeld[i]["feld"].value + ")");
					 				}
						}
						
						// Checkbox
						else if (Testfeld[i]["feld"].type=='checkbox') {
								var itemchecked = false;
					      var elems = document.getElementsByTagName("input");
					      for(var j=0; j<elems.length; j++) {
									if(elems[j].type=='checkbox'&&elems[j].name==Testfeld[i]["feld"].name) {
						      	if(elems[j].checked) {
						        	itemchecked = true;
						        	break;
					        	}
					      	}
					      }
					      if(!itemchecked) { 
									alert( Testfeld[i]["text"] );
		              Testfeld[i]["feld"].focus();  
									return false;
								}
								else {
					 					//alert(Testfeld[i]["feld"].name + " -> (" + Testfeld[i]["feld"].value + ")");
					 				}
						}
						
						// Select-one
						else if (Testfeld[i]["feld"].type=='select-one') {
							if (Testfeld[i]["feld"].selectedIndex<0 ) {
									alert( Testfeld[i]["text"] );
		              Testfeld[i]["feld"].focus();  
									return false;
					    } 					    
						}
						
						// Select-multiple
						else if (Testfeld[i]["feld"].type=='select-multiple') {
								var optionselected = false;
								
								
					      for(var j=0;j<Testfeld[i]["feld"].options.length; ++j) {
					      		if (Testfeld[i]["feld"].options[j].selected) {
					      			optionselected = true;
					      			break;
					      		}
					      }
					      if (!optionselected) {
									alert( Testfeld[i]["text"] + " -- " + Testfeld[i]["feld"] );
		              Testfeld[i]["feld"].focus();  
									return false;
					      }					      
						}        	                                            
        }
        catch (e) {
        		
            //alert(e);
            //alert("I:" + i + "\nObjekttyp:" + Testfeld[i]["feld"]); 					
            alert("Fehler: Leider ist ein Fehler beim Verarbeiten des Formulars aufgetreten!");
            return (false);   
        }  
    }
           
    return (true);        
}    

//Prüft ob ein Zeichen aus dem String checkNOK in checkStr vorkommt
//Falls nicht wird true zurückgegeben
function checkString (checkStr, checkNOK) {
  
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkNOK.length;  j++)
      if (ch == checkNOK.charAt(j)) {
        allValid = false;
        break;
    }
    if (!allValid) break;
  }
  return (allValid);
}



function checkmail(email) {                                      
    var ausdruck=/^[\w-\.]+@[\w-\.]+\.[a-zA-Z]{2,4}$/;          
     
    // alert(email + " -> " + email)
                                                                            
    if(ausdruck.test(email)==false||email.length<8){                            
        return false;                                              
    }
    return true                                                                                                                          
}  

// ----- setSelection ----------------------------------------------------------

function smartforms_setSelection(control, start, end, mode)
{
  control.focus();

  // ----- Netscape -----

  if (control.selectionStart !== undefined &&
      control.selectionEnd   !== undefined)
  {
    offset = control.selectionStart;
    if (mode == 'frStart') offset = 0;
    if (mode ==   'frEnd') offset = control.textLength;

    control.selectionStart = offset+start;
    control.selectionEnd   = offset+end;

    return true;
  }

  // ----- IE -----

  if (control.select                 !== undefined &&
      document.selection             !== undefined &&
      document.selection.createRange !== undefined)
  {
    if (mode == 'frStart' || mode == 'frEnd') control.select();

    range = document.selection.createRange();

    if (mode == 'frStart') range.moveEnd  ("character", -range.text.length);
    if (mode == 'frEnd')   range.moveStart("character",  range.text.length);

    range.moveStart("character", start);
    range.moveEnd  ("character", end);
    range.select();

    return true;
  }

  return false;
} 

//-->