var cal1_last_active = "0";
var cal2_last_active = "0";
var bu_change_active = 0;

function open_buchung(wie)
{
  objshadow = document.getElementById("rightshadowbox");
  objrahmen = document.getElementById("rightrahmenbox");
  objright = document.getElementById("rightbox");
  objkfz = document.getElementsByName("carsel");
  if(objshadow && objrahmen && objright)
  {
  	if(wie == 1){
	  objshadow.style.visibility = "visible";
	  objrahmen.style.visibility = "visible";
	  objright.style.visibility = "visible";
      if(objkfz[0]) objkfz[0].style.visibility = "visible";
      bu_move_set_pfeile(1);
      //stop movement angebote
      if(objtimeout) window.clearTimeout(objtimeout);
    } else {
	  objshadow.style.visibility = "hidden";
	  objrahmen.style.visibility = "hidden";
	  objright.style.visibility = "hidden";
	  bu_cabin_select(2);
      bu_open_cabin_select(0);
      if(objkfz[0]) objkfz[0].style.visibility = "hidden";
      bu_move_set_pfeile(0);
      //continue move angebote
      var objangeb = document.getElementById("leftibox");
      if(objangeb){
      	var val = parseInt(objangeb.style.left);
      	objtimeout = window.setTimeout("move_angeb(" + val + ")", 50);
      }
  	}
  }
}

function bu_clear_price()
{
  objKP = document.getElementById("buCP");
  if(objKP) objKP.innerHTML = '-';
  objKP = document.getElementById("buKP");
  if(objKP) objKP.innerHTML = '-';
  objKP = document.getElementById("buGP");
  if(objKP) objKP.innerHTML = '-';
}

