/* DEPRECATED used with old UIHelpBoxTag version. Replaced by four argument function below */
function tooltip_display(id) {
	elem = document.getElementById(id);
	Effect.BlindDown(id, { duration: 0.2 });
	return true;	
}

function tooltip_display(id, buttonId, xOffs, yOffs) {
	elem = document.getElementById(id);
	Effect.BlindDown(id, { duration: 0.2 });
	
	/* The code below determines the position of the popup window */
	/* It is a replacement for using 'position: relative' on the <div class="tooltip"> produced by old UIHelpBoxTag version */
	/* using position:relative tends to produce weird IE z-index effects */
	
	
	// deal with illegal arguments
	if(!isNumeric(xOffs) || !isNumeric(yOffs)) {
		xOffs = 0;
 		yOffs = 0;
	}

	// position popup window
 	try {
		var leftPos=document.getElementById(buttonId).offsetLeft;
		var topPos=document.getElementById(buttonId).offsetTop;
		document.getElementById(id).style.left=(leftPos+new Number(xOffs)); 
    	document.getElementById(id).style.top=(topPos+new Number(yOffs));
	} catch(err) {};
	return true;	
}

function tooltip_hide(id) {
	elem = document.getElementById(id);
	Effect.BlindUp(id, { duration: 0.2 });
}
function tooltip_init(id) {
	elem = document.getElementById(id);
	Element.hide(id);
	elem.onclick = function() {
		return tooltip_hide(id); 
	}
}

function isNumeric(str) {
	var re1 = /^-?[0-9.]+$/;
	var re2 = /\..*\./;
	var re3 = /^\.$/;
	
	// reject non-numeric characters
	if(!re1.test(str)) { 	
		return false; 
	}
		
	// reject some special cases
	if(re2.test(str) || re3.test(str)) { 
		return false;
	}
	
	return true;
}
