var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;
var DatArray = new Array("So.","Mo.","Di.","Mi.","Do.","Fr.","Sa.","??" );
var NameArray= new Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","??" );
var MonArray = new Array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember","??");
var RegionKey = "/ASI/SPP/KNA/BLE/KIK/KRE/TRA/GIZ/NOA/IMA/AFR/OSB/AEI/ES-/PT-/TR-/GR-/";
var allBerlin = "/THF/SXF/TXL/";
var AbDatum = DatumParm(8);
var ReDatum = DatumParm(36);
var WunschDatum = DatumParm(8);
var MaxReDatum = DatumParm(28);
var RestLink = "200000OOOO";
var NuFlLink = "100000NFNF";
var listet= new Array();
var SysMonat= 1+time.getMonth();
var SysJahr= 2000+(time.getYear()%100);
var klickcc=0;
var waitPic=new Image();
waitPic.src= "/oss/img/wl/lmn/warten.gif";
var animPic='';
wcu=1;
time = new Date

function OptionValue(Object) {
    console.debug(Object);
 if(Object.selectedIndex < 0){
  return( Object.options[0].value )
 }
return Object.options[Object.selectedIndex].value;
}

function SysDatum(){
 fehler=false;
 time = new Date;
 if(SysMonat != (1+time.getMonth()) ) fehler=true;
 if(SysJahr != (2000+(time.getYear()%100)) ) fehler=true;
 if(fehler) document.write('<font class=klein><b id=lm>Hinweis:<b> Ihr System-Datum ist falsch eingestellt !</font>');
}

function DatumBox(n){
 out='';
 SelDat= WunschDatum;
 if(n==null) n=300;
 else SelDat=MaxReDatum;
 for (i=1; i<=n;i++){
  pm= DatumParm(i);
  out+='<option value='+pm+((SelDat==pm) ? ' selected':'')+'>'+MakeDatum(i)+'</option>';
 }
document.write(out);
}

function DauerBox(n,mx){
 if(mx==null) mx=30;
 out='<option value="00">beliebig</option>';
 n=parseInt(n);
 for (i=1; i<=mx;i++) out+='<option value='+((i>9) ? i:'0'+i)+((i==n) ? ' selected':'')+'>'+i+((i==1) ? ' Tag':' Tage')+'</option>';
 document.write(out)
}

function apInfo(ar){
 out='';
 if(ar!='') out=' Gewählt sind: <b>';
 if(ar.indexOf('BER') >=0) out+='Berlin, ';
 for (i=1; i<= aa; i++) {
	if(ar.indexOf(abc[i]) >=0) out+=ainf[i]+', ';
 }
 out+='</b></font>';
 return(out);
}

function MakeDatum(days){
 time = new Date;
 time.setTime( time.getTime()+days*86400000);
 dd= ((time.getDate() >9) ? "":"0")+time.getDate();
 return( DatArray[time.getDay()]+' '+dd+((1+time.getMonth() >9) ? ".":".0")+(1+time.getMonth())+'.'+(2000+(time.getYear()%100))  );
}

function DatumParm(days){
 time = new Date;
 time.setTime( time.getTime()+days*86400000);
 dd= ((time.getDate() >9) ? "":"0")+time.getDate();
 mm= ((1+time.getMonth() >9) ? "":"0")+(1+time.getMonth());
 return( dd+mm+(2000+(time.getYear()%100)) );
}

function detail(i,g){
  document.IBuchen.ANR.value= i;
  document.IBuchen.GPREIS.value= g;
  document.IBuchen.submit();
}

function Refresh(){
 document.Sort.submit();
}

function MoveToPage(PageNumber){
 klickcc++
 document.Sort.ANR.value='';
 document.Sort.Next.value= PageNumber;
 Refresh();
}

function Sortieren(SortString){
  klickcc++
  document.Sort.ANR.value='';
  document.Sort.SortBy.value = SortString;
  document.Sort.ReSort.value = klickcc;
  Refresh();
}

