addLoadListener(function()
{
	bObj = document.getElementsByTagName('body')[0];

	popDiv = document.createElement('div');
	popDiv.setAttribute('id','dest_div');
	bObj.insertBefore(popDiv, bObj.nextSibling);
	
	coorX = findPosX(document.getElementById('map'));
	coorY = findPosY(document.getElementById('map'));
	document.getElementById('dest_div').style.left = coorX + 42 + 'px';
	document.getElementById('dest_div').style.top = coorY + 52 + 'px';
	
	closeRedButton = (isIE6) ?'<img src="images/spacer.png" style="width: 54px; height: 17px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/buttons/button_close_red_slammed.png\', sizingMethod=scale);" />':'<img src="images/buttons/button_close_red_slammed.png" alt="Close Destination" width="54" height="17">';
	
	html = '<a id="dest_close" href="javascript:;" onclick="popupDest(\'dest_div\',\'hide\')">'+closeRedButton+'</a>';
	html += '<div id="dest_top"></div>';
	html += '<div id="dest_middle">';
	html += '<div id="dest_middle_text">';
	html += '<div id="dest_top_content">';
	html += '<img id="dest_map" src="images/world_missions/newfoundland_slammed.png" alt="Newfoundland, Canada" width="200" height="200">';
	html += '<div id="top_content_text">';
	html += '<h2>Newfoundland</h2>';
	html += '<div id="country_stats"><div id="country_stats_top"><h3>Country Statistics</h3><div id="country_stats_content"></div><div><a class="stats_icon" href="javascript:;" onclick="showStats()">More Stats</a></div></div><div id="country_stats_bottom"></div></div>';
	html += '<h3>Tour Dates: <span></span></h3>';
	html += '<div id="ul_wrap"><ul><li>Current Date/Time:<span id="dest_date_time"></span></li>';
	html += '<li id="tour_schedule"></li>';
	html += '<li id="today">Where Are We Today? <span></span></li>';
	html += '<li>Prayer Requests/Tour Needs <a style="position: relative" href="javascript:;" onclick="showNeeds()">more...</a></li>';
	html += '<li>Information Links:';
	html += '<ul id="info_links"></ul></div>';
	html += '</li></ul>';
	html += '</div>';
	html += '</div>';
	html += '<div id="dest_bottom_content">';
//	html += '<div id="country_stats"><h3>Country Statistics</h3><div id="country_stats_content"></div></div>';
	html += '<div id="testimony"><h3></h3><div id="testimony_content"></div><div style="text-align: center"><a class="testimony_icon" href="javascript:;" onclick="showTestimony()">All thoughts...</a></div></div>';
	html += '<div id="team_members"><h3>Team Members</h3><div id="team_members_content"></div><div style="text-align: center"><a class="team_members_icon" href="javascript:;" onclick="showMembers()">Show All Team Members</a></div></div>';
	html += '</div>';
	html += '<div id="dest_photos_wrap"><div id="dest_photos_text"></div><div id="dest_photos"></div></div>';
	html += '</div>';
	html += '</div>';
	html += '<div id="dest_bottom"></div>';

	document.getElementById('dest_div').innerHTML = html;

/*	testDiv = document.createElement('div');
	testDiv.setAttribute('id','testimony_popup');
	bObj.insertBefore(testDiv, bObj.nextSibling);
//	document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
	document.getElementById('testimony_popup').style.top = coorY + 52 + 25 + 'px';
	document.getElementById('testimony_popup').innerHTML = '<h3></h3><div></div><a id="testimony_close" href="javascript:;" onclick="showTestimony()">'+closeRedButton+'</a>';*/
	
	testDiv = document.createElement('div');
	testDiv.setAttribute('id','testimony_popup');
	bObj.insertBefore(testDiv, bObj.nextSibling);
//	document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
	document.getElementById('testimony_popup').style.top = coorY + 52 + 25 + 'px';
	document.getElementById('testimony_popup').innerHTML = '<div class="wm_popup_top wm_blue_top"></div><div class="wm_popup_left wm_blue_left"></div><div class="wm_popup_middle wm_blue_middle"><h3></h3><div id="testimony_popup_content"></div><a id="testimony_close" href="javascript:;" onclick="showTestimony()">'+closeRedButton+'</a></div><div class="wm_popup_right wm_blue_right"></div><div class="wm_popup_bottom wm_blue_bottom"></div>';

/*	teamDiv = document.createElement('div');
	teamDiv.setAttribute('id','team_members_popup');
	bObj.insertBefore(teamDiv, bObj.nextSibling);
//	document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
	document.getElementById('team_members_popup').style.top = coorY + 52 + 25 + 'px';
	document.getElementById('team_members_popup').innerHTML = '<h3></h3><div id="team_row"></div><a id="team_members_close" href="javascript:;" onclick="showMembers()">'+closeRedButton+'</a>';*/
	
	teamDiv = document.createElement('div');
	teamDiv.setAttribute('id','team_members_popup');
	bObj.insertBefore(teamDiv, bObj.nextSibling);
//	document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
	document.getElementById('team_members_popup').style.top = coorY + 52 + 25 + 'px';
	document.getElementById('team_members_popup').innerHTML = '<div class="wm_popup_top wm_red_top"></div><div class="wm_popup_left wm_red_left"></div><div class="wm_popup_middle wm_red_middle"><h3></h3><div id="team_row"></div><a id="team_members_close" href="javascript:;" onclick="showMembers()">'+closeRedButton+'</a></div><div class="wm_popup_right wm_red_right"></div><div class="wm_popup_bottom wm_red_bottom"></div>';
	
/*	needsDiv = document.createElement('div');
	needsDiv.setAttribute('id','needs_popup');
	bObj.insertBefore(needsDiv, bObj.nextSibling);
//	document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
	document.getElementById('needs_popup').style.top = coorY + 52 + 25 + 'px';
	document.getElementById('needs_popup').innerHTML = '<h3>Prayer Requests/Tour Needs</h3><div></div><a id="needs_close" href="javascript:;" onclick="showNeeds()">'+closeRedButton+'</a>';*/

	needsDiv = document.createElement('div');
	needsDiv.setAttribute('id','needs_popup');
	bObj.insertBefore(needsDiv, bObj.nextSibling);
//	document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
	document.getElementById('needs_popup').style.top = coorY + 52 + 25 + 'px';
	document.getElementById('needs_popup').innerHTML = '<div class="wm_popup_top wm_green_top"></div><div class="wm_popup_left wm_green_left"></div><div class="wm_popup_middle wm_green_middle"><h3>Prayer Requests/Tour Needs</h3><div id="needs_popup_content"></div><a id="needs_close" href="javascript:;" onclick="showNeeds()">'+closeRedButton+'</a></div><div class="wm_popup_right wm_green_right"></div><div class="wm_popup_bottom wm_green_bottom"></div>';
	
	ccNote = document.createElement('div');
	ccNote.setAttribute('id','cc_note');
	bObj.insertBefore(ccNote, bObj.nextSibling);
		
	document.getElementById('cc_note').innerHTML = '<h3>Note: You are about to leave FullSail.org</h3><p>A new window will open and you will be taken to the requested web site. If you do not want to see this message again, please check the box below:<p><div class="not_again"><input type="checkbox" id="notAgainCheck" value="" /> Please do not show this message again.</div><div style="text-align: center"><input type="image" src="images/buttons/button_continue_green.gif" value="continue" onclick="leaveSite(\'continue\')" /></div>';
	
	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...';
	
	links = document.getElementById('map').getElementsByTagName('a');
	for (i=0; i<links.length; i++) {
	 wmid = links[i].href.match(/\d+$/);
	 links[i].onclick = new Function("popupDest('dest_div','show','"+wmid+"');return false;");
	}
	
	for (i=0; i<pin.length; i++) {
	 pObj = document.getElementById(pin[i][0]+'_pin');
	 pObj.style.left = pin[i][1] + 'px';

	 newDiv = document.createElement('div');
	 newDiv.setAttribute('id','shadow'+i);
	 newDiv.className = 'shadow';
	 pObj.parentNode.insertBefore(newDiv, pObj);

	 pObj.style.visibility = 'visible';
	 pinDrop(i);
	}
	
	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>'
	setTimeout('preloading("popup_dest_top_bg_slammed.png","popup_dest_middle_bg_slammed.png","popup_dest_bottom_bg_slammed.png","photo_balloon_top_bg_slammed.png","photo_balloon_middle_bg_slammed.png","photo_balloon_bottom_bg_slammed.png","popup_testimony_bg_slammed.png","popup_team_members_bg_slammed.png","popup_needs_bg_slammed.png","popups/wm_blue_bottom_slammed.png","popups/wm_blue_bottomOP_slammed.png","popups/wm_blue_left_slammed.png","popups/wm_blue_leftOP_slammed.png","popups/wm_blue_middle.jpg","popups/wm_blue_middleOP_slammed.png","popups/wm_blue_right_slammed.png","popups/wm_blue_rightOP_slammed.png","popups/wm_blue_top_slammed.png","popups/wm_blue_topOP_slammed.png","popups/wm_green_bottom_slammed.png","popups/wm_green_bottomOP_slammed.png","popups/wm_green_left_slammed.png","popups/wm_green_leftOP_slammed.png","popups/wm_green_middle.jpg","popups/wm_green_middleOP_slammed.png","popups/wm_green_right_slammed.png","popups/wm_green_rightOP_slammed.png","popups/wm_green_top_slammed.png","popups/wm_green_topOP_slammed.png","popups/wm_red_bottom_slammed.png","popups/wm_red_bottomOP_slammed.png","popups/wm_red_left_slammed.png","popups/wm_red_leftOP_slammed.png","popups/wm_red_middle.jpg","popups/wm_red_middleOP_slammed.png","popups/wm_red_right_slammed.png","popups/wm_red_rightOP_slammed.png","popups/wm_red_top_slammed.png","popups/wm_red_topOP_slammed.png","../icons/icon_less_red.gif","../icons/icon_video.gif")', 1000); // Need the delay so it doesn't slow down the pin drop.
});

