// PORTFOLIO

Event.observe(window, 'load', function(){
	hideOnMouseout("questionsRequestsText");
	hideOnMouseout("downloadPortfolioText", function() {
		$("downloadPortfolioText").style.visibility = "hidden";
	});

	var bigImage = $$('#slideshowBig img')[0];
	var elementX = Position.cumulativeOffset(bigImage)[0];
	var elementY = Position.cumulativeOffset(bigImage)[1];

	var prevOverlay = $('prevOverlay');
	var nextOverlay = $('nextOverlay');

	var hasPrevLink = true;
	var hasNextLink = true;

	if (prevOverlay == null) {
		hasPrevLink = false;
	}

	if (nextOverlay == null) {
		hasNextLink = false;
	}

	var imgWidth = bigImage.getWidth();

	var oneThird = imgWidth / 3;
	var twoThirds = oneThird * 2;

	Event.observe(bigImage, 'mousemove', function(e) {
		if (!Event.pointerX) {
			// prevent JS errors when browser sends some events without coords (?)...
			// may also be prototype's fault
			return;
		}
		var x = Event.pointerX(e);
		var y = Event.pointerY(e);

		var xInPicture = x - elementX;
		var yInPicture = y - elementY;

		if ( hasPrevLink && xInPicture < oneThird ) {
			bigImage.style.cursor = 'pointer';
			prevOverlay.style.display = 'block';
			prevOverlay.style.left = (x + 20) + 'px';
			prevOverlay.style.top = (y + 5) + 'px';

		} else if (hasNextLink && xInPicture > twoThirds ) {
			bigImage.style.cursor = 'pointer';
			nextOverlay.style.display = 'block';
			nextOverlay.style.left = (x + 20) + 'px';
			nextOverlay.style.top = (y + 5) + 'px';
		} else {
			bigImage.style.cursor = 'default';
			if (hasPrevLink) {
				prevOverlay.style.display = 'none';
			}
			if (hasNextLink) {
				nextOverlay.style.display = 'none';
			}
		}
	});

	Event.observe(bigImage, 'mouseout', function(e) {
		bigImage.style.cursor = 'default';
		if (hasPrevLink) {
			prevOverlay.style.display = 'none';
		}
		if (hasNextLink) {
			nextOverlay.style.display = 'none';
		}
	});

	Event.observe(bigImage, 'click', function(e) {
		var x = Event.pointerX(e);
		var y = Event.pointerY(e);

		var xInPicture = x - elementX;
		var yInPicture = y - elementY;

		if ( hasPrevLink && xInPicture < oneThird ) {
			document.location.href = $('prevLink').href;
		}
		if ( hasNextLink && xInPicture > twoThirds ) {
			document.location.href = $('nextLink').href;
		}
	});

});

function showquestionsRequests ()
{
	$("questionsRequestsText").style.display = "block";

}

function showdownloadPortfolio ()
{
	$("downloadPortfolioText").style.display = "block";
	$("downloadPortfolioText").style.visibility = "visible";
}


