﻿$(document).ready(function () {
    resizeColumns();
    $('.collapsible').addClass('collapsed').find('.content').hide();

    $("#ulMainNav li a").hover(
    function () {
        $(this).addClass("active");
    },
    function () {
        $(this).removeClass("active");
    })
});

var resizeColumns = function() {
    var col1 = $("#col1");
    var col2 = $("#col2");
    if (col1.height() > col2.height()) { col2.css("height", col1.height()); }
    else { col1.css("height", col2.height()); }
}

var log = function(msg) {
    if (typeof console == 'object' && typeof console.log == 'function') { console.log(msg); }
}

var contact = {
    setup: function () {
        $('#otherCare, #otherLocation, #txtContact').hide();
        $('#email').replaceWith('<a href=\"mailto:&#105;&#110;&#102;&#111;&#064;&#115;&#105;&#108;&#118;&#101;&#114;&#097;&#103;&#101;&#099;&#097;&#114;&#101;&#046;&#099;&#111;&#109;\">&#105;&#110;&#102;&#111;&#064;&#115;&#105;&#108;&#118;&#101;&#114;&#097;&#103;&#101;&#099;&#097;&#114;&#101;&#046;&#099;&#111;&#109;</a>');
        $('#phone').replaceWith("<span>&#050;&#048;&#054;&#046;&#054;&#054;&#057;&#046;&#055;&#049;&#057;&#049;</span>");
        resizeColumns();
        $('#contact-form #CareType').bind('change keyup', function () {
            if ($(this).val().toLowerCase() == 'other') { $('#otherCare').fadeIn(); }
            else { $('#otherCare').fadeOut(); }
            resizeColumns();
        });

        $('#contact-form #Location').bind('keyup change', function () {
            if ($(this).val().toLowerCase() == 'other') { $('#otherLocation').fadeIn(); }
            else { $('#otherLocation').fadeOut(); }
            resizeColumns();
        });

        $('#contacttype input:radio').bind('change', function () {
            var c = $('#txtContact label');
            if ($(this).val().toLowerCase() == 'phone') {
                c.text('Phone Number');
            }
            else { c.text('Email Address'); }
            $('#txtContact').fadeIn();
            resizeColumns();
        });
        $('a.submit').click(function (e) {
            e.preventDefault();
            $(this).closest('form').submit();
        });
    }
};
