var FROM_MOUSE	= newPoint(10, 20);

var overText,
	lightbox;

function iniImageHovers() {
	lightbox	= new Lightbox($$('.lightbox'));
	
	overText	= $$('.imgText');
	//overText.setAnimationProperties(['opacity, left, top'], [100, 100, 100], ['', 'ease-out', 'ease-out'], [0, 0, 0]);
	overText.setAnimationProperties(['opacity'], [200], [''], [0]);
	
	FROM_MOUSE.x	= -Math.round(overText.getSize()[0].x * .5) + 8;
	
	$$('.projectImage').each(function(el) {
		el.addEvent('mouseover', imageOver);
		el.addEvent('mouseout', imageOut);
		el.addEvent('click', imageClicked);
	});
	
}

function imageOver(e) {
	overText.animateStyle('opacity', 1);
	
	overText.setStyle('left', Math.round(e.client.x + FROM_MOUSE.x) + 'px');
	overText.setStyle('top', Math.round(e.client.y + FROM_MOUSE.y) + 'px');
	
	this.addEvent('mousemove', imageMouseMove);
}

function imageOut(e) {
	overText.animateStyle('opacity', 0);
	
	this.removeEvent('mousemove', imageMouseMove);
	overText.animateStyle('opacity', 0);
}

function imageMouseMove(e) {
	overText.setStyle('left', Math.round(e.client.x + FROM_MOUSE.x) + 'px');
	overText.setStyle('top', Math.round(e.client.y + FROM_MOUSE.y) + 'px');
}

function imageClicked(e) {
	imageOut(e);
	openLightbox(this.id);
}

function openLightbox(_id) {
	//var thisId		= this.id;
	//var slidesId	= thisId.replace('slides-', '');
	
	var id			= _id;
	var dashInd		= id.lastIndexOf('-');
	var numImgs		= id.substring(dashInd+1, id.length);
	var imgName		= id.substring(0, dashInd) + '_';
	
	lightbox.open(imgName, numImgs, '.jpg');
	return false;
}
