
function getData(Parent, Level, Pos, cat_id) {
    if (cat_id!='undefined') {
        if (Level==-1) {  //knop init
            AjaxRequest.get( {
                'url':'rpc.php?parent='+Parent+'&level='+Level+'&pos='+Pos+'&cat_id='+cat_id
                ,'onSuccess': function (req) {fill_knob(req)}
            })
         } else if (Level>4) {
             AjaxRequest.get( {
                 //afwijkend: Parent bevat cat_id en cat_id bevat nws_id. Hier is de draaiknop gebruikt
                 'url':'rpc.php?parent='+Parent+'&level='+Level+'&pos='+Pos+'&cat_id='+cat_id
                 ,'onLoading':function() {document.getElementById("cntimage").style.visibility="visible";}
                 ,'onSuccess': function (req) {show_content(req)}
             }
           )
        } else {
            AjaxRequest.get( {
                'url':'rpc.php?parent='+Parent+'&level='+Level+'&pos='+Pos+'&cat_id='+cat_id
                ,'onSuccess': function (req) {show_content(req)}
            }
          )
        }
    } else {
        //bij gebruik van de draaiknop volgende set ophalen wanneer het einde v/d lampjes is bereikt
        //Pos bevat hier het laatste news_id uit deze reeks
        AjaxRequest.get( {
            'url':'rpc.php?parent='+Parent+'&level='+Level+'&pos='+Pos+'&cat_id=undefined'
            ,'onSuccess': function (req) {show_content(req)}
            }
        )
    }
}