function bu_chanched(wer, was)
{
  //alert(wer + "ist ein:" + typeof(wer) + " was=" + was);
  switch(was){
  case 1:	//Strecke
    //GbuType: Bitfeld: 0x01=Hin und Zurück,   Abfahrt von 0=Hel, 0x02=Spb
    if(typeof(wer) == "object"){
      if(wer.value == "HELSPB") GbuType  &= (~0x02);
  	  else GbuType |= 0x02;
  	  fill_cal("1", GbuHinMth, GbuHinYar, GbuType);
  	  fill_cal("2", GbuHinMth, GbuHinYar, GbuType);
  	  bu_clear_price();
  	  GbuHinDay = 0;
  	  GbuRueDay = 0;
      //bu_get_update();
    }
    break;
  case 3:	//hin
    GbuType &= (~0x01);
  	objcalr = document.getElementById("calr");
  	if(objcalr){
  	  if(mybrowser == "ff") objcalr.style.opacity = 0.4;
  	  if(mybrowser == "ie") objcalr.style.filter = "Alpha(opacity=50)";;
  	}
    if(cal2_last_active != "0"){	//no background at old
  	  objcal = document.getElementById(cal2_last_active);
      if(objcal) objcal.style.backgroundColor = "#fff0f0";
      GbuRueDay = 0;
    }
    bu_get_update();
    break;
  case 4:	//hin und rueck
    GbuType |= 0x01;
  	objcalr = document.getElementById("calr");
  	if(objcalr){
  	  if(mybrowser == "ff") objcalr.style.opacity = 1.0;
  	  if(mybrowser == "ie") objcalr.style.filter = "Alpha(opacity=100)";;
  	}
    bu_get_update();
  	break;
  case 5:	//click in calender
    if(typeof(wer) == "object"){
      //alert("id=" + wer.id + " text:" + wer.innerHTML);
      if(wer.innerHTML == "") break;
      if(parseInt(wer.style.color.substring(4,7)) > 128) break;
//alert(parseInt(wer.style.color.substring(4,7)));      
      if(wer.id.substr(0,4) == "cal1"){
      	if((GbuRueDay > 0) && (GbuType & 0x01)){
      	  if( ((GbuRueYar * 10000) + (GbuRueMth * 100) + GbuRueDay) < ((GbuHinYar * 10000) + (GbuHinMth * 100) + parseInt(wer.innerHTML)) ){
      	  	alert("Rückfahrt vor Hinfahrt?\nBitte erst die Rückfahrt setzen!");
      	    break;  //not valid
      	  }
      	}
        if(cal1_last_active != "0"){	//no background at old
  		  objcal = document.getElementById(cal1_last_active);
      	  if(objcal) objcal.style.backgroundColor = "#f0fff0";
        }
        cal1_last_active = wer.id;
        GbuHinDay = parseInt(wer.innerHTML);
        wer.style.backgroundColor = "#80FF80";
      } else {
      	if((GbuType & 0x01) == 0) break;
      	if(GbuHinDay > 0){
      	  if( ((GbuRueYar * 10000) + (GbuRueMth * 100) + parseInt(wer.innerHTML)) < ((GbuHinYar * 10000) + (GbuHinMth * 100) + GbuHinDay) ){
      	  	alert("Rückfahrt vor Hinfahrt?\nBitte erst die Hinfahrt setzen!");
      	    break;  //not valid
      	  }
      	}
        if(cal2_last_active != "0"){	//no background at old
  		  objcal = document.getElementById(cal2_last_active);
      	  if(objcal) objcal.style.backgroundColor = "#fff0f0";
        }
        cal2_last_active = wer.id;
        GbuRueDay = parseInt(wer.innerHTML);
        wer.style.backgroundColor = "#FF8080";
      }
      bu_get_update();
    }
    break;
  case 6:	//monat dec
    if(typeof(wer) == "number"){
	  //alert(GbuHinMth + " " + GbuHinYar);
      if(wer == 1){
      	if( ((GbuHinYar * 100) + GbuHinMth) < ((todayyear * 100) + todaymonth) ) break;
      	if(GbuHinMth == 0){
      	  GbuHinMth = 11;
      	  GbuHinYar = GbuHinYar -1;
    	} else {
    	  GbuHinMth = GbuHinMth -1;
    	}
    	fill_cal("1", GbuHinMth, GbuHinYar, GbuType);
      } else {
      	if( ((GbuRueYar * 100) + GbuRueMth) < ((todayyear * 100) + todaymonth) ) break;
      	if( ((GbuRueYar * 100) + GbuRueMth) > ((GbuHinYar * 100) + GbuHinMth) ){
      	  if(GbuRueMth == 0){
      	    GbuRueMth = 11;
      	    GbuRueYar = GbuRueYar -1;
    	  } else {
    	    GbuRueMth = GbuRueMth -1;
    	  }
          fill_cal("2", GbuRueMth, GbuRueYar, GbuType);
        }
      }
      GbuHinDay = 0;
      GbuRueDay = 0;
  	  bu_clear_price();
	}
    break;
  case 7:	//monat inc  
    if(typeof(wer) == "number"){
      if(wer == 1){
      	if(GbuHinMth == 11){
      	  GbuHinMth = 0;
      	  GbuHinYar = GbuHinYar +1;
    	} else {
    	  GbuHinMth = GbuHinMth +1;
    	}
    	fill_cal("1", GbuHinMth, GbuHinYar, GbuType);
      	if( ((GbuRueYar * 100) + GbuRueMth) < ((GbuHinYar * 100) + GbuHinMth) ){
      	  GbuRueMth = GbuHinMth;
      	  GbuRueYar = GbuHinYar;
      	  fill_cal("2", GbuRueMth, GbuRueYar, GbuType);
      	}
      } else {
      	if(GbuRueMth == 11){
      	  GbuRueMth = 0;
      	  GbuRueYar = GbuRueYar +1;
    	} else {
    	  GbuRueMth = GbuRueMth +1;
    	}
    	fill_cal("2", GbuRueMth, GbuRueYar, GbuType);
      }
      GbuHinDay = 0;
      GbuRueDay = 0;
  	  bu_clear_price();
	}
    break;
  case 8:
    if(typeof(wer) == "object"){
      GbuKabin = wer.value;
      bu_get_update();
    }
    setDebugTest("change");
    bu_change_active = 1;
    bu_cabin_select(2);
    if((GbuKabin == "CM") || (GbuKabin == "D2"))
    {
      objverpf2 = document.getElementsByName("frühstück2");
      if(objverpf2[0]){
      	objverpf2[0].checked = true;
      }
      GbuVer2 = "1";
    }
    break;
  case 9:
    if(typeof(wer) == "object"){
      GbuCar = wer.value;
      bu_get_update();
    }
    objbusl = document.getElementById("buslenghtbox");
    if(objbusl){
      if(GbuCar.substr(0,1) == "B") objbusl.style.visibility = 'visible';
      else objbusl.style.visibility = 'hidden';
    }
    break;
  case 10:	//Erwachsene
    if(typeof(wer) == "object"){
      GbuPers = parseInt(wer.value);
      bu_get_update();
    }
    break;
  case 11:
    if(typeof(wer) == "object"){
      GbuKabin = wer.id;
      objcabintext = document.getElementById("cabinTableresult");
      if(objcabintext)
      {
      	objcabintext.innerHTML = wer.innerHTML;
      }
      bu_get_update();
    }
    bu_cabin_select(2);
    bu_open_cabin_select(0);
    if((GbuKabin == "CM") || (GbuKabin == "D2"))
    {
      objverpf2 = document.getElementsByName("frühstück2");
      if(objverpf2[0]){
      	objverpf2[0].checked = true;
      }
      GbuVer2 = "1";
    }
    break;
  case 12:	// Kinder bis 11
    if(typeof(wer) == "object"){
      GbuKind = parseInt(wer.value);
      bu_get_update();
    }
    break;
  case 13:	// City Bus Tour
    if(typeof(wer) == "object"){
      if(wer.checked)
        GbuCbt = "1";
      else
        GbuCbt = "0";
      bu_get_update();
    }
    break;
  case 14:	// Bus laenge
    if(typeof(wer) == "object"){
      GbuCarLen = parseInt(wer.value);
      bu_get_update();
    }
    break;
  case 15:	// frühstück-Buffet
    if(typeof(wer) == "object"){
      if(wer.checked)
        GbuVer1 = "1";
      else
        GbuVer1 = "0";
      bu_get_update();
    }
    break;
   case 16:	// frühstück-a la carte
    if(typeof(wer) == "object"){
      if(wer.checked)
        GbuVer2 = "1";
      else
        GbuVer2 = "0";
      bu_get_update();
    }
    break;
  case 17:	// Abend-Buffet
    if(typeof(wer) == "object"){
      if(wer.checked)
        GbuVer3 = "1";
      else
        GbuVer3 = "0";
      bu_get_update();
    }
    break;
 }
  var setvisatext = 0;
  var cbtdays = GbuRueDay - GbuHinDay;
  if(cbtdays > 3){
  	setvisatext = 1;
  }

  objburd = document.getElementById("bu_reisedatum");
  if(objburd){
  	var addstern = "";
  	if(setvisatext) addstern = '<span style="color:#800000"> ** Mehr als 72 Stunden!</span>';
  	if(GbuType & 0x01)
  	  objburd.innerHTML = GbuHinDay + "." + (GbuHinMth +1) + "." + GbuHinYar + " - " + GbuRueDay + "." + (GbuRueMth +1) + "." + GbuRueYar + addstern;
  	else {
  	  addstern = '<span style="color:#800000"> **</span>';
  	  setvisatext = 1;
  	  objburd.innerHTML = GbuHinDay + "." + (GbuHinMth +1) + "." + GbuHinYar + addstern;
  	}
  }

  objbukab = document.getElementById("bu_kabine");
  if(objbukab){
    objbukabsel = document.getElementsByName("cabsel");
    if(objbukabsel[0]){ 
  	  for(var i = 0; i < 10; i++)
  	  {
  	  	if(objbukabsel[0].options[i]){
  	  	  if(objbukabsel[0].options[i].value == GbuKabin){
  	  	    objbukab.innerHTML = "Kategorie " + objbukabsel[0].options[i].text;
  	  	    break;
  	  	  }
  	  	}
  		//if(i < 3) alert(objfahsel[0].options[i].value);
  	  }
  	}
  	else
  	{
  	  objbuTab = document.getElementById(GbuKabin);
  	  objbukab.innerHTML = "Kategorie " + objbuTab.innerHTML;
  	}
  }

  var tmpveranz = GbuPers + GbuKind;
  if(GbuType & 0x01) tmpveranz = tmpveranz * 2;
  
  objbuverpfl = document.getElementById("bu_ver1");
  if(objbuverpfl){
  	var tmptxt = "kein";
	if(GbuVer1 == "1"){
	  tmptxt = tmpveranz + " x Buffet";
	}
	if(GbuVer2 == "1"){
	  tmptxt = tmpveranz + " x a la carte";
	}
    objbuverpfl.innerHTML = tmptxt;
  }
  objbuverpfl = document.getElementById("bu_ver3");
  if(objbuverpfl){
  	var tmptxt = "kein";
	if(GbuVer3 == "1"){
	  tmptxt = tmpveranz + " x Buffet";
	}
    objbuverpfl.innerHTML = tmptxt;
  }

  objbups = document.getElementById("bu_personen");
  if(objbups){ 
  	if(GbuKind != "0"){
  	  if(GbuKind == "1")
  	    objbups.innerHTML = GbuPers + " Erwachsene, " + " ein Kind 6 bis 12 Jahre";
  	  else
  	    objbups.innerHTML = GbuPers + " Erwachsene, " + GbuKind + " Kinder 6 bis 12 Jahre";
  	} else {
  	  objbups.innerHTML = GbuPers + " Erwachsene";
  	}
  }
  objbucbt = document.getElementById("bu_cbt");
  if(objbucbt){
  	var cbttext = 'nein <span style="color:#800000"> **</span>';
  	if(GbuCbt == "1") cbttext = "ja";
  	else { 
  	  setvisatext = 1;
  	}
  	if(setvisatext){
  	  cbttext += '<br><span style="color:#800000"> ** Bitte beachten Sie die Visa-Bestimmungen!</span>';
  	}
  	objbucbt.innerHTML = cbttext;
  }
  objbufah = document.getElementById("bu_fahrzeug");
  if(objbufah){
  	objfahsel = document.getElementsByName("carsel");
  	if(objfahsel){
  	  for(var i = 0; i < 10; i++)
  	  {
  	  	if(objfahsel[0].options[i]){
  	  	  if(objfahsel[0].options[i].value == GbuCar){
  	  	    objbufah.innerHTML = objfahsel[0].options[i].text;
  	  	    break;
  	  	  }
  	  	}
  		//if(i < 3) alert(objfahsel[0].options[i].value);
  	  }
  	  if(GbuCar.substr(0,1) == "B"){
  	  	objbufah.innerHTML += ", Länge " + GbuCarLen + " Meter";
  	  }
  	}
  }
}


