﻿function ucwords(str) {
    return str.replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); });
}

function search(submit, root) {
    IE = (document.all)
    NC = (document.layers)
    Opera = (document.getElementById)
 
    if (IE) {
        eval('text = document.all["searchText"]')
        eval('form = document.all["searchForm"]')
    }
    if (NC) {
        eval('text = document.layers[searchText]')
        eval('form = document.layers[searchForm]')
    }
    if (Opera) {
        eval('text = document.getElementById("searchText")')
        eval('form = document.getElementById("searchForm")')
    }

    if (text.value == "") {
        text.focus();
        if (submit)
            return false;

    } else {
        text_value = ucwords(text.value.toLowerCase());
        re = /[^A-Za-z0-9]/g;

        txt = text_value.replace(re, "");

        if (txt == 0) {
            submit = false;
            return false;
        }


        expression = text_value.replace(re, "-");
        form.action = "http://www.filehum.com/search/" + expression + '/1.aspx';

        rowText.value = text.value;
        
        if (submit)
            return true;
    }
}