//--globals------------------------
var xdoc;
var them;


//--load xml-file-------------------
function init(){
	sendRequest('newslist.xml',init2);
}

//--save response document and show listing------
function init2(req){
        xdoc =  req.responseXML;
        showlist();
}

//--show listing by constructing new elements
function showlist(){

    var cont = document.getElementById('content');
    
    them = xdoc.getElementsByTagName('ref');
    
    for(i=0;i<them.length;i++){
        
        var tname = them[i].getAttribute('title');
        var tinh = them[i].getElementsByTagName('text');
        var tcont = tinh[0].firstChild.nodeValue;
        
        
        
        var mdiv = document.createElement('div');
        mdiv.className = 'refitem';
	var headline = document.createElement('div');
        headline.className = 'hdl';
        headline.appendChild(document.createTextNode(tname));
        
        var thetext = document.createElement('div');
        if(tcont.indexOf('*') >= 0){
                var paras = tcont.split('*');
                for(var j=0;j<paras.length;j++){
                        thetext.appendChild(document.createTextNode(paras[j]));
                        thetext.appendChild(document.createElement('br'));
                }
        }
        else thetext.appendChild(document.createTextNode(tcont));

        
       
        
        mdiv.appendChild(headline);
        mdiv.appendChild(thetext);
        
        cont.appendChild(mdiv);   
    }
    
}





