function getComponent(url,$component, $parent){
    //console.log('getComp');
    var at = 500;
    url = url.split('.')[0];

    $parent.toggleClass('load');
    $component.animate({
        opacity: 0
    },at,function(){
        window.location.hash='#!' + url+'.html';
        //console.log(url+'.json', ' JSON');
        $.ajax({
            url: url+'.json?_='+(new Date().getTime()),
            cache: false,
            dataType: 'json',
        }).success(function(data) {
                //console.log(data, ' DATA');
                switch (data.com) {
                    case 'Sites_Com':
                        var content = data.content;
                        var image = new Image();
                        $component.empty();
                    
                        if(content.image)
                            image.src = content.image;
                    
                        if(content.imgClass == 'bigimage')
                            $component.append('<img class="bigimage" src="'+content.image+'">');
                        else{
                            if(content.image)
                                $component.append('<img class="article" src="'+content.image+'">');
                            if(content.showTitle)
                                $component.append('<h1>'+content.title+'</h1>');
                            $component.append('<div>'+content.content+'</div>');
                        }
                        $component.css({
                            'display':'block'
                        });
                        $component.animate({
                            opacity: 1
                        });
                        $parent.toggleClass('load');
                        break;
                    default:
                        /*$.getJSON(url+'.html',function(data){
                        
                    });*/
                        window.location = url+'.html';
                        break;
                }
            }).error(function() { window.location = url+'.html'; });
    });
}
/*Jesli ktos skopiowal link to redirect z kotwicy*/
//alert('Aktualnie prowadzone są prace. Zapraszam później');

var adres = window.location.hash.split('!');

if(adres.length == 2)
    window.location = adres[1];

/*Asynchroniczne pobieranie strony*/
/*$(function(){
    //asynchroniczne
    $('.menu a').click(function(){
        var url = $(this).attr('href');
        var $parent = $('#content');
        var $component = $('#content div.space');

        getComponent(url, $component, $parent);

        return false;
    });
});*/

