 
function loadResults(queryString){
    if (queryString){
        $("#results_container").hide();
        $("#progress_icon").show();    

        $("#results_container").load('/search/results/?' + queryString, null, function(){
            $("#progress_icon").hide();
            $("#results_container").show();
        });
    }              
}

function ajaxSubmit() {
    
    var terms = [];
    $('#search_interface input').each(function(){ 
        if (this.type == 'radio' || this.type == 'checkbox'){
            if (this.checked){
                terms.push(this.name + '=' + this.value);
            }
        }
        else if (this.value){
            terms.push(this.name + '=' + this.value);
        }
    }); 
    $('#search_interface select').each(function(){
        if (this.value){
            terms.push(this.name + '=' + this.options[this.selectedIndex].value);
        }
    }); 
    var queryString = terms.join('&');
    
    loadResults(queryString);
    
    return false;
}

toggleRows = function(rowID, eventTarget){ 
    if (!rowID){
        clip_rows = $('#results_table .clip_rows');
    }         
    else {
        clip_rows = $('#results_table .'+rowID+'.clip_rows');
    }
    if (clip_rows.css('display') == 'none'){   
        if (jQuery.browser.msie){
            clip_rows.css('display', 'block');
        }                      
        else {
            clip_rows.css('display', 'table-row');
        }
        eventTarget.childNodes[0].src = '/images/design_elements/button_hide_topics.gif';
    }
    else {
        clip_rows.css('display', 'none');
        eventTarget.childNodes[0].src = '/images/design_elements/button_show_topics.gif';
    }                           
};

function showTopics(value){ 
    var clip_rows = $('#results_table .clip_rows'); 
    var icons = $('#results_table .vidlink img');
    if (value){
        if (jQuery.browser.msie){
            clip_rows.css('display', 'block');
        }                      
        else {
            clip_rows.css('display', 'table-row');
        }
        icons.attr('src', '/images/design_elements/button_hide_topics.gif');
    }
    else {
        clip_rows.css('display', 'none');
        icons.attr('src', '/images/design_elements/button_show_topics.gif');
    }
}