



var layers = new Array();
var over = false;
var temp = 0;
var timer;
var topZindexID;




$(document).ready(function() {

    $('.round-10').corner('10px');
    $('.releases-info').corner('10px');
    $('#remote ul li').corner('10px');
    $('#player #coda-nav-right-1').corner('10px');
    
    
    
    
    
    //    releases W
    
    $('#coda-slider-1').codaSlider({
        dynamicArrows: false,
        dynamicTabs: false
    });
    
    $('#coda-slider-2').codaSlider({
        dynamicArrows: false,
        dynamicTabs: false
    });
    
    
    //    release remove title
    
    $('.release-box img').removeAttr('title'); 
    
    //    imgs pool title remove
    
    $('#widget-images img').removeAttr('title'); 






    //set z-index layers and reorder
      
      
    var grp = $('#widget-images').children(".ngg-galleryoverview").children();
    var cnt = grp.length;

    var temp,x;
    for (var i = 0; i < cnt; i++) {
        temp = grp[i];
        x = Math.floor(Math.random() * cnt);
        grp[i] = grp[x];
        grp[x] = temp;
    }
    $(grp).remove();
    $('#widget-images').children(".ngg-galleryoverview").append($(grp));

      
      
        
    $('#widget-images').children('.ngg-galleryoverview').children('.img-show').each(function(index) {
        
        $(this).css('z-index', index);
        layers[index] = index;
        topZindexID = $(this).attr('id');
        
    });
        
        



    //random position images media pool

    $('#widget-images').children('.ngg-galleryoverview').children('.img-show').each(function() {
            
        var widthT = $(this).width();
        var heightT = $(this).height();
            
        var posLeft = Math.floor( (Math.random()) * ( $('#widget-images').width() - widthT ) );
        var posTop = Math.floor( Math.random() * ( $('#widget-images').height() - heightT ) );
            
        $(this).css('left', posLeft + 'px');
        $(this).css('top', posTop + 'px');
        
            
    });



  


    //FILTERING MANSORY

    var
    speed = 500,  // animation speed
    $wall = $('#lyric');

    $wall.masonry({
        singleMode: true,
        // only apply masonry layout to visible elements
        itemSelector: '.lyric-content:not(.invis)',
        animate: true,
        animationOptions: {
            duration: speed,
            queue: false
        }
    });

    $('#filtering-nav a').click(function(){
        var colorClass = '.' + $(this).attr('class');


        if(colorClass=='.all') {
            // show all hidden boxes
            $wall.children('.invis')
            .toggleClass('invis').fadeIn(speed);
        } else {
            // hide visible boxes
            $wall.children().not(colorClass).not('.invis')
            .toggleClass('invis').fadeOut(speed);
            // show hidden boxes
            $wall.children(colorClass+'.invis')
            .toggleClass('invis').fadeIn(speed);
        }
        $wall.masonry();

        return false;
    });


    $('#all-news').masonry({
        singleMode: true,
        itemSelector: '.post-news'
    });
    
    
    
    
    if ($("#all-news").length > 0){
        
        
        $('.blok-310-shdw-left').each(function() {
            
            var shdwH = $(this).height() - 37;
            $(this).height(shdwH);
               
        });
        $('.blok-310-shdw-right').each(function() {
            
            var shdwH = $(this).height() - 37;
            $(this).height(shdwH);
               
        });
        
        
    }
   
   
   
   
    //   HEIGHT PAGES FIX
   
   
    var heightCont = $('#body-container').height() + 156;
    var heightWindow = $(window).height();
     
     
    if (heightCont < heightWindow) {
        
        if( (heightWindow-301) < 625 ) {
            heightWindow=907;
            
        }
        
        $('.content-align').height(heightWindow-301);
        
        
    }


    if( (heightWindow-301) < 625 ) {
        
        
        if(heightCont < 625) {
            heightWindow=907;   
        } else {
            
            
            $('.content-align').height(heightCont-301);
        }
        
        
    }
        
        


    if( $('#all-news').height() < 625 ) {
        $('#all-news').height(626);
    } else {
        $('#all-news').height(heightWindow+300); 
    }
    
 
    if( $('#all-news').height() < heightWindow ) {
        $('#all-news').height(heightWindow-272);
    } 
        
    
    
   
   
   
   

    //   BLINDGALLERY
   
   
   
    if ($('.blindgallery').length > 0){
        
        
        
        
        
        var blindH = $('.content-align').height() - 350;
        $('.blindgallery').height(blindH);
        $('.home .blindgallery').height(628);
        
        $('.blindgallery').fadeIn(3000);
        
        
       
        
        $('.thumb').each(function() {
            
            
            
            
            var randomLeft = Math.floor( (Math.random()) * 100 );
            var randomTop = Math.floor( (Math.random()) * 100 );
            var winW = $(window).width();
             
            if ( ( (randomLeft/100) * winW)  < 250)  {
                 
                 
                randomLeft += 30;
                 
            }
             
             
            $(this).css('left', randomLeft + '%');
            $(this).css('top', randomTop + '%');
               
        });
    
        
        
    }
   
   
  
    




})