isIE6 = /msie|MSIE 6/.test(navigator.userAgent); // Test for IE6;

var type;
var destDirectory;

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

var wmidGlobal;

function popupDest(id,option,wmid) {
wmidGlobal = wmid;
obj = document.getElementById(id);
mapImgTag = document.getElementById('map_links').getElementsByTagName('img');
if (option == 'show') {
 for (i=0; i<mapImgTag.length; i++) {
  mapImgTag[i].style.visibility = 'hidden';
 }
 obj.style.display = 'block';
 obj.style.visibility = 'visible';
 getInfo();
} else {
 for (i=0; i<mapImgTag.length; i++) {
  mapImgTag[i].style.visibility = 'visible';
 }
 obj.style.visibility = 'hidden';
 obj.style.display = 'none';
 document.getElementById('dest_map').src = '';
 popText = document.getElementById('top_content_text');
 popText.childNodes[0].innerHTML = '';
 popText.childNodes[2].getElementsByTagName('span')[0].innerHTML = '';
 countryStatsContent = document.getElementById('country_stats_content');
 countryStatsContent.innerHTML = '';
 countryStatsContent.style.height = '116px';
 countryStatsContent.nextSibling.style.visibility = 'hidden';
 countryStatsContent.nextSibling.getElementsByTagName('a')[0].innerHTML = 'More Stats';
 countryStatsContent.nextSibling.getElementsByTagName('a')[0].style.backgroundImage = 'url(images/icons/icon_more_green.gif)';
 statsState = false;
 document.getElementById('testimony').getElementsByTagName('h3')[0].innerHTML = '';
 document.getElementById('testimony_content').innerHTML = '';
 document.getElementById('testimony').lastChild.style.visibility = 'hidden';
 document.getElementById('team_members_content').innerHTML = ''
 document.getElementById('team_members').lastChild.style.visibility = 'hidden';
 document.getElementById('dest_photos').innerHTML = '';
 document.getElementById('dest_photos_text').innerHTML = '';
 document.getElementById('dest_date_time').innerHTML = '';
}
}

