﻿$(document).ready(function() {
    $("#where").autocomplete("/suggest/loc", {
        minChars: 1,
        delay: 250,
        matchSubset: false,
        selectFirst: false,
        max: 10,
        autoFill: false,
        matchContains: false,
        scrollHeight: 220,
        extraParams: {}
    });

    $("#what").autocomplete("/suggest/job", {
        minChars: 1,
        delay: 250,
        matchSubset: false,
        selectFirst: false,
        max: 10,
        autoFill: false,
        matchContains: false,
        scrollHeight: 220,
        extraParams: {}
    });

    var error = "Please enter a location.";

    $(".searchForm").submit(function() {
        var where = $("#where");
        if ($.trim(where.val()) == "" || where.val() == error) {
            where.val(error);
            where.removeClass("bg");
            where.css("background-color", "#CC0000");
            where.animate({ color: "#CC0000", backgroundColor: "#FFFFFF" }, 750);
            return false;
        }
    });

    $("#where").focus(function() {
        if ($(this).val() == error) {
            $(this).addClass("bg");
            $(this).css("color", "");
            $(this).val("");
        }
    });
});