// JavaScript Document
var xmlHttp

function filterVideo(category, str, topic, date) { 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="http://www.cccamarillo.com/video_filter.php"
	url=url+"?category="+category
	url=url+"&q="+str
	url=url+"&topic="+topic
	url=url+"&date="+date
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=thumbChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function filterImage(category, str, topic, date) { 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="http://www.cccamarillo.com/image_filter.php"
	url=url+"?category="+category
	url=url+"&q="+str
	url=url+"&topic="+topic
	url=url+"&date="+date
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=thumbChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function filterSermon(category, str, topic, date) { 
	//alert(topic);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="http://www.cccamarillo.com/sermon_filter.php"
	url=url+"?category="+category
	url=url+"&q="+str
	url=url+"&topic="+topic
	url=url+"&date="+date
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=sermonChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function thumbChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		var return_text = xmlHttp.responseText.split('%');
		
		document.getElementById("number_videos").innerHTML=return_text[0] 
	 	document.getElementById("thumb_slider_holder").innerHTML=return_text[1] 
		
		//document.getElementById("thumb_slider_holder").innerHTML=xmlHttp.responseText 
	} 
}

function sermonChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("sermon_notes_here").innerHTML=xmlHttp.responseText 
	} 
}

// photo gallery
function photoGallery(imageFile) { 
	//alert(topic);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="http://www.cccamarillo.com/ajax_gallery.php"
	url=url+"?imageFile="+imageFile
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=galleryChange 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function galleryChange() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("media_lounge_player").innerHTML=xmlHttp.responseText;
		//document.getElementById('load_image').style.display='none';
	} 
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}