var statsExtra;

function getInfo() {
req = createXMLHttpRequest();
if (!req) {
 location.href='world-missions-destination.php?wmid='+wmidGlobal;
} else { 
 url = 'world-missions-process.php?wmid='+wmidGlobal;
 req.open('GET', url, true);
 req.onreadystatechange = handleResponse;
 req.send(null);
 return false;
}
}

function handleResponse() {
  if(req.readyState == 4){
    if (req.status == 200) {
      var response = req.responseText;
      info = response.split(':X:');

      wmid = info[0];
      dest = info[1];
      mapImg = info[2];
      tourDates = (info[3]) ? info[3]:'<span style="color: #b33d1f">(To Be Announced)</span>';
      if (info[4]) {
       scheduleSplit = info[4].split('|');
       schedule = '<a href="world-missions-process.php?f='+scheduleSplit['0']+'">Download Now!</a> (<img width="22" height="12" alt="PDF" src="images/icons/icon_pdf.gif" class="icon"/> '+scheduleSplit[1]+')';
      } else {
       schedule = '<span>Coming Soon...</span>';
      }
      needs = info[5];
      stats = info[6];
      statsExtra = info[7];
      countryTest = info[8];
      teamMembers = info[9];
      destImages = info[10];
      destDirectory = info[11];
      destDateTime = info[12];
      scheduleToday = info[13];
      links = info[14];
      
      teamContentCol1 = '';
      teamContentCol2 = '';
      teamContentPopup = '';
      
      document.getElementById('dest_map').src = 'images/world_missions/'+mapImg;
      popText = document.getElementById('top_content_text');
      popText.childNodes[0].innerHTML = dest;
      popText.childNodes[2].getElementsByTagName('span')[0].innerHTML = tourDates;
	  
	  getInfoDateTime(destDateTime);
	  
	  document.getElementById('tour_schedule').innerHTML = 'Tour Schedule:&nbsp;' + schedule;
	  
	  countryStatsID = document.getElementById('country_stats');
	  countryStatsContent = document.getElementById('country_stats_content');
	  if (stats) {
	   countryStatsContent.innerHTML = stats;
	   countryStatsContent.nextSibling.style.visibility = (statsExtra) ? 'visible':'hidden';
	  } else {
	   countryStatsContent.innerHTML = '<span style="color: #b33d1f">(None at this time. Statistically speaking, there really should be something here.)</span>';
	   countryStatsContent.nextSibling.style.visibility = 'hidden';
	  }
	  
	  testimonyID = document.getElementById('testimony');
	  testimonyContent = document.getElementById('testimony_content');
	  testimonyID.getElementsByTagName('h3')[0].innerHTML = 'Thoughts on '+dest;
	  if (countryTest) {
	   testimonyShort = countryTest.replace(/\r\n?\r\n?/, ' - ');
       testimonyShort = testimonyShort.replace(/<p>/, '');
       testimonyShort = testimonyShort.replace(/<\/p>/, ' ');
	   
	   if (testimonyShort.length > 440) {
 		testimonyShort = testimonyShort.substr(0,440);
		testimonyShort = testimonyShort.substr(0,(testimonyShort.lastIndexOf(' ')));
		testimonyShort += '...';
		testimonyID.lastChild.style.visibility = 'visible';
	   } else {
	    testimonyID.lastChild.style.visibility = 'hidden';
	   }
	   
	   testimonyContent.innerHTML = testimonyShort;
	  
	   document.getElementById('testimony_popup').getElementsByTagName('h3')[0].innerHTML = 'Thoughts on '+dest;
	   document.getElementById('testimony_popup_content').innerHTML = countryTest;
	  } else {
	   testimonyContent.innerHTML = '<span style="color: #b33d1f">(None at this time. Thoughtless of us, we know. We promise to do better.)</span>';
	   testimonyID.lastChild.style.visibility = 'hidden';
	  }
	  
	  if (needs) {
	   document.getElementById('needs_popup_content').innerHTML = needs;
	  } else {
	   document.getElementById('needs_popup_content').innerHTML = 'Please pray for this outreach. We will have more prayer requests and needs as time goes on.';
	  }
	  
	  if (scheduleToday) {
	   todaySplit = scheduleToday.split('|');
	   document.getElementById('today').getElementsByTagName('span')[0].innerHTML = (todaySplit[1]) ? todaySplit[0]+', '+todaySplit[1]:todaySplit[0];
	  } else {
	   document.getElementById('today').getElementsByTagName('span')[0].innerHTML = 'N/A';
	  }
	  
	  if (links) {
	   linksSplit = links.split('|');
	   linksLI = '';
	   for(i=0; i<linksSplit.length; i++) {
	    nameURL = linksSplit[i].split('~');
	    linksLI += '<li><a style="position: relative" href="javascript:;" onclick="leaveSite(\'http://'+nameURL[1]+'\')">'+nameURL[0]+'</a></li>';
	   }
	  } else {
	   linksLI = '<span style="color: #B33D1F">None at this time</span>';
	  }
	  document.getElementById('info_links').innerHTML = linksLI;
	  
	  teamMembersID = document.getElementById('team_members');
	  teamMembersContent = document.getElementById('team_members_content');
	  if (teamMembers) {
	  allMembers = teamMembers.split('|');
	  membersDisplayTotal = (allMembers.length < 6) ? allMembers.length:6;
	  
	   for (i=0; i<membersDisplayTotal; i++) {
	    memberInfo = allMembers[i].split('~');
//	    memberImg = (memberInfo[3]) ? memberInfo[3].substr(0,memberInfo[3].length-4):'no_photo';
	    memberImg = (memberInfo[3]) ? 'wm_'+memberInfo[3]:'no_photo';
	    if (i<3) {
	     marginbot = (i==2) ? ' style="margin-bottom: 0"':'';
	     teamContentCol1 += '<div class="team_member_small"'+marginbot+'><img src="images/team_members/'+memberImg+'_sm.gif" alt="'+memberInfo[1]+'" width="45" height="50">'+memberInfo[1]+'<br /><span>'+memberInfo[2]+'</span><br /><a href="team-members.php?tmid='+memberInfo[0]+'&amp;wmid='+wmid+'&ref=wm">More Info...</a></div>';
	    } else {
	     marginbot = (i==5) ? ' style="margin-bottom: 0"':'';
	     teamContentCol2 += '<div class="team_member_small"'+marginbot+'><img src="images/team_members/'+memberImg+'_sm.gif" alt="'+memberInfo[1]+'" width="45" height="50">'+memberInfo[1]+'<br /><span>'+memberInfo[2]+'</span><br /><a href="team-members.php?tmid='+memberInfo[0]+'&amp;wmid='+wmid+'&ref=wm">More Info...</a></div>';
	    }
	   }
	  
	   teamMembersContent.innerHTML = '<div id="col1">'+teamContentCol1+'</div><div id="col2">'+teamContentCol2+'</div>';
	   if (membersDisplayTotal > 5) {
	    teamMembersID.lastChild.style.visibility = 'visible';
       } else {
        teamMembersID.lastChild.style.visibility = 'hidden';
       }
       
       for (i=0; i<allMembers.length; i++) {
	    memberInfo = allMembers[i].split('~');
	    memberImg = (memberInfo[3]) ? 'wm_'+memberInfo[3]:'no_photo';
	    teamContentPopup += '<div class="team_member_small"><img src="images/team_members/'+memberImg+'_sm.gif" alt="'+memberInfo[1]+'" width="45" height="50">'+memberInfo[1]+'<br /><span>'+memberInfo[2]+'</span><br /><a href="team-members.php?tmid='+memberInfo[0]+'&amp;wmid='+wmid+'&ref=wm">More Info...</a></div>';
	   }
	   
       document.getElementById('team_members_popup').getElementsByTagName('h3')[0].innerHTML = dest + ' Outreach Team Members';
	   document.getElementById('team_row').innerHTML = teamContentPopup;
      } else {
       teamMembersContent.innerHTML = '<span style="color: #b33d1f">(No team member information at this time. Must have left it in my other computer, sorry.)</span>'
       teamMembersID.lastChild.style.visibility = 'hidden';
      }
      
      destPhotos = document.getElementById('dest_photos');
      destPhotosText = document.getElementById('dest_photos_text');
      if (destImages) {
       thumbs = destImages.split('|');
       allThumbs = '';
       photoInfo = [];
      
       for (i=0; i<thumbs.length; i++) {
        imageInfo = thumbs[i].split('~');
        imageThumb = imageInfo[1].substr(0,imageInfo[1].length-4);
        lastImg = (i == 8) ? ' style="margin-right: 0"':'';
        altImg = imageInfo[2].replace(/VIDEO_ICON_/,'<img src=&quot;images/icons/icon_video.gif&quot; width=&quot;31&quot; height=&quot;11&quot; alt=&quot;video&quot; /> ');
        allThumbs += '<div class="thumb_frame"'+lastImg+'><a style="position: relative" href="javascript:;" onclick="darkenPage();aniDiv(this,'+(i+1)+')" onmouseover="hoverDiv(\'show\',this)" onmouseout="hoverDiv(\'hide\',this)"><img src="images/world_missions/'+destDirectory+'/'+imageThumb+'_sm.jpg" height="43" width="43" alt="'+altImg+'" /></a></div>';
        
        imageInfo[2] = imageInfo[2].replace(/VIDEO_ICON_/,''); 
        photoInfo[i+1] = [imageInfo[1],imageInfo[3],imageInfo[4],imageInfo[2]];
       }

       destPhotos.innerHTML = allThumbs;
       destPhotosText.innerHTML = 'Click on an image to see a larger size, or view a video.';
      } else {
       destPhotos.innerHTML = '';
       destPhotosText.innerHTML = '<span style="color: #b33d1f">Sorry, but we don\'t have any photos quite yet.</span>';
      }
    }
  }
}

