// Browser Detection
var brw_browserVersion="", brw_browserName="", brw_clientPlatform="";
if (navigator!=undefined) {
	if (navigator.appName!=undefined) brw_browserName = navigator.appName;
	if (navigator.userAgent!=undefined) brw_browserVersion = navigator.userAgent;
	if (navigator.platform!=undefined) brw_clientPlatform = navigator.platform;
}
var brw_isIE = brw_isIE_W3C = brw_isNavigator = brw_isMozilla = brw_isFirefox = brw_isSafari = false;
brw_isIE = (brw_browserName == "Microsoft Internet Explorer");
if (brw_isIE) brw_isIE_W3C = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0)? true : false;
brw_isNavigator = (brw_browserName == "Netscape");
brw_isMozilla = brw_browserVersion.indexOf("ecko") != -1;
if (brw_isMozilla) {
	brw_isNavigator = false;
	brw_isFirefox = brw_browserVersion.indexOf("irefox") != -1;
	brw_isSafari = brw_browserVersion.indexOf("afari") != -1;
}
var brw_isNavOrMoz = brw_isNavigator || brw_isMozilla;

// Display Extended Tooltips
var mouseHit = null;
var mouseNum = null;
var mouseNumBlt=null;
var mousePt = null;
var mouseTm = null;
var mouseK = null;

// Notify that the mouse is over an image that displays an extended tooltip
function phototip(num, evt) {
	if (num!=null && evt && photos && photos.length) {
		try {
			mouseNum = parseInt(num,10);
			if (mouseNum>0 && mouseNum <= photos.length) {
				mouseTm = new Date();
				mouseTm = mouseTm.getTime(); 
				mousePt = toPoint(evt);
				mouseK = setTimeout("phototimer();",25);
			}
		} catch(e) {
			mouseNum = null;
			mouseTm = null;
			mousePt = null;
		}
	}
}

// Watch for mouse movement and memorize the new mouse point
function phototipTrack(evt) {
	if (evt && mousePt) {
		var newPt = toPoint(evt);
		var X = Math.abs(newPt.X-mousePt.X), Y = Math.abs(newPt.Y-mousePt.Y);
		var o = document.getElementById("SHS_tip");
		if (X<5 && Y<5) {
			// Leave the mouse point as is
		} else {
			if (o && o.style.display!="none") o.style.display="none";
			mousePt = newPt;
			mouseTm = new Date();
			mouseTm = mouseTm.getTime(); 
		}
	}
}
// Watch for any kind of mouse out (including mousing into the tooltip)
function unphototip(evt) {
	var o = document.getElementById("SHS_tip");
	if (evt) {
		if (mouseK) window.clearTimeout(mouseK);
		mousePt = mouseTm = mouseK = null;
		if (o && o.style.display!="none") o.style.display="none";
	}
}

// Display/Hide the tooltip if the mouse hasn't been moved for 1.25 seconds
function phototimer() {
	var hide=true, o = document.getElementById("SHS_tip");
	if (o==null) {
		var o = document.createElement("div");
		o.setAttribute("id","SHS_tip");
		o.className = "shs_tip";
		o.style.display="none";
		o.style.position="absolute";
		o.style.top="10px";
		o.style.left="10px";
		document.body.appendChild(o);
	}
	if (mouseTm!=null) {
		var newTm = new Date();
		newTm = newTm.getTime(); 
		hide = (newTm-mouseTm<1250);
	}
	if (hide) {
		if (o.style.display!="none") o.style.display="none";
	} else {
		if (o.style.display!="block") {
			o.style.left = (mousePt.X+10)+"px";
			o.style.top = (mousePt.Y+15)+"px";
			var txt = photos[mouseNum-1];
			if (txt.length && txt.length>0 && txt[0] && txt[0].length>0) {
				if (mouseNumBlt!=mouseNum) {
					mouseNumBlt = mouseNum;
					var hd = txt[0];
					var bd = (txt[1] && txt[1].length>0)?txt[1]:null;
					var ft = (txt[2] && txt[2].length>0)?txt[2]:null;
					var w =hd.length*.5;
					if (bd) w = Math.max(w,bd.length*.5);
					if (ft) w = Math.max(w,ft.length*.5);
					w = Math.min(w,26);
					o.style.width = w+"em";
					var str="<span class='shs_tip_title'>"+hd+"</span>";
					if (bd) str=str+"<p>"+bd+"</p>";
					if (ft) str=str+"<span class='shs_tip_foot'>"+ft+"</span>";
					o.innerHTML = str;
				}
				o.style.display = "block";
			}
		}
	}
	mouseK = setTimeout("phototimer();",25);		
}

// Convert an evt into a mouse point
function toPoint(evt) {
	var cX, cY;
	if (evt.pageX!=null) {
		cX = evt.pageX; cY = evt.pageY;
	} else {
		var sBase = (brw_isIE_W3C) ? document.body.parentNode : document.body;
		cX = evt.clientX; cY = evt.clientY;
		cX = cX + sBase.scrollLeft;
		cY = cY + sBase.scrollTop;
	}
	return {X: cX, Y: cY};
}

function showSec(thisObj, thisEvt) {
	if (thisObj && thisEvt) {
		var p = thisObj.parentNode;
		while (p && p.tagName && p.tagName.toUpperCase()!="P") p = p.parentNode;
		if (p && p.tagName && p.tagName.toUpperCase()=="P" && p.nextSibling) {
			p = p.nextSibling;
			if (p.tagName==undefined) p = p.nextSibling;
			if (p && p.tagName && p.tagName.toUpperCase()=="P") {
				if (p.style.display=="none")
					p.style.display="block";
				else
					p.style.display="none";
			}
		}
	}
	return false;
}

decayTimer = null;
function decayPop(thisEvt) {
	var o = document.getElementById("stopPop");
	if (o) {
		if (decayTimer) window.clearTimeout(decayTimer);
		var decayPt=toPoint(thisEvt);
		var src = (thisEvt.target) ? thisEvt.target : ((thisEvt.srcElement) ? thisEvt.srcElement : null);
		var h = (src)?(parseInt(src.offsetHeight, 10)-4):15;
		var x = decayPt.X-20;
		var y = decayPt.Y+h;
		x = (x<0)?0:x;
		o.style.left = x+"px";
		o.style.top = y+"px";
		o.style.display = "block";
		decayTimer = setTimeout("decayUnpop();",750);		
	}
}
function decayUnpop() {
	decayTimer=null;
	var o = document.getElementById("stopPop");
	if (o) o.style.display="none";
	
}