 /*******************************************************************
 $Id: tooltip.js,v 1.1 2007/01/04 22:48:57 psanjays Exp $

 Copyright (c) 2000-2006 MassMedia Studios Pty Ltd.
 68-72 Wentworth Ave, Surry Hills, NSW 2010, Australia.
 All rights reserved.

 This software is the confidential and proprietary information of 
 MassMedia Studios Pty Ltd. ("Confidential Information").  You shall not
 disclose such Confidential Information and shall use it only in
 accordance with the terms of the license agreement you entered into
 with MassMedia Studios Pty Ltd.
 ------------------------------------------------------------------------
 Author:				Ben Gillies -> ben.gillies at massmedia.com.au
 Created:				20 September 2006
 Last Modified:			20 September 2006
 ------------------------------------------------------------------------
 Comments:	Smart Edit Tooltip functionality support script.
 
 ***********************************************************************/
 
function setupRedDots() {
	var myRedDots = document.getElementsByTagName('div');
	var myDiv = null;
	for (var i=0; i < myRedDots.length; i++) {
		if (myRedDots[i].className.indexOf("redDot") != -1) {
			myRedDots[i].id = "redDot" + i;
			if (myRedDots[i].childNodes.length > 1 && myRedDots[i].childNodes[0].childNodes.length > 0) {
				if (myRedDots[i].childNodes[1].nodeValue != "") {
					// if a tool tip description exists..
					
					// create tool tip div...
					myDiv = document.createElement("div");
					myDiv.id = "t_" + myRedDots[i].id;
					myDiv.className = "tip";
					myDiv.style.top = eval(i * 20) + "px";

					if (myRedDots[i].childNodes.length > 2 && myRedDots[i].childNodes[2].nodeType == 3) {
						// set tooltip div content...
						myDiv.innerHTML = myRedDots[i].childNodes[2].nodeValue;
						// clear tool tip description from page...
						myRedDots[i].childNodes[2].nodeValue = "";
					} else {
						// set tooltip div content...
						myDiv.innerHTML = myRedDots[i].childNodes[1].nodeValue;
						// clear tool tip description from page...
						myRedDots[i].childNodes[1].nodeValue = "";
					}
					// append tooltip div to globalWrap...
					document.getElementById("globalWrap").appendChild(myDiv);
					
					// remove title from reddot image...
					myRedDots[i].childNodes[0].childNodes[0].title = "";
					// associate reddot div to tool tip div...
					myRedDots[i].childNodes[0].onmouseover = toggleToolTip;
					myRedDots[i].childNodes[0].onmouseout = toggleToolTip;
				}
			}
		}
	}
}
	
function toggleToolTip(e) {
	if (ie) {
		popUp(event, "t_" + this.parentNode.id);
	} else {
		popUp(e, "t_" + this.parentNode.id);
	}
}


/* Included Tooltip functionality.. why re-invent the wheel... */
	// Extended Tooltip Javascript
	// copyright 9th August 2002, 3rd July 2005
	// by Stephen Chapman, Felgall Pty Ltd
	
	// permission is granted to use this javascript provided that the below code is not altered
	var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} function fd(oi, wS) {if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); if (al) return wS ? document.all[oi].style: document.all[oi]; if (an) return document.layers[oi];}
	function pw() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}
	function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
	function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}
	function popUp(evt,oi) {if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else {tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!an) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";}}}
/* end included Tooltip functionality */