function getInfoDateTime(dateTimeID) {
req = createXMLHttpRequest();
url = 'world-missions-process.php?date_time_id='+dateTimeID;
req.open('GET', url, true);
req.onreadystatechange = handleResponseDateTime;
req.send(null);
return false;
}

function handleResponseDateTime() {
  if(req.readyState == 4){
    if (req.status == 200) {
      var response = req.responseText;
      document.getElementById('dest_date_time').innerHTML = '&nbsp;'+response;
    }
  }
}

// pin[] = [div id, X, Y] 
pin = [];
pin[0] = ['newfoundland',281,161];
pin[1] = ['thailand',680,305];
pin[2] = ['albania',459,194];
pin[3] = ['haiti',220,265];
pin[4] = ['india',617,270];

var pinObj = [];
var shadowObj = [];
var labelObj = [];
var movePin = [];
var pinRate = [];
var newPinTop = [];
var pinCount = 0;
//var otype;

var pinInc = 15;

function pinDrop(pinNum) {
framePause = true;
pinObj[pinNum] = document.getElementById(pin[pinNum][0]+'_pin');
shadowObj[pinNum] = document.getElementById('shadow'+pinNum);
labelObj[pinNum] = document.getElementById(pin[pinNum][0]+'_label');
//otype = (typeof pinObj[pinNum].filters == 'object') ? 'ie':'';
newPinTop[pinNum] = 0;
pinObj[pinNum].opChangeInt = window.setInterval(
	function () {
		pinRate[pinNum] = Math.ceil((pin[pinNum][2] - newPinTop[pinNum] ) / pinInc);
		newPinTop[pinNum] = pinObj[pinNum].offsetTop + parseInt(pinRate[pinNum]);
		
		if (newPinTop[pinNum] < pin[pinNum][2]) { // Not there yet, keep moving pin.
		 pinObj[pinNum].style.top = newPinTop[pinNum] + 'px';
		 newShadX = getTriSides(pinNum,newPinTop[pinNum]);
		 shadowObj[pinNum].style.top = newPinTop[pinNum] + 'px';
		 shadowObj[pinNum].style.left = newShadX + 'px';
		 
/*		 newOpacity = newPinTop[pinNum] / pin[pinNum][2];
		 newOpacity = newOpacity.toFixed(2);

		 if (otype == 'ie') {
		  shadowObj[pinNum].style.filter = 'alpha(opacity='+parseInt(newOpacity * 100)+')';
		 } else {
		  shadowObj[pinNum].style.opacity = newOpacity;
		 }
*/
		} else {
		 window.clearInterval(pinObj[pinNum].opChangeInt);
		 pinObj[pinNum].style.top = newPinTop[pinNum] + 'px';
		 shadowObj[pinNum].style.top = newPinTop[pinNum] + 'px';
		 shadowObj[pinNum].style.left = pin[pinNum][1] + 'px';
		 
		 labelObj[pinNum].style.top = pin[pinNum][2] - labelObj[pinNum].offsetHeight + 3 + 'px';
		 labelObj[pinNum].style.left = pin[pinNum][1] - parseInt(labelObj[pinNum].offsetWidth / 2) + 4 + 'px';
		 labelObj[pinNum].style.visibility = 'visible';
		 pinCount++;
		 if (pinCount == pin.length) {
		  framePause = false;
		  if (typeof wmidAuto != 'undefined') {
		   popupDest('dest_div','show',wmidAuto);
		  }
		 }
		}
	}
, 2)

}

