﻿$(document).ready(function () {
    $('.searchBtn').click(function () {
        if (($('#dynamicSearch').val() == "Search by Keyword") || ($('#dynamicSearch').val() == "")) {
            return false;
        } else {
            siteSearch.submit();
        }
        return false;
    });
    $("#dynamicSearch").bind("keypress", function (e) {
        if (jQuery.browser.msie) {
            if (($('#dynamicSearch').val() == "") && (e.keyCode == 13)) {
                return false;
            }
        } else {
            if (e.which == "Search by Keyword") return false;
            if (e.which == "") return false;
        }
    });
    $('.advancedSearchText').focus(function () {
        if ($(this).attr('disabled', 'true')) {
            $(this).removeAttr('disabled');
        }
    });
    $('#all_words').blur(function () {
        if ($('#all_words').val() !== "") {
            $('#exact_phrase').attr('disabled', 'true');
            $('#any_word').attr('disabled', 'true');
        } else {
            $('#exact_phrase').removeAttr('disabled');
            $('#any_word').removeAttr('disabled');
        }
    }).focus(function () {
        if ($('#all_words').val() == "") {
            $('#exact_phrase').removeAttr('disabled');
            $('#any_word').removeAttr('disabled');
        }
    });
    $('#exact_phrase').blur(function () {
        if ($('#exact_phrase').val() !== "") {
            $('#all_words').attr('disabled', 'true');
            $('#any_word').attr('disabled', 'true');
        } else {
            $('#all_words').removeAttr('disabled');
            $('#any_word').removeAttr('disabled');
        }
    }).focus(function () {
        if ($('#exact_phrase').val() == "") {
            $('#all_words').removeAttr('disabled');
            $('#any_word').removeAttr('disabled');
        }
    });
    $('#any_word').blur(function () {
        if ($('#any_word').val() !== "") {
            $('#exact_phrase').attr('disabled', 'true');
            $('#all_words').attr('disabled', 'true');
        } else {
            $('#all_words').removeAttr('disabled');
            $('#exact_phrase').removeAttr('disabled');
        }
    }).focus(function () {
        if ($('#any_word').val() == "") {
            $('#all_words').removeAttr('disabled');
            $('#exact_phrase').removeAttr('disabled');
        }
    });
});
