//QUELLE: http://www.traffics-switch.de/website/allinone/templates/all-in-one/scripts/functions.js
var hmi="bitte wählen;Nord;- Ost;- Mitte;- Süd;- West;- Österreich;- Schweiz;Berlin;Berlin Schönefeld;Berlin Tegel;Bremen;Dortmund;Dresden;Düsseldorf;Erfurt;Frankfurt / Main;Friedrichshafen;Hamburg;Hannover;Hof;Karlsruhe;Köln / Bonn;Leipzig;München;Münster;Nürnberg;Paderborn;Rostock;Saarbrücken;Salzburg;Stuttgart;Wien;Linz;Zürich;Basel/Mülhausen;";
var hmi_values="BRE,HAJ,HAM,LBC;AOC,DRS,ERF,FNB,LEJ,RLG,SXF,SZW,TXL,THF;FKB,FRA,HHN;AGB,FDH,HOQ,MUC,NUE,STR;CGN,DTM,DUS,FMO,MGL,NRN,PAD,SCN;SZG,LNZ,VIE;BSL,ZRH;AOC;AGB;BSL;TXL,SXF,THF;SXF;TXL;THF;BRE;DTM;DRS;DUS;ERF;FRA;FDH;HHN;HAM;HAJ;HOQ;FKB;CGN;LEJ;LNZ;LBC;MGL;MUC;FMO;FNB;NRN;NUE;PAD;RLG;SCN;SZG;SZW;STR;VIE;ZRH;AMS,MLH,BSL,LUX,LGG,BRU,MST;AMS;&nbsp;MLH;&nbsp;BSL,MLH;LUX;LGG;BRU;MST;";

var dsi="Mallorca";
var dsi_values="PMI";

var dsihotel="Mallorca";
var dsihotel_values="PMI";

var stc="beliebig";
var src_values="*";

function makeValues(liste,stelle,ziel){
	var listeValues = liste.split(";");
	document.forms['frmTRFXSuchmaske'].elements[ziel].value=listeValues[stelle];
}


function deleteSelectOptions(feld){
	var laenge = feld.length;
	for (i=0; i <laenge; i++){
		feld.options[feld.length-1] = null;
	}
}


function addSelectOption(selectionElement, text)
{
	var option = document.createElement("OPTION");
	var Text = document.createTextNode(text);
	option.appendChild(Text);
	selectionElement.appendChild(option)
}

function fillSelect(liste, ziel, init) {
	var liste1 = liste.split(";");
	if (init == 1){
		deleteSelectOptions(ziel);
	}
	for (i=0; i<liste1.length; i++){
		addSelectOption(ziel, liste1[i]);
	}
}


function radioWert(rObj) {
	for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
	return false;
}


function chancheExpress(){

	switch (radioWert(document.forms['frmTRFXSuchmaske'].typ)){
		case('P'):
			document.forms['frmTRFXSuchmaske'].ixp.value='pauschal';
			fillSelect(hmi, document.forms['frmTRFXSuchmaske'].spacerone, 1);
			fillSelect(dsi, document.forms['frmTRFXSuchmaske'].spacertwo, 1);
			document.getElementById('titleone').firstChild.nodeValue="Abflughafen";
			document.getElementById('titletwo').firstChild.nodeValue="Frühester Abflug";
			document.getElementById('titlethree').firstChild.nodeValue="Reiseziel";
			document.getElementById('titlefour').firstChild.nodeValue="Spätester Rückflug";
			break;
		case('N'):
			document.forms['frmTRFXSuchmaske'].ixp.value='charter';
			fillSelect(hmi, document.forms['frmTRFXSuchmaske'].spacerone, 1);
			fillSelect(dsi, document.forms['frmTRFXSuchmaske'].spacertwo, 1);
			document.getElementById('titleone').firstChild.nodeValue="Abflughafen";
			document.getElementById('titletwo').firstChild.nodeValue="Frühester Abflug";
			document.getElementById('titlethree').firstChild.nodeValue="Reiseziel";
			document.getElementById('titlefour').firstChild.nodeValue="Spätester Rückflug";
			break;
		case('H'):
			document.forms['frmTRFXSuchmaske'].ixp.value='hotel';
			fillSelect(dsihotel, document.forms['frmTRFXSuchmaske'].spacerone, 1);
			fillSelect(stc, document.forms['frmTRFXSuchmaske'].spacertwo, 1);
			document.getElementById('titleone').firstChild.nodeValue="Reiseziel";
			document.getElementById('titletwo').firstChild.nodeValue="Früheste Anreise";
			document.getElementById('titlethree').firstChild.nodeValue="Hotelkategorie";
			document.getElementById('titlefour').firstChild.nodeValue="Späteste Abreise";
			break;
	}
	abreise();
}

function setKeywords(sValue) {
    document.forms['frmTRFXSuchmaske'].elements['fts'].value = document.forms['frmTRFXSuchmaske'].elements['fts'].value + ' ' + sValue;
}


