/*
Created by Eight Bit Studios, LLC
for the common good...
Nay. For the betterment of the world.
*/
// $(window).scroll(function() {
//     $('#masthead').css('top', $(this).scrollTop() + "px");
// });

$(document).ready(function() {

    // $('#masthead').css("position", "fixed");
    

    $('.slideShow').after('<div id="pager">').cycle({ 
        fx:     'scrollLeft', 
        speed:  'fast', 
        timeout: 0,
        pager:  '#pager'
    });   
    
    
    
    if($('.production-view,.bit-view').length > 0) {
            
        $('div.home').css("cursor", "pointer");
        $('#masthead').animate({
            width: 0,
            opacity: 0,
            marginRight: "0px"
        }, "slow");
        

        $('.content-wrapper').animate({
          marginLeft: "75px"
        }, "slow");

        $('.home').click(function(){
            if($(this).hasClass("level-up")) {
                $(this).removeClass("level-up");
                if($('#masthead').hasClass("open")){
                    $('#masthead').animate({
                      width: 0,
                      opacity: "0",
                      marginRight: "0"
                    }, "slow");

                    $('.content-wrapper').animate({
                      marginLeft: "75px"
                    }, "slow");
            
                    $('#masthead').removeClass("open");
                }
                return false;
            }
            else {
                $(this).addClass("level-up");
            }
        });
        $('.home').mouseover(function(){
            
                $('#masthead').animate({
                  opacity: "1",
                  width: 145,
                  marginRight: "15px"
                }, "slow");

                $('.content-wrapper').animate({
                  marginLeft: "235px"
                }, "slow");
            
                $('#masthead').addClass("open");
            
        });

        $('.content-wrapper').mouseover(function(){
            if(!$('.home').hasClass("level-up")) {
                if($('#masthead').hasClass("open")){
                    $('#masthead').animate({
                      width: 0,
                      opacity: "0",
                      marginRight: "0"
                    }, "slow");

                    $('.content-wrapper').animate({
                      marginLeft: "75px"
                    }, "slow");
            
                    $('#masthead').removeClass("open");
                }
                return false;
                }
            return false;
        });


    };
    
    $(function(){
        $.ajax({
            url: 'http://api.twitter.com/1/users/show.json',
            data: {screen_name: 'eightbitstudios'},
            dataType: 'jsonp',
            success: function(data) {
                $('#followers').html(data.followers_count);
            }
        });
    });
    
    $('.content-wrapper').height($(document).height());
    $('.home').height($(document).height()-50);
    // $('#content').height($(document).height()-50);
    
    //mouseover effect on cards
    // $('.card').hover(
    //         function() {
    //             $(this).css({"borderTop":"1px solid #3eaeff", "borderLeft":"1px solid #3eaeff"});
    //         },
    //         function() {
    //             $(this).css({"borderTop":"1px solid #ccc", "borderLeft":"1px solid #ccc"});
    //         }
    //     );
    
    
    //handles comment box hiding
    $('#comments .box .content').toggle('blind');
    $('#comments h2').click( function() {
        $('#comments .box .content').toggle('blind');
        $(this).hide();
    })
    
    //mobile scroll events
    $('#content').touchScroll();

});



