function tt_show(eleAnchor,editID) {
	if (!$('tt_frame') && !$('tt_hide')) {
		eleAnchor.id = 'tt_anchor';
		
		new Ajax.Request('functions/get_tooltip.cfm?editID='+editID,{
			onSuccess:tt_response	 
		});
	}
}

function tt_response(http_request) {
	var tt_text = http_request.responseText;
	// Only show tt if it isn't already visible
	if (!$('tt_frame') && !$('tt_hide') && $('tt_anchor')) {
		tt_frame = document.createElement('div');
			tt_frame.id = 'tt_frame';
			tt_frame.className = 'tt_frame';
			tt_frame.style.zIndex = 9999;
			// The anchor takes its width from the name of the anchor width attribute if it has one
			if ($('tt_anchor').attributes.width) tt_frame.style.width = $('tt_anchor').attributes.width.value+'px';
			tt_frame.onmouseout = tt_hide;
			tt_frame.onmouseover = tt_stophide;
			tt_frame.innerHTML = tt_text;
		document.body.appendChild(tt_frame);
		positionElement('tt_frame','tt_anchor');
	}
}

function tt_hide() {
	if ($('tt_frame')) {
		var ele = $('tt_frame');
		ele.id = 'tt_hide';	
	}
	setTimeout(tt_execHide,100);
}

function tt_execHide() {
	if ($('tt_hide')) document.body.removeChild($('tt_hide'));
	if ($('tt_anchor')) {
		var ele = $('tt_anchor');
		ele.id = '';
	}
}

function tt_stophide() {
	if ($('tt_hide')) {
		var ele = $('tt_hide');
		ele.id = 'tt_frame';
	}
}

function makeRequest(url,process) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = tt_response;
	http_request.open('GET', url, true);
	http_request.send(null);
}


function positionElement(el_ToMove,el_Anchor) {
	var pos_x = 0;
	var pos_y = 0;
	
	// Ok so find out if the anchor exists
	if ($(el_ToMove) && $(el_Anchor)) {
		// Now set this to element
		ele = $(el_Anchor);
		element_MoveMe = $(el_ToMove);
		// This will move to right of element
		if(ele.offsetWidth) pos_x = ele.offsetWidth;
		// This will move to bottom of element
		//if(ele.offsetHeight) pos_y = ele.offsetHeight;
		while (ele.tagName !== 'BODY') {
			if (ele.offsetLeft) pos_x = pos_x + ele.offsetLeft;	
			if (ele.offsetTop) pos_y = pos_y + ele.offsetTop;
			if (ele.offsetParent) ele = ele.offsetParent;
			else break;
		}
		element_MoveMe.style.left = pos_x+'px';
		element_MoveMe.style.top = pos_y+'px';
	}
}


