﻿jQuery(
    function($) {
        //$("#q").focus();
});

function doSearch() {
    if (!isQueryEmpty()) {
        document.getElementById("searchForm").submit();
    }
}

function isQueryEmpty() {
    return (trim(document.getElementById("q").value, " ") == "");
}

/**
*
*  Javascript trim, ltrim, rtrim
*  http://www.webtoolkit.info/
*
**/
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
