// adds <h1>content to <title>
// doesn't add to the title for google searches
/*$(window).load(function updateTitle() {
	// creates a variable using the second [1] instance of <h1>
	var pageh1 = document.getElementsByTagName("H1")[1];
	// if <h1> exists, set it as the prefix for <title>
	if (pageh1) document.title = pageh1.innerHTML + " | " + document.title;
});*/

// changes <header> background when mouseover <ul class="primarynavigation"><li>
$(document).ready(function() {
	$('.primarynavigation li').hover(
	function(){$('header').addClass(this.className)},
	function(){$('header').removeClass(this.className)}
	)
})

// uses ajax to embed the media into the page without reloading the page (keeps the sermon list scrolled to where you were)
function embedMedia(str) {
	if (str.length==0) {
		document.getElementById("embeddedmedia").innerHTML="";
		return;
	}
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById("embeddedmedia").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","include/embedmedia.php?episode="+str,true);
	xmlhttp.send();
}
