/**
 * @desc    Passion For Food JavaScript Library
 * @author  designersfactory
 * @package passionforfood
 */



// === THUMBNAILS =================================================================================

var thumb_length = 4;
var thumb_pos    = 0;



function updateBigImage(imagepath)
{
//     document.images['big'].src =
//         "image.php?file=" + imagepath +
//         "&amp;width=480&amp;height=360&amp;crop=middle_center";
    element = document.getElementById('big');
    element.innerHTML =
        '<img src="image.php?file=' + imagepath +
        '&amp;width=480&amp;height=360&amp;crop=middle_center"' +
        ' width="480" height="360" alt="" class="big" />';

}



function setThumbnail(id, imagepath)
{
    element = document.getElementById(id);
    element.innerHTML =
        '<a href="javascript:updateBigImage(\'' + imagepath + '\');">' +
        '<img src="image.php?file=' + imagepath +
        '&amp;width=112&amp;height=87&amp;crop=middle_center"' +
        ' width="112" height="87" alt="" class="thumb" />' +
        '</a>';
}



function nextThumbnails()
{
    list_length = thumb_images.length;

    if (list_length > thumb_length)
    {
        for (i = 0; i < thumb_length; i++)
        {
            setThumbnail('thumbnail' + i, thumb_images[nextIndex(i + thumb_pos, list_length)]);
        }

        thumb_pos = nextIndex(thumb_pos, list_length);
    }
}



function previousThumbnails()
{
    list_length = thumb_images.length;

    if (list_length > thumb_length)
    {
        for (i = 0; i < thumb_length; i++)
        {
            setThumbnail('thumbnail' + i, thumb_images[previousIndex(i + thumb_pos, list_length)]);
        }

        thumb_pos = previousIndex(thumb_pos, list_length);
    }
}

