// JavaScript File

//if we can rip the inner HTML out of the news div, we can do pretty well what we want with it... //
function init(){
    var BBC_news_ticker;
    BBC_news_ticker = document.getElementById("BBC_news_ticker");
    var strHTML;
    strHTML = BBC_news_ticker.innerHTML;
    //alert(strHTML);
    //and it works - We (in fact, *I*) have extracted the news text from the div. 
    
    //now manipulate the  div's content
    var mySymbol;
    mySymbol = "�";//used in the news text instead of a "£" symbol
    
    //alert(strHTML.indexOf("\n"));
    var myRegEx = /�/g;
    //now replace with a Pound ("£") symbol
    strHTML = strHTML.replace(myRegEx, "&pound;");
    
    /* get rid of opening <div> tags */
    /* note: I have catered for upper and lower case tags */
    myRegEx = /<div class="rss-box">/;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<div class=rss-box>/;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<DIV class="rss-box">/;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<DIV class=rss-box>/;
    strHTML = strHTML.replace(myRegEx, "");
    
    /* now dispose of opening list <ul> tags */
    myRegEx = /<ul class="rss-items">/g;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<ul class=rss-items>/g;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<UL class="rss-items">/g;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<UL class=rss-items>/g;
    strHTML = strHTML.replace(myRegEx, "");

    /* now get rid of tags for listitems <li> */
    myRegEx = /<li class="rss-item">/g;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<li class=rss-item>/g;
    strHTML = strHTML.replace(myRegEx, "")
    myRegEx = /<LI class="rss-item">/g;
    strHTML = strHTML.replace(myRegEx, "");
    myRegEx = /<LI class=rss-item>/g;
    strHTML = strHTML.replace(myRegEx, "");
    
    myRegEx = /<BR>/g;
    strHTML = strHTML.replace(myRegEx, "&nbsp;&#149;&nbsp;");
    myRegEx = /<br>/g;
    strHTML = strHTML.replace(myRegEx, "&nbsp;&nbsp;&#149;&nbsp;"); 
    
    myRegEx = /\n/g;
    strHTML = strHTML.replace(myRegEx, "");
    
    myRegEx = /target=_self/g;
    strHTML = strHTML.replace(myRegEx, 'target="_blank"');      
    myRegEx = /target="_self"/g;
    strHTML = strHTML.replace(myRegEx, 'target="_blank"');
    myRegEx = /_self/g;
    strHTML = strHTML.replace(myRegEx, '_blank');
    
    myRegEx = /<\/li>/g;
    strHTML = strHTML.replace(myRegEx, "&nbsp;");
    myRegEx = /<\/LI>/g;
    strHTML = strHTML.replace(myRegEx, "&nbsp;");
    
    //alert(strHTML);
    
    BBC_news_ticker.innerHTML = strHTML;
    //get a handle on the new "ticker" div
    var ticker = document.getElementById("ticker");
    ticker.innerHTML = "<strong>Latest Business News from the BBC&nbsp;&nbsp;&#149;&nbsp;" + strHTML + "</strong>";
}