function DatumCheck(d,p){
 document.Filter.PLUS.value= p;
 document.Filter.ABDATUM.value= d;
 document.Filter.submit();
 return(false);

 cbo = document.Filter.ABDATUM;
 for (i = 0;  i < cbo.length;  i++) {
  if(cbo.options[i].value==d) {
    cbo.selectedIndex=i;
    cbo.options[i].defaultSelected=true;
    document.Filter.submit();
  }
 }
}

function AbAll(){
 if(Klick==0){
 cbo = document.Filter.Abflug;
  for (i = 0;  i < cbo.length;  i++) {
   if(cbo.options[i].value=='---') {
    cbo.selectedIndex=i;
    cbo.options[i].defaultSelected=true;
    Klick=1;
    document.Filter.submit();
   }
  }
 }
}


function ExistAP(ap){
  for(t=0; t < listet.length; t++) {
    if(listet[t]==ap) return(true);
  }
 listet[t]=ap;
 return(false)
}

function LaZiel(lc){
count=0;
   for (t=1; t<= zz; t++) {
     if(Lco[t]==lc) count++
   }
return(count >1);
}

function oWin(URL,w,h,m){
 wName="InfoPopUp";
 if(window.event){
	Ereignis= window.event;
	X=Ereignis.screenX;
	Y=Ereignis.screenY;
 }else{
	Ereignis= window;
	X=Ereignis.screenX+mousex+10;
	Y=Ereignis.screenY+mousey+100;
 }
 if(w==null){
  w="320";
  h="372";
 } 
 WinObj= window.open(URL,wName,'width='+w+',height='+h+',resizable=no,toolbar=no,scrollbars=no')
 if(m==null) WinObj.moveTo(X,Y);
}

function FHname(s){
 if(s=='---') return(document.write('alle'))
 for (i=1; i<= aa; i++) {
   if(s==abc[i])
    return(document.write(ainf[i]))
 }
return(document.write(s))
}


function Momant(){
 if(wcu >=75) wcu=0;
 wcu+=5
 document.images[animPic].width = 50-wcu+1;
 document.images[animPic].width = wcu;
 setTimeout("Momant()",1000)
}

function pBug(s){
 r='';
 for (t = 0; t < s.length; t++) {
  c = s.charAt(t);
  if(c=='+') r+= '%2B';
  else r+= escape(c);
 }
 return (r);
}

function TST(R,P){
 if(Klick==0){
  Klick++;
  animPic= 'p'+R;
  document.images[animPic].src = waitPic.src;
  document.images[animPic].width =50;
	TheURL = '/suchen.asp'
	TheURL+= '?PLUS='+document.Sort.PLUS.value;
	TheURL+= '&UDI='+escape(document.Sort.UDI.value);
	TheURL+= '&HotSuch='+pBug(document.Sort.HotSuch.value);
	TheURL+= '&Next='+document.Sort.Next.value;
	TheURL+= '&ANR='+R;
	Momant();
  location.href=TheURL;
 }
}

function sfo(fo){
tp= fo.tp.value
tst= OptionValue(fo.ABFL)
 document.Aktiv.HotSuch.value= fo.hot.value;
 document.Aktiv.ID.value= tst;
 document.Aktiv.submit();
}


function wait(){
 if(wr >19){
  wr=0;
  for (i=1; i <= 20; i++){
   Bild = "pp"+i
   document.images[Bild].src = cBild.src
  }
  setTimeout("wait()",1000)
 }else{
 wr = wr+1
 Bild = "pp"+wr
 document.images[Bild].src = bBild.src
 setTimeout("wait()",1000)
 }
}

function PopUp(url,wn) {
 WinName= (wn==null, 'Kalender', wn)
 if(window.event){
	Ereignis= window.event;
	X=Ereignis.screenX;
	Y=Ereignis.screenY;
 }else{
	Ereignis= window;
	X=Ereignis.screenX+mousex+10;
	Y=Ereignis.screenY+mousey+100;
 }
 Calwin= window.open(url,WinName,'height=185,width=165,status=no,dependent=yes');
 Calwin.moveTo(X,Y);
}