function bu_get_update()
{
  var data = "  <buType>"    + GbuType  + "</buType>\n";
  data = data + "  <buHinYar>"    + GbuHinYar  + "</buHinYar>\n";
  data = data + "  <buHinMth>"    + GbuHinMth  + "</buHinMth>\n";
  data = data + "  <buHinDay>"    + GbuHinDay  + "</buHinDay>\n";
  data = data + "  <buRueYar>"    + GbuRueYar  + "</buRueYar>\n";
  data = data + "  <buRueMth>"    + GbuRueMth  + "</buRueMth>\n";
  data = data + "  <buRueDay>"    + GbuRueDay  + "</buRueDay>\n";
  data = data + "  <buRueDay>"    + GbuRueDay  + "</buRueDay>\n";
  data = data + "  <buCabin>"     + GbuKabin   + "</buCabin>\n";
  data = data + "  <buCar>"       + GbuCar     + "</buCar>\n";
  data = data + "  <buCarLen>"    + GbuCarLen  + "</buCarLen>\n";
  data = data + "  <buCbt>"       + GbuCbt     + "</buCbt>\n";
  data = data + "  <buPers>"      + GbuPers    + "</buPers>\n";
  data = data + "  <buKind>"      + GbuKind    + "</buKind>\n";
  data = data + "  <buVer1>"      + GbuVer1    + "</buVer1>\n";
  data = data + "  <buVer2>"      + GbuVer2    + "</buVer2>\n";
  data = data + "  <buVer3>"      + GbuVer3    + "</buVer3>\n";
  //alert(data);
  sendRequest( 'db/get_price.php', "data=" + data, 2, 1);
}

