// JavaScript Document

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 getWindowHeight () {
	if (window.innerHeight) return window.innerHeight;
	else if (document.documentElement.clientHeight) return document.documentElement.clientHeight;
	else return document.body.clientHeight;
}

function getWindowWidth () {
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement.clientWidth) return document.documentElement.clientWidth;
	else return document.body.clientWidth;
}

function showBigPhoto (element, filename) {
	var bigPhoto = document.getElementById('bigPhoto');
	var photoBig = document.getElementById('photoBig');
	var elementPosition = findPos(element);
	var elementSize = [element.offsetWidth, element.offsetHeight];
	photoLeft = elementPosition[0] + elementSize[0] + 5;
	photoTop = elementPosition[1] + elementSize[1] + 5;
	if ((photoTop + 240) > getWindowHeight()) photoTop = getWindowHeight() - 240 - 10;
	if ((photoLeft + 320) > getWindowWidth()) photoLeft = elementPosition[0] - 320 - 10;
	bigPhoto.style.left = photoLeft + 'px';
	bigPhoto.style.top = photoTop + 'px';
	photoBig.src='content/estates/' + filename;
	bigPhoto.style.visibility='visible';
}

function hideBigPhoto () {
	document.getElementById('bigPhoto').style.visibility='hidden';
}