/**
 * Data set
 */
var items = new Array();
items.push({ 
    'name': 'Website Design & Development', 
    'descr': 'We design professional websites that provide a platform for your web presence.',
    'image': './images/projects/panda.png'
});
items.push({
    'name': 'Bespoke Photo Sales',
    'descr': 'We offer great quality photos specifically for clients that have unique needs in terms of subject matter.',
    'image': './images/projects/mobify.png'
});

/**
 * Action code
 */
$(document).ready(function() {
    // this is the current item, by array key
    var curIndex = 0;
    // how many items are in the list
    var max = items.length;

    // "previous" action
    $('.prev').click(function() {
        // decrement the curIndex
        curIndex--;
        if (curIndex < 0) {
            curIndex = max-1;
        }
        
        updateProject();
    });
        
    $('.next').click(function() {
        curIndex++;
        if (curIndex >= max) {
            curIndex = 0;
        }

        updateProject();
    });

    // update the latest project
    function updateProject() {
        $('#latest-project .preview .image').attr('src', items[curIndex]['image']);
        $('#latest-project .descr .title').html(items[curIndex]['name']);
        $('#latest-project .descr .description').html(items[curIndex]['descr']);
    }
});

