﻿var visibleDiv = "#home";

$(document).ready(function () {
    // Select tab
    selectTab();

    // Accordian
    accordianSetup();

    // Contact info
    contactHoverOvers();

    // Cloud animation
    animateCloud();
    
    // Animate code blocks
    animateCodeBlocks();
});

function selectTab() {
    $("#header ul.tabs li").each(function () {
        var link = $(this).find("a").attr("href");
        if (link === window.location.pathname) {
            $(this).addClass("active");
        }
    });
}

function animateCloud()
{
    $("#cloud").animate({ 'left': '900px' }, 180000, 'linear', function() {
        $(this).css('left', '-66px');
        animateCloud();
    });
}

function animateCodeBlocks(){
    // Wrap the syntax highlighter content to allow expanding areas
    $("pre, .syntaxhighlighter").wrap("<div class='brushwindow'></div>").wrap("<div class='brushwrap'></div>");
    $(".brushwrap").width("850px");
    $(".brushwindow").hover(function() {
        $(this).animate({ width: '850px' });
    }, function() {
        $(this).animate({ width: '594px' });
    });
}

function accordianSetup() {
    $(".accordion_child").hide();
    $(".accordion_header:first").addClass("header_highlight").show();
    $(".accordion_child:first").show();
    $(".accordion_header").click(function() {
        $(".accordion_header").removeClass("header_highlight").show();
        $(".accordion_child").slideUp("slow");
        $(this).addClass("header_highlight").show();
        $(this).next(".accordion_child").slideDown("slow");
    });
}

function contactHoverOvers() {
    $("#gmail").mouseover(
        function() {
            $("#contact_info").css('background-position', '0 0');
        }
    );
        $("#twitter").mouseover(
        function() {
            $("#contact_info").css('background-position', '0 -20px');
        }
    );
        $("#linkedin").mouseover(
        function() {
            $("#contact_info").css('background-position', '0 -40px');
        }
    );
}