var resizeTimer = null;
$(window).bind('resize', function() {
    
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(doSomething(), 100);
});





function doSomething() {
    
    var heightCont = $('.hentry').height() + 156;
    var heightWindow = $(window).height();
     
     
    if (heightCont < heightWindow) {
        
        if( (heightWindow-301) < 625 ) {
            heightWindow=907;
            $('.content-align').height(heightWindow-301);
        }
        
        
        if( (heightCont) < 625 ) {
            $('.content-align').height(heightWindow-301);
        }
        
        
        
        
        
        
        if( $('#all-news').height() < 460 ) {
            $('#all-news').height(461);
        } else {
            $('#all-news').height(heightWindow-272); 
        }
    }  
    
    
    
    
  
    
    
    
}












    
    
        
//    news W

$(window).load(function() {
    
    
 
 
 
    var titleH = $("#post-middle h2").height();
    var textN = $('#post-middle').find('p').text();


    $('#post-middle .post-text').css('display', 'none');
    $('#post-middle .post-text').css('visibility', 'visible');

    if ( (titleH > 22) && (titleH < 30) ) {
        $('#post-middle').find('p').text(textN.substring(0,255) + '...');
    }
    
    
    if ( (titleH > 50) && (titleH < 55) ) {
        $('#post-middle').find('p').text(textN.substring(0,165) + '...');
    }
    
    
    if ( (titleH > 70) && (titleH < 82) ) {
        $('#post-middle').find('p').text(textN.substring(0,120) + '...');
    }
    
    
    if ( (titleH > 100) && (titleH < 110) ) {
        $('#post-middle').find('p').text(textN.substring(0,80) + '...');
    }
    
    
    if ( (titleH > 125) && (titleH < 135) ) {
        $('#post-middle').find('p').text('...'); 
    }
    
    
    
    $('#post-middle .post-text').fadeIn(300);
    
    



    titleH = $("#post-big h2").height();
    //    alert(titleH);
    textN = $('#post-big').find('p').text();


    $('#post-big .post-text').css('display', 'none');
    $('#post-big .post-text').css('visibility', 'visible');

    if ( (titleH > 22) && (titleH < 30) ) {
        $('#post-big').find('p').text(textN.substring(0,255) + '...');
    }
    
    
    if ( (titleH > 50) && (titleH < 55) ) {
        $('#post-big').find('p').text(textN.substring(0,210) + '...');
    }
    
    
    if ( (titleH > 70) && (titleH < 82) ) {
        $('#post-big').find('p').text(textN.substring(0,140) + '...');
    }
    
    
    if ( (titleH > 100) && (titleH < 110) ) {
        $('#post-big').find('p').text(textN.substring(0,90) + '...');
    }
    
    
    if ( (titleH > 150) && (titleH < 160) ) {
        $('#post-big').find('p').text(textN.substring(0,30) + '...');
    }
    
    
    
    $('#post-big .post-text').fadeIn(1800);



    //video position 


    $('#video').css('top',  ($('#widget-images').height()/2) - ($('#video').height()/2) - 0 + 'px' )








});








$(function() {
  
  
    $('#video-toggle').click(function() {
        
        $('#video').fadeIn(300);
        $('.img-show').fadeOut(300);
        $('#video-toggle').hide();
        $('#foto-toggle').show();


    }); 
    
    
    $('#foto-toggle').click(function() {
        
        $('.img-show').fadeIn(300);
        $('#video').fadeOut(300);
        $('#video-toggle').show();
        $('#foto-toggle').hide();
        
    });
    
    
    
    
    $('#video-toggle').mouseenter(function() {
        
        $('#circle').fadeIn(250);


    });
    
    $('#video-toggle').mouseleave(function() {
        
        $('#circle').fadeOut(250);


    });
    $('#foto-toggle').mouseenter(function() {
        
        $('#circle').fadeIn(250);


    });
    
    $('#foto-toggle').mouseleave(function() {
        
        $('#circle').fadeOut(250);


    });
  
});


$(function() {
  
    $('#coda-nav-left-1').hover(function() {
        
        $('#coda-nav-right-1 a').css('color','transparent');


    }, function() {
        
        $('#coda-nav-right-1 a').css('color','inherit');
        $('#coda-nav-right-1 a:hover').css('color','gray');
        
    });



    $('#post-navi-newer').hover(function() {
        
        $('#post-navi-older a').css('color','transparent');


    }, function() {
        
        $('#post-navi-older a').css('color','inherit');
        $('#post-navi-older a:hover').css('color','black');
        
    });
  
});






$(function() {
  
  
    $('#widget-images').hover(function() {
        
        over = true;
        rotuj();
          
    }, function() {
        over = false;
    });
  
});



$(function() {

    $('#widget-images').mouseleave(function() {
        
        over = false;
        clearTimeout(timer);
        
    });


});




function rotuj() {


    var lastEl = layers[layers.length-1];
    layers.pop();
    layers.unshift(lastEl);
            
    $('#widget-images').children('.ngg-galleryoverview').children('.img-show').each(function(index) {
        $(this).css('z-index', layers[index]);
               
    });
            
    if(over) {
        timer = setTimeout(rotuj ,700);
    }
             
}
