var xmlHttp

//AJAX initation thing.
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;
				}

//State changers
		function CNGstateChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				var content = document.getElementById('eventContent');
				var txt = document.getElementById(chgid); 
 				txt.innerHTML=xmlHttp.responseText 
 				content.innerHTML=xmlHttp.responseText; 
 				} 
			}
			
		function ADDstateChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				var content = document.getElementById('eventContent');
				var el = document.addForm.elements;
				for ( var elem, i = 0; ( elem = el[i] ); i++ ){
						if(elem.type=='text'){
							elem.value='';
					//		elem.style.background = '#fff';
						}
					}
 				content.innerHTML=xmlHttp.responseText; 				
 				} 
			}
			
// Log Sermon Listen 
		function logSermon(id,type){ 
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null){
 				alert ("Browser does not support HTTP Request")
 				return
 				}
			var url="../includes/functions.php"
			url=url+"?id="+id
			url=url+"&type="+type
			url=url+"&sermonLog=true"
			url=url+"&sid="+Math.random()
	//		xmlHttp.onreadystatechange=CNGstateChanged
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
			}
			
function openMP(id){
	window.open('../media/listen.php?id='+id+'',
		'MPd',
		'height=340, width=650, scrollbars=no');
	return false;
	}
	
function openMPw(type,filename,title,artist){
	window.open('/media/mediaplayer.php?type=' + type + '&filename=' + filename + '&title=' + title + '&artist=' + artist + '',
		'MPd',
		'height=340, width=650, scrollbars=no');
	return false;
	}
	
function displayMP(sermon){
	logSermon(sermon, 'listened');
		<!--
		document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="16" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">\n');
		document.write('<param name="src" value="http://www.vbcaurora.org/Sermons/'+ sermon +'.mp3" />\n');
		document.write('<embed src="http://www.vbcaurora.org/Sermons/'+ sermon +'.mp3" width="320" height="16" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed>\n');
		document.write('</object>\n');
		// -->
	}
	
function displayMPw(media){
				<!--
				document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="16" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">\n');
				document.write('<param name="src" value="/media/'+ media +'.mp3" />\n');
				document.write('<embed src="/media/'+media+'.mp3" width="320" height="16" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed>\n');
				document.write('</object>\n');
			// -->
	}

		
	
