/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var mod_magasiner = {};

mod_magasiner.getNewest = function() {
    var len = mod_magasiner.imgObj.length;
    return mod_magasiner.imgObj[len-1];
}

mod_magasiner.setupMagasiner = function() {
    $('magasiner').empty();
    $('magasiner').adopt(mod_magasiner.getNewest());
}

mod_magasiner.nextImage = function() {

    currentIndex++;
    $('magasinNavLeft').style.display = "";
    if(currentIndex == images.length-1) {
        $('magasinNavRight').style.display = "none";
    } else {
        $('magasinNavRight').style.display = "";
    }

    if(currentIndex <= (mod_magasiner.imgObj.length - 1)  && currentIndex >= 0) {
//        var link = 'index2.php?option=com_flippingbook&view=book&id='+images[currentIndex].id;
        var link = images[currentIndex].link;
        $('magasiner').empty();
        $('magasiner').adopt(mod_magasiner.imgObj[currentIndex]);//$("magasinImage").src = base+folder+images[currentIndex].preview_image;
        $("magasinLink").href = base+link;
    }
}

mod_magasiner.prevImage = function() {
    
    currentIndex--;
    $('magasinNavRight').style.display = "";
    if(currentIndex == 0) {
        $('magasinNavLeft').style.display = "none";
    } else {
        $('magasinNavLeft').style.display = "";
    }
    if(currentIndex <= (mod_magasiner.imgObj.length - 1)  && currentIndex >= 0) {
//        var link = 'index2.php?option=com_flippingbook&view=book&id='+images[currentIndex].id;
        var link = images[currentIndex].link;
        $('magasiner').empty();
        $('magasiner').adopt(mod_magasiner.imgObj[currentIndex]);//$("magasinImage").src = base+folder+images[currentIndex].preview_image;
        //$("magasinImage").src = base+folder+images[currentIndex].preview_image;
        $("magasinLink").href = base+link;
    }
}
