var sermons;
var updates;
var others;

function ShowSermons() {

    if( sermons == null)
        sermons = document.getElementById("sermons");

    if (updates == null)    
        updates = document.getElementById("updates");
    
    updates.style.display = "none";
    sermons.style.display = "";
}


function ShowUpdates() {

    if (sermons == null)
        sermons = document.getElementById("sermons");

    if (updates == null)
        updates = document.getElementById("updates");
    
    updates.style.display = "";
    sermons.style.display = "none";
}

function ShowOther() {
	
    if (others == null){
        others = document.getElementById("other_things");
        visible = false;
	}

    if(!visible){
	    others.style.display = "";
	    visible = true;
    }else{
	    others.style.display = "none";
		visible = false;
    }
}


// Functions for HTTP Request to search page
function SearchSermons(){
	var preachers = document.getElementById("PreacherSelect");
	var option = preachers.options[preachers.selectedIndex];
	var preacher = encodeURI(option.text);
	
	var series = document.getElementById("SeriesSelect");
	var option = series.options[series.selectedIndex];
	var sname = escape(option.text);
	
	var SearchURL = "search.php?preacher=" + preacher + "&series=" + sname;
	
	StartSearch(SearchURL); // Function defined in Search.js

	var sermons_table = document.getElementById("table");
	var loading_section = document.getElementById("loading_message");
	sermons_table.style.display = "none";
	loading_section.style.display = "block";
}

function ProcessSearchResults(SearchText) {
    var sermons_header = document.getElementById("table_title");
    var sermons_table = document.getElementById("table");
    
    var loading_section = document.getElementById("loading_message");
    loading_section.style.display = "none";

	sermons_header.innerHTML = "SERMON SEARCH RESULTS";
	sermons_table.innerHTML = SearchText;
	sermons_table.style.display = "block";
}
