$(window).load(function () {
    if (document.width % 2 == 1) {
        $('html').css('margin-left', '-1px');
    }
});

$(window).resize(function () {
    if (document.width % 2 == 1) {
        $('html').css('margin-left', '-1px');
    } else {
        $('html').css('margin-left', '');
    }
});

$.fn.clearDefault = function () {
    return this.each(function () {
        var default_value = $(this).val();
        $(this).focus(function () {
            if ($(this).val() == default_value) $(this).val("");
        });
        $(this).blur(function () {
            if ($(this).val() == "") $(this).val(default_value);
        });
    });
};

$(document).ready(function () {
    var config = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
        interval: 0, // number = milliseconds for onMouseOver polling interval    
        over: expandMenu, // function = onMouseOver callback (REQUIRED)    
        timeout: 300, // number = milliseconds delay before onMouseOut    
        out: collapseMenu // function = onMouseOut callback (REQUIRED)    
    };

    $(".middle-container .ribbon .nav ul li.parent").hoverIntent(config);
    if ($('.colorbox').length) {
        $(".colorbox").colorbox({ iframe: true, innerWidth: 425, innerHeight: 344 });
    }
    if ($('.clearDefault').length) {
        $('.clearDefault').clearDefault();
    }
    if ($('.datepicker').length) {
        $('.datepicker').datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: '1980:2020'
        });
    }
    if ($('.reset').length) {
        $('.reset').click(function (e) {
            $('form')[0].reset();
            e.preventDefault();
        });
    }
});

function expandMenu() {
	jQuery(this).addClass('hover');
}

function collapseMenu() {
	jQuery(this).removeClass('hover');
}
