// Ensure LIT namespace is available
if (typeof(LIT) == "undefined")
{
    var LIT = {};
}

/**
 * Handles random display of project details in a project spotlight section.
 */
LIT.ProjectSpotlight =
{
    projects: [
        {name: "Personal Insurance", content: ["<strong>Personal Markets</strong>, Liberty Mutual's largest business segment, provides full lines of coverage for private passenger automobile, homeowners, valuable possessions and personal liability through its own sales force in more than 400 offices throughout the U.S., two direct response centers, appointed Prudential agents and the internet.", "It also offers a wide range of traditional and variable life insurance and annuity products. Liberty IT is the primary developer of the main sales portal for Personal Markets.", "Available twenty-four hours a day, 365 days of the year, the quality of the applications developed by Liberty IT are key to the ongoing success of this market."]},
        {name: "Commercial Insurance", content: ["Liberty Mutual's <strong>Commercial Markets</strong> provides sophisticated risk and disability management and risk transfer services.", "As one of the leading providers of workers compensation (employers liability) insurance, Liberty Mutual has 90 years of experience serving the needs of businesses.", "Liberty IT has contributed to the success of Commercial Markets by developing and supporting the underlying workers compensation rating and policy issuance system.", "Our efforts over the years has allowed Liberty Mutual to respond to customer demand by simplifying the policy issuance process."]},
        {name: "Agency Sales", content: ["<strong>Agency Markets</strong> consists of property and casualty, and specialty insurance carriers that distribute their products and services primarily through independent agents and brokers.", "Core property and casualty products, including a comprehensive set of personal and commercial coverages are available in most states.", "Whilst still being a relatively new venture for Liberty IT, we are already responsible for the support and development of the main commercial lines policy administration system, and are actively researching emerging technology trends to ensure that Liberty Mutual retains its competitive advantage."]},
        {name: "International Operations", content: ["Within <strong>Liberty International</strong>, Liberty IT are assisting Liberty Mutual in its continued global expansion by devising and implementing an Information Management strategy.", "By providing access to accurate and up-to-date information, Liberty IT is helping to ensure that the Underwriters take on the right risk."]}
//        {name: "Unidentified Project", content: ["We can have as many or as few of these as we like. JB has written this using JavaScript and can include many many types of <strong>hyper</strong> <em>text</em> <sub>mark</sub> <sup>up</sup> that we like.", "All very nifty if you ask me."]}
    ],

    init: function()
    {
        var container = $("project-spotlight");
        if (!container)
        {
            return;
        }

        this.clearElement(container);
        var project = this.projects[Math.floor(Math.random() * this.projects.length)];
        var header = document.createElement("h3");
        header.appendChild(document.createTextNode(project.name));
        container.appendChild(header);
        for (var i = 0, l = project.content.length; i < l; i++)
        {
            var paragraph = document.createElement("p");
            paragraph.innerHTML = project.content[i];
            container.appendChild(paragraph);
        }
    },

    /**
     * Clears the given DOM element of any content.
     *
     * @param el {Element} the element to be cleared of content.
     */
    clearElement: function(el)
    {
        while(el.firstChild)
        {
            el.removeChild(el.firstChild);
        }
    }
};

// Always initialise on page load
Event.observe(window, "load", LIT.ProjectSpotlight.init.bind(LIT.ProjectSpotlight));