function Dcheck(VonBis){
 with (document.aform){
	Oldbis = 0;
	Oldvon = 0;
	stay = Math.max(DAUER.value,0);
	stay = ((stay==0) ? 28 : stay);
	for (i = 0;  i < ABDATUM.length;  i++) {
		if(ABDATUM.options[i].value==AbDatum) {
			Oldvon=i; break;
			}
	}
	for (i = 0;  i < REDATUM.length;  i++) {
		if(REDATUM.options[i].value==ReDatum) {
			Oldbis=i; break;
			}
	}
	Plus = ((Oldbis-Oldvon >0) ? Oldbis-Oldvon : stay);
	Von1 = ABDATUM.selectedIndex;
	REDATUM.selectedIndex = Von1+Plus;
	}
}

 
function getQuery(Name) {
var search = Name.toUpperCase() + "=";
var query = document.location.search.toUpperCase();
   if (query.length > 0) {
      offset = query.indexOf(search);
      if (offset != -1) {
         offset += search.length;
         end = query.indexOf("&", offset);
         if (end == -1)
            end = query.length;
         return unescape(query.substring(offset, end));
      }
   }
}

function OptionText(Object,v){
  for(t=0; t < Object.length; t++) {
    if(Object.options[t].value == v){
     return(Object.options[t].text);
    }
  }
return(v)
}


function dieZiele(s){
bg='background-color:#DAEAFE';
bg='background-color:#ffcae2';
tt='<option value="---">alle Reiseziele</option>';
tt+='<option style="background-color:#ffcae2" value="NOA"'+((s=='NOA') ? ' selected':'')+'>Ägypten - Tunesien - Marokko</option>'
 +'<option style="'+bg+'" value="AFR"'+((s=='AFR') ? ' selected':'')+'>Afrika - Mauritius - Seychellen</option>'
 +'<option style="'+bg+'" value="AEI"'+((s=='AEI') ? ' selected':'')+'>Arabische Halbinsel - Israel</option>'
 +'<option style="'+bg+'" value="ASI"'+((s=='ASI') ? ' selected':'')+'>Asien - Thailand - Malediven</option>'
 +'<option style="'+bg+'" value="IMA"'+((s=='IMA') ? ' selected':'')+'>Italien - Malta</option>'
 +'<option style="'+bg+'" value="BLE"'+((s=='BLE') ? ' selected':'')+'>Mallorca - Ibiza - Menorca</option>'
 +'<option style="'+bg+'" value="KNA"'+((s=='KNA') ? ' selected':'')+'>Kanarische Inseln</option>'
 +'<option style="'+bg+'" value="KIK"'+((s=='KIK') ? ' selected':'')+'>Karibik - Mexiko - Dom.Rep.</option>'
 +'<option style="'+bg+'" value="OSB"'+((s=='OSB') ? ' selected':'')+'>Kroatien - Bulgarien - Osteuropa</option>'
 +'<option style="'+bg+'" value="GIZ"'+((s=='GIZ') ? ' selected':'')+'>Griechische Inseln - Zypern</option>'
 +'<option style="'+bg+'" value="SPP"'+((s=='SPP') ? ' selected':'')+'>Spanien Festland / Portugal</option>'
 +'<option style="'+bg+'" value="TRA"'+((s=='TRA') ? ' selected':'')+'>Türkische Riviera/Ägäis</option>'
 +'<optgroup label="Land/Reiseziel"></optgroup>';
 for (i=1; i<= ll; i++) {
 LandZiel=true;
   if(LandZiel) tt+='<option style="'+bg+'" value="'+Lcode[i]+'-"'+((Lcode[i] == s) ? " selected":"")+'>'+Land[i]+'</option>'
   for (z=1; z<= zz; z++) {
     if(Lcode[i]==Lco[z]){
	tt+='<option style="padding-left:20px" value="'+Zic[z]+'"'+((Zic[z] == s) ? " selected":"")+'>'+Zif[z]+'</option>'
     }
   }
 }
document.write(tt);
}

