function changeCountry ()
    {
    selctlaenge=document.getElementById("ortsname").length;
    for(i=1; i < selctlaenge; i++)
        document.getElementById("ortsname").options[document.getElementById("ortsname").length - 1] = null;
   	
    document.getElementById("plz").value ="";
   	document.getElementById("plz").focus();
   	
    }  
function checkPLZ (inhalt)
    {    
    country=document.getElementById("country").options[document.getElementById("country").selectedIndex].text;
    country_id=document.getElementById("country").options[document.getElementById("country").selectedIndex].value;
  	Makeajax=0;
    if(country=="- Bitte wähle dein Land-" ) 
      {
      alert("Bitte zuerst den Staat auswählen.");
      document.getElementById("country").focus();
      exit;
      }
    if(country == "Österreich")
  	     {
         if (inhalt.length != 4)
            {
            alert("Österreichische Postleitzahl 4 Zahlen erforderlich!");
            document.getElementById("plz").focus();
            }
         else
            {  
            Makeajax=1;
            } 
        }
    else if (country == "Deutschland" )    
          {
          if (inhalt.length != 5)
            { 
          alert("Deutsche Postleitzahl 5 Zahlen erforderlich!");
          document.getElementById("plz").focus();
            }
        else
            {  
            Makeajax=1;
            }  
          }
    else if (country == "Schweiz" && inhalt.length != 4)    
          {
          alert("Schweizer Postleitzahl 4 Zahlen erforderlich!");
          document.getElementById("plz").focus();
          }
    else
        {
        selctlaenge=document.getElementById("ortsname").length;
    
        for(i=1; i < selctlaenge; i++)
            document.getElementById("ortsname").options[document.getElementById("ortsname").length - 1] = null;
   	            
        }
    
    if(Makeajax==1 ) 
        {  
        var myAjax = new Ajax();
        myAjax.url= "../ajax/plzCheck.php";
        myAjax.params="elStiego="+inhalt+"&country="+country_id;
        myAjax.onSuccess=successHandler;
        myAjax.onError=errorHandler;
        myAjax.doRequest();
        } 
     
        
        
    }
  
function successHandler(txt,xml)
    {
  	  	
  	document.getElementById("ortsname").options.length=0;    
    document.getElementById("ortsname").options[0] = new Option("Bitte Ort auswählen");
   
    plz_files=txt.split("\n");
    row=0;    
    for(i=0; i < plz_files.length; i=i+2)
        {
        row++;        
        NeuerEintrag = new Option(plz_files[i],plz_files[i+1], false, true);
        document.getElementById("ortsname").options[row] =  NeuerEintrag;    
          
        }
    document.getElementById("ortsname").selectedIndex = 1;
    
    
    }
    
function errorHandler(msg)
    {  
    document.getElementById("xxx").value=msg;
    
    }
