﻿/// <reference path="jquery-vsdoc.js" />
//*************************************************************************************
// File     : lojr_functions.js
// Requires : jquery.js (version 1.4.2+), braingnat.js (version 0.4.0+), bgGoogle.js (version 0.4.0+)
// Author   : Kyle Weems (ksw)
// Origin   : mindfly.com
// Created  : Mar 05, 2010
// Modified : Apr 19, 2010
//*************************************************************************************

$(document).ready(function() {
    $('body').addClass('hasJS'); /* To deactivate any non-JS CSS defaults. */
    fitContentToWindow();
    sliderMenu();
    googleMap();
});

/* Ensure that the columns are equal in height, and that the content is large enough to keep the footer at the bottom of screen. */
function fitContentToWindow() {
    if ($('#primary').height() < $('#secondary').height()) {
        $('#primary').css('min-height', $('#secondary').height() + 'px');
    } else {
        $('#secondary').css('min-height', $('#primary').height() + 'px');
    }
    var difference = $(window).height() - ($('#header').outerHeight() + $('#footer').outerHeight()) + ($('#main').height() + ($('#main').css('margin-top').substr(0, $('#main').css('margin-top').length - 2) * -1));
    difference = difference - 76;

    if ($('#content').height() < difference) {
        $('#content').css('min-height', difference + 'px');
    }
}

/* Slide open a submenu showing a page's grandchildren if on the child page. */
function sliderMenu() {
    if ($('.sub .active + ul .current').length > 0) {
        $('.sub .active + ul').css('display', 'block');
    } else {
        var t = setTimeout("$('.sub .active + ul').slideDown();", 1000);
    }
}

/* On the About Me page, load a map showing the office's location in Google Maps. */
function googleMap() {
    if ($('#map').length > 0) {
        BrainGnat.Google.map.loadFromHCard("#footer .vcard", "#map", 16);
    }
}