var queryElm;
var noQuery = 'Search...';
var noQueryCSS = {color: '#999', fontStyle: 'italic'};
var queryCSS = {color: '#303030', fontStyle: 'normal'};

$(document).ready(function () {
    queryElm = $('#search-form #query');

    queryElm.focus(queryFn);
    queryElm.blur(noQueryFn);
    $('#search-form').submit(function () {
        if (queryElm.val() == noQuery) {
            alert('Please enter at least one keyword to search for!');
            return false;
        }
    });
    noQueryFn(null, true);
    
    $.each($('#menu li a'), function (i, obj) {
        if ($(obj).text() == 'Home') {
            // home will match every URL, so it must be exact
            if (window.location.href == obj.href) {
                $(this).addClass('active');
            }
        }
        else if (window.location.href.search(obj.href) == 0) {
            $(this).addClass('active');
        }
    });
});
function queryFn() {
    if (queryElm.val() == noQuery) {
        queryElm.css(queryCSS);
        queryElm.val('');
    }
}
function noQueryFn(evt, force) {
    if (force != undefined || queryElm.val().length <= 0) {
        queryElm.val(noQuery);
        queryElm.css(noQueryCSS);
    }
}