//var monarchsNewsHeadlinesRssURL = "/monarchs/rss/Monarchs_News_Ticker_RSS-229779-465.html";
var monarchsNewsHeadlinesRssURL = "/monarchs/rss/monarchs-news-ticker.xml";
//END LAH ADD 061807

createElem = iventa.dom.createElem;
function $(elemId) { return document.getElementById(elemId); }
hasClass = iventa.dom.hasClass;
addClass = iventa.dom.addClass;
removeClass = iventa.dom.removeClass;
removeChildren = iventa.dom.removeChildren;
addEvent = iventa.events.addEvent;

//LAH - 061807 - Add ticker code

iventa.events.addOnLoad(startHeadlinesDisplay);
 
function startHeadlinesDisplay() {
    var xmlconvertor = new XmlToJSONConvertor;
    xmlconvertor.loadXML(monarchsNewsHeadlinesRssURL, function (data) {
        serializedNewsHeadlines = data;
        showHeadlines(0);
    });
}
 
function showHeadlines(index) {
    var span = $("newsHeadlines").getElementsByTagName("span")[0];
    removeChildren(span);
    span.appendChild(createElem("a", {
        href: serializedNewsHeadlines.rss.channel.item[index].link, 
        title: "Read more about this news story", 
        content: serializedNewsHeadlines.rss.channel.item[index].title
    }));
    var nextIndex = ++index;
    if (index == serializedNewsHeadlines.rss.channel.item.length) {
        var nextIndex = 0;
    }
 
    setTimeout("showHeadlines(" + nextIndex + ");", 10000);
}
//LAH 061807 - END Add Ticker Code
//LM 060409 - Navigation Drop Down
window.onload = function() {
            // Work the menus
            var navigation = $("mainNavigation");
            navChildren = navigation.childNodes;
            //var lis = navigation.getElementsByTagName("li");
            for(var i=0; i<navChildren.length; i++) {
                if(navChildren[i].nodeName.toLowerCase() == "li") {
                    addEvent(navChildren[i], "mouseover", function() {
                        addClass(this, "over");
                        if(this.getElementsByTagName("ul").length > 0)
                            this.getElementsByTagName("ul")[0].style.display = "block";
                    });

                    addEvent(navChildren[i], "mouseout", function() {
                        removeClass(this, "over");
                        if(this.getElementsByTagName("ul").length > 0)
                            this.getElementsByTagName("ul")[0].style.display = "none";
                    });

                }
            }
            navigation = $("secNavigation");
            navChildren = navigation.childNodes;
            //var lis = navigation.getElementsByTagName("li");
            for(var i=0; i<navChildren.length; i++) {
                if(navChildren[i].nodeName.toLowerCase() == "li") {
                    addEvent(navChildren[i], "mouseover", function() {
                        addClass(this, "over");
                        if(this.getElementsByTagName("ul").length > 0)
                            this.getElementsByTagName("ul")[0].style.display = "block";
                    });

                    addEvent(navChildren[i], "mouseout", function() {
                        removeClass(this, "over");
                        if(this.getElementsByTagName("ul").length > 0)
                            this.getElementsByTagName("ul")[0].style.display = "none";
                    });

                }
            }        
            navigation = $("Links");
            navChildren = navigation.childNodes;
            //var lis = navigation.getElementsByTagName("li");
            for(var i=0; i<navChildren.length; i++) {
                if(navChildren[i].nodeName.toLowerCase() == "li") {
                    addEvent(navChildren[i], "mouseover", function() {
                        addClass(this, "over");
                        if(this.getElementsByTagName("ul").length > 0)
                            this.getElementsByTagName("ul")[0].style.display = "block";
                    });

                    addEvent(navChildren[i], "mouseout", function() {                        
                        removeClass(this, "over");
                        if(this.getElementsByTagName("ul").length > 0)
                            this.getElementsByTagName("ul")[0].style.display = "none";
                    });
                    
                }
            }
        }
