function goTo(targ,selObj,restore)
{
	eval (targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
	
	if (restore)
	{
		selObj.selectedIndex = 0;
	}
};

var origWidth, origHeight;
var origWidth2, origHeight2;
var cur_lyr;
var cur_lyr2;

if (document.layers)
{
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function()
	{
		if (window.innerWidth != origWidth || window.innerHeight != origHeight) 
		{
			history.go(0);
		}
	}
}

function swapLatest(id)
{
	if (cur_lyr) hideLayer(cur_lyr);
	{
		showLayer(id);
		cur_lyr = id;
	}
	
	if (id == "latestPhotos")
	{
		document.getElementById('latestPhotosTab').className = 'latestOn';
		document.getElementById('latestJournalsTab').className = 'latestOff';
	}

	else if (id == "latestJournals")
	{
		document.getElementById('latestJournalsTab').className = 'latestOn';
		document.getElementById('latestPhotosTab').className = 'latestOff';
	}	
};

function showLayer(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css)
	{
		lyr.css.display = "inline";
	}
};

function hideLayer(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css)
	{
		lyr.css.display = "none";
	}
};

function getElemRefs(id)
{
	var el = (document.getElementById)? document.getElementById(id) : (document.all) ? document.all[id] : (document.layers) ? getLyrRef(id,document): null;
	if (el) el.css = (el.style) ? el.style : el;
	return el;
};

function getLyrRef(lyr,doc)
{
	if (document.layers)
	{
		var theLyr;
		for (var i=0; i<doc.layers.length; i++)
		{
	  		theLyr = doc.layers[i];
			if (theLyr.name == lyr)
			{
				return theLyr;
			}
			
			else if (theLyr.document.layers.length > 0) 
	    	{
				if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
				{
					return theLyr;
				}
			}
	  	}
		
		return null;
  	}
};

function showML()
{
	document.getElementById('mlForm').innerHTML = '<div id="mlFormIEFix"><form name="ml" action="javascript:submitML();" id="ml"><input type="text" name="ea" class="mlField" /><input type="image" name="mlBtn" id="mlBtn" src="http://www.peterhill.net/images/ml_btn.gif" onmouseover="this.src=\'http://www.peterhill.net/images/ml_btn_over.gif\'" onmouseout="this.src=\'http://www.peterhill.net/images/ml_btn.gif\'" alt="Submit" /></form></div>';
};

function submitML()
{
	var mlDo = function(str)
	{
		document.getElementById('mlForm').innerHTML = str;
	}
	
	ajax.doGet('http://www.peterhill.net/ml.php?e=' + document.forms.ml.ea.value, mlDo, 'mlForm');
};

function changeLatest(to)
{
	if (to == "photos")
	{
		document.getElementById('latestPhotos').className = 'latestOn';
		document.getElementById('latestJournals').className = 'latestOff';
	}

	else if (to == "journals")
	{
		document.getElementById('latestJournals').className = 'latestOn';
		document.getElementById('latestPhotos').className = 'latestOff';
	}
};