function show_content(req) {
    // access elements. deze heten allemaal 'item'
    //De eerste laag begint met 'a'. Dit is tevens de identifier van de layers. a1, a2 enz.
    var item = req.responseXML.getElementsByTagName('item');
                         var myArr = new Array;
                         myArr = getElementsByClass("titlefont");
    nws_count=0;
    cat_count=0;
    var tmp=0;
    for (i=1;i<item.length+1;i++) {
        bfound=false;
         //i begint bij 1 omdat i ook de pos is uit de database en die begint bij 1
         //document.getElementById('debug').innerHTML=item[i-1].getAttribute('cat_level');
        if (item[i-1].getAttribute('cat_id')!=null) {
             //eerste 4 categorie namen tonen (init)
            cat_id=item[i-1].getAttribute('cat_id');
            if (item[i-1].getAttribute('cat_level')==1) {
                document.getElementById("head"+item[i-1].getAttribute('cat_pos')).innerHTML='<img src="images/spacer.gif" alt="" height="1" width="3" border="0">'+item[i-1].getAttribute('cat_name');
                if (item[i-1].getAttribute('cat_pos')==1) {
                    cat_id1=item[i-1].getAttribute('cat_id');
                } else if (item[i-1].getAttribute('cat_pos')==2) {
                    cat_id2=item[i-1].getAttribute('cat_id');
                } else if (item[i-1].getAttribute('cat_pos')==3) {
                    cat_id3=item[i-1].getAttribute('cat_id');
                } else if (item[i-1].getAttribute('cat_pos')==4) {
                    cat_id4=item[i-1].getAttribute('cat_id');
                }
           } else if (item[i-1].getAttribute('cat_level')==2) {
                //op 1 van de knoppen geklikt
                if (typeof titles!="object") {
                    titles = new getObj('cnttitles');
                }
                subcat_style='position: relative; top: -185px; left: 33px; height: 15px; width:180px; color:#FFFFFF; background-color: #DFDFDF; z-index:2;';
                document.getElementById('titles'+item[i-1].getAttribute('parpos')).innerHTML=document.getElementById('titles'+item[i-1].getAttribute('parpos')).innerHTML+' \n \
                <div class="nav" id="b'+item[i-1].getAttribute('cat_id')+'" style="'+subcat_style+'"> \n \
                    <a href="javascript:void(0)" onclick="show(\'cnttitles|'+item[i-1].getAttribute('cat_parent')+'|'+item[i-1].getAttribute('cat_id')+'\');"> \n \
                        <div id="d'+item[i-1].getAttribute('cat_id')+'" style="position: relative; left:2px;"> \n \
                            <font class="titlefont" id="df'+item[i-1].getAttribute('cat_id')+'"> \n \
                                 - '+item[i-1].getAttribute('cat_name')+' \n \
                            </font> \n \
                        </div> \n \
                    </a> \n \
                </div>\n';
           } else if (item[i-1].getAttribute('cat_level')==3) {
                // op een link onder de knoppen geklikt. middelste blok wordt gevuld
                cat_ids[cat_count]=cat_id;
                cat_count++;
                subcat_style='position: relative; top: 0px; left: 2px; height: 15px; width:127px; color:#FFFFFF; background-color: #DFDFDF; z-index:3;';
                var o = testForObject("cnttitles","div");
                if (o) {
                    document.getElementById('cnttitles').innerHTML=document.getElementById('cnttitles').innerHTML+' \n \
                    <div class="titles" id="c'+item[i-1].getAttribute('cat_id')+'" style="'+subcat_style+'"> \n \
                        <a href="javascript:void(0)" onclick="show(\'news|'+item[i-1].getAttribute('cat_parent')+'|'+item[i-1].getAttribute('cat_id')+'\');"> \n \
                            <div id="d'+item[i-1].getAttribute('cat_id')+'"> \n \
                                <font class="titlefont" id="df'+item[i-1].getAttribute('cat_id')+'"> \n \
                                     - '+item[i-1].getAttribute('cat_name')+' \n \
                                </font> \n \
                            </div> \n \
                        </a> \n \
                    </div>\n';
                }
            }
        }

        if (item[i-1].getAttribute('nws_id')!=null) {
            nws_id=item[i-1].getAttribute('nws_id');
            nws_pos=item[i-1].getAttribute('nws_pos');
            cur_cat_id=item[i-1].getAttribute('nws_cat_id');
            if (item[i-1].getAttribute('cat_pos')==1 && item[i-1].getAttribute('cat_level')==1) {
                // INFO vullen
                cText=item[i-1].getAttribute('nws_text');
                cText=cText.replace(/!@#/g,'<br>');
                cText=cText.replace(/&lt;/g,'<');
                cText=cText.replace(/&gt;/g,'>');
                var o = testForObject("f"+nws_pos,"div");
                if (o) {
                    document.getElementById("f"+nws_pos).innerHTML=cText;
                }
            } else {
                    //bij gebruik van de lampjes op de knop is level 5. De count en array mogen dan niet worden bijgewerkt. ZIjn anders beide 1
                    //wanneer een nws_id al in de array zit komt dit omdat er meerdere afbeeldingen bij zijn opgeslagen. In dat geval alleen de extra afbeelding erbij tonen
                ontdubbel:
                for (var a=0;a<1000;a++){  //nws_ids.length werkt niet. komen toch niet meer dan 1000 items in 1 category
                    if (nws_ids[a]=='undefined') {
                        break ontdubbel;
                    } else if (nws_ids[a]==nws_id) {
                        bfound=true;
                        break ontdubbel;
                    }
                }
                if (item[i-1].getAttribute('cat_parent')>0) {
                    cat_parent=item[i-1].getAttribute('cat_parent');
                }
                if (item[i-1].getAttribute('nws_cat_id')>0) {
                    //cat_parent wordt hier overschreven
                    cat_parent=item[i-1].getAttribute('nws_cat_id');
                }
                if (bfound) {
                    if (item[i-1].getAttribute('clb_filename')!=null) {
                        var o = testForObject("cntimage","div");
                        if (o) {
                           document.getElementById("cntimage").innerHTML='<img src="cnt_img/'+item[i-1].getAttribute('clb_filename')+'" alt="">';
                        }
                    }
                } else {
                    nws_ids[nws_count]=nws_id;
                    var o = testForObject("cntimage","div");
                    if (o) {
                        if (item[i-1].getAttribute('clb_filename')!=null && InStr(document.getElementById("cntimage").innerHTML, 'loading.gif')>0) {
                            document.getElementById("cntimage").innerHTML='<img src="cnt_img/'+item[i-1].getAttribute('clb_filename')+'">';
                            //alert(item[i-1].getAttribute('clb_filename'));
                        }
                    }
                nws_count++;
                }
                var o = testForObject("news","div");
                if (o) {
                    if (document.getElementById("news").innerHTML=='') {
                        cur_nws_id=nws_id;
                        cText=item[i-1].getAttribute('nws_text').replace(/!@#/g,'<br>');
                        //In sommige texten staat ergens achterin de text een '>'. Alles achter dit pijltje moet dat in italic.
                        italic='';
                        if (cText.indexOf('__ITALIC__')) {
                            cText=cText.replace(/__ITALIC__/g,"<i>&gt;");
//in een string wordt de string '__ITALIC__' gevonden. Dit wordt replaced met <i>
//Alleen nu moet de eerstvolgende <br> vervangen worden voor </i><br>
                        italic='</i>';
                        }
                        document.getElementById("news").innerHTML='<b>'+item[i-1].getAttribute('nws_title')+'</b><br>'+cText+italic+'<br><br>';
                        if (item[i-1].getAttribute('cat_parent')!=null) {
                            //bepalen welke categorie ook alweer rood moest worden. Dat id even bewaren. Dit kan bij gebruik van de kop niet in de functie show.
                            //stukkie naar beneden wordt tmp gebruikt
                            tmp=cat_parent;
                        }
                    }
                }
            }
        }
    }
    if (tmp>0) {
        for (x=0;x<myArr.length; x++){
            myArr[x].style.color = "#000000";
        }
        document.getElementById("df"+tmp).style.color="#C40000";
        document.getElementById("df"+cat_parent_parent).style.color="#C40000";
    }
    if (nws_count>0) {
        if (nws_count > 11) {nws_count=11}
        let_there_be_light(0, 1, nws_count+1);  //bedien de lampjes, Functie zit in js.js
    }
}
try {
  alert(document.getElementById('cnttitles').height);
} catch (err) {}
// if (testForObject("titles2","div")) {
//   alert(document.getElementById('titles2').style.zIndex);
//   document.getElementById('titles2').style.zIndex='3';
//   alert(document.getElementById('titles2').style.zIndex);
// }
//catch(err){}

function fill_knob(req) {
    var item = req.responseXML.getElementsByTagName('item');
    for (i=1;i<item.length+1;i++) {
        if (item[i-1].getAttribute('nws_id')!=null) {

        }
    }
}

