function zur_suche(showresult)
{
    window.location.href=uebergabe+'&showresult='+showresult;
}
function zum_zielgebiet(showresult)
{
    window.location.href=uebergabe+'&detail=zielgebiet&showresult='+showresult;
}
function zum_hotel(showresult,startposition_hotel,zielgebiets_kenner)
{
    window.location.href=uebergabe+'&detail=hotel&showresult='+showresult+'&startposition='+startposition_hotel+'&zielgebiets_kenner='+zielgebiets_kenner;
}
function skippen(zaehler,sortierung)
{
    window.location.href=uebergabe+'&startposition='+zaehler+'&sortierung='+sortierung+'&detail=termine'+skip_and_order;
}
function order(sortierung)
{
    window.location.href=uebergabe+'&sortierung='+sortierung+'&detail=termine&startposition=0'+skip_and_order;
}
var tmp;
function vakanz_success(strParams)
{
    if(strParams){
        tmp=strParams;
        setTimeout('vakanz_success()',100);
        if(vak_layer!=1){
            vakanzfenster.close();
        }
    }
    else{
        var form=document.forms['bengine'];
        form.vakanz.value=tmp;
        form.detail.value="buchung";
        if(linksec == 1){
            form.action=sec_cluster_url+"/booking/reiselinie/erde/index.php?KID="+KID;
        }
        form.submit();
    }
}
function onlineR()
{
    if(document.bengine.refresh.value=='1'){
        alert("Bitte klicken Sie erst auf Angebote aktualisieren!")
        return false;
   }
   return true;
}
function check_eingabe(kk,kk8)
{
   if(onlineR())
       buchungsanfrage(kk,kk8);
}
function cancel_vak(){
        window.vak.location.href='dummy.html';
        document.getElementById("inhalt").style.visibility = "hidden";
}
function absLeft(el) {
     return (el.offsetParent)?
     el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}
function absTop(el) {
     return (el.offsetParent)?
     el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}
var vakanzfenster;
function buchungsanfrage(kenner_id)
{
    if(vak_layer!=1){
        parts=stermin_i[kenner_id].split("%");
        var top=screen.height;
        var left=screen.width;
        posx=((left/2)-200);
        posy=((top/2)-90);
        vakanzfenster = window.open (vakanz+'&Buchungs_ID='+parts[11]+'&hotel_attribut='+parts[6],'checkwindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=180,screenX='+posx+',screenY='+posy+',left='+posx+',top='+posy+'');
        vakanzfenster.focus();
    }
    else{
        parts=stermin_i[kenner_id].split("%");
        document.getElementById("inhalt").style.visibility = "visible";
        nX=absLeft(window.document.getElementById('bzpk'));
        nY=(document.body.clientHeight-document.getElementById("inhalt").offsetHeight)/2;
        nY+=document.body.scrollTop;
        document.getElementById("inhalt").style.left = nX+44;
        document.getElementById("inhalt").style.top = nY;
        window.vak.location.href=vakanz+'&Buchungs_ID='+parts[11]+'&hotel_attribut='+parts[6];
    }

}
function vakanz_fail(strError)
{
    var form=document.forms['bengine'];
    form.vakanz.value='';
    form.strError.value=strError;
    form.detail.value='termine';
    form.submit();
}

