
var stObj = new Object();

$(document).ready(function(){

    //FB.init("ccd552c51ed5cd5ff64e5eb0d2cc52c7");

    // init
    var hash = window.location.hash;
    var cleanHash = hash.substr(1);
    
    // hide all
    $(".container").hide();
    
    // opening from load
    if(hash != '') {
        $("#menu a").each(function(){
            var $thisLink = $(this);
            if($thisLink.attr("href") == hash) {
                $("#menu a").removeClass("active");
                $thisLink.addClass("active");
                $(hash).show();
                if(hash != "#trailer") {
                    $("#fb_box").show();
                    if(hash == "#soundtracks") {
                        buildSoundtracks();
                    }
                } else {
                    $("#fb_box").hide();
                    buildTrailer();
                }
            }
        });
    } else {
        $firstLink = $("#menu a:first");
        $firstLink.addClass("active");
        $($firstLink.attr("href")).show();
        $("#fb_box").hide();
        buildTrailer();
    }
    
    
    $("#menu a").click(function(){
    
        if(!$(this).is(".active")) {
        
            var $thisLink = $(this);
            
            pageTracker._trackPageview("/"+$thisLink.attr("href"));
            
            $("#menu a").removeClass("active");
            $thisLink.addClass("active");
            
            if(!$.browser.msie) {
                window.location.hash = $thisLink.attr("href");
            }
            
            stopObjects();
            
            $("#wrapper .container:visible").fadeOut("normal", function(){
                $($thisLink.attr("href")).fadeIn();
                if($thisLink.attr("href") != "#trailer") {
                    $("#fb_box").fadeIn();
                    if($thisLink.attr("href") == "#soundtracks") {
                        buildSoundtracks();
                    }
                } else {
                    $("#fb_box").fadeOut();
                    buildTrailer();
                }
            });
        
        }
    
        return false;
    });














});


function buildTrailer() {

    // build trailer
    var trailerPlayer = new SWFObject('player.swf','trailerPlayerId','720','396','9','#ffffff');
    trailerPlayer.addParam('allowfullscreen','true');
    trailerPlayer.addParam('allowscriptaccess','always');
    trailerPlayer.addParam('wmode','opaque');
    trailerPlayer.addVariable('file','media/trailer_new.flv');
    trailerPlayer.addVariable('image','media/trailer_new_preview.jpg');
    trailerPlayer.addVariable('skin','bekle.swf');
    trailerPlayer.addVariable('controlbar','over');
    trailerPlayer.addVariable('fullscreen','true');
    trailerPlayer.addVariable('stretching','fill');
    trailerPlayer.addVariable('volume','90');
    trailerPlayer.write('trailerPlayer');

}


function buildSoundtracks() {

    var st_tovli = new SWFObject('player.swf','tovliId','450','57','9','#ffffff');
    st_tovli.addVariable('file','media/Jgupi_18_-_Tovli_Mosula_soundtrack_KAIKINO.COM_.mp3');
    st_tovli.addVariable('skin','bekle_audio.swf');
    st_tovli.addVariable('screencolor','FFFFFF');
    st_tovli.write('st_tovli');

    var st_pipkebi = new SWFObject('player.swf','pipkebiId','450','57','9','#ffffff');
    st_pipkebi.addVariable('file','media/Temo_Sajaia_-_Pipkebi_soundtrack_KAIKINO.COM_.mp3');
    st_pipkebi.addVariable('skin','bekle_audio.swf');
    st_pipkebi.addVariable('screencolor','FFFFFF');
    st_pipkebi.write('st_pipkebi');

    var st_korkota = new SWFObject('player.swf','korkotaId','450','57','9','#ffffff');
    st_korkota.addVariable('file','../mp3/Salome_Korkotashvili_-_Rac_Kvelaze_Dzalian_Gikvars_%5Bkaikino.com%5D.mp3');
    st_korkota.addVariable('skin','bekle_audio.swf');
    st_korkota.addVariable('screencolor','FFFFFF');
    st_korkota.write('st_korkota');

    var st_akhali_tseli = new SWFObject('player.swf','akhalitseliId','450','57','9','#ffffff');
    st_akhali_tseli.addVariable('file','../mp3/Dato_Lomidze_%26_String_-_Akhali_Tseli_%5Bkaikino.com%5D.mp3');
    st_akhali_tseli.addVariable('skin','bekle_audio.swf');
    st_akhali_tseli.addVariable('screencolor','FFFFFF');
    st_akhali_tseli.write('st_akhali_tseli');

    var st_push_me = new SWFObject('player.swf','pushmeId','450','57','9','#ffffff');
    st_push_me.addVariable('file','../mp3/Salome_Korkotashvili_%26_Achiko_Guledani_-_Push_Me_%5Bkaikino.com%5D.mp3');
    st_push_me.addVariable('skin','bekle_audio.swf');
    st_push_me.addVariable('screencolor','FFFFFF');
    st_push_me.write('st_push_me');

    var st_lost = new SWFObject('player.swf','lostId','450','57','9','#ffffff');
    st_lost.addVariable('file','../mp3/Dato_Lomidze_-_Lost_%5Bkaikino.com%5D.mp3');
    st_lost.addVariable('skin','bekle_audio.swf');
    st_lost.addVariable('screencolor','FFFFFF');
    st_lost.write('st_lost');

    var st_lost_remix = new SWFObject('player.swf','lostremixId','450','57','9','#ffffff');
    st_lost_remix.addVariable('file','../mp3/Dato_Lomidze_-_Lost_(remix)_%5Bkaikino.com%5D.mp3');
    st_lost_remix.addVariable('skin','bekle_audio.swf');
    st_lost_remix.addVariable('screencolor','FFFFFF');
    st_lost_remix.write('st_lost_remix');

}


function stopObjects() {
    $(".container object").remove();
}

