// JavaScript Document

d=document;

function showHide(elementid){ 
  if (document.getElementById(elementid).style.display == 'none'){ 
    document.getElementById(elementid).style.display = '';
  } else { 
    document.getElementById(elementid).style.display = 'none'; 
  } 
}

function hideAnnouncement(){
	document.getElementById("announcement").style.display = 'none';
	document.getElementById("screen").style.display = 'none';
	document.getElementById("fullscreen").style.display = 'none';
}

function launchPlayer(messageID){
  if(playerWin){
	playerWin.close();
  }
  var playerWin=window.open('/media_player.asp?messageID=' + messageID,playerWin,'width=550,height=450,toolbar=false,resizable=false,menubar=false,scrollbars=false,status=false');
}	

function launchPlayerLarge(messageID,winWidth,winHeight){
	if(playerWin){
		playerWin.close();
	}
	var playerWin=window.open('/media_player.asp?type=large&messageID=' + messageID,playerWin,'width=' + winWidth + ',height=' + winHeight + ',toolbar=false,resizable=false,menubar=false,scrollbars=false,status=false');
}

//
/*LIVE SHOW FUNCTIONS*/

function launchLiveShowPlayer(groupID,winWidth,winHeight,movieName){

  if(playerWin){
	  playerWin.close();
  }
  var playerWin=window.open('http://www.mbclive.org/liveShowPlayer.asp?groupID=' + groupID + '&movie=' + movieName,playerWin,'width=' + winWidth + ',height=' + winHeight + ',toolbar=false,resizable=false,menubar=false,scrollbars=false,status=false');
}

function openExternalLink(xurl){
	window.open(xurl, '_blank', 'toolbar=yes,location=yes,directories=yes,resizable=yes,menubar=yes,scrollbars=yes, status=yes');
}

var noteWindow; 
var Notes;	

function noteLauncher(myNotes, method) {
	  //make sure the LiveShowNotes isn't already open
	if (noteWindow) {
		noteWindow.close();
	}
	noteWindow = window.open("/liveShowNotes.asp?method=" + method, "noteWindow", "height=480,width=325");
	Notes = myNotes;
	noteWindow.focus();
}

function popNewWindow(eventID, type) {
	window.open('/event_detail.asp?id=' + eventID + '&type=' + type, '_blank', 'width=450, height=450, scrollbars=yes, menubar=no');
}

function showStaff(total, obj, source){  
  for(var i=1; i<=total; i++){
	if(i==obj){
	  d.getElementById('staff' + obj).style.display='';
	  var image="<img src='" + source + "'>";
	  d.getElementById('staff_image' + obj).innerHTML=image;
	}else{
	  d.getElementById('staff' + i).style.display='none';
	}
  }
}

/* Campus menu*/
// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 


//FUNCTION TO LAUNCH FELLOWSHIP ONE WEBLINK WINDOWS
function launchF1(url){
	if(f1Win){
		f1Win.close();
	}
	var f1Win=window.open(url,f1Win,'width=650,height=750,toolbar=0,resizable=1,menubar=0,scrollbars=1,status=0');
}

//sfHover couresty of http://www.htmldog.com (http://www.htmldog.com/articles/suckerfish/dropdowns/)
/*sfHover = function() {
	var sfEls = d.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/

if(window.attachEvent){
  window.attachEvent("onload", startUp);
}


function startUp(){
  ////replaceActiveX();
  
  if(d.getElementById("standard_login")){
	bodyOnLoad();
  }
}


function updateName(myName){
  if(myName){
    d.getElementById('staff_name').innerHTML=myName;
  }else{
	d.getElementById('staff_name').innerHTML="Click a photo below to view details";
  }
}

function URLencode(sStr) {
  return escape(sStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
}

function fileDownload(filePath){
  filePath = URLencode(filePath);
  var fileDownloader=window.open('http://www.mcleanbible.org/file_download_launch.asp?filePath=' + filePath,'fileDialog','width=400,height=300,toolbar=false,resizable=false,menubar=false,scrollbars=false,status=false');
}	

function popEmailWindow(thisHREF,title) {
                window.open('/emailThisPage.asp?href=' + thisHREF + '&title=' + title, '_blank', 'width=450, height=450, scrollbars=no, menubar=no');
}

