MouseHandling = {

	//event that is called when mouse is clicked. It identify the element that has been clicked and send it to the right view.
	onMouseClick: function(event) {

		var clickedId = MouseHandling.getIdOfTargetedElement(event);
		DOUT(clickedId);

		if(typeof (AMOSTV.views[AMOSTV.currView].mouseClicked) == 'function') {
			AMOSTV.views[AMOSTV.currView].mouseClicked(clickedId);
		}
	},

	//event that is called when the mousepointer is moved over a element.
	onMouseMove: function (event){

		var idHovered = MouseHandling.getIdOfTargetedElement(event);

		if(typeof (AMOSTV.views[AMOSTV.currView].mouseOver) == 'function'){
			AMOSTV.views[AMOSTV.currView].mouseOver(idHovered);
		}
	},

	getIdOfTargetedElement: function(e) {
		var theId = "";
		if (e.target) {

			if(e.target.className == 'menuText'){
				if(typeof e.element == 'undefined'){
					//IE
					theId = e.target.parentElement.parentElement.id;
				} else {
					//Others
					theId = e.element().up(1).id;
				}
			} else {
				theId = e.target.id;
			}

		} else if (e.srcElement) {
			theId = e.srcElement.getAttribute("id") || "";

		}
		return theId;
	}
}