function getTriSides(pinNum,currTop) { // a equals the distance traveled by the pin: 0 to final Y
a = pin[pinNum][2] - currTop; // distance from current top Y to final Y of pin
an = 30; // 30 degree angle of the shadow

// Find distance between pin starting X and shadow starting X.
deg = Math.tan(an*Math.PI/180);
o = Math.round(deg*a*10000)/10000;
return parseInt(pin[pinNum][1] + o);
}

var popState = false;
function showMembers() {
if (!popState) {
 coorX = findPosX(document.getElementById('map'));
 document.getElementById('team_members_popup').style.left = coorX + 42 + 23 + 'px';
 document.getElementById('dest_close').style.visibility = 'hidden';
} else {
 document.getElementById('team_members_popup').style.left = '-9999px';
 document.getElementById('dest_close').style.visibility = 'visible';
}
popState = (popState) ? false:true;
}

function showTestimony() {
if (!popState) {
 coorX = findPosX(document.getElementById('map'));
 document.getElementById('testimony_popup').style.left = coorX + 42 + 23 + 'px';
 document.getElementById('dest_close').style.visibility = 'hidden';
} else {
 document.getElementById('testimony_popup').style.left = '-9999px';
 document.getElementById('dest_close').style.visibility = 'visible';
}
popState = (popState) ? false:true;
}

