﻿/**
 * Global jQuery functions
 */

// Ensures that DOM has been loaded before adding events
$(document).ready(function() 
{

    // Toggles visibility of the login box
    $("#login .btn").toggle(
        function() {
            $("#login").addClass("active");
        },
        function() {
            $("#login").removeClass("active");
        }
    );

    // onBlur and onFocus for all input text fields
    $("input:text").not(".noblur").focus(function() {
        if ( $.trim(this.value) == this.defaultValue )
            this.value = "";
    });
    $("input:text").not(".noblur").blur(function() {
        if ( $.trim(this.value) == "" )
            this.value = (this.defaultValue) ? this.defaultValue : "";
    });
});

$.fn.equalHeights = function() {
    $(this).each(function() {
        var currentTallest = 0;
        $(this).children().each(function(i) {
            if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
        });
        //if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
        // for ie6, set height since min-height isn't supported
        if (($.browser.msie && $.browser.version < 7)) { $(this).children().css({ 'height': currentTallest }); }
        $(this).children().css({ 'min-height': currentTallest });
    });
    return this;
};