function MakeSelect(s) {
bg='background-color:#DAEAFE';
bg='background-color:#ffcae2';
 AT='<option value="---">alle Reiseziele</option>'
 +'<option style="'+bg+'" value="NOA"'+((s=='NOA') ? ' selected':'')+'>Ägypten - Tunesien - Marokko</option>'
 +'<option style="'+bg+'" value="AFR"'+((s=='AFR') ? ' selected':'')+'>Afrika - Mauritius - Seychellen</option>'
 +'<option style="'+bg+'" value="AEI"'+((s=='AEI') ? ' selected':'')+'>Arabische Halbinsel - Israel</option>'
 +'<option style="'+bg+'" value="ASI"'+((s=='ASI') ? ' selected':'')+'>Asien - Thailand - Malediven</option>'
 +'<option style="'+bg+'" value="IMA"'+((s=='IMA') ? ' selected':'')+'>Italien - Malta</option>'
 +'<option style="'+bg+'" value="BLE"'+((s=='BLE') ? ' selected':'')+'>Mallorca - Ibiza - Menorca</option>'
 +'<option style="'+bg+'" value="KNA"'+((s=='KNA') ? ' selected':'')+'>Kanarische Inseln</option>'
 +'<option style="'+bg+'" value="KIK"'+((s=='KIK') ? ' selected':'')+'>Karibik - Mexiko - Dom.Rep.</option>'
 +'<option style="'+bg+'" value="OSB"'+((s=='OSB') ? ' selected':'')+'>Kroatien - Bulgarien - Osteuropa</option>'
 +'<option style="'+bg+'" value="GIZ"'+((s=='GIZ') ? ' selected':'')+'>Griechische Inseln - Zypern</option>'
 +'<option style="'+bg+'" value="SPP"'+((s=='SPP') ? ' selected':'')+'>Spanien Festland / Portugal</option>'
 +'<option style="'+bg+'" value="TRA"'+((s=='TRA') ? ' selected':'')+'>Türkische Riviera/Ägäis</option>'
 +'<optgroup label="Land/Reiseziel"></optgroup>';
 for (i=1; i<= ll; i++) {
  sele="" 
   if(Lcode[i] == s) sele=" selected"
   AT+='<option style="'+bg+'" value="'+Lcode[i]+'-"'+sele+'>'+Land[i]+'</option>'

   for (z=1; z<= zz; z++) {
     if(Lcode[i]==Lco[z]){
	sele=""
	if(Zic[z] == s) sele=" selected"
	AT+='<option style="padding-left:20px" value="'+Zic[z]+'"'+sele+'>'+Zif[z]+'</option>'
     }
   }
 }
document.write(AT);
}