function s_termin_tabelle(pfad_images,port)
{
    if(stermin_i.length<=0)
    {}
    else
    {
        //---Ausgabe der Ergebnisliste LM und Pauschal-----
        var n_AltFlag=0; var n_TopFlag=0;
        for(i=0;i<stermin_i.length;i++)
        {
            parts_i=stermin_i[i].split("%");
            var alt_point,parts_hotel_attribut="",strVerpflegunglang="";

            va_logo=parts_i[8].split("-");
            if (va_logo[1]) va_bild=KID+'-'+va_logo[0];
            else va_bild=va_logo[0];

            //Verpfelgung ueber hotel_atribut vp;zi;veranstalter;anzahl_personen
            parts_hotel_attribut=parts_i[6].split(";");
            //alttag für Verpflegung setzen
            var ttvf=getvf(parts_hotel_attribut[0]);

            if(parts_i[12]==0){
                if(n_TopFlag==0){
                    c_strTR="tertab5trres"
                    n_TopFlag=1;
                }
            }
            else{
                if(alt_point!=1){
                    c_strTR="tertab5trresALT"
                    document.write('<tr>');
                    document.write('<td colspan="6" class="alttxt">&nbsp;Alternative Reiseangebote die Ihren Wünschen nahe kommen:</td>');
                    document.write('</tr>');
                    document.write('<tr>');
                    document.write('<td class="tertab5tdtrenner" colspan="6"><img src="/images/spacer.gif" width="1" height="1" border="0" alt=""></td>');
                    document.write('</tr>');
                    alt_point=1;
                }
            }

            document.write('<tr>');
            //Abreisetag
            document.write('<td class="'+c_strTR+'">&nbsp;'+parts_i[9]);if(parts_i[2]==1){document.write('<img src="'+pfad_images+'/smile_2.gif" alt="" border="0" width="11" height="11" align="absmiddle" hspace="2">'); }document.write('</td>');
            //Dauer
            document.write('<td class="'+c_strTR+'">'+parts_i[0]);if(parts_i[3]==1){document.write('<img src="'+pfad_images+'/smile_2.gif" alt="" border="0" width="11" height="11" align="absmiddle" hspace="2">'); }document.write('</td>');
            //Anbieter
            document.write('<td class="'+c_strTR+'"  align="center"><img src="'+imgservPfad+'/images/content/va_logos/small/'+va_bild+'.gif" alt="Veranstalter '+parts_i[7]+'" border="0" width="75" height="21"></td>');
            //Leistung
            document.write('<td class="'+c_strTR+'"">'+parts_i[14]+'<br>'+ttvf);if(parts_i[13]!=""){document.write('<br>'+parts_i[13]);}if(parts_i[4]==1){document.write('<img src="'+pfad_images+'/smile_2.gif" alt="" border="0" width="11" height="11" align="absmiddle" hspace="2">'); }document.write('</td>');
            //Preis
            document.write('<td class="'+c_strTR+'" align="right">'+parts_i[10]+',- &euro;');if(parts_i[5]==1){document.write('<img src="'+pfad_images+'/smile_2.gif" alt="" border="0" width="11" height="11" align="absmiddle" hspace="2">'); }document.write('</td>');
            //Prüfen
            document.write('<td class="'+c_strTR+'" align="right"><a href="javascript:check_eingabe(\''+i+'\');\" class="terpruefe">prüfen</a>&nbsp;</td>');
            document.write('</tr>');

            if(i!=(stermin_i.length-1))
            {
                document.write('<tr>');
                document.write('<td class="tertab5tdtrenner" colspan="6"><img src="/images/spacer.gif" width="1" height="1" border="0" alt=""></td>');
                document.write('</tr>');
            }

        }

    }
}
function pageSkip(seiten,apage,sortierung){
    for (t=1;t<=seiten;t++)
    {
        zaehler=(t-1)*20;
        if(t!=apage)
           document.write('<a href="javascript:skippen('+zaehler+',\''+sortierung+'\');" class="pageskip" title="Angebote der Seite '+t+' abrufen">'+t+'</a>&nbsp;&nbsp;');
        else
            document.write('<span class="pageaktive">'+t+'</span>&nbsp;&nbsp;');
    }
}

function showExtraFilter(selName,selSelected,cssClass, arrValues){
  var i,aktValue;
  var strSelected = "";
  var strDisabled = "";

  document.write('<select id="'+selName+'" name="'+selName+'" class="'+cssClass+'" style="font-weight:normal;" onchange="setzeFilter(this, \''+selName+'\');">');
  document.write('<option value="">beliebig</option>');
  for(i=0;i<arrValues.length;i++){
    aktValue =  arrValues[i].split(";");
    if(selSelected==aktValue[0])
     strSelected = " selected";
    else
      strSelected = "";
    if(selName=='efAbflughafen' && aktValue[2]=='0')
      strDisabled = " disabled";
    else
      strDisabled = "";
    document.write('<option value="'+aktValue[0]+'"'+strSelected+strDisabled+'>'+aktValue[1]+'</option>');
  }
  document.write('</select>');
}

function setzeFilter(Selectbox, Filter){
  var toSet,fValue;
  var selValue = Selectbox.options[Selectbox.selectedIndex].value;

  switch(Filter){
   case 'efAbflughafen':
    toSet  = "abflughafen";
    break;
   case 'efTermine':
    toSet = "termin";
    break;
   case 'efDauer':
    toSet = "dauer";
    break;
  }

  document.getElementsByName(toSet)[0].value=selValue;

  // Wenn expliziter Termin gesetzt wird,
  // => setze rücktermin auf -1
  // => setze Gewichtung für Rücktermin auf "normal" (rute=1)
  // => setze Gewichtung für Termin auf "wichtig" (te_g=2)
  if(toSet=='termin'){
    var selTermin = document.getElementById('efTermine');
    document.getElementsByName('ruecktermin')[0].value = "-1";
    document.getElementsByName('rute_g')[0].value = "1";
    if(selTermin[selTermin.selectedIndex].value!=""){
      document.getElementsByName('te_g')[0].value = "2";
    }else{
      document.getElementsByName('te_g')[0].value = "1";
    }
  }

  document.bengine.submit();
}
