/**
 * CursorHint Class
 * 
 * @author   Volodymyr Iatsyshyn
 * @date     2009-06-02
 * @see
 */

if (!window.Keepa)
	var Keepa = {};

dojo.provide('Keepa.CursorHint');

dojo.declare('Keepa.CursorHint', null, {
	ELEMENT_X_OFFSET: 10,
	ELEMENT_Y_OFFSET: 5,
	
	container: null,
	
	constructor: function (element) {
		this.container = element;
	
		dojo.connect(element.parentNode, 'mousemove', this, 'doMove_');
		dojo.connect(element.parentNode, 'mousedown', this, 'doHide_');
		// do not show hint again
		//dojo.connect(element.parentNode, 'mouseup', this, 'doShow_');
		
		this.doShow_({});
	},
	
	doMove_: function (event) {
		dojo.style(this.container, {
			left: event.clientX + this.ELEMENT_X_OFFSET + 'px',
			top: event.clientY + this.ELEMENT_Y_OFFSET + 'px'
		});
		
		return this;
	},
	
	doHide_: function (event) {
		dojo.style(this.container, 'display', 'none');
		return this;
	},
	
	doShow_: function (event) {
		dojo.style(this.container, 'display', 'block');
		return this;
	}
});

dojo.mixin(Keepa.CursorHint, {
	initialize: function () {
		new Keepa.CursorHint(dojo.byId('drag-hint'));
		return this;
	}
});

dojo.addOnLoad(Keepa.CursorHint, 'initialize');