
function disableDailyEvents() {
  if (page == 'dailyEventsWeek') {
    document.getElementById("changeDaySelect").disabled=true;
    document.getElementById("changeMonthSelect").disabled=true;
  } else  if (page == 'dailyEventsDay') {
    document.getElementById("changeDaySelect").disabled=true;
    document.getElementById("changeMonthSelect").disabled=true;
  } else  if (page == 'dailyEventsMonth') {
    document.getElementById("changeMonthSelect").disabled=true;
  }
}

/**
 * Opens new window for Answers link
 * identical to openFootnote except it does not have the onblur close
 */
function openAnswer( footnoteId, title) {
  var htmlOpen = '<html><head><title>'+title+'</title><link href="/ldsorg/lds_css/footnote.css" rel="stylesheet" type="text/css"/><script src="/ldsorg/lds_script/content.js" type="text/javascript"></script><script src="/ldsorg/lds_script/global.js" type="text/javascript"></script></head>';
  var header = '<div id="header"><div>'+title+'</div><div id="close"><a href="javascript:window.close()">Close</a></div></div>';
  var theContent = document.getElementById(footnoteId).innerHTML;

  var content = '<div id="content">'+theContent+'</div>';
  var htmlClose = "</body></html>";
  var lengthOfContent = theContent.length/40; // used to determine length of popup content

var replacestr = '\/\/';
var newContent = content.replace(/document.write/g, replacestr);

  height = 100;
  if (lengthOfContent>3) {
    height = height+(lengthOfContent-3)*15;  // adds height to adjust for length of popup content
  }

  width = 300;
  // centers popup on the page
  topOffset = ( screen.availHeight - height ) / 2;
  leftOffset = ( screen.availWidth - width ) / 2 ;

  // opens popup window for glossary and footnote items
  var footnoteWin = window.open('', "footnoteWindow","menubar=no,scrollbars=yes,buttonbar=no,toolbar=no,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
  footnoteWin.document.write(htmlOpen + header + newContent + htmlClose);
  footnoteWin.document.close();
}

/**
 * Opens new window for footnote
 */
function openFootnote( footnoteId, title) {
  var htmlOpen = '<html><head><title>'+title+'</title><link href="/ldsorg/lds_css/footnote.css" rel="stylesheet" type="text/css"/><script src="/ldsorg/lds_script/content.js" type="text/javascript"></script><script src="/ldsorg/lds_script/global.js" type="text/javascript"></script></head><body onblur="javascript:window.close()">';
  var header = '<div id="header"><div>'+title+'</div><div id="close"><a href="javascript:window.close()">Close</a></div></div>';
  var theContent = document.getElementById(footnoteId).innerHTML;

  var content = '<div id="content">'+theContent+'</div>';
  var htmlClose = "</body></html>";
  var lengthOfContent = theContent.length/40; // used to determine length of popup content

var replacestr = '\/\/';
var newContent = content.replace(/document.write/g, replacestr);

  height = 100;
  if (lengthOfContent>3) {
    height = height+(lengthOfContent-3)*15;  // adds height to adjust for length of popup content
  }

  width = 300;
  // centers popup on the page
  topOffset = ( screen.availHeight - height ) / 2;
  leftOffset = ( screen.availWidth - width ) / 2 ;

  // opens popup window for glossary and footnote items
  var footnoteWin = window.open('', "footnoteWindow","menubar=no,scrollbars=yes,buttonbar=no,toolbar=no,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
  footnoteWin.document.write(htmlOpen + header + newContent + htmlClose);
  footnoteWin.document.close();
}

/**
 * Opens new window for image
 */
function openImage( path, altText, width, height, printText, closeText, copyright ) {
  var title = altText;
  var htmlOpen = '<html><head><title>'+title+'</title><link href="/ldsorg/lds_css/footnote.css" rel="stylesheet" type="text/css"/></head><body>';
  var header = '<div id="header" class="noPrint"><div id="close" class="noPrint"><a href="javascript:window.print()">'+printText+'</a>&nbsp;|&nbsp;<a href="javascript:window.close()">'+closeText+'</a></div></div>';
  
  var image = '<img src="'+path+'" alt="'+altText+'" align="center">';
	var copyright = '<p style="align:center">&#169;&nbsp;' + copyright + '</p>';
  var htmlClose = "</body></html>";
  
  height = height/1 + 15;
	width = width/1 + 15;

  // centers popup on the page
  topOffset = ( screen.availHeight - height ) / 2;
  leftOffset = ( screen.availWidth - width ) / 2 ;
	//alert(screen.topOffset);
	//alert(height);
  // opens popup window for image
  if(window.parent.name == 'footnoteWindow') {
	  var footnoteWin = window.open('', "imageWindow","menubar=no,scrollbars=yes,buttonbar=no,toolbar=no,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
	  footnoteWin.document.write(htmlOpen + header +  image + copyright + htmlClose);
	  footnoteWin.document.close();
  } else {
	  var footnoteWin = window.open('', "footnoteWindow","menubar=no,scrollbars=yes,buttonbar=no,toolbar=no,height="+height+",width="+width+",top="+topOffset+",left="+leftOffset+",resizable=yes");
	  footnoteWin.document.write(htmlOpen + header +  image + copyright + htmlClose);
	  footnoteWin.document.close();
  }
}

function newWindow(theURL) {
var portionFloat = .6;
var features='menubar=yes,scrollbars=yes,buttonbar=yes,status=yes,toolbar=yes,resizable=yes,location=yes,';

winName = 'contentWindow';
windowCoord = setWindowValues();

var windowWidth = windowCoord.shift();
var windowHeight = windowCoord.shift();
var screenWidth = windowCoord.shift();
var screenHeight = windowCoord.shift();
var calcTop = windowCoord.shift();
var calcLeft = windowCoord.shift();

newWidth = parseInt(windowWidth * portionFloat);
newHeight = parseInt(windowHeight * portionFloat);

newXOffset = parseInt((windowWidth - newWidth) * .5) + calcLeft;
newYOffset = parseInt((windowHeight - newHeight) * .5) + calcTop;

if (navigator.appName == 'Microsoft Internet Explorer'){
	offsetString = ',top=' + newYOffset + ', left=' + newXOffset;
	}
	else {
	offsetString = ',screenX=' + newYOffset + ', screenY=' + newXOffset;
	}

features = features + 'width=' + newWidth + ',height=' + newHeight + offsetString;

windowName = self.open(theURL,winName,features);
}

//Popup Window functions
function setWindowValues(){
 
	windowWidth = getWindowWidth(self); // or you could just apply some value here
  windowHeight = getWindowHeight(self); // or you could just apply some value here
	screenWidth = screen.availWidth ? screen.availWidth : screen.width;
	screenHeight = screen.availHeight ? screen.availHeight : screen.height;
	
	calcTop = window.screenY ? window.screenY : self.screenTop;
	calcLeft = window.screenX ? window.screenX : self.screenLeft;
	
	return (windowCoord = new Array(windowWidth,windowHeight,screenWidth,screenHeight,calcTop,calcLeft));
}
function getWindowWidth (windowObject) {
		var windowWidth = 0

		if (windowObject.innerWidth)
		{
			windowWidth = windowObject.innerWidth;
		}
		else if (windowObject.document.documentElement && windowObject.document.documentElement.clientWidth)
		{
			windowWidth = windowObject.document.documentElement.clientWidth;
		}
		else if (windowObject.document.body)
		{
			windowWidth = windowObject.document.body.clientWidth;
		}
		if (windowWidth < 500){
			windowWidth = 500;
			}
		return windowWidth;
	}

	function getWindowHeight (windowObject) {
		
		if (windowObject.innerHeight)
		{
			windowHeight = windowObject.innerHeight;
		}
		else if (windowObject.document.documentElement && windowObject.document.documentElement.clientHeight)
		{
			windowHeight = windowObject.document.documentElement.clientHeight;
		}
		else if (windowObject.document.body)
		{
			windowHeight = windowObject.document.body.clientHeight;
		}
		if (windowHeight < 325){
			windowHeight = 325;
			}
		return windowHeight;
	}
	//END Popup Window Functions
