window.onload = function() {
	var view = document.getElementById("viewport");
	if (view.innerHTML.length > 0)
		return;
	var xmlhttp, bComplete = false;
	if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	} else if (window.XMLHttpRequest) {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			return false;
		}
		xmlhttp.overrideMimeType("text/xml");
	}
	try {
		if (document.all.length >= 95) {
			xmlhttp.open("GET", "http://www.covenantpca.net/sermons/embed.asp", true);
			try {
				xmlhttp.setRequestHeader("Content-Type","text/xml");
				xmlhttp.setRequestHeader("Cache-Control", "no-cache");
			} catch (e) {};
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && !bComplete) {
					if (xmlhttp.status == 200) {
						bComplete = true;
						view.innerHTML = xmlhttp.responseText;
					}
				}
			};
		} else {
			xmlhttp.open("GET", "http://www.covenantpca.net/sermons/reload.asp", true);
			try {
				xmlhttp.setRequestHeader("Content-Type","text/xml");
				xmlhttp.setRequestHeader("Cache-Control", "no-cache");
			} catch (e) {};
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && !bComplete) {
					if (xmlhttp.status == 200) {
						bComplete = true;
						window.location = "http://www.covenantpca.net/Sermons.asp";
					}
				}
			};
		}
		xmlhttp.send(null);
	} catch(z) {
		return false;
	}
	return true;
};
function getElementsByName_iefix(tag, name) {
	var elem = document.getElementsByTagName(tag);
	var arr = new Array();
	for(i = 0,iarr = 0; i < elem.length; i++) {
		att = elem[i].getAttribute("name");
		if(att == name) {
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	return arr;
}
function postback() {
	// Filter Method
	var month = document.getElementById("month").value;
	var period = document.getElementById("period").value;
	var artist = document.getElementById("artist").value;
	var files = getElementsByName_iefix("div", "file");
	for (var i = 0; i < files.length; i++) {
		var id = files[i].id;
		files[i].style.display = "none";
		if (month == "" || id.indexOf(month) >= 0) {
			if (period == "" || id.indexOf(period) >= 0) {
				if (artist == "" || id.indexOf(artist) >= 0) {
					files[i].style.display = "block";
				}
			}
		}
	}
}