function bu_update(xmldoc)
{
  var my_node = xmldoc.getElementsByTagName("buCabinPrice");
  if(my_node.item(0)){
  	objKP = document.getElementById("buCP");
  	if(objKP){
  	  if(my_node.item(0).firstChild.data != "0")
  	    objKP.innerHTML = "€ " + my_node.item(0).firstChild.data + ",-";
  	  else
  	    objKP.innerHTML = "-"
  	}
  }
  var my_node = xmldoc.getElementsByTagName("buCabinPerPers");
  if(my_node.item(0)){
  	objKP = document.getElementById("buCT");
  	objKA = document.getElementById("buCA");
  	if(objKP && objKA){
  	  if(my_node.item(0).firstChild.data == "1")
  	  {
  	    objKP.innerHTML = "Preis pro Peron";
  	    objKA.innerHTML = "";
  	  }
  	  else
  	  {
  	    objKP.innerHTML = "Preis pro Kabine";
  		var my_node = xmldoc.getElementsByTagName("buCabinAnzahl");
  		if(my_node.item(0)){
  		  if(my_node.item(0).firstChild.data != "1")
  		  {
  		  	GbuKabAnz = parseInt(my_node.item(0).firstChild.data);
  	        objKA.innerHTML = my_node.item(0).firstChild.data + " Kabinen";
  	      }
  	      else
  	      {
  	        objKA.innerHTML = "";
  	        GbuKabAnz = 1;
  	      }
  	    }
  	  }
  	}
  }
  var my_node = xmldoc.getElementsByTagName("buVerPrice");
  if(my_node.item(0)){
  	objTP = document.getElementById("buVP");
  	if(objTP){
  	  if(my_node.item(0).firstChild.data != "0")
  	    objTP.innerHTML = "€ " + my_node.item(0).firstChild.data + ',-';
  	  else
  	    objTP.innerHTML = "-"
  	}
  }
  var my_node = xmldoc.getElementsByTagName("buCarPrice");
  if(my_node.item(0)){
  	objKP = document.getElementById("buKP");
  	if(objKP){
  	  if(my_node.item(0).firstChild.data != "0")
  	    objKP.innerHTML = "€ " + my_node.item(0).firstChild.data;
  	  else
  	    objKP.innerHTML = "-"
  	}
  }
  var my_node = xmldoc.getElementsByTagName("buCbtPrice");
  if(my_node.item(0)){
  	objTP = document.getElementById("buTP");
  	if(objTP){
  	  if(my_node.item(0).firstChild.data != "0")
  	    objTP.innerHTML = "€ " + my_node.item(0).firstChild.data + ',-';
  	  else
  	    objTP.innerHTML = "-"
  	}
  }
  var my_node = xmldoc.getElementsByTagName("buGesPrice");
  if(my_node.item(0)){
  	objKP = document.getElementById("buGP");
  	if(objKP){
  	  if(my_node.item(0).firstChild.data != "0")
  	    objKP.innerHTML = "€ " + my_node.item(0).firstChild.data + ',-';
  	  else
  	    objKP.innerHTML = "-"
  	}
  }
}

