﻿var sTxtKeyValue = "Product Search";
var oTxtKey = document.getElementById("searchKeywords");
oTxtKey.value = sTxtKeyValue;
oTxtKey.style.color = "#999999";

oTxtKey.onclick = function() {
    //alert('onclick');
    if (this.value == sTxtKeyValue) this.value = '';
};

oTxtKey.onblur = function() {
    //alert('onblur');
    if (this.value == '') {
        this.value = sTxtKeyValue;
        this.style.color = '#999999';
    }
};

oTxtKey.onkeydown = function(ev) {
    //alert('onkeydown');
    this.style.color = '#333333';

    var event = ev || window.event;
    var keyCode = event.charCode || event.keyCode;
    if (keyCode == 13) return startSearch();
};

function startSearch() {
    var keyBox = document.getElementById("searchKeywords");

    if (keyBox.value.length == 0 || keyBox.value == sTxtKeyValue) {
        keyBox.focus();
        keyBox.select();
        alert('Please input the keywords');
        return false;
    }

    location.href = "search.aspx?key=" + keyBox.value;
    return false;
}
