var myrules = {
	'#eloquex_footer a' : function(element){
		element.onmouseover = function(){
			var obj_div = document.getElementById(element.id + 'D');
			if(obj_div)
			{
				var obj_pos = findPos(this);
				obj_div.style.left = obj_pos[0];
				obj_div.style.top = obj_pos[1];
				obj_div.style.position = "absolute";
				obj_div.style.display = "block";
				var h = obj_div.offsetHeight;
				var w = obj_div.offsetWidth;
				obj_div.style.top = obj_pos[1] - h;

				var obj_img = document.getElementById(element.id + 'IMG');
				if(obj_img)
				{
					var wnd_size = getWidowInnerSize();
					var a_width = element.offsetWidth;
					var obj_div_left = obj_pos[0] - (w / 2) + (a_width / 2);
					obj_img_marginLeft = (w / 2) - (a_width / 2);
					// check rigth overflow
					if (wnd_size[0] > 0 && (obj_div_left + w) > wnd_size[0] - 10)
					{
						obj_img_marginLeft -= wnd_size[0] - w - 10 - obj_div_left;
						obj_div_left = wnd_size[0] - w - 10;
					}
					// check left overflow
					if(obj_div_left < 10)
					{
						obj_img_marginLeft -= 10 - obj_div_left;
						obj_div_left = 10
					}
					obj_div.style.left = obj_div_left;
					obj_img.style.marginLeft = obj_img_marginLeft;
				}
			}
		}
		element.onmouseout = function(){
			var obj_div = document.getElementById(element.id + 'D');
			if(obj_div)
			{
				obj_div.style.display = "none";
			}
		}
	}
};

Behaviour.register(myrules);

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function getWidowInnerSize(obj) {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth, myHeight];
}