// JavaScript Document
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
// REDO SO NOT RELIANT ON THIS FUNCTION AT ALL.... !!!!
// GOOD FOR 2 sets of submenus!
function setAtags()
{
//	alert(document.getElementById('menu').innerHTML);
	atags = document.getElementById('menu').getElementsByTagName('a');
	for(i = 0; i < atags.length; i++)
	{
		if(atags[i])
		{
			var pos_pound = atags[i].href.search('#'); // hex code for '?' - \x3F
			if(pos_pound == ((''+atags[i].href).length - 1))
			{
				var par = atags[i].parentNode.parentNode.parentNode.firstChild;
				var par_pgid = par.id.substr(par.id.lastIndexOf('|') + 1);
				var this_pgid = parseInt(atags[i].id.substr(atags[i].id.lastIndexOf('|') + 1));
				if(!isNaN(par_pgid) && (page_data[par_pgid].split('|')[3].search('program') < 0))
				{
					//alert('old id: ' + par_pgid);
					par = atags[i].parentNode.parentNode.parentNode.parentNode.parentNode.firstChild;
					par_pgid = par.id.substr(par.id.lastIndexOf('|') + 1);
					//alert('new id: ' + par_pgid);
				}
				if(!isNaN(this_pgid))
				{
					if( ((atags[i].id != 'na') && (atags[i].parentNode.className == 'sub')) || ((par.id.search(/xmenu/) == 0) && isNaN(parseInt(par_pgid))) )
						atags[i].href = '#' + simpleName(atags[i].innerHTML);
					else
						atags[i].href = '#' + simpleName(par.innerHTML) + '-' + simpleName(atags[i].innerHTML);
						//atags[i].href = '#' + simpleName(atags[i].parentNode.parentNode.parentNode.childNodes[0].innerHTML) + '-' + simpleName(atags[i].innerHTML);
				}
			}
		}
	}
	setMouseOvers();
}
function simpleName(s)
{
	var ppos = s.search(/\x28/);
	if(ppos > -1)
		s = s.substr(0, ppos);
	ppos = s.search(/<br>/i);
	if(ppos > -1)
		s = s.substr(0, ppos);
	s = s.toLowerCase();
	s = s.replace(/'/g, '');
	s = s.replace(/ /g, '');
	s = s.replace(/&amp;/, 'and'); // replaces &'s with and's
	return s;
}
function doRefresh()
{
	loc = '';
	loc += window.location;
	pos = loc.search('#'); // hex code for '?' - \x3F
//	alert(loc);
	if(loc[loc.length-1] == '#')
		return;
	if(pos < 0)
		return;
	subtag = '';
	if(pos >= 0)
	{											// if found #, indicating sub-page...
		tag = loc.substr(pos+1);				// tag = entire thing...
		pos = tag.search('-');					// search for a secondary tag....
		if(pos >= 0)
		{										// if found _, indicating sub-sub-page...
			subtag = tag.substring(pos+1);		// subtag = second part...
			tag = tag.substring(0, pos);		// re-define tag to be just first part
		}
		showSecond(tag, subtag);				// at least sub-page found, show it
	}
	document.bPreventClick = false;
}
var currentPage = '';
var currentPageID = '';
var currentPageType;
function showSecond(mother_page, child_page)
{
//	alert('mother_page: ' + mother_page + ' and child_page: ' + child_page);// + 'page_data: ' + page_data.length);
	var compare_page = (child_page == '') ? mother_page : child_page;
	var page_id = '';
	var mother_page_id = 0;
	var mother_menu_id = 0;
	var mother_page_title = '';
	var child_page_title = '';
	
	// LOOK FOR QUERY!
	var query = '';
	if(child_page.search(/\?/) >= 0)
		query = child_page.substr(child_page.search(/\?/)+1);
	if(query != '')
		child_page = child_page.substr(0, child_page.search(/\?/));
	
	// FIND MOTHER PAGE ID IN THIS "TIER" OF THE MAIN MENU...
	var mmas = document.getElementById('menu').getElementsByTagName('a');
	for(var i = 0; i < mmas.length; i++)
	{
		if(simpleName(mmas[i].innerHTML) == mother_page)
		{
			if(child_page != '')
			{
				if(mmas[i].nextSibling)
				{
					subs = mmas[i].nextSibling.getElementsByTagName('a');
					for(var j = 0; j < subs.length; j++)
					{
						if(simpleName(subs[j].innerHTML) == child_page)
						{
							page_id = subs[j].id.substr(subs[j].id.lastIndexOf('|') + 1);
							child_page_title = subs[j].innerHTML;
							mother_page_id = mmas[i].id.substr(mmas[i].id.lastIndexOf('|') + 1);
							mother_menu_id = mmas[i].id;
							mother_page_title = mmas[i].innerHTML;

							// IF SUBMENU'S MOTHER PAGE IS NOT A PROGRAM PAGE, KEEP SEARCHING
							if(page_data[mother_page_id].split('|')[3].search('program') < 0)
							{
								mother_page_id = mmas[i].id.substr(mmas[i].id.lastIndexOf('_')+1, mmas[i].id.lastIndexOf('|'));
								//alert(mother_page_id);
							}
							break;
						}
					}
				}
			}
			else
			{
				page_id = mother_page_id = mmas[i].id.substr(mmas[i].id.lastIndexOf('|') + 1);
				child_page_title = mmas[i].innerHTML;
				mother_menu_id = mmas[i].id;
				mother_page_title = mmas[i].innerHTML;
				//alert(mother_page_title + ' -- in the else');
			}
		}
	}
	if(!page_id || page_id == '')
	{
		pageDoesNotExist();
		return;
	}

	var full_page = (page_data[page_id].split('|')[3].search('full') >= 0);
	var newPageType = full_page;
	
	// CUT OFF SUBTITLE
	if(mother_page_title.search(/<br>/i) >= 0)
		mother_page_title = mother_page_title.substring(0, mother_page_title.search(/<br>/i));

	// DISABLE IMAGE MAPS FOR HOME PAGE
	document.getElementById('image_map_main').style.display = 'none';
	
	// Following if is to preserve elements on the page that don't need refreshing...
	// ----------IF NEW PAGE ---------- OR SWITCHING BETWEEN PORTAL AND FULL!!
	if(currentPage != mother_page || currentPageType != newPageType)
	{
		//alert('changing page');
		// BASE ON PAGE_TYPE FROM PAGE_DATA
		initPageStyle(mother_page_id);
		currentPage = mother_page;
		currentPageID = mother_page_id;
		currentPageType = newPageType;
		main = document.getElementById('main_background');
		left = document.getElementById('leftcolumn');
		mid = document.getElementById('midcolumn');
		right = document.getElementById('rightcolumn');
		
		// FULL PAGES
		if(full_page)
		{
			left.className = 'second-level-column-left';
			left.style.width = '1050px';
			left.innerHTML = '';
			right.className = 'second-level-column-right';
			right.innerHTML = '';
			main.style.backgroundImage = "url('backgrounds/" + page_data[page_id].split("|")[8] + "')";
			main.style.backgroundPosition = 'center 15px';
		}
		else // PORTAL PAGES
		{
			left.className = 'second-level-column-left';
			left.innerHTML = '';
			left.style.width = '250px';
			right.className = 'second-level-column-right';
			right.innerHTML = '';
	//		alert('page: ' + page_id + ', mother_page_id: ' + mother_page_id);// + ', setting background to: ' + page_data[mother_page_id].split("|")[8]);
			main.style.backgroundImage = "url('backgrounds/" + page_data[mother_page_id].split("|")[8] + "')";
			main.style.backgroundPosition = 'center 15px';
		
	/* ------ CREATES DESCRIPTION FOR PROGRAM PAGES ------ */
			var desc = document.createElement('div');
			desc.id = 'page_desc';
			desc.innerHTML = page_data[mother_page_id].split("|")[2].replace(/ampersand;/g, '&');
			desc.style.marginTop = '100px'; // '70px';
			desc.style.marginLeft = '15px';
			desc.style.textAlign = 'left';
			desc.style.fontFamily = 'arial';
			desc.style.fontSize = '10px'; //'0.88em';
			if(isIE6()) desc.style.fontSize = '10px'; //'0.75em';
			desc.style.fontWeight = 'bold';
			left.appendChild(desc);
	
	/* ------ CREATES VERTICAL MENU ----- */
			if(document.getElementById(mother_menu_id).nextSibling)
			{
				var menu = document.createElement('div');
				var vmenu = "<div id='hor_table'>";
				var velems = document.getElementById(mother_menu_id).nextSibling.childNodes;
				for(var i = 0; i < velems.length; i++)
					vmenu += "<ul class='horizmenu'><li>" + velems[i].innerHTML + "</li></ul>";
				vmenu += "</div>";
				menu.innerHTML = vmenu;
				//alert(menu.innerHTML);
				
				menu.style.position = 'absolute';
				menu.style.top = '135px';
				menu.style.left = '0px';
				if(isIE6())
				{
					menu.style.top = '150px';
					menu.style.left = '355px';
				}
				if(isIE7())
					menu.style.top = '170px';
				menu.style.fontWeight = 'bold';
				menu.style.zIndex = '500';
				menu.id = 'vertical_menu';
				right.appendChild(menu);
			}
		}
		if(mid)
			mid.style.display = 'none';
	}
	// --------- END IF NEW PAGE -----------

		var frm = document.getElementById('innerFrame');
		if(frm)
			frm.parentNode.removeChild(frm);
		right.align = '';
		left.align = '';
		/* ------ FOR EXTERNAL PAGES ------ */
		if(page_data[page_id].split('|')[3].search('external') >= 0)
		{
			frm = document.createElement('iframe');
			frm.id = 'innerFrame';
			frm.style.position = 'relative';
			frm.width = '636px'; // + 10px from original
			if(isIE6())
			{
				frm.style.width = parseInt(frm.width) + 64 + 'px'; //64 , '700px';
				if(full_page)
					frm.style.width = parseInt(frm.width) + 364 + 'px';
			}
			if(full_page)
				frm.width = parseInt(frm.width) + 364 + 'px';
			frm.height = '533px'; // + 10px from original
			if(full_page)
				frm.height = '573px';
			frm.style.top = '20px'; //20 -> -5
			frm.style.left = '120px';
			if(isIE6())
				frm.style.left = '180px';
			if(full_page)
				frm.style.left = '5px';
			//frm.scrolling = 'no';
			frm.frameBorder = 'no';//0';
			frm.style.backgroundColor = 'transparent';
			frm.allowTransparency = 'true';
			frm.style.zIndex = '1';
			if(full_page)
				left.appendChild(frm);
			else
				right.appendChild(frm);
//			var url = "get_page_db_data.php?id=" + page_data[page_id].split('|')[0];
			var url = page_data[page_id].split('|')[4];
			document.getElementById('innerFrame').src = url;
		}
		/* ------ FOR INTERNAL PAGES ------ */
		else
		{
			frm = document.createElement('div');
			frm.id = 'innerFrame';
			frm.style.position = 'relative';
			frm.style.width = '636px';
			frm.style.height = '523px';
			if(isIE6())
				frm.style.width = '650px'; //'700px';
			if(page_data[page_id].split('|')[3].search('full') >= 0)
				frm.style.width = parseInt(frm.style.width) + 364 + 'px';
			if(full_page)
				frm.style.width = '1000px';
			frm.style.top = '33px'; //21
			frm.style.left = '120px';
			if(isIE6())
				frm.style.left = '170px';
			if(full_page)
				frm.style.left = '5px';
			frm.style.overflow = 'hidden';
			frm.style.overflowY = 'auto';
			if(full_page)
				left.appendChild(frm);
			else
				right.appendChild(frm);
			var ihtml = page_data[page_id].split('|')[4].replace(/ampersand;/g, '&');
			ihtml = ihtml.replace(/plussign;/g, '+');
			frm.innerHTML = ihtml;
		}
	
	if(navigator.userAgent.search(/windows/gi) >= 0)
	{
		var tbs = frm.getElementsByTagName('div');
		for(var t = 0; t < tbs.length; t++)
		{
			if(tbs[t].id.search(/text_box/) >= 0)
			{
				if(tbs[t].currentStyle)
					tbs[t].style.fontSize = (parseInt(tbs[t].currentStyle["fontSize"]) / 12) - 0.344 + 'em';
				else if(window.getComputedStyle)
					tbs[t].style.fontSize = parseInt(document.defaultView.getComputedStyle(tbs[t], null).getPropertyValue("font-size")) - 1 + 'px';
			}
		}
	}
	makePopupImages();

/* ------ SETS UP MOVERS ON VERTICAL MENU ------ */
	if(document.getElementById('hor_table'))
	{
		var lis = document.getElementById('hor_table').getElementsByTagName('li');
		for(var i = 0; i < lis.length; i++)
		{
			if(lis[i].id.search(/mover_/) < 0)
			{
				lis[i].id = 'mover_' + i;
				lis[i].firstChild.id = 'hidden_a_' + i;

				if( simpleName(lis[i].firstChild.innerHTML) == child_page )
					makeMover(lis[i].id, true);
				else
					makeMover(lis[i].id);
			}
			else
			{
				if( simpleName(lis[i].firstChild.innerHTML) == child_page )
					growToLock(lis[i].id);
				if(child_page == '')
					makeMover(lis[i].id);
			}			
		}
	}

/* ------ CHANGES TITLE TO REFLECT SELECTED PAGE ------ */
	document.title = 'Camp Eagle - ' + mother_page_title; //pg[0].toUpperCase() + pg.substring(1);
	if(child_page)
		document.title += ' - ' + child_page_title.replace(/&amp;/g, '&'); //child_page[0].toUpperCase() + child_page.substring(1);

	// SHOULD BE VAR PG
	var pg = mother_page.toLowerCase();
	pg = pg.replace(/ /g, '');

/* ------ COLORS MAIN MENU ELEMENTS TO REFLECT THE SELECTED PAGE ------ */
	mainmenutags = document.getElementById('menu').getElementsByTagName('a');
	for(i = 0; i < mainmenutags.length; i++)
	{
		if(simpleName(mainmenutags[i].innerHTML) == pg)
		{
			if(mainmenutags[i].parentNode.parentNode.parentNode.nodeName.toLowerCase() == 'li')
				mainmenutags[i].parentNode.parentNode.parentNode.childNodes[0].style.color = '#00FFFF';
			mainmenutags[i].style.color = '#00FFFF';
		}
		else
			mainmenutags[i].style.color = '#FFFFFF';

		if(simpleName(mainmenutags[i].innerHTML) == child_page)
		{
			if((mainmenutags[i].parentNode.parentNode.parentNode.childNodes[0].style.color == '#00FFFF') || (mainmenutags[i].parentNode.parentNode.parentNode.childNodes[0].style.color == 'rgb(0, 255, 255)'))
				mainmenutags[i].style.color = '#00FFFF';
		}
	}
//	applyPrintButton();
}
function initPageStyle(p)
{
	var headtag = document.getElementsByTagName('head')[0];
	var htmltag = document.getElementsByTagName('html')[0];
	var bodytag = document.getElementsByTagName('body')[0];
	var styletag = document.getElementsByTagName('style')[0];

	var ss = document.createElement('style');
	
	if(!headtag)
	{
		headtag = document.createElement('head');
		ss.appendChild(document.createTextNode(page_data[p].split('|')[5]));
		headtag.appendChild(ss);
		htmltag.insertBefore(headtag, bodytag);
		//alert('no head tag');
	}
	else
	{
		if(styletag)
		{
			styletag.setAttribute('type', 'text/css');
			if(styletag.styleSheet)
				styletag.styleSheet.cssText = page_data[p].split('|')[5];
			else
				styletag.appendChild(document.createTextNode(page_data[p].split('|')[5]));
		}
		else
		{
			//alert('head tag exists but style tag does not');
			ss.setAttribute('type', 'text/css');
			if(ss.styleSheet)
				ss.styleSheet.cssText = page_data[p].split('|')[5];
			else
				ss.appendChild(document.createTextNode(page_data[p].split('|')[5]));
			headtag.appendChild(ss);
		}
	}
//	prompt('',document.getElementsByTagName('head')[0].innerHTML);
}
function pageDoesNotExist()
{
	//alert('Page does not exist');
	window.location.hash = '';
	showMain();
//	if(navigator.userAgent.toLowerCase().search('safari') >= 0)
//		window.location.reload();
//	else
//		window.location.refresh();
}
function showSub()
{
	for(var i = 0; i < this.childNodes.length; i++)
	{
		if(this.childNodes[i].nodeName.toLowerCase() == 'ul')
		{
			this.childNodes[i].style.display = 'block';
			this.childNodes[i].style.visibility = 'visible';
		}
	}
}
function clearSub(except)
{
	var m = document.getElementById('menu');
	var uls = m.getElementsByTagName('ul');
	for(var i = 0; i < uls.length; i++)
	{
		if((uls[i].parentNode.id != 'menu') && (uls[i].id != except))
		{
			uls[i].style.display = 'none';
			uls[i].style.visibility = 'hidden';
		}
	}
}
//setMouseOvers();
function setMouseOvers()
{
	if(navigator.appName.search(/Microsoft Internet Explorer/i) >= 0)
	{
		var iepos = -1;
		var num = 0;
		if((iepos = navigator.appVersion.search(/MSIE/i)) >= 0)
		{
			var semi = navigator.appVersion.indexOf(';', iepos);
			num = parseFloat(navigator.appVersion.substring(iepos+4, semi));
		}
		if(num < 7)
		{
		//alert('burn');
			var m = document.getElementById('menu');
			var lis = m.getElementsByTagName('li');
			for(var i = 0; i < lis.length; i++)
			{
				//alert('assigning mouseovers');
				lis[i].onmouseover = showSub;
				lis[i].onmouseout = clearSub;
			}
		}
	}
}

function makePopupImages()
{
//	var enlargables = document.getElementById('innerFrame').getElementsByClassName('enlargable');
	// IF CLASSNAMES DOESN'T WORK:
	var enlargables = document.getElementById('innerFrame').getElementsByTagName('div');
	for(var i = 0; i < enlargables.length; i++)
	{
		if(enlargables[i].className == 'enlargable')
		{
			enlargables[i].style.cursor = 'pointer';
			enlargables[i].onclick = function() { var imgs = this.getElementsByTagName('img'); displayPopupImage(imgs[0].src); };
		}
	}
}
function displayPopupImage(image)
{
	var existing;

	if(existing = document.getElementById('popupImageDIV'))
		existing.onclick();

	var imDiv = document.createElement('div');

	imDiv.id = 'popupImageDIV';
	imDiv.style.position = 'relative';
	if(!(document.getElementById && !document.all))
		imDiv.style.top = '-560px';
	else
		imDiv.style.top = '0px';
	imDiv.style.left = '100px';
	imDiv.style.width = '800px';
	imDiv.style.height = '550px';
	imDiv.style.backgroundColor = '#000000';
	imDiv.style.border = 'solid 1px';
	imDiv.style.margin = '10px 10px';
	imDiv.style.zIndex = '600';
	imDiv.onclick = function() { /*var vm = document.getElementById('vertical_menu'); if(vm) vm.style.visibility = 'visible';*/ this.parentNode.removeChild(this); };
	imDiv.align = 'center';
	if(!(document.getElementById && !document.all))
		imDiv.innerHTML = "<span style='color: #FFFFFF; font-family: arial; font-size: 0.75em; position: relative; top: 0px;'>click image to close<span><br><br><img id='enlargedImage' src='" + image + "' /><br><br><span style='color: #FFFFFF; font-family: arial; font-size: 0.75em;'>click image to close<span>";
	else
		imDiv.innerHTML = "<br><span style='color: #FFFFFF; font-family: arial; font-size: 0.75em; position: relative; top: -550px;'>click image to close<span><br><br><img id='enlargedImage' src='" + image + "' /><br><br><span style='color: #FFFFFF; font-family: arial; font-size: 0.75em;'>click image to close<span>";
	document.getElementById('main_background').appendChild(imDiv);
	
	var im = document.getElementById('enlargedImage');
	var h = parseInt(im.offsetHeight);
	var w = parseInt(im.offsetWidth);
	var maxh = parseInt(imDiv.offsetHeight);
	var maxw = parseInt(imDiv.offsetWidth);
	while((h > (maxh-50)) || (w > maxw))
	{
		h = Math.round(h*0.9);
		w = Math.round(w*0.9);
	}
	im.style.height = h + 'px';
	im.style.width = w + 'px';
}
savedLocation = '';
var mainPageHTML;
mainPageHTML = document.getElementById('main_background').innerHTML;
function showMain()
{
	document.getElementById('main_background').innerHTML = mainPageHTML;
	document.getElementById('main_background').style.background = '';
	document.getElementById('main_background').className = 'main_background';
	document.getElementById('midcolumn').className = 'main-column-middle';
	//document.getElementById('image_map_main').style.visibility = 'visible';
	var tmp = '' + window.location;
	var tmppos = tmp.search('#');
	var newloc = tmp.substring(0,tmppos);//'http://www.campeagle.org/mock/#';
	window.location = newloc;
	bClickedMain = true;
}

var bPreventClick;
function getHomeNews()
{
	var xmlHttp = getRequestObject();

	var loca = '' + window.location;
	var pound = loca.search('#');
	if((loca[loca.length-1] != "#") && (pound >= 0))
		return;
	
	// Set onreadystatechange function
	xmlHttp.onreadystatechange = function()
	{
		if( xmlHttp.readyState == 4 )
		{
			if( xmlHttp.responseText.search("failed") >= 0 ){ alert('calendar failure- ' + xmlHttp.responseText); return; }
			var newsInfo = xmlHttp.responseText.split('|');
			var newsTitle = newsInfo[0];
			var newsDate = newsInfo[1];
			var newsTxt = newsInfo[3];
			var year = newsDate.split('-')[0];
			var mon = newsDate.split('-')[1];
			var day = newsDate.split('-')[2];
			var monTxt = months[mon - 1];
			var newsDiv = document.getElementById('home_news');
			var tdiv = document.createElement('span');
			tdiv.style.fontSize = '1.50em';
			tdiv.style.textDecoration = 'underline';
			tdiv.style.fontWeight = 'bold';
			tdiv.innerHTML = newsTitle;
			var tdiv2 = document.createElement('span');
			tdiv2.style.textAlign = 'right';
			tdiv2.style.fontSize = '0.75em';
			tdiv2.style.fontStyle = 'italic';
			tdiv2.style.position = 'relative';
			tdiv2.style.left = '80px';
			tdiv2.innerHTML = monTxt + ' ' + day + ', ' + year;
			newsDiv.appendChild(tdiv);
			newsDiv.appendChild(tdiv2);
			tdiv2.style.left = (newsDiv.offsetWidth - tdiv.offsetWidth - tdiv2.offsetWidth) + 'px';
			newsDiv.appendChild(document.createElement('br'));
			newsDiv.appendChild(document.createElement('br'));
			var sp = document.createElement('span');
			if(!(document.getElementById && !document.all))
				sp.style.fontSize = '0.92em';
			else if(navigator.userAgent.search(/safari/i) >= 0)
				sp.style.fontSize = '11px';
			else
				sp.style.fontSize = '12px';//'1.00em';
			sp.innerHTML = newsTxt;
			newsDiv.appendChild(sp);
			var tdiv3 = document.createElement('div');
			tdiv3.style.textAlign = 'right';
			tdiv3.style.fontSize = '0.69em';
			tdiv3.style.fontStyle = 'italic';
			tdiv3.style.textDecoration = 'underline';
			tdiv3.style.color = '#0000FF';
			tdiv3.style.cursor = 'pointer';
			tdiv3.onclick = getAllNews;
			tdiv3.title = 'archived news';
			tdiv3.innerHTML = 'archived news';
			newsDiv.appendChild(tdiv3);
			if(!(document.getElementById && !document.all))
				newsDiv.style.top = '10px';
		}
	}
	
	var url = "get_news.php?count=1";
	
	xmlHttp.open( "GET", url, true );
	xmlHttp.send( null );
}
function getAllNews()
{
	var xmlHttp = getRequestObject();
	// Set onreadystatechange function
	xmlHttp.onreadystatechange = function()
	{
		if( xmlHttp.readyState == 4 )
		{
			if( xmlHttp.responseText.search("failed") >= 0 ){ alert('calendar failure- ' + xmlHttp.responseText); return; }

			var allNews = xmlHttp.responseText.split('\n'); // this split produces 1 extra length!
			var newsArch = document.getElementById('midcolumn');
			var newsHTML = "<br><div class='archive_news_column'>";
			for(var n = 0; n < allNews.length - 1; n++)
			{
				var newsInfo = allNews[n].split('|');
				var newsTitle = newsInfo[0];
				var newsDate = newsInfo[1];
				var newsTxt = newsInfo[3];
				var year = newsDate.split('-')[0];
				var mon = newsDate.split('-')[1];
				var day = newsDate.split('-')[2];
				var monTxt = months[mon - 1];
				newsHTML += "<div style='text-align: left; font-size: 0.88em; font-weight: bold; font-style: italic;'>" + monTxt + ' ' + day + ", " + year + "</div><div style='font-size: 0.88em; text-decoration: underline; font-weight: bold;'>" + newsTitle + "</div>" + newsTxt + "<br><br>";			
//				alert('year: ' + year + ' mon: ' + mon + ' day: ' + day + ', news: ' + newsTxt + '#');
			}
			newsHTML += '</div>';
			newsArch.innerHTML = newsHTML;
		}
	}
	
	var url = "get_news.php?count=0";
	
	document.getElementById('image_map_main').style.display = 'none';

	document.getElementById('leftcolumn').innerHTML = '';
	document.getElementById('leftcolumn').style.width = '1px';
	document.getElementById('rightcolumn').innerHTML = '';
	document.getElementById('rightcolumn').style.width = '1px';
	document.getElementById('main_background').className = 'archive_news_background';//style.background = 'url("backgrounds/orgstarburst.jpg")';
	document.getElementById('midcolumn').className = 'archive_news';
	document.getElementById('midcolumn').innerHTML = "<center>Loading... <img src='ajax-loader.gif' /></center>";
//	document.getElementById('midcolumn').align = 'center';
	
	xmlHttp.open( "GET", url, true );
	xmlHttp.send( null );
}
function unlockHomePage()
{
	var lc = document.getElementById('leftcolumn');
	var mc = document.getElementById('midcolumn');
	var rc = document.getElementById('rightcolumn');
	lc.style.visibility = 'visible';
	mc.style.visibility = 'visible';
	rc.style.visibility = 'visible';
	document.getElementById('image_map_main').style.display = 'block';
	
	document.getElementById('waterslides').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="186" height="140" title="New Waterslides at Camp Eagle"><param name="movie" value="waterslide.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent"></param><embed src="waterslide.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="186" height="140" wmode="opaque"></embed></object>';
	document.getElementById('preload_backgrounds').innerHTML = '<img src="backgrounds/eagleprofile.jpg"><img src="backgrounds/eaglequest.jpg"><img src="backgrounds/events.jpg"><img src="backgrounds/headwaters.jpg"><img src="backgrounds/journey.jpg"><img src="backgrounds/retreats.jpg"><img src="backgrounds/riversedge.jpg"><img src="backgrounds/staff.jpg"><!--	<img src="backgrounds/tourmap.jpg">--><img src="backgrounds/campeaglecombo.jpg">';
	if(document.getElementById('slideshow_faces'))
		ajax_slideshow('faces');
	if(document.getElementById('slideshow_nature'))
		ajax_slideshow('nature');
}
function applyPrintButton()
{
	if(document.getElementById('portalToolbar'))
		return;
	var r = document.getElementById('rightcolumn');
	var dif = document.getElementById('innerFrame');
	var difp = dif.parentNode;
	var pb = document.createElement('div');
	pb.id = 'portalToolbar';
	//alert('top: ' + dif.offsetTop + ', left: ' + dif.offsetLeft);
	pb.style.position = 'absolute';
	pb.style.zIndex = '500';
	//pb.style.position = 'fixed';
	//pb.style.top = parseInt(r.offsetTop) + parseInt(dif.offsetTop) + 80 + 'px';
	//pb.style.left = parseInt(r.offsetLeft) + parseInt(dif.offsetLeft) + 90 + 'px';
	pb.style.top = '120px'; //parseInt(r.offsetTop) + parseInt(dif.offsetTop) + 80 + 'px';
	pb.style.left = '20px'; //parseInt(r.offsetLeft) + parseInt(dif.offsetLeft) - 90 + 'px';
	if(isIE6()) pb.style.left = '90px';
	pb.style.border = '1px solid black';
	pb.style.backgroundColor = '#FFFFFF';
	pb.style.padding = '3px';
	pb.style.fontFamily = 'arial';
	pb.style.fontSize = '10px';
	pb.style.cursor = 'pointer';
	pb.onclick = function() { printFromToolbar(); };
	pb.innerHTML = "<img src='images/printer_icon.gif' /> print this page";
	difp.appendChild(pb);
}
function printFromToolbar()
{
	var pd = document.createElement('div');
	pd.id = 'myPrintDiv';
	var tab =  '' + document.getElementById('innerFrame').innerHTML;
	if(tab == '')
		tab = '' + document.getElementById('innerFrame').contentDocument.body.innerHTML;
	pd.innerHTML = '<form target="_blank" action="printPortal.php" method="post" id="print_form"><textarea id="myApp" name="myApp">' + tab + '</textarea></form>';
	document.getElementById('innerFrame').appendChild(pd);
	document.getElementById('print_form').submit();
	document.getElementById('innerFrame').removeChild(document.getElementById('myPrintDiv'));
}
function isIE6()
{
	if(navigator.appName.search(/Microsoft Internet Explorer/i) >= 0)
	{
		var iepos = -1;
		var num = 0;
		if((iepos = navigator.appVersion.search(/MSIE/i)) >= 0)
		{
			var semi = navigator.appVersion.indexOf(';', iepos);
			num = parseFloat(navigator.appVersion.substring(iepos+4, semi));
		}
		if(num < 7)
			return true;
	}
	return false;
}

bClickedMain = false;
function checkLocation()
{
	if(window.location != prevLocation)
	{
		savedLocation = prevLocation;
		prevLocation = '' + window.location;
		if((navigator.userAgent.search("Safari") >= 0) && bClickedMain)
		{
			window.location.reload();
			bClickedMain = false;
		}
		else
			doRefresh();
//			window.location.reload();
	}
}
var prevLocation = '' + window.location;
locationInterval = window.setInterval('checkLocation()', 100);