function bu_cabin_select(wie)
{
  //alert("Hallo");	
  objinfobox = document.getElementById("infobox");
  if(objinfobox){
  	switch(wie){
  	case 1:
  	  objinfobox.style.visibility = "visible";
  	  break;
  	case 2:
  	  objinfobox.style.visibility = "hidden";
  	  break;
  	case 3:
  	  if(bu_change_active == 0){
  	    objinfobox.style.visibility = "visible";
	    setDebugTest("click");
	  }
	  bu_change_active = 0;
  	  break;
  	}
  	if(mybrowser == 'ff'){
  	  objinfobox.style.top = 404;
  	  objinfobox.style.height = 180;
  	}
  }
}

function bu_cabin_select_o(obj)
{
  var objval = "";
  if(typeof(obj) == "object"){
  	objval = obj.value;
  } else {
  	objval = obj;	//a text comming in
  }
  
  objinfotext = document.getElementById("infotext");
  objinfobild = document.getElementById("infobild");
  if(objinfotext && objinfobild){
  	objinfotext.innerHTML = objval;
  	switch(objval){
  	case "E4":
  	  objinfobild.src = bild[0].src;
  	  objinfotext.innerHTML = text[0];
  	  break;
  	case "B4":
  	  objinfobild.src = bild[0].src;
  	  objinfotext.innerHTML = text[1];
  	  break;
   	case "A2":
  	  objinfobild.src = bild[1].src;
  	  objinfotext.innerHTML = text[2];
  	  break;
   	case "AD":
  	  objinfobild.src = bild[1].src;
  	  objinfotext.innerHTML = text[3];
  	  break;
   	case "CM":
  	  objinfobild.src = bild[2].src;
  	  objinfotext.innerHTML = text[4];
  	  break;
   	case "D2":
  	  objinfobild.src = bild[3].src;
  	  objinfotext.innerHTML = text[5];
  	  break;
  	case "E1":
  	  objinfobild.src = bild[0].src;
  	  objinfotext.innerHTML = text[6];
  	  break;
  	case "B1":
  	  objinfobild.src = bild[0].src;
  	  objinfotext.innerHTML = text[7];
  	  break;
 	}
  	
  	
  	
  }
}
var bu_open_cabin = 0;

function bu_open_cabin_select(wie)
{
  if(wie == 2)
  {
  	if(bu_open_cabin == 0) bu_open_cabin = 1;
  	else bu_open_cabin = 0;
  	wie = bu_open_cabin;
  }
  else bu_open_cabin = wie;
  
  objcabinTable = document.getElementById("cabinT");
  objkfz = document.getElementsByName("carsel");
  if(objcabinTable)
  {
  	if(bu_open_cabin == 1)
  	{
  	  objcabinTable.style.visibility = "visible";
      if(objkfz[0]) objkfz[0].style.visibility = "hidden";
      bu_cabin_select(1);
    }
  	else
  	{
  	  objcabinTable.style.visibility = "hidden";
      if(objkfz[0]) objkfz[0].style.visibility = "visible";
      bu_cabin_select(2);
    }
  }
}

