function makeValues(liste,stelle,ziel){
        var listeValues = liste.split(";");
        document.affiliate.elements[ziel].value=listeValues[stelle];
}


function setRegion(what){
//        if(document.affiliate.ixp.value=="katalog_2"){
//                fillSelect(dsi_P[what], document.affiliate.dsi_detail, 1)
//        }
//        if(document.affiliate.ixp.value=="hotel"){
//                fillSelect(dsi_H[what], document.affiliate.dsi_detail, 1)
//        }
//        if(document.affiliate.ixp.value=="charter"){
//                fillSelect(dsi_N[what], document.affiliate.dsi_detail, 1)
//        }
}

function deleteSelectOptions(feld){
        var laenge = feld.length;
        for (i=0; i <laenge; i++){
                feld.options[feld.length-1] = null;
        }
}


function addSelectOption(selectionElement,text,value)
{
        var option = document.createElement("OPTION");
        var Text = document.createTextNode(text);
        option.appendChild(Text);
        selectionElement.appendChild(option);
        selectionElement.options[selectionElement.options.length-1].value=value;
}

function fillSelects(){
	fillSelect(TTAFH, document.affiliate.abflughafen, 1);
	fillSelect(TTFDRZ, document.affiliate.ziel, 1);
	fillSelect(TOC, document.affiliate.marke, 1);
}

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]);
//        }
        deleteSelectOptions(ziel)
        for (i=0; i<liste.length; i++){
        var liste1 = liste[i].split(";");
                addSelectOption(ziel,liste1[0],liste1[1]);
        ziel.style.width="210px";
        }
}


function radioWert(rObj) {
        for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
        return false;
}


function chancheExpress(what){
        switch (what){
                case('P'):
                        //document.getElementById('five').style.display="";
                        //document.getElementById('six').style.display="";
                        //document.getElementById('seven').style.display="";
                        document.affiliate.ixp.value='katalog_2';
                        document.affiliate.action='./index.php?page=ibe_pauschal';
                        //fillSelect(hmi, document.affiliate.spacerone, 1);
                        fillSelect(dsi_P_Reg, document.affiliate.dsi_all, 1);
                        document.getElementById('switchfield4').style.display='';
                        document.getElementById('labelvnd').firstChild.nodeValue="Abflug";
                        document.getElementById('labelbsd').firstChild.nodeValue="Rückflug";
                        //document.getElementById('switchfield1').style.display='';
                        //document.getElementById('titlefive').firstChild.nodeValue="Reiseziel";
                        //document.getElementById('titlesix').firstChild.nodeValue="Region";
                        break;
                case('N'):
                        //document.getElementById('five').style.display="";
                        //document.getElementById('seven').style.display="none";
                        document.affiliate.ixp.value='charter';
                        document.affiliate.action='./index.php?page=ibe_charter';

                        //fillSelect(hmi, document.affiliate.spacerone, 1);
                        fillSelect(dsi_N_Reg, document.affiliate.dsi_all, 1);
                        document.getElementById('switchfield4').style.display='';
                        document.getElementById('labelvnd').firstChild.nodeValue="Abflug";
                        document.getElementById('labelbsd').firstChild.nodeValue="Rückflug";
                        //document.getElementById('switchfield4').style.display='';
                        //document.getElementById('titlefive').firstChild.nodeValue="Reiseziel";
                        //document.getElementById('six').style.display="none";
                        break;
                case('H'):
                        document.affiliate.ixp.value='hotel';
                        //alert(document.getElementById('switchfield3').firstChild.firstChild);
                        document.affiliate.action='./index.php?page=hotel&method=result';
                        document.getElementById('switchfield4').style.display='none';
                        document.getElementById('switchfield2').style.display='';
                        fillSelect(dsi_H_Reg, document.affiliate.dsi_all, 1);
                        setRegion(0);
                        document.getElementById('labelvnd').firstChild.nodeValue="Anreise";
                        document.getElementById('labelbsd').firstChild.nodeValue="Abreise";
                        break;
        }
}


function submitData(){
what=radioWert(document.affiliate.typ)
        switch(what){
                case('P'):
                        //makeValues(hmi_values,document.affiliate.spacerone.selectedIndex,"hmi")
                        makeValues(dsi_P_value[document.affiliate.dsi_all.selectedIndex],document.affiliate.dsi_detail.selectedIndex,"dsi")
                        break;
                case('N'):
                        //makeValues(hmi_values,document.affiliate.spacerone.selectedIndex,"hmi")
                        makeValues(dsi_N_value[document.affiliate.dsi_all.selectedIndex],document.affiliate.dsi_detail.selectedIndex,"dsi")
                        break;
                case('H'):
                        //document.affiliate.hmi.value="";
                        makeValues(dsi_H_value[document.affiliate.dsi_all.selectedIndex],document.affiliate.dsi_detail.selectedIndex,"dsi")
                        //makeValues(stc_values,document.affiliate.spacerfive.selectedIndex,"stc");
                        break;
        }
        document.forms['affiliate'].submit();
}
