addLoadListener(function()
{
	if (location.search.indexOf('posid=') != -1) {
	 bObj = document.getElementsByTagName('body')[0];
	 
	 addDiv = document.createElement('div');
	 addDiv.setAttribute('id','print');
	 bObj.insertBefore(addDiv, bObj.firstChild);
	 
	 lnid = location.search.substr(7);

	 links = document.getElementById('entry_header').getElementsByTagName('a');
	 links[1].onclick = function() {printStory(this);return false;};
	 
	 darkDiv = document.createElement('div');
	 darkDiv.setAttribute('id','page_screen');
	 bObj.insertBefore(darkDiv, bObj.nextSibling);
	
	 var pageScreen = document.getElementById('page_screen');

	 if (typeof pageScreen.style.opacity != 'undefined') {
	  type = 'w3c';
	 } else {
	  type = 'ie';
	 }

	 bigPicDiv = document.createElement('div');
	 bigPicDiv.setAttribute('id','bigPic_container');
	 bObj.insertBefore(bigPicDiv, bObj.nextSibling);
	 html = '<div id="imgWrap"><img src="images/spacer.gif" alt="Big Picture" name="bigPic" id="bigPic" width="0" height="0" onclick="hideBig()" /></div>';
	 html += '<div id="bigPic_text"></div>';
	 document.getElementById('bigPic_container').innerHTML = html;

	 closeDivDiv = document.createElement('div');
	 closeDivDiv.setAttribute('id','closeDiv');
	 bObj.insertBefore(closeDivDiv, bObj.nextSibling);
	 document.getElementById('closeDiv').innerHTML = '<a href="javascript:;" onclick="lightenPage();aniDiv(\'hide\')">Close</a>';

	 closeDivObj = document.getElementById('closeDiv');
	 closeDivObj.style.top = (closeDivObj.offsetHeight * -1) + 'px';
	 closeDivObj.style.visibility = 'visible';
	
	 loadingDiv = document.createElement('div');
	 loadingDiv.setAttribute('id','loadingPic');
	 bObj.insertBefore(loadingDiv, bObj.nextSibling);
	 document.getElementById('loadingPic').innerHTML = 'Loading...';
	
	 newDiv = document.createElement('div');
	 newDiv.setAttribute('id','photo_balloon');
	 bObj.insertBefore(newDiv, bObj.nextSibling);
	 document.getElementById('photo_balloon').innerHTML = '<div id="balloon_top"></div><div id="balloon_middle"><div id="balloon_middle_text"></div></div><div id="balloon_bottom"></div>'
	
	 preloading("photo_balloon_top.png","photo_balloon_middle.png","photo_balloon_bottom.png")
	}
});

var type;

var myimages = [];
function preloading() {
for (x=0; x<preloading.arguments.length; x++){
myimages[x] = new Image();
myimages[x].src = "images/world_missions/past_outreaches/"+preloading.arguments[x];
}
}

function printStory(obj) {
tour = document.getElementsByTagName('h2')[0].innerHTML;
storyTitle = document.getElementsByTagName('h3')[0].innerHTML;
textInfo = document.getElementById('entry_text').innerHTML;

printText = '<h1>Full Sail Ministries</h1><h2>Using the Arts to Communicate God\'s Heart</h2>';
printText += '<h3 class="print_sub_header">'+tour+'</h3>';
printText += '<strong>'+storyTitle+'</strong><br /><br />';
printText += textInfo+'<br />';
printText += '<div id="print_footer">Full Sail Ministries &#8226; 130 N. Kelsey Street, Suite C &#8226; Visalia, CA &#8226; 93291 &#8226; (559) 651-1233<br />www.FullSail.org</div>';

document.getElementById('print').innerHTML = printText;
window.print();
}

var flag = false;