function bu_overtable(obj, wie)
{
  if(typeof(obj) != "object"){
  	alert("bu_cabin_select_o: No Objekt");
  	return;
  }
  if(wie == 1)
  {
    obj.style.backgroundColor = '#2020A0';
    obj.style.color = '#FFFFFF';
    bu_cabin_select_o(obj.id)
  }
  else
  {
    obj.style.backgroundColor = '#FFFFFF';
    obj.style.color = '#202020';
  }
}

var bu_move_position = 0;
var bu_move_offset_sol = 0;

function bu_move_set_pfeile(wie)
{
  	var objpfeil_l = document.getElementById("bu_l_pfeil");
  	var objpfeil_r = document.getElementById("bu_r_pfeil");
    var objbusend  = document.getElementById("bu_l_send");
    var objbudruc  = document.getElementById("bu_l_druck");
    if(objpfeil_l && objpfeil_r && objbusend ){
  	  if(wie == 0){
  	  	objpfeil_l.style.visibility = 'hidden';
  	  	objpfeil_r.style.visibility = 'hidden';
  	  	objbusend .style.visibility = 'hidden';
  	  	objbudruc .style.visibility = 'hidden';
  	  } else {
  	  	switch(bu_move_position){
  	  	case 0:
          objpfeil_l.style.visibility = 'hidden';
          objpfeil_r.style.visibility = 'visible';
  	  	  objbusend .style.visibility = 'hidden';
  	  	  objbudruc .style.visibility = 'hidden';
          break;
        case 1:
          objpfeil_l.style.visibility = 'visible';
          objpfeil_r.style.visibility = 'visible';
  	  	  objbusend .style.visibility = 'hidden';
  	  	  objbudruc .style.visibility = 'hidden';
          break;
        case 2:
          objpfeil_l.style.visibility = 'visible';
          objpfeil_r.style.visibility = 'hidden';
          objbusend .style.visibility = 'visible';
  	  	  objbudruc .style.visibility = 'visible';
  	      if((mybrowser == "ff") || (mybrowser == "sf"))objbudruc.style.opacity = 0.4;
  	      if(mybrowser == "ie") objbudruc.style.filter = "Alpha(opacity=50)";;
          break;
        }
      }
    }
}

var send_done = 0;

function bu_move_leftright(wie)
{
	var enableTimer = 0;
    if((bu_move_position == 1) && (wie != 0)){
      var ret = bu_check();
      if(ret == 0) return;
    }
  	if(wie == 0){
  	  if(bu_move_position > 0){
  	  	bu_move_position--;
  	    bu_move_offset_sol = -398 * bu_move_position;
  	    enableTimer = 1;
  	  }
	} else {
  	  if(bu_move_position < 2){
  	  	bu_move_position++;
  	    bu_move_offset_sol = -398 * bu_move_position;
  	    enableTimer = 1;
  	  }
	}
	bu_move_set_pfeile(1);
	var objbusend = document.getElementById("bu_l_send");
	if((objbusend) && (bu_move_position != 2)){
	 objbusend.style.visibility = "hidden";
	}
    if(enableTimer)
      objtimeout = window.setTimeout("move_bu()", 50);
}

function move_bu()
{
  var objbu = document.getElementById("rightcontentbox");
  if(objbu)
  {
  	var act = parseInt(objbu.style.left);
	var dif = bu_move_offset_sol - act;
    if(bu_move_offset_sol < act) dif = act - bu_move_offset_sol;
	if(dif < 5)        angeb_act_inc = 1;
	else if(dif < 20)  angeb_act_inc = 2;
	else if(dif < 50)  angeb_act_inc = 5;
	else if(dif < 100) angeb_act_inc = 10;
	else               angeb_act_inc = 40;


    if(bu_move_offset_sol > act){
      objbu.style.left = act + angeb_act_inc;
  	  objtimeout = window.setTimeout("move_bu()", 50);
	} else if(bu_move_offset_sol < act){
      objbu.style.left = act - angeb_act_inc;
  	  objtimeout = window.setTimeout("move_bu()", 50);
	} else {
	  var objbusend = document.getElementById("bu_l_send");
	  if((objbusend) && (bu_move_position == 2)){
	  	objbusend.style.visibility = "visible";
	  }
      var objbudruc  = document.getElementById("bu_l_druck");
      if((objbudruc) && (send_done)){
  	    if((mybrowser == "ff") || (mybrowser == "sf"))objbudruc.style.opacity = 1.0;
  	    if(mybrowser == "ie") objbudruc.style.filter = "Alpha(opacity=100)";
      }
	}

  }
}


