
/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2003-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// adjust horizontal and vertical offsets here
// (distance from mouseover event which activates tooltip)
Tooltip.offX = -25	;  
Tooltip.offY = -15	;
Tooltip.followMouse = false;  // must be turned off for hover-tip

var imageName	=	''	;	// global variable holds the input phoneme sound

var notLoaded	=	true	;	//	11/13/2006 - this will indicate if the Tooltip.init()
					//	has ran yet or not

function doTooltip2(e, msg, inputImage) {

  if  ( notLoaded )	{			//	11/13/2006 - was notLoaded boolean variable set yet? 
	preLoadPhoneme();			//	11/13/2006
	Tooltip.init();				//	11/13/2006 - run the init procedure
	notLoaded	= false;		//	11/13/2006 - set variable to skip from now on
  };						//	11/13/2006


  if  ( inputImage ) {	// 12-18-2006
			// this might be blank! if so, skip it

	imageName = inputImage;		// save the input phoneme sound
					// into this global variable

	if  ( document.myform[imageName].type != 'text' )	// 12-11-2006
	{							// 12-11-2006
		  var imageSource = document[imageName].src;		// 11/09/2006
			// look for '\/yes$' string (note back-escaped forward slash using back slash, and the dollar
			// sign indicates this string occurs at the END of the line
		  var pos = imageSource.search('\/yes$');		// changed string - 2007-01-09
		  if  ( pos > -1 )					// 11/09/2006
			// if '\/yes$' string exists
		  {							// 11/09/2006
			var urlArray = new Array();			// 2007-02-21
			urlArray = imageSource.split('/');		// 2007-02-21
			var lastElement = urlArray.length;		// 2007-02-21 - points to just BEYOND last element
			movePicture ( urlArray[lastElement -2]);	// 2007-02-21 - get second to last element
			//movePicture(imageSource.charAt(pos -1) );			// 11/09/2006
				// call the movePicture string with the phoneme
				// symbol righr before the string
			return;						// 11/09/1006
		  };							// 11/09/2006
	};	// 12-11-2006
  };	//12-18-2006


  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.clearTimer();
  var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
  if ( tip && tip.onmouseout == null ) {
      tip.onmouseout = Tooltip.tipOutCheck;
      tip.onmouseover = Tooltip.clearTimer;
  }
  Tooltip.show(e, msg);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.timerId = setTimeout("Tooltip.hide()", 300);
}

Tooltip.tipOutCheck = function(e) {
  e = dw_event.DOMit(e);
  // is element moused into contained by tooltip?
  var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
  if ( this != toEl && !contained(toEl, this) ) Tooltip.hide();
}

// returns true of oNode is contained by oCont (container)
function contained(oNode, oCont) {
  if (!oNode) return; // in case alt-tab away while hovering (prevent error)
  while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
  return false;
}

Tooltip.timerId = 0;
Tooltip.clearTimer = function() {
  if (Tooltip.timerId) { clearTimeout(Tooltip.timerId); Tooltip.timerId = 0; }
}

Tooltip.unHookHover = function () {
    var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
    if (tip) {
        tip.onmouseover = null; 
        tip.onmouseout = null;
        tip = null;
    }
}

dw_event.add(window, "unload", Tooltip.unHookHover, true);

function incrCount(img_src) {
	document.myform[img_src].value++;
}

function moveText(img_src) {
	document.myform[imageName].value=img_src;
}

function movePicture(img_src) {
/*
//	document[imageName].src= htmlLinkPrefix + img_src + htmlLinkSuffix;
//	document[imageName].src= htmlLinkPrefix + img_src ;
*/

		// set the picture to this input name
	document[imageName].src			= htmlErrorSoundPhp + img_src ;
		// set the 'hidden' html variable to this name
	document.myform[imageName].value	= img_src;
}

