/* Author: 

*/

$(document).ready(function() {
    
    $('.special-content, #highlight').click(function(){
        var myHref = $(this).find('a').attr('href');
        window.location = myHref;
    });
    
    //blog
    if($('.blog-list .blog').length > 0){
        var tCount = $('.blog-list .blog').length;
        var tRemainder = Math.floor(tCount/3) *3;
        
        
        if(tRemainder === tCount){
            tRemainder = tRemainder-4;
        }else{
            tRemainder--;
        }
        $('.blog-list .blog').css({
            'border-right':'1px #C8C7C7 solid',
            'border-bottom':'1px #C8C7C7 solid'
        });
        $('.blog-list .blog:nth-child(3n)').css('border-right','1px #fff solid');
        
        if(tRemainder>0){
            $('.blog-list .blog:gt('+tRemainder+')').css('border-bottom','1px #fff solid');
        }else{
            $('.blog-list .blog').css('border-bottom','1px #fff solid');
        }
    }

    //menu
    
    if($('.source li').length != 0){
        
        $('.menu-finder').click(function(e) {

            $('.menu-finder').removeClass('active');
            $(this).addClass('active');

            location.hash = $(this).attr('href');
            e.preventDefault();

        });
        
        $.fn.hashchange.src = '/';
        $.fn.hashchange.domain = document.domain;

        $(window).hashchange( function(){
            var hash = location.hash;
            var needle = hash.substr(1);
            

            
            $('.destination').quicksand( $('.source li.'+needle), {
                easing:'easeInOutQuad',
                useScaling: true
            }, function(){
                
                $('.destination li').css({
                    'border-right':'1px #C8C7C7 solid',
                    'border-bottom':'1px #C8C7C7 solid'
                });
                $('.destination li:nth-child(4n)').css('border-right','1px #fff solid');
                
                var tCount = $('.destination li').length;
                var tRemainder = Math.floor(tCount/4) *4;

                if(tRemainder === tCount){
                    tRemainder = tRemainder-5;
                }else{
                    tRemainder--;
                }
                if(tRemainder>0){
                    $('.destination li:gt('+tRemainder+')').css('border-bottom','1px #fff solid');
                }else{
                    $('.destination li').css('border-bottom','1px #fff solid');
                }             
                
            });
            
            

        });
        
        if(location.hash==''){
            $('.menu-finder:first').click();
        }else{
            $('.menu-finder[href='+location.hash+']').click();
        }
        
        $(window).hashchange();
    }
    
    //end menu

});




















