// Display the Phoenix Temple calendar

// Find the location of this document
if(typeof(loc)=="undefined"||loc==""){

	var loc="";

	if(document.body&&document.body.innerHTML){

		var tt=document.body.innerHTML;
		var ml=tt.match(/["']([^'"]*)navmenu.js["']/i);
		if(ml && ml.length > 1) loc=ml[1];
	}
}

var popupCal = null;
var popupCalLogin = null;
var popupFlier = null;
var popupMap = null;

// Pop up a window with the current month
function ShowCalendar() {
  if (window.screen) {

  var w = 700;
  var h = 300;
  writew=w-238;
  writeh=h-50;

  var chasm = screen.availWidth;
  var mount = screen.availHeight;

  popupCal = window.open('','popupCal','width=' + (screen.availWidth - 10) + ',height=' + (screen.availHeight - 30) + ',left=' + 0 + ',top=' + 0 + ', scrollbars=yes');
  // popupCal = window.open('','popupCal','width=' + (chasm - 60) + ',height=' + (mount - 60) + ',left=' + 30 + ',top=' + 0 + ', scrollbars=yes');
	}

  popupCal.location.href = loc+"../../"+"calendar/calendar.php";
}

// Pop up a window with the volunteer database
function ShowFlier(FLIER_FILE,w,h) {
  if (window.screen) {

	  // var w = 640;
	  // var h = 828;

  popupFlier = window.open('','popupFlier','width=' + (w + 40) + ',height=' + (h + 40) + ',left=' + (screen.availWidth - (w + 40))/2 + ',top=' + (screen.availHeight - (h + 40))/2 + ', scrollbars=yes');
	}

  popupFlier.location.href = FLIER_FILE;
}

// Pop up a window with the interactive map
function ShowMap(MAP_FILE) {
  if (window.screen) {

	  var w = 700;
	  var h = 300;
	  writew=w-238;
	  writeh=h-50;

	  var chasm = screen.availWidth;
	  var mount = screen.availHeight;

	  popupMap = window.open('','popupMap','width=' + (screen.availWidth - 200) + ',height=' + (screen.availHeight - 30) + ',left=' + 0 + ',top=' + 0 + ', scrollbars=yes');
  }

  popupMap.location.href = MAP_FILE;
}


// Pop up a login window for the interactive calendar
function loginCalendar() {
  if (window.screen) {

  var w = 425;
  var h = 180;

  var chasm = screen.availWidth;
  var mount = screen.availHeight;

  //popupCalLogin = window.open('','popupCalLogin','width=' + (screen.availWidth - 200) + ',height=' + (screen.availHeight - 30) + ',left=' + 0 + ',top=' + 0 + ', scrollbars=yes');
  popupCalLogin = window.open('','popupCalLogin','width=' + w + ',height=' + h + ',left=' + (chasm - w)/2 + ',top=' + (mount - h)/2 + ', scrollbars=no');
	}

  // popupCalLogin.location.href = loc+"../../db";
  popupCalLogin.location.href = "/calendar/calendar.php?display=admin&task=login";
}

function blowOut() {
  //if (popupCal != null && popupCal.open) popupCal.close();
  //if (popupCalLogin != null && popupCalLogin.open) popupCalLogin.close();
  //if (popupFlier != null && popupFlier.open) popupFlier.close();
  //if (popupMap != null && popupMap.open) popupMap.close();
}

window.onfocus=blowOut;

// Close the popup and redirect
function cc_close_relocate( topage ) {
	self.close();
	window.opener.location.href=topage;
}


// Pop up a window with the flash window
function getflash(FLASH) {
  if (window.screen) {

	  var w = 800;
	  var h = 500;

	  popupFlash = window.open('','popupFlash','width=' + w + ',height=' + h + ',left=' + 0 + ',top=' + 0 + ', scrollbars=yes');
  }

  popupFlash.location.href = FLASH;
}
