﻿$(document).ready(function () {
    $("input.txtSearch").watermark({
        watermarkText: "Type to search.."
    });

    $('input.txtSearch').keydown(function (event) {
        if (event.keyCode == 13) {
            runSearch(this.value);
            return false;
        }
    });

    $('input.btnSearch').click(function () {
        var q = $('input.txtSearch').val();
        runSearch(q);
    });

    Cufon.replace('.magnum', { fontFamily: 'Magnum' });

    window.setTimeout(function () {
        $('h1.bg').each(function (index) {
            var header = $(this);
            var width = header.children('span').first().innerWidth() + 10;
            var widthCss = width + 'px 18px';
            header.css('background-position', widthCss);
        });
    }, 300);
});

function runSearch(query) {
    window.location = "/search?q=" + query;
}
