﻿// JScript File

        // This function is used by the tbSearch for when the user clicks to enter text
        function searchClick(obj)
        {
            // Make sure we have an object given to us
            if(obj)
            {
                obj.style.color = '#000';
                if(obj.value == 'enter keyword / item #')
                {
                    //  Reset the value if it's our default
                    obj.value = '';
                }
                else
                {
                    // Otherwise select all the text in the box
                    //obj.select();
                }
            }
        }
        
        /*
         * Name:        searchKeyDown(e)
         * Purpose:     This function catches keydown events, and if the enter key is pressed then a search is performed
         * Author:      Kevin M
         * Arguments:   e - an event
         */ 
        function searchKeyDown(e)
        {
            var Key = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            //alert(Key);
            if(Key == 13)
            {   
                onSearch('ctl00_tbSearch');   
                return false;
                
            }
            
        }

        // This function is used by the tbSearch for when the user leaves the textbox
        function searchBlur(obj)
        {
            // Make sure we have an object given to us
            if(obj)
            {
                // If the box is empty, we'll add back in our default value
                if(obj.value == '')
                {
                    //obj.value = '(Enter Keyword)';
                    // We always reset the color to an "inactive" visual state
                    obj.style.color = '#bbb';
                }
                else
                {

                }
            }
        }
        
         // Search click
        function onSearch(obj1)
        {
            
            // Make sure we have an object given to us
            if(obj1)
            {
                var obj = document.getElementById(obj1);
            //if(obj)
            //{
                // If the box is empty, we'll add back in our default value
                if(obj.value == '' || obj.value == 'enter keyword / item #')
                {
                    obj.value = 'enter keyword / item #';
                }
                else
                {                    
                    window.location="/search/?q=" + obj.value;
                    //location.replace("/search/?q=" + obj.value);
                }
            }
        }
 /*       
        function onKeyPress(obj,ev) 
        {
         var keycode;
         if (window.event) {
            keycode = window.event.keyCode;
            }
        else {
            if (ev) {
                keycode = ev.which;
                }
            else {
                return true;
                }
            }
         //keycode = e.which;

         if (keycode == 13) {
         // Make sure we have an object given to us
            if(obj)
            {
                // If the box is empty, we'll add back in our default value
                if(obj.value == '' || obj.value == '(Enter Keyword)')
                {
                    obj.value = '(Enter Keyword)';
                }
                else
                {
                    window.location="/search/?q=" + obj.value;
                }
            }
        }
        }
*/
