/* 
 * Javascript für Gallery-Content Bereich
 */
function initGallery(){
    //Slideshow MaterialGallery
    $('#ajaxLoad').hide();
    //initPictures();
    $('#pages a, .navileft a, .naviright a').click(function(event){
        event.preventDefault();
        var page=$(this).urlParamValue('number');
        if(page!=null)
            changePage(page);
    });
    initMaterialRequest();
}

function initMaterialRequest(){
    $('span.pic a').click(function(event){
        event.preventDefault();
        var id=$(this).urlParamValue('id');
        ajaxGetMaterialPage(id);
    });
}

/*function initPictures(){
    $('.pic a').css('overflow', 'hidden');
    $('.pic a img.hidden').css('display', 'none');
    $('.pic a').hover(
        function () {
            $(this).cycle({
                fx:'fade',
                speed:500,
                timeout:1000
            }).next().show();
        },
        function () {
            $(this).cycle({
                startingSlide:0,
                autostop:1,
                autostopCount:1
            }).next().hide();
        });
}*/

function expandMaterialGallery(){
    $('#materialGallery').animate({
        width: "toggle"
    }, 1500);
    $('#naviRight').animate({
        width: "0px",
        opacity: 0.0
    }, 1500,function(){
        $('#naviRight').hide();
    });
}

function minimizeMaterialGallery(){
    $('#materialGallery').animate({
        width: "toggle"
    }, 200,function(){
        $('#naviRight').animate({
            width: "200px",
            opacity: 1
        }, 1500, function(){
            $('#naviRight').show();
        });
    });
}

function changePage(page){
    $.ajax({
        type: "GET",
        url: "gallery/galleryPage.jsp",
        dataType:"html",
        data: "action=page&number="+page,
        success:
        function(data){
            $("#content").html(data);
            initGallery();
        },
        error:
        function (xhr){
            alert(xhr.status+" "+xhr.statusText);
        }
    });
}