function downloadSchedule() {
alert('download schedule');
}

function showToday() {
alert('show today');
}

function showNeeds() {
if (!popState) {
 coorX = findPosX(document.getElementById('map'));
 document.getElementById('needs_popup').style.left = coorX + 42 + 23 + 'px';
 document.getElementById('dest_close').style.visibility = 'hidden';
} else {
 document.getElementById('needs_popup').style.left = '-9999px';
 document.getElementById('dest_close').style.visibility = 'visible';
}
popState = (popState) ? false:true;
}

var statsState = false;
function showStats() {
countryStatsContent = document.getElementById('country_stats_content');
if (!statsState) {
 countryStatsContent.style.overflow = 'hidden';
 statsObj = countryStatsContent.getElementsByTagName('table')[0];
 newDiv = document.createElement('div');
 newDiv.setAttribute('id','statsExtraDiv');

 statsObj.parentNode.insertBefore(newDiv, statsObj.nextSibling); // This adds the new element AFTER the object

 document.getElementById('statsExtraDiv').innerHTML = statsExtra;

 statsExtraHeight = document.getElementById('statsExtraDiv').offsetHeight;

// countryStatsContent.style.height = (statsExtraHeight <= 250) ? countryStatsContent.offsetHeight + statsExtraHeight - 10 + 'px':'240px';

 changeObj = countryStatsContent;
 intervals = 2;
 speed = 4; // Larger number means slower, but smoother
 startPoint = 116;
 endPoint = (statsExtraHeight <= 250) ? countryStatsContent.offsetHeight + statsExtraHeight - 10:countryStatsContent.offsetHeight + 240;

 changeObj.changePos = window.setInterval(
  function() {
  startPoint += Math.ceil((endPoint - startPoint) / speed);
  if (startPoint != endPoint) {
   changeObj.style.height = startPoint + 'px';
  } else {
   window.clearInterval(changeObj.changePos);
   changeObj.style.height = endPoint + 'px';
   countryStatsContent.style.overflow = 'auto';
   countryStatsContent.nextSibling.getElementsByTagName('a')[0].innerHTML = 'Less Stats';
   countryStatsContent.nextSibling.getElementsByTagName('a')[0].style.backgroundImage = 'url(images/icons/icon_less_red.gif)';
  }
  }
 , intervals)
} else {
 countryStatsContent.style.overflow = 'hidden';

 changeObj = countryStatsContent;
 intervals = 2;
 speed = 4; // Larger number means slower, but smoother
 startPoint = countryStatsContent.offsetHeight;
 endPoint = 116;

 changeObj.changePos = window.setInterval(
  function() {
  startPoint += Math.floor((endPoint - startPoint) / speed);
  if (startPoint != endPoint) {
   changeObj.style.height = startPoint + 'px';
  } else {
   window.clearInterval(changeObj.changePos);
   changeObj.style.height = endPoint + 'px';
   countryStatsContent.nextSibling.getElementsByTagName('a')[0].innerHTML = 'More Stats';
   countryStatsContent.nextSibling.getElementsByTagName('a')[0].style.backgroundImage = 'url(images/icons/icon_more_green.gif)';
 
   el = document.getElementById('statsExtraDiv');
   el.parentNode.removeChild(el);

   countryStatsContent.style.overflow = 'auto';
  }
  }
 , intervals)
}

statsState = (statsState) ? false:true;
}

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.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';
divObj.style.overflow = 'auto';
divObj.style.display = 'none';
divCloseObj = document.getElementById('closeDiv');
divCloseObj.style.top = (divCloseObj.offsetHeight * -1) + 'px';
document.getElementById('imgWrap').innerHTML = '<img src="images/spacer.gif" alt="Big Picture" name="bigPic" id="bigPic" width="0" height="0" onclick="hideBig()" />';
document.getElementById('bigPic').src = 'images/spacer.gif';
framePause = false;
return;
}

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

