<!--

function CheckCar(theForm, sstat, vtype,act){
	/* The action flag determines if it is a new car or an existing car being edited. */
  var error = false

  with (theForm){
    if (act == 1){
       if ( model.value.length < 2){
	  alert("Please enter a model")
	  error = true
       }
     
       if (!error && (year.value < 1900 || isNaN(year.value))){
	  alert("Sie haben ein falsche Jahr eingegeben - Bitte in Format JJJJ eingeben.\n" +
	    "Überprüfen Sie auch, ob dieses Jahr existiert!.")
	  error=true
       }
  
       if (!error && color.selectedIndex == 0){
	  alert("Bitte wählen Sie eine Farbe");
          error = true;
       }
    }
    if (!error && (odo.value < 0 || isNaN(odo.value))){
	alert("Bitte geben Sie den Kilometer Stand ein")
	error = true
    }

    if(!error && ((price.value < 100) || isNaN(price.value))){
	alert("Bitte geben Sie den Preis korrekt ein.\nDas System formatiert den Preis selbst!\nBitte einfach für 10.000 € nur 10000 eingeben !")
	error = true
    }

    if (extras4.checked && !error){
	if (odo.value > 1000){
	     alert("Sie bezeichnen ein Fahrzeug, das mehr als 1000 KM hat als neu ??.\n" +
		"Wir erlauben nur Eingaben bis 1000 KM als Neufahrzeug für dieses Inserat!\n" +
		"Bitte korrigieren oder Option neu ausschalten.");
             error=true;
        }
    }
    if ((vtype == 'car') || (vtype == 'ldv')){
       if (extras5.checked && !error){
	  motorplan.value= motorplan.value.toUpperCase()
          if (motorplan.value.length < 10){
	     alert("Bitte Service Details eingeben oder Option ausschalten.")
	     error = true
          }

          else if (motorplan.value.length > 80){
	      alert("Bitte nicht mehr als 80 Zeichen für Services eintragen.\n"+
		"Sie nutzen derzeit " + motorplan.value.length +
		" Zeichen."); 
	      error = true;
	  }
       }

       if (!error && motorplan.value.length > 0){
	  if (!extras5.checked){
	     alert("Bitte die Option eingetragene Services deaktivieren, \n" +
		"wenn Sie keine Services eintragen!");
	     error=true;
          }
       }
    }

    if (!error){
        if (remarks.value.length > 700){
	   alert("Ihr weitere Extras/Bemerkungen Feld ist zu lang.\nEs enthält "+ 
		remarks.value.length + " Buchstaben.");
	   error = true;
        }
    }

  if (!error && sstat == 0)
        error = CheckUser(theForm);

    if (!error && (act == 1)){
        st = "Sie haben folgende Daten eingegeben:\n" + 
	"Hersteller: " + make[make.selectedIndex].value + "\n" +
	"Modell: " + model.value + "\n" +
	"Baujahr: " + year.value + "\n" + 
	"Kategorie: "+ category[category.selectedIndex].value + "\n" +
	"Farbe: " + color[color.selectedIndex].value + "\n" +
	"Km Stand: " + odo.value + "\n" +
	"Preis: " + price.value + "\n" +
	"Bemerkungen : " + remarks.value +"\n"
	
	if ((vtype == 'ldv') || (vtype == 'car')){
           if (extras5.checked)
	      st = st + "Services: " + motorplan.value + "\n"
        }
        error = !confirm(st)
    } 
  }
  return !error
}  	


function unWanted(term, crap){
  var err = false;

  for (i =0; i < term.length; i ++){
    c = term.charAt(i);
    if (err = crap.indexOf(c) >= 0)
       break; 
  } 
  return err;
}


