function getTag(o, name) {
	if(!o) return null;
	var imgs = o.getElementsByTagName(name);
	if(imgs.length > 0) {
		return imgs[0];
	}
	return null;
}

function getElementPosition(o) {
    var offsetTrail = o;
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}


var _mouseFollowTarget;
var _mouseFollowInterval;

function startFollowMouse(o) {
	_mouseFollowTarget = o;
	followMouse();
	_mouseFollowInterval = setInterval(followMouse, 25);
}

function stopFollowMouse() {
	clearInterval(_mouseFollowInterval);
}

function followMouse() {
	_mouseFollowTarget.style.left = (g_cursor.x + 12) + "px";
	_mouseFollowTarget.style.top = (g_cursor.y + 28) + "px";
}



var g_cursor = {x:0, y:0};
function getMousePosition(e) {
	if(!e) {
		e = window.event;
	}
	
	if (e.pageX || e.pageY) {
		g_cursor.x = e.pageX;
		g_cursor.y = e.pageY;
	} else {
		g_cursor.x = e.clientX + 
			(document.documentElement.scrollLeft || 
			document.body.scrollLeft) - 
			(document.documentElement.clientLeft || 
			document.body.clientLeft);
		g_cursor.y = e.clientY + 
			(document.documentElement.scrollTop || 
			document.body.scrollTop) - 
			(document.documentElement.clientTop || 
			document.body.clientTop);
	}
}



// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG()
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement && img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }


