/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var myGlobalHandlers = {
    onCreate: function(){
        Element.show('systemWorking');
    },

    onComplete: function() {
        if(Ajax.activeRequestCount == 0){
            Element.hide('systemWorking');
        }
    }
};
Ajax.Responders.register(myGlobalHandlers);


function showOneGallery(galleryId){
    $('galleries').hide();
    $('zgallery_cover').appear({ duration: 0.6, from: 0, to: 0.9 });

    var qs      = "act=showOneGallery&galleryId=" + galleryId;

    new Ajax.Updater(
        { success: "zgallery_cover"},
            "http://gyerko.hu/zgallery/zgallery_worker.php",
            {
                method: 'post',
                parameters: qs,
                onSuccess: function(reply) {
                    Element.setStyle($('zgallery_header_properties'), "display:block;");
                    //Element.update($('zgallery_header_properties'), '');
                },
                onFailure: function(reply){
                    Alert("Nem sikert az Ajax művelet!");
                }
            }
    );
}

function imageBrowser(galId,imgId){
    if($('allCoverDiv').getStyle("display") == "none"){
        Element.setStyle($('allCoverDiv'), "display:block;");
        Element.setOpacity($('cover_oplayer'), "0.9");
    }
    Element.update($('img_place'), "");
    
    var qs      = "act=showOneImage&galleryId=" + galId + "&imageId="+imgId+"&reqParam=toolbar";

    new Ajax.Updater(
        { success: "cover_toolbar"},
        "http://gyerko.hu/zgallery/zgallery_worker.php",
        {
            method: 'post',
            parameters: qs,
            onSuccess: function(reply) {
                setTimeout(
                    function(){
                        new Ajax.Updater(
                            { success: "img_place" },
                            "http://gyerko.hu/zgallery/zgallery_worker.php",
                            {   method: "post",
                                parameters: "act=showOneImage&galleryId=" + galId + "&imageId="+imgId +"&reqParam=path",
                                asynchronous: true
                            }
                        );
                    }, 200
                );
            },
            onFailure: function(reply){
                alert("Nem sikert az Ajax művelet! \n" + reply);
            }

        }
    );

    return false;
}

function hideImageBrowser() {
    Element.update($('img_place'), "");
    Element.update($('cover_toolbar'), "");
    Element.setStyle($('allCoverDiv'), "display:none;");
    return false;
}

function backToGals(){
    $('zgallery_header_properties').hide();
    $('zgallery_cover').hide();
    $('galleries').appear({ duration: 0.6, from: 0, to: 0.9 });
}

