var flipOnce = true;
var flipped = false;	
var picSrc; 
var picId = "pic";
var timeoutId;

if (document.getElementById(picId) != null) {

	// Preload
	var egg = new Image();
	egg.src = getImagePath() + "joe50-62f.gif";
	
	function flip() { 
		document.getElementById(picId).src = egg.src;
		setTimeout("revert();", 350);
	} // flip
	
	function over() {
		picSrc = document.getElementById(picId).src;
		timeoutId = setTimeout("flip();", 3000);
	} // over
	
	function revert() {
		document.getElementById(picId).src = picSrc;
	} // revert
	
	function cancel() { clearTimeout(timeoutId); }
	
	var picEl = document.getElementById(picId);
	picEl.onmouseover = over;
	picEl.onmouseout = cancel;
	
	//document.write('<img id="pic" border="0" src="' + getImagePath() +'joe50-62.gif" width="50" height="62" alt="Joe Murray" title="Joe Murray" onMouseOver="over();">');
	
} // endif

function removeBefore(toRemove, fromString) {
	return fromString.substring(fromString.indexOf(toRemove)+toRemove.length, fromString.length);
} // remove

function getImagePath() {
	var path = document.URL.substring(0, document.URL.lastIndexOf("/")+1).toLowerCase();
	var subpath = removeBefore("youth/", path); 
	var imagePath = "./";
	var start = 0;
	var index = subpath.indexOf("/", start); 
	
	while (index > -1) {
			imagePath += "../";
			//if (!confirm("start: "+start+"\rsubpath: "+subpath)) break;
			subpath = removeBefore("/", subpath);
			start = index;
			index = subpath.indexOf("/", start);
	   } // while
	
	imagePath += "images/";
	return imagePath;
} // getImagePath