function MakeAbflug(s){
 bb=true;
 tt='<option value="---">alle Abflughäfen</option>';
 tt+='<optgroup label="Abflughäfen Deutschland">'
  +'<option value="NNN"'+((s=='NNN') ? ' selected':'')+'>- Nord</option>'
  +'<option value="SSS"'+((s=='SSS') ? ' selected':'')+'>- Süd</option>'
  +'<option value="WWW"'+((s=='WWW') ? ' selected':'')+'>- West</option>'
  +'<option value="OOO"'+((s=='OOO') ? ' selected':'')+'>- Ost</option>';
  for (i=1; i<= aa; i++) {
	if(aLC[i]=='DE' || aLC[i]=='LU'){
	if(bb && allBerlin.indexOf(abc[i]) >0) tt+='<option value="BER"'+((s=='BER') ? ' selected':'')+'>Berlin</option>',bb=false;
	if(abc[i] !='NNN' && abc[i]!='SSS' && abc[i]!='WWW' && abc[i]!='OOO' && allBerlin.indexOf(abc[i]) <0) tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
	}
  }
  tt+='</optgroup><optgroup label="Abflughäfen Österreich">';
  for (i=1; i<= aa; i++) if(aLC[i]=='AT') tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
  tt+='</optgroup><optgroup label="Abflughäfen Schweiz">';
  for (i=1; i<= aa; i++) if(aLC[i]=='CH') tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
  tt+='</optgroup><optgroup label="Abflughäfen Frankreich">';
  for (i=1; i<= aa; i++) if(aLC[i]=='FR') tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
  tt+='</optgroup><optgroup label="Abflughäfen Belgien">';
  for (i=1; i<= aa; i++) if(aLC[i]=='BE') tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
  tt+='</optgroup><optgroup label="Abflughäfen Niederlande">';
  for (i=1; i<= aa; i++) if(aLC[i]=='NL') tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
  tt+='<optgroup label="Abflughäfen in Italien">';
  for (i=1; i<= aa; i++) if(aLC[i]=='IT') tt+='<option value="'+abc[i]+'"'+((s==abc[i]) ? ' selected':'')+'>'+ainf[i]+'</option>';
  tt+='</optgroup><optgroup label="alle Abflughäfen in:">';
  tt+='<option value="DE-"'+((s=='DE-') ? ' selected':'')+'>- Deutschland</option>';
  tt+='<option value="AT-"'+((s=='AT-') ? ' selected':'')+'>- Österreich</option>';
  tt+='<option value="CH-"'+((s=='CH-') ? ' selected':'')+'>- Schweiz</option>';
  tt+='<option value="FR-"'+((s=='FR-') ? ' selected':'')+'>- Frankreich</option>';
  tt+='<option value="BE-"'+((s=='BE-') ? ' selected':'')+'>- Belgien</option>';
  tt+='<option value="NL-"'+((s=='NL-') ? ' selected':'')+'>- Niederlande</option>';
  tt+='<option value="LU-"'+((s=='LU-') ? ' selected':'')+'>- Luxemburg</option>';
  tt+='<option value="IT-"'+((s=='IT-') ? ' selected':'')+'>- Italien</option></optgroup>';
  document.write(tt);
}


function Welcome( Query ){
var i = 0;
var cbo;
var isFlug=false;

	if( (Query!=null) && (Query.length >0) ) {
		var abfl = Query.substr( 0,3).toUpperCase();
		var ziel = Query.substr( 3,3).toUpperCase();
		var erwa = Query.substr( 6,1).toUpperCase();
		var kind = Query.substr( 7,1).toUpperCase();
		var baby = Query.substr( 8,1).toUpperCase();
		var stay = Query.substr( 9,2).toUpperCase();
		var star = Query.substr(11,1).toUpperCase();
		var room = Query.substr(12,2).toUpperCase();
		var food = Query.substr(14,2).toUpperCase();
		var tag  = Query.substr(16,2).toUpperCase();
		var monat= Query.substr(18,2).toUpperCase();
		var jahr = Query.substr(20,4).toUpperCase();
		var preis= Query.substr(24,4).toUpperCase();
		var tour = Query.substr(28,4).toUpperCase();

		isFlug= (room=="NF" && food=="NF");

		setSelBox(document.aform.ABFLUG,abfl);
		setSelBox(document.aform.ZIEL,ziel);
		setSelBox(document.aform.PERS,(erwa==0 ? 2:erwa));
		setSelBox(document.aform.KIND,kind);
		setSelBox(document.aform.BABY,baby);
		setSelBox(document.aform.DAUER,stay);

		if(!isFlug) setSelBox(document.aform.STERNE,star);
		if(!isFlug) setSelBox(document.aform.LEISTUNG,food);
		document.aform.ABDATUM.value= getStrDate(tag+monat+jahr);
		document.aform.REDATUM.value= getStrDate(ReDatum);

        }else{
		setSelBox(document.aform.PERS,"2");
		setSelBox(document.aform.DAUER,"08");
		document.aform.ABDATUM.value= getStrDate(AbDatum);
		document.aform.REDATUM.value= getStrDate(ReDatum);
	}
}

function setSelBox(cbo,v){
 for (i=0; i< cbo.length; i++) {
	if(cbo.options[i].value== v){
	 cbo.selectedIndex=i;
	 cbo.options[i].defaultSelected=true;
	 break;
	}
 }
}

function FlugZeit(theUrl){
 fZeit=window.open(theUrl, 'fZeit', 'scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,width=510,height=300');
}

