var imgfx_active = false;
var currBoxesFirstId = 0;

function showFullImage(imgsrc, pictitle) {

    if(!imgfx_active) {

        var newcontent = "<div class='img-bg opacity_seventy'>&nbsp; &nbsp;</div>";
        newcontent += "<div id='picgalleryclose'>κλείσιμο [x]</div>";
        if(pictitle != "") { newcontent += "<div id='picgallerytitle'>" + pictitle + "</div>"; }
        newcontent += "<img id='largeimg' src='includes/projectImg.php?src="+imgsrc+"'\n\
                        onload='centerFullImage(this)' onclick='hideFullImage()'/>";

        $('fullimage').update(newcontent);
        $('fullimage').style.display = 'block';

        $('largeimg').setOpacity('0');
    }
}

function hideFullImage() {

    if(!imgfx_active) {
        imgfx_active = true;

        $('fullimage').update("");
        $('fullimage').style.display = 'none';
        imgfx_active = false;
    }
}

function centerFullImage(obj) {
    imgfx_active = true;

    var imgtop = (369 - $(obj).getHeight()) * 0.5;
    var imgleft = (710 - $(obj).getWidth()) * 0.5;

    $(obj).setStyle({
        top: imgtop.toString() + "px",
        left: imgleft.toString() + "px"
    });
    $(obj).morph("opacity: 1.0", {duration: 0.5, afterFinish: function() {
        imgfx_active = false;
    }});
}

function showNextBoxes(tab_id) {

    var el_prefix = 'accordion_menu_text_' + tab_id + '_';

    // Hide as many boxes exist
    for(var i = 0; i < 3; i++) {
        if($(el_prefix+(currBoxesFirstId+i))) {
            $(el_prefix+(currBoxesFirstId+i)).style.display = 'none';
        }
    }
    
    // Check if further boxes exist
    if($(el_prefix+(currBoxesFirstId+3))) {   
        currBoxesFirstId += 3;
    } else {
        currBoxesFirstId = 0;
    }

    // Show as many boxes exist
    for(var i = 0; i < 3; i++) {
        if($(el_prefix+(currBoxesFirstId+i))) {
            $(el_prefix+(currBoxesFirstId+i)).style.display = 'block';
        }
    }
}