function CheckUser(theForm){

  var error = false

  with (theForm){
    crap = "`~1234567890!@#$%^&*()+_=|\{}[]:;'<>?,/";
    if ((name.value.length < 5) || unWanted(name.value, crap)){
	alert("Entweder ist Ihr Name zu kurz, oder Sie haben " +
		"unerlaubte Zeichen verwendet.\n Bitte überprüfen.")
	error = true
    }
    crap ="~`!@#$%^&*()_-+=\|}{[]';:?/><,";
    if (!error && ((addr1.value.length > 0) && unWanted(addr1.value, crap))){
	alert("Ihre Adresse enthält nicht erlaubte Zeichen.\n"+
		"Bitte überprüfen")
	error = true
    } 
    crap="~!@#$%^&*()_+|`1234567890=\{}[]:;'<>?,";
    if (!error && ((city.value.length < 3) || unWanted(city, crap))){
	alert("Der Stadtname ist zu Kurz oder enthält nicht erlaubte Zeichen.")
	error = true
    }

    if (!error && province[province.selectedIndex].value == "null"){
	alert("Bitte wählen Sie eine Region");
        error=true;
    }

   crap="~!@#$%^&*()_+|\=-[]{}:;'?/.,<>qwertyuiopasdfghjklmnbvcxz";
    if (!error && (unWanted(worktel.value.toLowerCase(), crap) ||
	unWanted(hometel.value.toLowerCase(), crap) ||
	unWanted(faxno.value.toLowerCase(), crap) ||
	unWanted(cellno.value.toLowerCase(), crap))){
       alert("Bitte nur Zahlen und Leerzeichen für Telefonnummern verwenden!");
       error = true;
    } 
  } 
  return error 
}	

function MakeType(theForm){

  url = top.location.href + "&type=" +
	theForm.types[theForm.types.selectedIndex].value; 
  window.location = url;
//  alert(url);  
  return false;
} 


function ShowPic(pic){


  detail = window.open("", "detail", 	
	"scrollbars=1,status=0,width=400,height=400");  
  detail.document.open()
  with (detail.document){
  	write("<html><head><title>Weitere Bilder</title></head>\n") 
  	write("<body bgcolor=\"#345574\" text=\"#00FFFF\">\n")
  	write("<center><img src=\"/pictures/" + pic + "\">\n")
  	write("<form>\n")
  	write("<input type=\"button\" value=\"schliessen\" "+
		" onClick=\"window.close()\">\n");
  	write("</form>\n");
	write("</body></html>\n");
  }
  detail.document.close();
  detail.focus();
  return false;
}

function Searchfunc(n, count, max){

  var result = false
  if (n == 3){
     if (count > 0)
        history.go(count * (-1))
     else
	history.go(-1)
  }

  if (n == 2){
     if (count < max)
        result = true 
  }

  if (n == 1){
     if (count > 1) 
     result = true
  }

  if (n == 4){
     url = location.protocol +"//"+ location.host + "/index.php?action=search"
     window.location = url
  }
  return result
} 

function MailFriend(carid){

  aWindow = window.open("", "aWindow", "width=380,height=200");
  aWindow.document.open();
  with (aWindow.document){
     write("<html><head></head><body bgcolor=\"#345574\" text=\"#00FFFF\">\n");
     write("<center><font=\"Arial\"><b>Empfehlen Sie dieses Fahrzeug</b></center><p>\n");

     write("<form action=\"index.php?action=mailfriend&carid="+ carid +
	"\"\n\t method=\"post\">\n");
     write("Ihre Email Adresse <input type=\"text\" name=\"mymail\" size=25 maxlength=50><p>\n");
     write("Empfänger Email    <input type=\"text\" name=\"friendmail\" size=25 maxlength=50><p>\n");
     write("<center><input type=\"submit\" value=\"Fahrzeug empfehlen\" ></center>");
     //	"onClick=\"window.close()\"></center>\n");
     write("</form>\n");
     write("</body></html>\n");
  }  
  aWindow.document.close();  
  aWindow.focus();  
  return false

}

function DealerInput(theForm){

  var result = false;
  with (location)
     alert(query);

  return result;
}

function Features(theForm){

  with (theForm){
     fcount.value =699 - remarks.value.length;
     if (fcount.value < 0)
	alert("Weitere Eingaben werden ignoriert");
  }

}

function Motorplan(theForm){

  with (theForm){
     mcount.value= 79 - motorplan.value.length;
     if (mcount.value < 0)
	alert("Weitere Eingaben werden ignoriert");
  }
}

/*
* Sicherheitsabfrage für Löschanfragen
* Created by sven koechel> on 31.10.2004
*/
function delete_warn(name, url_ver, url_dec) {
	var delok;
	delok = confirm ("Wollen Sie das Fahrzeug '" + name +"' wirklich aus Ihrer Beobachtungsliste entfernen?");
	if  (delok==true ) {
		// window.location.href = url_ver;
		window.document.delconfirm.action = url_ver;
	} else {
		// window.location.href = url_dec;
		// document.delconfirm.action = url_dec;
		window.document.delconfirm.action = '#';
	}
}


// -->
