﻿$(function() {
    _solutionSearch = new SolutionSearch();
    var _searchBase = new SearchBase();
    
    function SolutionSearch () {       
        
        this.searchRadio = searchRadio;
        this.searchTopic = searchTopic;
        this.DoSolutionSearch = DoSolutionSearch;

        var SEARCHPAGE = "/SolutionSearchResults?";
          
        var _keywordSearchType = 0;
        var _serchTerm = "";
        var _topicIDs = new Array();
        
        
        function DoSolutionSearch()
        {
            _searchTerm = $('#iSearchBox').val();
            if (_searchTerm.length == 0)
            {
                return;            
            }
            else
            {
                if (_searchTerm == 'Search Health Care Solutions')
                {
                    _searchTerm = '';
                }
                
                var topics = "";
                var i=0;
                while(i < _topicIDs.length)
                {
                    topics = topics + "&I=" + _topicIDs[i];
                    i++;
                }
                                
                //build search string
                var qs = "KST=" + _keywordSearchType + "&KT=" + _searchTerm + topics;
                window.location = SEARCHPAGE + qs;
            }
        }
        
        function searchRadio(ref){
            _searchBase.searchRadio(ref);
            _keywordSearchType = ref;            
        }
        
        function searchTopic(ref)
        {
            var isOn = _searchBase.toggleTopic(ref);
            _searchBase.manageArray(_topicIDs, isOn, ref);
        }
    };
});
