var m_showcases = new Array();
m_showcases[0] = new showcase('ManagedText&trade; Financial Suite', 'showcase_1.jpg', 'mt_suite_financial.html', 'Addresses the communications challenges faced by banking and finance companies today.');
m_showcases[1] = new showcase('ManagedText&trade; Police Suite', 'showcase_2.jpg', 'mt_suite_police.html', 'Specifically designed to help address the communications challenges faced by Police forces today.');
m_showcases[2] = new showcase('ManagedText&trade; Systems Integrators Suite', 'showcase_3.png', 'mt_suite_systemsintegrator.html', 'A flexible and secure framework to support bespoke development solutions.');
m_showcases[3] = new showcase('ManagedText&trade; SME Suite', 'showcase_4.jpg', 'mt_suite_sme.html', 'Addresses the communications challenges faced by small businesses today.');
m_showcases[4] = new showcase('ManagedText&trade; Local Government Suite', 'showcase_5.png', 'mt_suite_localgovernment.html', 'Addresses the communications challenges faced by local government today.');

// Used to store the array indicies of already-selected showcases
var m_pickedShowcases = new Array();

function featureShowcases(numberOfShowcases)
{   
    var showcaseNumber;
    var pickedShowcase;
    var html = '';
    
    html += ('<ul>');
    
    for (var i=0; i<numberOfShowcases; i++)
    {    
        showcaseNumber = pickShowcase();
        m_pickedShowcases[m_pickedShowcases.length+1] = showcaseNumber;
        pickedShowcase = m_showcases[showcaseNumber];
        
        // Render the showcase
        html += ('<li>');
        html += ('<a href="' + pickedShowcase.href + '"><img src="images/' + pickedShowcase.img + '" width="110" alt="' + pickedShowcase.title + '" /></a>');
        html += ('<div>');
        html += ('<h1>' + pickedShowcase.title + '</h1>');
        html += ('<a href="' + pickedShowcase.href + '">' + pickedShowcase.blurb + '</a>');
        html += ('</div>');
        html += ('</li>');
    }
    
    // Inject the HTML for the showcase content into the right place   
    /*
    var panel = document.getElementById('home-showcase-panel');
    panel.innerHTML = html + panel.innerHTML;
    */
    document.write(html);
}

function pickShowcase()
{
    var alreadyPicked = true;
    var showcaseNumber;

    // Generate a random number between 0 and #showcases
    while(alreadyPicked)
    {
        showcaseNumber = (Math.round((Math.random()*(m_showcases.length-1))));
        alreadyPicked = false;
        for(var i=0; i<m_pickedShowcases.length; i++)
        {
            if (showcaseNumber == m_pickedShowcases[i])
            {
                alreadyPicked = true;
            }
        }
    }
    
    return showcaseNumber;
}

// Class definition for a showcase
function showcase(_title, _img, _href, _blurb)
{
    this.title = _title;
    this.blurb = _blurb;
    this.img = _img;
    this.href = _href;
}