function bu_check()
{
  if(send_done) return 1;
  var buName = "";
  var buVorn = "";
  var buStra = "";
  var buOrt  = "";
  var buTele = "";
  var buMail = "";
	
  //check input values
  var errortext = "";
  obj = document.getElementsByName("r_name");
  if(obj[0]){
  	if(obj[0].value == ""){
  	  errortext = ": kein Name angeben!";
  	} else buName = obj[0].value;
  } else errortext = ": internal Error: no field r_name";
  if(errortext == ""){
    obj = document.getElementsByName("r_vor");
    if(obj[0]){
  	  if(obj[0].value == ""){
  	    errortext = ": kein Vorname angeben!";
  	  } else buVorn = obj[0].value;
    } else errortext = ": internal Error: no field r_vor";
  }
  GbuName = buName + "," + buVorn;
  if(errortext == ""){
    obj = document.getElementsByName("r_strasse");
    if(obj[0]){
  	  if(obj[0].value == ""){
  	    errortext = ": keine Straße angeben!";
  	  } else buStra = obj[0].value;
    } else errortext = ": internal Error: no field r_strasse";
  }
  if(errortext == ""){
    obj = document.getElementsByName("r_ort");
    if(obj[0]){
  	  if(obj[0].value == ""){
  	    errortext = ": kein Ort angeben!";
  	  } else buOrt = obj[0].value;
    } else errortext = ": internal Error: no field r_ort";
  }
  if(errortext == ""){
    obj = document.getElementsByName("r_mail");
    if(obj[0]){
  	  if(obj[0].value == ""){
  	    errortext = ": keine e-Mail Adresse angeben!";
  	  } else buMail = obj[0].value;
    } else errortext = ": internal Error: no field r_mail";
  }
  obj = document.getElementsByName("r_tele");
  if(obj[0]){
   if(obj[0].value != ""){
     buTele = obj[0].value;
   }
  }
  
  var objbucheckresult = document.getElementById("checkresult");
  if(objbucheckresult) objbucheckresult.innerHTML = errortext;
  if(errortext != ""){
  	return 0;
  }

  var data = "Passage Buchen\n\n";
  data = data + buVorn + " " + buName +"\n";
  data = data + buStra +"\n";
  data = data + buOrt +"\n";
  if(buTele != "") data = data + "Telefon: " + buTele +"\n";
  data = data + "e-Mail: " + buMail +"\n\n";
  data = data + "Angebots-Code: HEL-SPB\n";
  if((GbuType & 0x02) == 0)
      data = data + GbuHinDay + "." + (GbuHinMth+1) + "." + GbuHinYar + " ab 19:00 " + "Helsinki - an 9:30 (nächster Tag) St.Petersburg\n"
  else
      data = data + GbuHinDay + "." + (GbuHinMth+1) + "." + GbuHinYar + " ab 19:00 " + "St.Petersburg - an 8:30 (nächster Tag) Helsinki\n"
  if(GbuType & 0x01){
    if(GbuType & 0x02)
      data = data + GbuRueDay + "." + (GbuRueMth+1) + "." + GbuRueYar + " ab 19:00 " + "Helsinki - an 9:30 (nächster Tag) St.Petersburg\n"
    else
      data = data + GbuRueDay + "." + (GbuRueMth+1) + "." + GbuRueYar + " ab 19:00 " + "St.Petersburg - an 8:30 (nächster Tag) Helsinki\n"
  }
  var obj  = document.getElementById("bu_kabine");
  var objp = document.getElementById("buCP");
  var objt = document.getElementById("buCT");
  var preis = objp.innerHTML;
  if(preis.substring(0,1) == '€'){
    preis = "EUR" + preis.substring(1);
  }
  if(obj && objp && objt){ 
  	if(GbuKabAnz == 1)
  	  data = data + "Kabine: " + obj.innerHTML + "  " + objt.innerHTML + " " + preis + "\n";
  	else
  	  data = data + GbuKabAnz + " Kabinen: " + obj.innerHTML + "  " + objt.innerHTML + " " + preis + "\n";
  }
  var tmptxt = "";
  var tmpvercount = 0;
  if(GbuVer1 == "1"){
	  tmptxt += "Frühstücks-Buffet";
	  tmpvercount++;
  }
  if(GbuVer2 == "1"){
      tmptxt += "Frühstück-a la carte";
	  tmpvercount++;
  }
  if(GbuVer3 == "1"){
      tmptxt += "  Abend-Buffet";
	  tmpvercount++;
  }
  if(tmpvercount > 0)
  {
  	var tmpveranz = GbuPers + GbuKind;
  	if(GbuType & 0x01) tmpveranz = tmpveranz * 2;
    if(tmpvercount > 1)
      tmpveranz = "je " + tmpveranz;
    var objp = document.getElementById("buVP");
    var preis = "";
    if(objp){
      var preis = objp.innerHTML;
      if(preis.substring(0,1) == '€'){
        preis = "EUR" + preis.substring(1);
      }
    }

    data = data + tmpveranz + " mal " + tmptxt + "  " + preis + "\n";

  }

  var obj = document.getElementById("bu_personen");
  if(obj) data = data + "Personen: " + obj.innerHTML + "\n";
  
  if(GbuCar == "0"){
  	data = data + "kein Fahrzeug\n";
  } else {
    var obj = document.getElementById("bu_fahrzeug");
    var objp = document.getElementById("buKP");
    if(obj && objp){
      var preis = objp.innerHTML;
      if(preis.substring(0,1) == '€'){
        preis = "EUR" + preis.substring(1);
      }
      data = data + "Fahrzeug: " + obj.innerHTML + "  " + preis + "\n";
    }
  }

  if(GbuCbt == "0"){
  	data = data + "keine City-Bus-Tour!\n";
  } else {
    var objp = document.getElementById("buTP");
    if(objp){
      var preis = objp.innerHTML;
      if(preis.substring(0,1) == '€'){
        preis = "EUR" + preis.substring(1);
      }
      data = data + "City-Bus-Tour für alle Peronen zusammen " + preis + "\n";
    }
  }
  var objp = document.getElementById("buGP");
  if(objp){
    var preis = objp.innerHTML;
    if(preis.substring(0,1) == '€'){
      preis = "EUR" + preis.substring(1);
    }
    data = data + "\nGesamtpreis: " + preis + "\n";
  }

  Gmydata = data;
  
  var objbubest = document.getElementsByName("r_bestaetigung");
  if(objbubest){
    //alert(objbubest[0].value);
  	objbubest[0].value = data;
  }
  return 1;
}

