/*
Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
Copyright 2002 by Sharon Paine
Visit http://www.dynamicdrive.com for this script
*/

/* IMPORTANT: Put script after tooltip div or 
	 put tooltip div just before </BODY>. */

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 0;
var offX= 10;	// how far from mouse to show tip
var offY= 10; 
var tipFontFamily= "Arial, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#EEEEEE"; 
var tipBorderColor= "#280700";
var tipBorderWidth= 2;
var tipBorderStyle= "ridge";
var tipPadding= 5;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip

messages[0] = new Array('images/site-cleaningstlouis.com-75h.jpg','<strong>cleaningstlouis.com</strong><br />website');
messages[1] = new Array('images/site-1pulse.com-75h.jpg','<strong>1pulse.com</strong><br />website');
messages[2] = new Array('images/site-aftershockonline.com-75h.jpg','<strong>aftershockonline.com</strong><br />website');
messages[3] = new Array('images/site-bill-duncan.com-75h.jpg','<strong>bill-duncan.com</strong><br />website');
messages[4] = new Array('images/site-midlaneparkbaptist.org-75h.jpg','<strong>midlaneparkbaptist.org</strong><br />website');
messages[5] = new Array('images/site-upper_room_coffee_house-75h.jpg','<strong>upper_room_coffee_house</strong><br />website');
messages[6] = new Array('images/site-my_wedding-75h.jpg','<strong>my_wedding</strong><br />website');
messages[7] = new Array('images/site-transition_skate_park-75h.jpg','<strong>transition_skate_park</strong><br />website');
messages[8] = new Array('images/site-semperfi.cl-75h.jpg','<strong>semperfi.cl</strong><br />website');
messages[9] = new Array('images/site-christopheles_quest-75h.jpg','<strong>christopheles_quest</strong><br />website');
messages[10] = new Array('images/site-amber_faith-75h.jpg','<strong>amber_faith</strong><br />website');
messages[11] = new Array('images/site-100mostbeautifulbabies.com-75h.jpg','<strong>100mostbeautifulbabies.com</strong><br />website');
messages[12] = new Array('images/site-babieshelpingbabies.com-75h.jpg','<strong>babieshelpingbabies.com</strong><br />website');
messages[13] = new Array('images/site-chrisandabby.com-75h.jpg','<strong>chrisandabby.com</strong><br />website');
messages[14] = new Array('images/site-proofthatgodexists.org-75h.jpg','<strong>proofthatgodexists.org</strong><br />website');
messages[15] = new Array('images/site-vips.org-75h.jpg','<strong>vips.org</strong><br />website');
messages[16] = new Array('images/site-parklandbaptistchurch.org-75h.jpg','<strong>parklandbaptistchurch.org</strong><br />website');
messages[17] = new Array('images/chris_and_abby-bg-50h.jpg','<strong>chris and abby</strong><br />wallpaper');
messages[18] = new Array('images/tunnel_of_light-bg-50h.jpg','<strong>tunnel of light</strong><br />wallpaper');
messages[19] = new Array('images/metal_flower-bg-50h.jpg','<strong>metal flower</strong><br />wallpaper');
messages[20] = new Array('images/agapao-bg-50h.jpg','<strong>agapao (love)</strong><br />wallpaper');
messages[21] = new Array('images/elpizo-bg-50h.jpg','<strong>elpizo (hope)</strong><br />wallpaper');
messages[22] = new Array('images/pisteuo-bg-50h.jpg','<strong>pisteuo (faith)</strong><br />wallpaper');
messages[23] = new Array('images/laptop-bg-50h.jpg','<strong>laptop</strong><br />wallpaper');
messages[24] = new Array('images/space_scene_2-bg-50h.jpg','<strong>space scene 2</strong><br />wallpaper');
messages[25] = new Array('images/eclipse-bg-50h.jpg','<strong>eclipse</strong><br />wallpaper');
messages[26] = new Array('images/north_star-bg-50h.jpg','<strong>north star</strong><br />wallpaper');
messages[27] = new Array('images/pawn_stand_off-bg-50h.jpg','<strong>pawn stand-off</strong><br />wallpaper');
messages[28] = new Array('images/three_phenomena-bg-50h.jpg','<strong>three phenomena</strong><br />wallpaper');
messages[29] = new Array('images/closer_to_the_sun-bg-50h.jpg','<strong>closer to the sun</strong><br />wallpaper');
messages[30] = new Array('images/care_free-bg-50h.jpg','<strong>care free</strong><br />wallpaper');
messages[31] = new Array('images/closer_to_the_moon-bg-50h.jpg','<strong>closer to the moon</strong><br />wallpaper');
messages[32] = new Array('images/video_thumb-lightsaber.jpg','<strong>lightsaber</strong><br />video');
messages[33] = new Array('images/video_thumb-cloning.jpg','<strong>cloning (more lightsabers)</strong><br />video');
messages[34] = new Array('images/video_thumb-mirror.jpg','<strong>mirror (more cloning)</strong><br />video');
messages[35] = new Array('images/video_thumb-upper_room_anniversary.jpg','<strong>upper room anniversary</strong><br />video');
messages[36] = new Array('images/other_thumb-light_ray.jpg','<strong>light ray</strong><br />graphic');
messages[37] = new Array('images/other_thumb-thug.jpg','<strong>thug</strong><br />logo');
messages[38] = new Array('images/other_thumb-interface_signature.jpg','<strong>interface</strong><br />signature');
messages[39] = new Array('images/other_thumb-animated_aftershock_logo.jpg','<strong>aftershock youth ministry</strong><br />logo/animation');
messages[40] = new Array('images/other_thumb-shewa_fight.jpg','<strong>shewa fight</strong><br />flash animation');
messages[41] = new Array('images/other_thumb-get_real_logo.jpg','<strong>get real youth ministry</strong><br />logo');
messages[42] = new Array('images/other_thumb-computer_signature.jpg','<strong>computer</strong><br />signature');
messages[43] = new Array('images/other_thumb-upper_room_logo.jpg','<strong>upper room coffee house</strong><br />logo');
messages[44] = new Array('images/other_thumb-one_door.jpg','<strong>one door</strong><br />photo manipulation');
messages[45] = new Array('images/other_thumb-cartoon_park.jpg','<strong>cartoon park</strong><br />illustration');
messages[46] = new Array('images/other_thumb-uth_stuph.jpg','<strong>uth stuph</strong><br />illustration');
messages[47] = new Array('images/other_thumb-controller.jpg','<strong>game controller</strong><br />3d render');
messages[48] = new Array('images/other_thumb-mp3_player.jpg','<strong>mp3 player</strong><br />graphic');

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<div><img src="';
var midStr = '" border="0"><br />';
var endStr = '</div';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles for all but ns4. 
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ns4) {
		var tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td>'+ startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
		tooltip.write(tip);
		tooltip.close();
	} else if (ie4||ie5||ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
	else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}
