﻿/// <reference path="jquery-1.3.2-vsdoc.js" />

// JQuery Extensions
(function ($) {
    /**
    * Clears the form data.  Takes the following actions on the form's input fields:
    *  - input text fields will have their 'value' property set to the empty string
    *  - select elements will have their 'selectedIndex' property set to -1
    *  - checkbox and radio inputs will have their 'checked' property set to false
    *  - inputs of type submit, button, reset, and hidden will *not* be effected
    *  - button elements will *not* be effected
    */
    $.fn.clearForm = function () {
        return this.each(function () {
            $('input,select,textarea', this).clearFields();
        });
    };

    /**
    * Clears the selected form elements.
    */
    $.fn.clearFields = $.fn.clearInputs = function () {
        var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
        return this.each(function () {
            var t = this.type, tag = this.tagName.toLowerCase();
            if (re.test(t) || tag == 'textarea') {
                this.value = '';
            }
            else if (t == 'checkbox' || t == 'radio') {
                this.checked = false;
            }
            else if (tag == 'select') {
                this.selectedIndex = -1;
            }
        });
    };

    $.fn.getDate = function () {
        if (this.val().length == 0)
            return null;

        return new Date(this.val());
    };
})(jQuery);

// Wire up action links
// <a href="?action=DoSomething&id=3">click to do something</a>
/*$('a[href*="?action="]').live("click", function (e) {
    e.preventDefault();

    var query = $(this).attr("href").slice(1).split("&");
    var args = new Object();
    for (var i = 0; i < query.length; i++) {
        var temp = query[i].split("=");
        args[temp[0]] = temp[1];
    }

    var fn = window[args.action];
    if (typeof fn === 'function') {
        fn(args);
    }
});*/


// Drop down menu
//Now in dd_menu.js
/*$(document).ready(function() {
    $("#navigationBar > ul > li").hover(
        function() { $(this).addClass("hovering"); },
        function() { $(this).removeClass("hovering"); }
    );
});*/

// Course Unit Nav
$(document).ready(function() {
    $(".tab-links > li > h1").click(
        function() {
            if($("+ .units", this).hasClass("show"))
                $("+ .units", this).removeClass("show");
            else
                $("+ .units", this).addClass("show");
        }
    );
});

// Dialogue
$(document).ready(function() {
    $(".dialogue > div").addClass('character clearfix');
    $(".dialogue > div").wrapInner('<div class="text"></div>');
    $(".dialogue > div").prepend('<div class="picture"></div>');
    $(".dialogue .text:odd").addClass('alt');
});

function showNotification(message, messageClass) {
    $('#notification').html('<div class="message ' + messageClass + '">' + message + '</div>');
    $('#notification').slideDown('normal', function() {
        setTimeout('$("#notification").slideUp()', 4000);
    });
}

$(document).ready(function() {
    $(".MessageEdit table table td:even").addClass("label");
});
