function MM_swapImgRestore() 
{
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage()
{
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){
     document.MM_sr[j++]=x; 
     if(!x.oSrc) x.oSrc=x.src; 
     x.src=a[i+2];
     }
}

function MM_findObj(n, d) 
{
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); 
  return x;
}

function mtwo(adr,host,disp)
{
	var s1,s2;
	s1="<a"+" h"+"r"+"ef="+"m"+"ai"+"l"+"t"+"o"+":";
	s2="."+"co"+"m"+">";
	document.write(s1+adr+"&#64;"+host+s2+adr+"&#64;"+"<img border=0 valign=middle src="+disp+">"+"</a>")
}

function ShowSermon(nSermon_ID)
{
	var strURL;
	strURL =  '/sermon_display.php?sermon_id='+nSermon_ID;
	popupWin = window.open(strURL,'Sermon_Window','width=700,height=500,menubar,resizable,scrollbars,status,titlebar,toolbar')
}

function ShowDay(sQueryString)
/* used by the calendar to pop a window with the calendar events */
{
	var strURL;
	strURL =  '/lib/calendar_day.php?day='+sQueryString;
	popupWin = window.open(strURL,'Calendar_Day','width=400,height=300,resizable,scrollbars,titlebar')
}

function openWindow(anchor, options) {
	/*
	HTML example
	<a href="http://www.sourcesnippets.com" 
	    title="Free source snippets" 
	   onclick="return openWindow(this, {width:790,height:450,center:true})">Click this link</a> 
	*/
	var args = '';
 
	if (typeof(options) == 'undefined') { var options = new Object(); }
	if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }
 
	if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "height=" + options.height + ",";
	}
 
	if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "width=" + options.width + ",";
	}
 
	if (typeof(options.fullscreen) != 'undefined') {
		args += "width=" + screen.availWidth + ",";
		args += "height=" + screen.availHeight + ",";
	}
 
	if (typeof(options.center) == 'undefined') {
		options.x = 0;
		options.y = 0;
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);
		options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }
	if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; }
	if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; }
	if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; }
 
	var win = window.open(anchor, options.name, args);
	return false;
}

function display_element(strID)
{
	var obj=document.getElementById(strID);
	if (obj.style.display == 'none')
		obj.style.display = 'inline';
	else
		obj.style.display = 'none';
}

function switch_more_less(strDivID)
{
	/*
	Switched from innerText to innerHTML because it is supported in IE and Firefox
	*/
	var obj=document.getElementById("more_"+strDivID);
	if (obj.innerHTML == "more")
		obj.innerHTML = "less";
	else
		obj.innerHTML = "more";

	display_element(strDivID);
}