divObj.style.display = 'block';

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

  if (photoInfo[photoNum][0].substr(photoInfo[photoNum][0].length-3) == 'flv') {
   showBigFinish(photoNum);
  } else {
   picTemp = new Image(); // Reset picTemp so that it "picTemp.complete" will give a reading on the newly loading picture.
   picTemp.src = 'images/world_missions/'+destDirectory+'/'+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';
bigPicImgWrapObj = document.getElementById('imgWrap');
if (photoInfo[photoNum][0].substr(photoInfo[photoNum][0].length-3) == 'flv') {
 bigPicImgWrapObj.innerHTML = '<div id="video_flv"></div>';

 var flashvars = {
      file: "../media/video/"+photoInfo[photoNum][0],
      autostart: "true"
 };
 var params = {
      wmode: "opaque",
      allowfullscreen: "true",
      allowscriptaccess: "always"
 };
 var attributes = {
      id: "video_flv",  
      name: "video_flv"
 };

 swfobject.embedSWF("media/player.swf", "video_flv", photoInfo[photoNum][1], photoInfo[photoNum][2], "9", "media/expressInstall.swf", flashvars, params, attributes);
} else {
 bigPicObj = document.getElementById('bigPic');
 bigPicObj.src = 'images/world_missions/'+destDirectory+'/'+photoInfo[photoNum][0];
 bigPicObj.width = photoInfo[photoNum][1];
 bigPicObj.height = photoInfo[photoNum][2];

 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)*/
}

