﻿$(document).ready(function () {
    registerSearch();
    registerExamples();
    registerInvalidNote();

    registerAutoComplete(false);
});
function registerInvalidNote() {
    var note = $("div#search-box div.invalid-note");

    if (note.length > 0) {
        setTimeout(function() { note.fadeOut(); }, 5000);
    }
}
function registerExamples() {
    $("ul#query li div.examples a").click(function() {
        var loc = $("ul#query li input.location");

        loc.val($(this).text() + ", ");
        loc.focus();
        updateAutoComplete();

        return false;
    });
}
function registerSearch() {
    var from = $("ul#query input.num-from");
    var to = $("ul#query input.num-to");

    $.watermark.options.useNative = false;

    from.thousand(".");
    from.watermark("Fra");
    to.thousand(".");
    to.watermark("Til");

    if (Bolig.section == "Owner")
        $("div#search-box input.location").watermark("Kommune, by, postnummer eller vej");
    else
        $("div#search-box input.location").watermark("Kommune, by eller postnummer");
}
