/*
 * This is the rotation sript for the Companion Projects section
 *
 * we hase some limited number of static items whcih are displayed always and
 * the rest is rendered randomly
 */
function renderCompanionProjectIcons() {
    /* number of items we want to render */
    var itemsToRender = 3;

    /* domain where images live - we can easily switch for local testing to localhost to see images */
    var domain = "http://www.netbeans.org"; // http://localhost

    /* html  output */
    var output = "";

    /* items definition using JSON object notation */
    var itemsContainer = {
        "items" : [
        {
            "image": "/images/v6/vbox.gif",
            "link":"http://www.virtualbox.org/wiki/VirtualBox",
            "alt": "Virtual Box - full virtualizer",
            "width": "108",
            "height": "35"
        },

        {
            "image": "/images/v6/open-esb.gif",
            "link":"https://open-esb.dev.java.net/",
            "alt": "Open ESB - The Open Enterprise Service Bus",
            "width": "90",
            "height": "30"
        },

        {
            "image": "/images/v6/javanet.gif",
            "link":"http://community.java.net/mobileandembedded/",
            "alt": "Java.net - The Source for Java Technology Collaboration",
            "width": "80",
            "height": "36"
        },

        {
            "image": "/images/v6/open-office.gif",
            "link":"http://www.openoffice.org/",
            "alt": "OpenOffice - The free and open productivity suite",
            "width": "111",
            "height": "35"
        },
        ]
    };

    /* now randomize the items array */
    itemsContainer.items.sort(function() {return (Math.round(Math.random())-0.5)});

    /* make sure we do not want to display more items then we actually have */
    itemsToRender = (itemsToRender > itemsContainer.items.length)? itemsContainer.items.length : itemsToRender ;

    /* now display items */
    for (i = 0; i < itemsToRender; i++) {
        // setup the style - there is line after the last item
        var style = (i==(itemsToRender-1))? 'class="valign-center b-green-right" style="padding-right:10px;"' : 'class="valign-center"' ;
        var space = (i==(itemsToRender-1))? '' : '&nbsp;';
        output += '<td '+style+'><a href="'+itemsContainer.items[i].link+'"><img src="'+domain+itemsContainer.items[i].image+'" alt="'+itemsContainer.items[i].alt+'" title="'+itemsContainer.items[i].alt+'" width="'+itemsContainer.items[i].width+'" height="'+itemsContainer.items[i].height+'"></a>'+space+'</td>';
    }
    /* return the html */
    return output;
}