function fromChanged(what) {
  var v1 = document.forms.buch.p_datvon_mon.options[document.forms.buch.p_datvon_mon.selectedIndex].value.split(".");
  document.forms.buch.p_datvon.value=document.forms.buch.p_datvon_day.options[document.forms.buch.p_datvon_day.selectedIndex].value + "." + 				                   document.forms.buch.p_datvon_mon.options[document.forms.buch.p_datvon_mon.selectedIndex].value;
}


function submit_zimmersuche() {
  document.forms.buch.anzeige.value="0";
  document.forms.buch.submit();
}

function get_dfl(arr, val) {
	var len = eval('new_'+arr+'_idx'+'.length');
	for (i=0;i<len;i++) {
		nam = 'new_' + arr + '_idx [' + i + ']';
	    txt = eval(nam);
		if (txt==val) {
			break;
		}
	}
  return(eval('new_'+arr+'_def['+i+']'));
}

function getIndex(combo,line) {
  var i=0, cnt=0;
  while (i < document.forms.buch.elements.length) {
    if (document.forms.buch.elements[i].name==combo) {
	  cnt++;
	  if (cnt==line)
	    break;
    }       
	i++;
  }	
  return i;
}

function getElementIndex(elidx,val) {
  var i=document.forms.buch.elements[elidx].options.length-1;
  while (i > 0) {
    if (document.forms.buch.elements[elidx].options[i].value==val)
      break;
	i--;
  }	
  return i;
}

function fillCombo(combo, arr) {
  var len = eval(arr + ".length"), i=0;
  for(i = 0; i < len; i++) {
    txt = eval(arr + "[" + i + "]");
    o = new Option;
    var a = /(.*)\|(.*)/;
    a.exec(txt);
    o.text  = RegExp.$1;
    o.value = RegExp.$2;
    document.forms.buch.elements[combo].options[i] = o;
  }
  document.forms.buch.elements[combo].selectedIndex = 0;
}

function comboChanged(combo, line, other, arr) {
  otheridx = getIndex(other,line);
  document.forms.buch.elements[otheridx].length=0;
  comboidx = getIndex(combo, line);
  idx = document.forms.buch.elements[comboidx].selectedIndex;
  val = document.forms.buch.elements[comboidx].options[idx].value;
  fillCombo(otheridx, arr + "_" + val);
  document.forms.buch.elements[otheridx].selectedIndex = getElementIndex(otheridx,get_dfl(arr,val));
}

function comboInit(combo, line, arr) {
  comboidx = getIndex(combo, line);
  document.forms.buch.elements[comboidx].length=0;
  fillCombo(comboidx, arr);
}

function do_options(lines) {
  var i;
  for (i=0;i<lines;i++) document.write("<OPTION>");
}
