var xMousePos = 0;
var yMousePos = 0;
var xMousePosMax = 0;
var yMousePosMax = 0;
var oldTitle = '';
var oldAlt = '';
var oldparent;

function showTitle(imgPath, parent, offX, offY, e){
	var d;
	if(!e){
		e = window.event;
	}
	captureMousePosition(e)
	//alert(xMousePos);
	if(!document.getElementById('langTitle')){
		
		d = document.createElement('span');
		im = document.createElement('img');
		im.src=imgPath;
		im.style.zIndex='10';
		d.appendChild(im);
		d.style.border='1px solid #000000';
		d.style.background='#FFFFFF';
		d.style.padding='2px 2px 4px 4px';
		d.style.zIndex='10';
		d.id='langTitle';
		parent.parentNode.appendChild(d);
		oldTitle = parent.title;
		oldAlt = parent.alt;
		parent.title='';
		parent.alt='';
		oldparent = parent;
	}else{
		d = document.getElementById('langTitle');
	}
	d.style['position']='absolute';
	d.style['top'] = yMousePos + 25+'px';
	d.style['left'] = xMousePos - 35+'px';
	//alert(xMousePos-35);
	if(d.style['left'] + d.clientWidth > document.body.clientWidth){
		d.style['right'] = window.clientWidth;
	}
}

function hideTitle(){
	var v = document.getElementById('langTitle');
	if(v){
		v.parentNode.removeChild(v);
		oldparent.title = oldTitle;
		oldTitle = '';
		oldparent.alt = oldAlt;
		oldAlt = '';
	}
}

function captureMousePosition(e) {
	if (document.layers) {
		// When the page scrolls in Netscape, the event's mouse position
		// reflects the absolute position on the screen. innerHight/Width
		// is the position from the top/left of the screen that the user is
		// looking at. pageX/YOffset is the amount that the user has 
		// scrolled into the page. So the values will be in relation to
		// each other as the total offsets into the page, no matter if
		// the user has scrolled or not.
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	} else if (document.all) {
		// When the page scrolls in IE, the event's mouse position 
		// reflects the position from the top/left of the screen the 
		// user is looking at. scrollLeft/Top is the amount the user
		// has scrolled into the page. clientWidth/Height is the height/
		// width of the current page the user is looking at. So, to be
		// consistent with Netscape (above), add the scroll offsets to
		// both so we end up with an absolute value on the page, no 
		// matter if the user has scrolled or not.
		xMousePos = window.event.x+document.documentElement.scrollLeft;
		yMousePos = window.event.y+document.documentElement.scrollTop;
		//if document.documentElement
		//xMousePos = window.event.clientX;
		//yMousePos = window.event.clientY;
		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight+document.body.scrollTop;
	} else if (document.getElementById) {
		// Netscape 6 behaves the same as Netscape 4 in this regard 
		xMousePos = e.pageX;
		xMousePos = e.clientX + document.body.scrollLeft;
		//alert(xMousePos);
		yMousePos = e.pageY;
		yMousePos = e.clientY + document.body.scrollTop;
		//alert(xMousePos);
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
		//var x = e.clientX + document.body.scrollLeft;
		//var y = e.clientY + document.body.scrollTop;
	}
//	if(window.event){
//	}
}