function getStrDate(d){
 if(d.indexOf('.') >0) d=d.replace(/./g, '');
 return(d.substr(0,2)+'.'+d.substr(2,2)+'.'+d.substr(4,4))
}

function DatumFormat(ffma,n){
 if(ffma.indexOf(',') >0) ffma=ffma.replace(/,/g, ".");
 if(ffma.indexOf('-') >0) ffma=ffma.replace(/-/g, ".");
 ffch = DatumParm(n);
 ffmd = parseInt( ffma.substring(0, ffma.indexOf('.')), 10);
 if(isNaN(ffmd)) ffmd= ffch.substr(0,2);
 ffmd = (ffmd >9 ? '' : '0')+ffmd;
 ffmm = parseInt( ffma.substring(ffma.indexOf('.')+1, ffma.lastIndexOf('.')), 10);
 if(isNaN(ffmm)) ffmm= ffch.substr(2,2);
 ffmm = (ffmm >9 ? '' : '0')+ffmm;
 ffmy = parseInt( ffma.substring(ffma.lastIndexOf('.')+1, ffma.length), 10);
 if(isNaN(ffmy)) ffmy= ffch.substr(4,4);
 if(ffmy < 2000) ffmy= ffmy+2000
 if(ffma=='') ffma= ffch;
 else ffma= ffmd+ffmm+ffmy;
 return(ffma)
}

function StartSearch(){
ab=OptionValue(document.aform.ABFLUG);
an=OptionValue(document.aform.ZIEL);

  a=ab+an;
  b=OptionValue(document.aform.PERS)+OptionValue(document.aform.KIND)+OptionValue(document.aform.BABY)
  c=OptionValue(document.aform.DAUER);
  d=OptionValue(document.aform.STERNE);
  e=OptionValue(document.aform.ZIMMER);
  f=OptionValue(document.aform.LEISTUNG);
  if(document.aform.FLUG.checked) f="NF"
  g=DatumFormat(document.aform.ABDATUM.value,1);
  r=DatumFormat(document.aform.REDATUM.value,29);
  h="0000"
  i=""
  if(f=="NF") d=0, e="OO";
  start = new Date(g.substr(4,4),g.substr(2,2)-1,g.substr(0,2));
  rueck = new Date(r.substr(4,4),r.substr(2,2)-1,r.substr(0,2));
  Days  = Math.round((rueck-start)/86400000) 
  if(Days > 0 && Days <=300){
   if(Days >= 0+c-2){

    if( (an=="---") || (RegionKey.indexOf(an) >0) ){

	if(Klick!=10){
	 Klick=1;
	 out= escape(a+b+c+d+e+f+g+h+i);
	 document.Alleziele.ALL.value= out;
	 document.Alleziele.PLUS.value= Days;
	 progress_work();
	 document.Alleziele.submit();
	}

    }else{

	if(Klick!=10){
	 Klick=1;
	 out= escape(a+b+c+d+e+f+g+h+i);
	 document.Search.ID.value= out;
	 document.Search.PLUS.value= Days;
	 progress_work();
	 document.Search.submit();
	}

    }
   }else{
    alert("Die Reisedauer passt nicht in den gewünschten Urlaubszeitraum!")
    return (false);
   }
  }else{
	if( isNaN(Days) ) alert("Bitte wählen Sie Ihren Urlaubszeitraum!")
	if( Days==0 ) alert("Bitte wählen Sie einen gültigen Urlaubszeitraum!")
	if( Days >300 ) alert("Bitte wählen Sie einen gültigen Urlaubszeitraum!\nAb "+MakeDatum(1)+"\nbis max. "+MakeDatum(300))
	if( Days <0 ) alert("Der Rückreisetermin liegt vor dem Abreisetermin!")	
   return (false);
  }

 return (false);
}


function EASearch(){
 progress_work();
 return (true);
}


function VeranSelect(Object,Wert) {
 for (i = 0;  i < Object.length;  i++) {
  if(Object.options[i].value==Wert) {
   Object.selectedIndex=i;
   Object.options[i].defaultSelected=true;
  }
 }
}