var currentExitInfo;

function leaveSite(exitInfo) {
if (exitInfo == 'continue' || getCookie('FsStoreCc')) {
 if (document.getElementById('notAgainCheck').checked) {
  var now = new Date();
  now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); // One year
  setCookie('FsStoreCc','no',now);
 }

 currentExitInfo = (exitInfo == 'continue') ? currentExitInfo:exitInfo;
  
 winSize = windowSize();
 winWidth = winSize[0] - 60;
 winHeight = winSize[1] - 30;
 newwindow = window.open(currentExitInfo,'mywindow','top=30,left=30,width='+winWidth+',height='+winHeight+',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
 if (window.focus) {newwindow.focus()}
 lightenPage();
 popupDiv('cc_note','hide');
 return;
}
 darkenPage();
 currentExitInfo = exitInfo;
 popupDiv('cc_note','show');
}

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

function popupDiv(id,option) {
obj = document.getElementById(id);
if (option == 'show') {
 obj.style.display = 'block';
 winSize = windowSize();
 screenWidth = winSize[0];
 screenHeight = winSize[1];
// divWidth = screenWidth - 80;
// divHeight = screenHeight - 60;
 divWidth = obj.offsetWidth;
 divHeight = obj.offsetHeight;
 scrollPosTop = f_scrollTop();
 divLeft = parseInt((screenWidth-divWidth)/2);
 divTop = parseInt((screenHeight-divHeight)/2);
// obj.style.width = divWidth+'px';
// obj.style.height = divHeight+'px';
 obj.style.left = divLeft+'px';
 obj.style.top = scrollPosTop+divTop+'px';

// headerHeight = document.getElementById('header').offsetHeight;
// footerHeight = document.getElementById('footer').offsetHeight;
 //alert(headerHeight+' - '+footerHeight);
// document.getElementById('imgLib_iframe').style.height = (divHeight - headerHeight - footerHeight) + 'px';

 obj.style.visibility = 'visible';
 if (typeof document.uniqueID != 'undefined') {
//  createIframeLayer(document.getElementById(id));
 }
} else {
 obj.style.visibility = 'hidden';
 obj.style.display = 'none';
 if (typeof document.uniqueID != 'undefined') {
//  removeIframeLayer(document.getElementById(id))
 }
}
}

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;
  }

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
