﻿var tkExpanded = false;

function toggleToolkit(headerHeight, tkHeight) {
    if (tkExpanded) {
        $('#bodyWrapper').animate({ top: -1 * (tkHeight - headerHeight + 1) }, 'slow');
        tkExpanded = false;
    } else {
        $('#bodyWrapper').animate({ top: headerHeight }, 'slow');
        tkExpanded = true;
    }
}

// All page elements need to be loaded to accurately calculate the height, which needs to be precise
// in order for the shelf UI element to function correctly. Hence, window load.
window.onload = function() {
    var headerHeight;
    var tkHeight;

    /*
    $('.headerIcons .one').mouseover(function (e) {
        $('.tooltip.one').fadeTo('normal', 1.0);
    });
    $('.headerIcons .one').mouseout(function (e) {
        $('.tooltip.one').fadeTo('normal', 0.0);
    });
    $('.headerIcons .two').mouseover(function (e) {
        $('.tooltip.two').fadeTo('normal', 1.0);
    });
    $('.headerIcons .two').mouseout(function (e) {
        $('.tooltip.two').fadeTo('normal', 0.0);
    });
    $('#toolkit_header').mouseover(function (e) {
        $('.tooltip.toolkit').fadeTo('normal', 1.0);
    });
    $('#toolkit_header').mouseout(function (e) {
        $('.tooltip.toolkit').fadeTo('normal', 0.0);
    });
    */
    $('#toolkit_header').click(function (e) {
        toggleToolkit(headerHeight, tkHeight);
        return false;
    });
    $('#toolkit_homepageTiles').click(function (e) {
        toggleToolkit(headerHeight, tkHeight);
    });

	var calcNav = function() {
		headerHeight = $('.header').height();
        tkHeight = $('#toolkit').height() + 10;
        
        $('#bodyWrapper').css({"top": -1 * (tkHeight - headerHeight + 1) + "px", "visibility":"visible"});
	};
	
    $('ul#tags').columns(4, false, function () {
    	$('#bodyWrapper').css({'visibility':'hidden'});
        //setTimeout(calcNav,500);
        calcNav();
    });

};
