
function displayGallery()
{
    clearClick = false;
    if (isIE)
    {
        if ($('#content').css('display') == 'none')
        {
            $('#home-text').stop(true, true).animate({'opacity':'1'}, 600, function(){$('#home-text').css('display', 'none');});
            $('#news').stop(true, true).animate({'margin-top':$(window).height()}, 600, function()
            {
                $('#news').css('display', 'none');
                $('#content').css('display', 'block');
                initGallery();
            });
        }
        else
        {
            $('#content').animate({'margin-left':$(window).width()}, 600, function()
            {
                initGallery();
            });
        }
    }
    else
    {
        if ($('#content').css('display') == 'none')
        {
            $('#content').stop(true, true).animate({'opacity':'0'}, 0,  function()
            {
                $('#home-text').stop(true, true).animate({'opacity':'1'}, 600, function(){$('#home-text').css('display', 'none');});
                $('#news').stop(true, true).animate({'margin-top':$(window).height()}, 600, function()
                {
                    $('#news').css('display', 'none');
                    $('#content').css('display', 'block');
                    initGallery();
                });
            });
        }
        else
        {
            $('#content').animate({'margin-left':$(window).width(), 'opacity':'0'}, 600, function()
            {
                initGallery();
            });
        }
    }
}

function initGallery()
{
    initPageType1();
    $('#content-scroll-content').html('');
    
    $('#content-loader').css('display', 'block');
    $.post('includes/php/gallery.php', {action:'load'}, function(data)
    {
        
        $('#content-fix').html('<div id="content-title" style="padding:0;"></div><div id="content-gallery"></div>');
        $('#content-gallery').height(424);
        $('#content-loader').css('display', 'none');
        $('#content-fix').css('display', 'block');
        $('#content-scroll').css('display', 'none');

        var theGalleries = new Array();
        var firstGallery, i;
        var menu = '';
        
        theGalleries = data.split(';;;');
        
        for (i=0; i<theGalleries.length; i++)
        {
            if (i == 0)
            {
                firstGallery = theGalleries[i].split(';;')[0];
                menu += '<a id="special-title-link-'+theGalleries[i].split(';;')[0]+'" class="special-title-link special-title-link-selected" href="javascript:showGall('+theGalleries[i].split(';;')[0]+')">'+theGalleries[i].split(';;')[1]+'</a>';
            }
            else
            {
                menu += '<a id="special-title-link-'+theGalleries[i].split(';;')[0]+'" style="margin:0 0 0 10px;" class="special-title-link" href="javascript:showGall('+theGalleries[i].split(';;')[0]+')">'+theGalleries[i].split(';;')[1]+'</a>';
            }
        }
        $('#content-title').html(menu);

        showGall(firstGallery);

        RPContent();
        
        if (isIE) clearClick = true;
        else $('#content').stop(true, true).animate({'opacity':'1'}, 300, function(){clearClick = true;});
    });
}

function showGall(id)
{
    $('a', '#content-title').removeClass('special-title-link-selected');
    $('a', '#content-title').addClass('special-title-link');
    $('#special-title-link-'+id).removeClass('special-title-link');
    $('#special-title-link-'+id).addClass('special-title-link-selected');
    $.post('libraries/com/dop/php/ThumbnailGallery.php', {galleryID:id}, function(data)
    {
        gallery.reset();
        gallery.init(id, "#content-gallery", data);
    });
}
