/**
 * partsearch.js
 *
 * Dependencies:
 * forms.js 
 * 		toggleLayer
 * tags.js
 * 		getObject
 *   	getStyle
 *
 * 08/21/06 JLS P6847  Created file for part search forms.
 */

	/**
	 * Controls the display of the manufacturer options to the user.
	 */
    function showhideMfgOptions()
    {
        toggleLayer("mfgOptions");
    }

    /**
     * This function is triggered by the user clicking on the account rep link.
     * This function is to communicate account rep information to the user.
     */
    function accountRepClicked()
    {
		var whichLayer = "popUp";
		var style2 = getStyle(getObject(whichLayer));
		
		if(style2 && style2 != null)
			style2.display = "block";
    }
    
    /**
     * Closes the account rep window.
     */
    function closeAccountRepWindow()
    {
		var whichLayer = "popUp";

		var style2 = getStyle(getObject(whichLayer));

		if(style2 && style2 != null)
			style2.display = "none";
    }
    
    /**
     * Validates the search form.
     * 
     * @param objForm - The form being submited.
     * @param searchTermsMsg - The message to display if validation
     *        fails for the searchTerms field.
     * @return false = validation failed, cancel form submit.
     */
    function validateSearchForm(objForm, searchTermsMsg)
    {
        try
        {
	        if(objForm.searchTerms)
	        {
	            var searchTerms = new String(objForm.searchTerms.value);
	            
	            if(searchTerms.length == 0)
	            {
	            	alert(searchTermsMsg);
	            	objForm.searchTerms.focus();
	            	return false;
	            }
	        }
		}
		catch(ex)
		{
			// ignore error.  Allow form to submit.  Rely on server-side
			// error checking.
		}
		
        return true;
    }