function submitData(){
	var ibelink="http://comfort.traffics-switch.de/tibet.php";
	var quicksearchdata="?";
    document.forms['frmTRFXSuchmaske'].elements['thm'].value=customer_thm;
	/*options[feld.selectedIndex].value;
	form.elements['mySel'].options[0].value
	form.elements['mySel'].options[0].value
	document.forms['frmTRFXSuchmaske'].elements["Auswahl"].selectedIndex*/
	quicksearchdata += "cfg="+customer_cfg;
	quicksearchdata += "&thm="+customer_thm;
	quicksearchdata += "&ref=";
	quicksearchdata += document.forms['frmTRFXSuchmaske'].ref.value;
	quicksearchdata += "&stp=2";
	quicksearchdata += "&epc="+document.forms['frmTRFXSuchmaske'].elements["epc"].options[document.forms['frmTRFXSuchmaske'].elements["epc"].selectedIndex].value;
	quicksearchdata += "&ka1="+document.forms['frmTRFXSuchmaske'].elements["ka1"].options[document.forms['frmTRFXSuchmaske'].elements["ka1"].selectedIndex].value;
	quicksearchdata += "&ka2="+document.forms['frmTRFXSuchmaske'].elements["ka2"].options[document.forms['frmTRFXSuchmaske'].elements["ka2"].selectedIndex].value;
	quicksearchdata += "&ka3="+document.forms['frmTRFXSuchmaske'].elements["ka3"].options[document.forms['frmTRFXSuchmaske'].elements["ka3"].selectedIndex].value;
	quicksearchdata += "&vnd="+document.forms['frmTRFXSuchmaske'].elements["vnd"].options[document.forms['frmTRFXSuchmaske'].elements["vnd"].selectedIndex].value;
	quicksearchdata += "&bsd="+document.forms['frmTRFXSuchmaske'].elements["bsd"].options[document.forms['frmTRFXSuchmaske'].elements["bsd"].selectedIndex].value;
	quicksearchdata += "&mmc="+document.forms['frmTRFXSuchmaske'].elements["mmc"].options[document.forms['frmTRFXSuchmaske'].elements["mmc"].selectedIndex].value;
	quicksearchdata += "&sub="+document.forms['frmTRFXSuchmaske'].elements["sub"].options[document.forms['frmTRFXSuchmaske'].elements["sub"].selectedIndex].value;

	switch(radioWert(document.forms['frmTRFXSuchmaske'].typ)){
		case('P'):
			quicksearchdata += "&ixp=pauschal";
			quicksearchdata += "&typ=P";
			makeValues(hmi_values,document.forms['frmTRFXSuchmaske'].elements["spacerone"].selectedIndex,"hmi");
			makeValues(dsi_values,document.forms['frmTRFXSuchmaske'].spacertwo.selectedIndex,"dsi");
			quicksearchdata += "&hmi="+document.getElementById("hmi").value;
			quicksearchdata += "&dsi="+document.getElementById("dsi").value;
			// ORIGINAL // ibelink="lastminute.php";
			break;
		case('N'):
			quicksearchdata += "&ixp=charter";
			quicksearchdata += "&typ=N";
			makeValues(hmi_values,document.forms['frmTRFXSuchmaske'].spacerone.selectedIndex,"hmi");
			makeValues(dsi_values,document.forms['frmTRFXSuchmaske'].spacertwo.selectedIndex,"dsi");
			quicksearchdata += "&hmi="+document.getElementById("hmi").value;
			quicksearchdata += "&dsi="+document.getElementById("dsi").value;
			break;
		case('H'):
			quicksearchdata += "&ixp=hotel";
			quicksearchdata += "&typ=H";
			document.forms['frmTRFXSuchmaske'].hmi.value="";
			makeValues(dsihotel_values,document.forms['frmTRFXSuchmaske'].spacerone.selectedIndex,"dsi");
			var sterne=src_values.split(";");
			sterne[0]="0";
			//var sterne=makeValues(src_values,document.forms['frmTRFXSuchmaske'].spacertwo.selectedIndex,"stc");
			//quicksearchdata += "&stc="+document.getElementById("spacertwo").value;
			quicksearchdata += "&stc="+sterne[(document.forms['frmTRFXSuchmaske'].spacertwo.selectedIndex)];
			quicksearchdata += "&dsi="+document.getElementById("dsi").value;
			break;
	}
	//location.href=""+ibelink+quicksearchdata;
	submit2IFrame(ibelink+quicksearchdata);
	//document.forms['frmTRFXSuchmaske'].submit();
}


// Anzeige der Ergebnisse in einem IFrame unter der Suchmaske
function submit2IFrame(URL)
{
	document.getElementById("DTFLUG").style.display="block";
	document.getElementById("TFLUG").height = "880";
	document.getElementById("TFLUG").src = URL;
}