function hoverDiv(option, linkObj) {
obj = document.getElementById('photo_balloon');

if (option == 'hide') {
 obj.style.visibility = 'hidden';
 obj.style.display = 'none';
 document.getElementById('balloon_middle_text').innerHTML = '';
 flag = false;
} else {
 if (!flag) {
  document.getElementById('balloon_middle_text').innerHTML = linkObj.getElementsByTagName('img')[0].getAttribute('alt');
  obj.style.display = 'block';
  balloonHeight = obj.offsetHeight;
  startY = findPosY(document.getElementById('dest_photos'));
  startX = findPosX(linkObj);
  obj.style.left = startX - 158 + 'px';
//  obj.style.top = startY + 15 - balloonHeight + 'px';
  obj.style.top = startY + 54 + 'px';
  obj.style.visibility = 'visible';
  flag = true;
 }
}
}

function setFade(obj,value) {
if (type == 'ie') {
 obj.style.filter = 'alpha(opacity='+value * 100+')';
} else {
 obj.style.opacity = (value == 1 ? 0.9999999 : value);
}
}

/*===================================================================================*/

photoInfo = [];

function aniDiv(linkObj,photoNum) {
divObj = document.getElementById('bigPic_container');
bigPicObj = document.getElementById('bigPic');

if (linkObj == 'hide') {
divObj.style.visibility = 'hidden';
bigPicObj.src = 'images/spacer.gif';
divObj.style.overflow = 'auto';
divObj.style.display = 'none';
divCloseObj = document.getElementById('closeDiv');
divCloseObj.style.top = (divCloseObj.offsetHeight * -1) + 'px';
return;
}

winSize = windowSize();
screenWidth = winSize[0];
screenHeight = winSize[1];
scrollPosTop = f_scrollTop();
 
startWidth = 0;
startHeight = 0;

divObj.style.display = 'block';

endWidth = Number(photoInfo[photoNum][2]) + 2; // width of picture + borders of containers
document.getElementById('bigPic_text').innerHTML = photoInfo[photoNum][1];
divObj.style.width = endWidth + 'px';
textHeight = document.getElementById('bigPic_text').offsetHeight + 2; // height of text + borders of container
endHeight = Number(photoInfo[photoNum][3]) + textHeight; // height of picture + text + borders of container

divObj.style.width = startWidth + 'px';
divObj.style.height = startHeight + 'px';
startY = findPosY(document.getElementById('dest_photos'));
startX = findPosX(linkObj);
divObj.style.left = startX + 'px';
divObj.style.top = startY + 'px';
divObj.style.overflow = 'hidden';

divObjOpStart = 0;
divObjOpEnd = 100;
setFade(divObj,divObjOpStart*.01);

endX = parseInt((screenWidth - endWidth) / 2);
endY = parseInt((screenHeight - endHeight) / 2) + scrollPosTop;

divObj.style.visibility = 'visible';

intervals = 2;
speed = 2; // Larger number means slower, but smoother

divObj.posChangeInt = window.setInterval(
  function() {
  startWidth = (endWidth > startWidth) ? startWidth + Math.ceil((endWidth - startWidth) / speed):startWidth - Math.ceil((startWidth - endWidth) / speed);
  startHeight = (endHeight > startHeight) ? startHeight + Math.ceil((endHeight - startHeight) / speed):startHeight - Math.ceil((startHeight - endHeight) / speed);
  startX = (endX > startX) ? startX + Math.ceil((endX - startX) / speed):startX - Math.ceil((startX - endX) / speed);
  startY = (endY > startY) ? startY + Math.ceil((endY - startY) / speed):startY - Math.ceil((startY - endY) / speed);
  divObjOpStart += Math.ceil((divObjOpEnd - divObjOpStart) / speed);
  
  if (startWidth != endWidth) {
   divObj.style.width = startWidth + 'px';
   divObj.style.height = startHeight + 'px';
   divObj.style.left = startX + 'px';
   divObj.style.top = startY + 'px';
   setFade(divObj,divObjOpStart*.01);
   
   bigPicObj.width = startWidth - 2;
   bigPicObj.height = (startHeight - textHeight);
  } else {
   window.clearInterval(divObj.posChangeInt);
   divObj.style.width = endWidth + 'px';
   divObj.style.height = endHeight + 'px';
   divObj.style.left = endX + 'px';
   divObj.style.top = endY + 'px';
   setFade(divObj, 1);

   divObjTop = divObj.offsetTop;
   divObjRight = divObj.offsetLeft + divObj.offsetWidth;
   closeDivOp(divObjRight,divObjTop);

   picTemp = new Image(); // Reset picTemp so that it "picTemp.complete" will give a reading on the newly loading picture.
   picTemp.src = 'images/world_missions/past_outreaches/poid'+poid+'/'+photoInfo[photoNum][0];
   
   imgWrapObj = document.getElementById('imgWrap');
   loadingPicObj = document.getElementById('loadingPic');
   imgWrapWidth = imgWrapObj.offsetWidth;
   imgWrapHeight = imgWrapObj.offsetHeight;
   imgWrapLeft = findPosX(imgWrapObj);
   imgWrapTop = findPosY(imgWrapObj);
   loadingPicObj.style.left = parseInt((imgWrapWidth - loadingPicObj.offsetWidth) / 2) + imgWrapLeft + 'px';
   loadingPicObj.style.top = parseInt((imgWrapHeight - loadingPicObj.offsetHeight) / 2) + imgWrapTop + 'px';
   if (picTemp.complete) { // Check to see if the image is already in the browser cache.
    showBigFinish(photoNum);
   } else { // Image is not in the browser cache and is in the process of loading. Call function when it has completed loading.
    picTemp.onload = function() { showBigFinish(photoNum); };
   }
  }
  }
  , intervals)
}

