function loadPage(hash)
{
    if(hash) {
        // restore ajax loaded state
        if($.browser.msie) {
            // jquery's $.load() function does't work when hash include special characters like aao.
            hash = encodeURIComponent(hash);
        }
        $.get(
            hash,
            function(data){
                $('#stranica').html(data);
                $('.loader').fadeOut(350);
                hook_content();
            }
        );
    } else {
        // start page
        $("#stranica").html(first_content);
        hook_content();
    }
}


function load_popup(href)
{
    $.get(
        href,
        function(data){
            $('#prozorcic').html(data).parent().fadeIn(400);
            $('.loader').fadeOut(350);
            hook_content();
        }
    );
}

var first_content;

function hook_content()
{
    $('.scrollable').jScrollPane();
    $('.slideshow').cycle({ fx: 'fade', random: 1, timeout: 3000 });
}

$(document).ready(function(){

    first_content = $('#stranica').html();

    $.historyInit(loadPage, "index.html");
        
    /*
    $('.meni a').click(function(e){
        $('.loader').show();
        e.preventDefault();

        $.historyLoad(this.href);
    });*/

    $('.close').click(function(){
        $(this).parent().hide();
    });


    $('.popup-open').click(function(e){
        $('.loader').show()
        e.preventDefault();
        var href = $(this).attr('href');
        load_popup(href);
    });
    
    hook_content();
});