// QUELLE: T.I.B.E.T. Schnellsuchmaske 1


DatArray = new Array("So","Mo","Di","Mi","Do","Fr","Sa","??" );
var today = new Date();
var dayOffset = 1000 * 60 *60 * 24;
var tomorow = new Date(today.getTime() + dayOffset);

function writeDateSelect(startDate, howMany, selected) {
    startTime = startDate.getTime();
    var day = new Date(startTime);
    for (var i=1; i<howMany; i++) {
        day.setTime(startTime + (dayOffset * i));
        var selectStr = "<option value=\"" + (day.getTime()-
            (day.getTime()%1000))/1000 + "\""
        if (i == selected) {
            selectStr = selectStr + " selected "
        }
        selectStr = selectStr + ">" + Getdatum(i) + "</option>";
        document.write(selectStr);
    }
}

function Getdatum(offset) {
    var time = new Date()
    time.setTime( time.getTime()+offset*86400000)
    return DatArray[time.getDay()]+' '+time.getDate()
        +'.'+(1+time.getMonth())+'.'+(2000+(time.getYear()%100))
}

function abreise() {
    var value = (document.forms['frmTRFXSuchmaske'].mmc.options[document.forms['frmTRFXSuchmaske'].mmc.selectedIndex].value);
    var duration_default = 15;
    switch(value) {
        case "0": duration = 28; break;
        case "1-5t": duration = 5; break;
        case "1w": duration = 7; break;
        case "6-8t": duration = 8; break;
        case "9-12t": duration = 12; break;
        case "2w": duration = 14; break;
        case "13-16t": duration = 16; break;
        case "3w": duration = 21; break;
        case "17-22t": duration = 22; break;
        case "4w": duration = 28; break;
        case "27-28t": duration = 28; break;
        case "tr1": case "tr2": case "tr3": duration = duration_default; break;
        default: duration = duration_default; break;
    }
    if (document.forms['frmTRFXSuchmaske'].bsd.selectedIndex < (document.forms['frmTRFXSuchmaske'].vnd.selectedIndex + duration)) {
        if ((document.forms['frmTRFXSuchmaske'].vnd.selectedIndex + duration) <= document.forms['frmTRFXSuchmaske'].bsd.options.length) {
            document.forms['frmTRFXSuchmaske'].bsd.selectedIndex = document.forms['frmTRFXSuchmaske'].vnd.selectedIndex + duration;
        } else {
            document.forms['frmTRFXSuchmaske'].bsd.selectedIndex = document.forms['frmTRFXSuchmaske'].bsd.options.length-1;
        }
    }
}

function MM_reloadPage(init)
{ //reloads the window if Nav4 resized
    if (init==true) with (navigator) {
        if ((appName=='Netscape')&&(parseInt(appVersion)==4)) {
            document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
        }
    } else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
        location.reload();
}

MM_reloadPage(true);
var zufallszahl = 1 + 9999999*(Math.random());
var zahl = Math.round(zufallszahl);
// Funktioniert nicht mit Netscape 4.7 !!!

// Kommentar: ermittle heutiges Datum (Richtet sich nach dem Datum, das der Anwender auf seine Rechner hat
var jetzt = new Date();
var Tag = jetzt.getDate()+3;
var Monat = jetzt.getMonth();
var Jahr = jetzt.getFullYear();

// Kommentar: heutiges Datum plus 7 Tage ( + 7 kann verändert werden)
var bald = new Date(Jahr,Monat,Tag + 7);
var Tag_b = bald.getDate();
var Monat_b = bald.getMonth();
var Jahr_b = bald.getFullYear();

// Kommentar: erzeuge Dropdown-Inhalt per JS-Function
function create_dd(start,end,selected) {
    for(var COUNT=start; COUNT <= end; COUNT++) {
        if (COUNT == selected)
            document.write("<option value=" + COUNT +"selected>" + COUNT + "</option>");
        else
            document.write("<option value="+ COUNT+">"+ COUNT+"</option>");
    }
}


function getCoords(){

    var top = screen.availHeight;

    if(document.all){
        var yadd = document.body.scrollTop;
        var left = document.body.offsetWidth;
    }
    else{
        var yadd = window.pageYOffset;
        var left = window.innerWidth;
    }

    if(((left/2)- 280)>0){
        posx=((left/2)-140);
    }
    else{
        posx=20;
    }
    if(((top/2)- 100)>0){
        posy=(((top/2) - 200) + yadd + 0);
    }
    else{
        posy=20;
    }
}


function show_animation() {
    getCoords();
    document.getElementById('animation').style.left = posx+'px';
    document.getElementById('animation').style.top = posy+'px';
    document.getElementById('animation').style.visibility = "visible";
}

function position_animation() {
    getCoords();
    document.getElementById('animation').style.left = posx+'px';
    document.getElementById('animation').style.top = posy+'px';
}