function bu_send()
{
  if(send_done) return;
  send_done = 1;
  var objbusend = document.getElementById("bu_l_send");
  if(objbusend){
  	if((mybrowser == "ff") || (mybrowser == "sf"))objbusend.style.opacity = 0.4;
  	if(mybrowser == "ie") objbusend.style.filter = "Alpha(opacity=50)";;
  }
  var objbudruc  = document.getElementById("bu_l_druck");
  if(objbudruc){
  	if((mybrowser == "ff") || (mybrowser == "sf"))objbudruc.style.opacity = 1.0;
  	if(mybrowser == "ie") objbudruc.style.filter = "Alpha(opacity=100)";;
  }

  var data =    "  <buType>" + GbuType  + "</buType>\n";
  data = data + "  <buHin>"  + GbuHinDay + "." + (GbuHinMth+1) + "." + GbuHinYar + "</buHin>\n";
  data = data + "  <buRue>"  + GbuRueDay + "." + (GbuRueMth+1) + "." + GbuRueYar + "</buRue>\n";
  data = data + "  <buPers>" + GbuPers + "," + GbuKind + "</buPers>\n";
  data = data + "  <buName>" + GbuName + "</buName>\n";
  data = data + "  <buData>" + Gmydata + "</budata>\n";
  sendRequest( 'db/send_mail.php', "data=" + data, 2, 2);

}

var buNum = "";

function bu_confirm(xmldoc)
{
  var dat = "";
  var my_node = xmldoc.getElementsByTagName("buDate");
  if(my_node.item(0)){
    dat = my_node.item(0).firstChild.data;
  }
  var my_node = xmldoc.getElementsByTagName("buNum");
  if(my_node.item(0)){
    var objbubest = document.getElementsByName("r_bestaetigung");
    if(objbubest){
      buNum = my_node.item(0).firstChild.data;
  	  objbubest[0].value += "\n\nVielen Dank für Ihre Anfrage.\nBuchung gespeichert " + dat + "\nBuchungs-Nummer: " + my_node.item(0).firstChild.data + "\nSie erhalten in Kürze eine Bestätigung per e-Mail.";
    }
  }

}


function bu_print_anfrage()
{
  var seite = "seiten/anf_drucken.php?obj=" + buNum;
  var para = "width=720,height=800,scrollbars=yes,resizable=yes,location=no";
  var Fenster1 = window.open(seite, "Anfragedrucken", para );
  Fenster1.focus();
}