function showBigFinish(photoNum) {
document.getElementById('loadingPic').style.left = '-100px';
bigPicObj = document.getElementById('bigPic');
bigPicObj.src = 'images/world_missions/past_outreaches/poid'+poid+'/'+photoInfo[photoNum][0];
bigPicObj.width = photoInfo[photoNum][2];
bigPicObj.height = photoInfo[photoNum][3];

BPobj = document.getElementById('bigPic');
//steps = time * fps;
//dofade(steps, obj, 0, true, type); // Fade in

setFade(BPobj,0);

intervals = 2;
speed = 4; // Larger number means slower, but smoother
bpOpStart = 0;
bpOpEnd = 100;

BPobj.bpChangeOpInt = window.setInterval(
  function() {
  bpOpStart += Math.ceil((bpOpEnd - bpOpStart) / speed);
  
  if (bpOpStart != bpOpEnd) {
   setFade(BPobj,bpOpStart*.01);
  } else {
   window.clearInterval(BPobj.bpChangeOpInt);
   setFade(BPobj, 1);
  }
  }
  , intervals)
}

function closeDivOp(divLeft,divTop) {
divCloseObj = document.getElementById('closeDiv');

topOffset = 17;
leftOffset = 13

/*divObjOpStart = 0;
divObjOpEnd = 100;
setFade(divCloseObj,divObjOpStart*.01);*/

divCloseObj.style.top = divObjTop - divCloseObj.offsetHeight + topOffset + 'px';
divCloseObj.style.left = divObjRight - divCloseObj.offsetWidth + leftOffset + 'px';

//intervals = 2;
//speed = 5; // Larger number means slower, but smoother

/*divCloseObj.closeChangeOpInt = window.setInterval(
  function() {
  divObjOpStart += Math.ceil((divObjOpEnd - divObjOpStart) / speed);
  
  if (divObjOpStart != divObjOpEnd) {
   setFade(divCloseObj,divObjOpStart*.01);
  } else {
   window.clearInterval(divCloseObj.closeChangeOpInt);
   setFade(divCloseObj, 1);
  }
  }
  , intervals)*/
}

/*------------------------
Generic functions
------------------------*/

function darkenPage() {
pageScreen = document.getElementById('page_screen');
if (typeof( window.innerWidth ) == 'number') {
 //Non-IE
 myHeight = window.innerHeight;
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
 //IE 6+ in 'standards compliant mode'
 myHeight = document.documentElement.clientHeight;
}

scrollH = document.body.parentNode.scrollHeight

pageScreen.style.height = (myHeight > scrollH) ? myHeight + 'px':scrollH + 'px';
pageScreen.style.display = 'block';
}


function lightenPage() {
pageScreen = document.getElementById('page_screen');
pageScreen.style.display = 'none';
}

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
//  window.alert( 'Width = ' + myWidth );
//  window.alert( 'Height = ' + myHeight );
  return [myWidth,myHeight];

}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
