function change(x)
  {
    if (x==-1)
      {
        document.suchformular.gebiet.options.length=1;
        document.suchformular.weingut.options.length=1;
        document.suchformular.gebiet.options[0].text="Bitte Land wählen";
        document.suchformular.weingut.options[0].text="Bitte Land wählen";
      }
    else
      {
        document.suchformular.gebiet.options.length=a_gebiet[x].length/2+1;
        document.suchformular.weingut.options.length=a_weingut[x].length/2+1;
        document.suchformular.gebiet.options[0].text="egal";
        document.suchformular.weingut.options[0].text="egal";
 
        for(i = 0; i < a_gebiet[x].length; i+=2)
          {
            document.suchformular.gebiet.options[i/2+1].text=a_gebiet[x][i+1];
            document.suchformular.gebiet.options[i/2+1].value=a_gebiet[x][i];
          }

        for(i = 0; i < a_weingut[x].length; i+=2)
          {
            document.suchformular.weingut.options[i/2+1].text=a_weingut[x][i+1];
            document.suchformular.weingut.options[i/2+1].value=a_weingut[x][i];
          }
        return;
      }
  }

function loadForm() 
  {
    // Initialisiert das Formular

    var elnam = new String();

    var order = new String(getCookie("Wein-Web"));
	
    for (var i = 0; i < document.formular.elements.length; i++)
      { 
        if (document.formular.elements[i].type == "text")
          {
	    document.formular.elements[i].value = getQty(order, document.formular.elements[i].name);
  	  }	
      }
    return null;
  }

function getQty(str, name2evaluate) 
  {
    // Ermittelt aus der Zeichenkette str den Wert zwischen Schluessel item2delete und dem naechsten Semikolon

    var objnam = new String(name2evaluate + ",");

    var delbgn = str.indexOf(objnam);

    if (delbgn < 0) 
      {
        return "0"; 
      }
    else 
      {
        var varbgn = delbgn + objnam.length;
	varend = str.indexOf("$", delbgn);
	return str.substring (varbgn, varend);
      }
  }	

function getCookie (coknam)
  {
    var doccok = document.cookie; 
    coknam = coknam + "=";
    var coklen = doccok.length;
    var cokbgn = 0;

    while (cokbgn < coklen)
      {
        var varbgn = cokbgn + coknam.length;
		
        if (doccok.substring(cokbgn, varbgn) == coknam)
          { 
            var varend = doccok.indexOf (";", varbgn);

            if (varend == -1) varend = coklen;
            return unescape(doccok.substring(varbgn, varend));
          }
         
        cokbgn = doccok.indexOf(" ", cokbgn) + 1;
 
        if (cokbgn == 0) break;
      }
    return "";
  }

function fenster(wert)
  {
    F1=open("weinsuche.pl?aktion=weindetail&weindetail=" + wert + "&treffer=" + document.suchformular.treffer.value ,"Weindetail","width=420,height=480,screenX=0,screenY=0");
  }

function druckansicht()
  {
    F1=open("weinsuche.pl?aktion=druckansicht&treffer=" + document.suchformular.treffer.value ,"Druckansicht","screenX=0,screenY=0, scrollbars=yes, resizable=yes, menubar=yes, toolbar=yes");
  }

function weindetail_gv(wert)
  {
	treffer     = document.suchformular.treffer.value;
	gv_artnr    = document.formular.gv_artnr.value;
	gv_flaschen = document.formular.gv_flaschen.value;

    F1=open("geschenk.pl?weindetail=" + wert + "&treffer=" + treffer + "&gv_artnr=" + gv_artnr + "&gv_flaschen=" + gv_flaschen ,"Weindetail","width=420,height=480,screenX=0,screenY=0");
  }

function gv_fenster(wert)
  {
    F1=open("weinsuche.pl?aktion=gv_bild&artnr=" + wert,"Weindetail","width=320,height=450,screenX=0,screenY=0");
  }  

function warenkorb()
  {
    var inhalt ="";

    for (var i = 0; i < document.formular.elements.length; i++)
      {
        elnam = document.formular.elements[i];

        if (elnam.type == "text")
          {
            inhalt = inhalt + elnam.name + ";";     
          }
      }
    document.formular.weine.value = inhalt;
    document.formular.submit();
  }


function check_user_data()
  {
    if (document.suchformular.jahr.value.search(/[^0-9]/) != -1)
      {
        alert ("Bitte geben Sie im Formularfeld \"Jahrgang\" nur Zahlen ein !");
        document.suchformular.jahr.focus();
        document.suchformular.jahr.select();
        return false;
      }

    if (document.suchformular.suchbegriffe.value.search(/[^a-zA-Z\säÄöÖüÜ-]/) != -1)
      {
        alert ("Bitte geben Sie im Formularfeld \"Suchbegriffe\" nur Worte ein !");
        document.suchformular.suchbegriffe.focus();
        document.suchformular.suchbegriffe.select();
        return false;
      }

    if (document.suchformular.farbe.selectedIndex==0 && 
        document.suchformular.preis.selectedIndex==0 &&
        document.suchformular.jahr.value=="" &&
        document.suchformular.land.selectedIndex==0 &&
        document.suchformular.weingut.selectedIndex==0 &&
        document.suchformular.gebiet.selectedIndex==0 &&
        document.suchformular.suchbegriffe.value=="")
      {
        alert ("Bitte geben Sie wenigstens 1 Suchkriterium an !")
        return false;
      }

    document.suchformular.erg_seite.value=0;
  }

function check_user_data_druck()
  {
    if (document.suchformular.jahr.value.search(/[^0-9]/) != -1)
      {
        alert ("Bitte geben Sie im Formularfeld \"Jahrgang\" nur Zahlen ein !");
        document.suchformular.jahr.focus();
        document.suchformular.jahr.select();
        return false;
      }

    if (document.suchformular.suchbegriffe.value.search(/[^a-zA-Z\säÄöÖüÜ-]/) != -1)
      {
        alert ("Bitte geben Sie im Formularfeld \"Suchbegriffe\" nur Worte ein !");
        document.suchformular.suchbegriffe.focus();
        document.suchformular.suchbegriffe.select();
        return false;
      }

    document.suchformular.erg_seite.value=0;
  }
  
function seite(wert)
  {
    document.suchformular.erg_seite.value=wert;
    document.suchformular.submit(); 
  }


function absenden()
  {
    var inhalt ="";

    for (var i = 0; i < document.formular.elements.length; i++)
      {
        elnam = document.formular.elements[i];

        if (elnam.type == "text")
          {
            inhalt = inhalt + elnam.name + ";";     
          }
      }
   
    document.formular.weine.value = inhalt;
    document.formular.aktion.value="userdaten";


    if (document.formular.weine.value)
      {
        document.formular.submit();
      }
    else
      {
        alert("Ihr Warenkorb ist zur Zeit noch leer !")
      }
  }
