var has_inner = typeof(window.innerWidth) == 'number';
var has_element = document.documentElement && document.documentElement.clientWidth;

function resize() {
	var id1 = document.getElementById('center');
	var id2 = document.getElementById('left_img');
	var id3 = document.getElementById('right_img');
	var id4 = document.getElementById('content');
	if (id1 && id2 && id3 && id4) {
		cleft = has_inner ? pageXOffset + window.innerWidth : has_element ? document.documentElement.scrollLeft + document.documentElement.clientWidth : document.body.scrollLeft + document.body.clientWidth;
		var height = id1.offsetHeight;
		if (height < id2.offsetHeight) height = id2.offsetHeight;
		if (height < id3.offsetHeight) height = id3.offsetHeight;
		if (height < id4.offsetHeight) height = id4.offsetHeight;
		id1.style.height = height + 'px';
		id4.style.height = height - 174 + 'px';
		id1.style.zIndex = 5000;
		id2.style.zIndex = 6000;
		id3.style.zIndex = 6000;
	}
	var id1 = document.getElementById('click_left');
	var id2 = document.getElementById('click_left_div');
	if (id1) {
		if (!id2) {
			var id2 = document.createElement('div');
			id2.setAttribute('id', 'click_left_div');
			id2.style.width = id1.offsetWidth + 'px';
			id2.style.height = id1.offsetHeight + 'px';
			id2.style.position = "absolute";
			id2.style.cursor = "pointer";
			id2.innerHTML = '<a href="/archivum"><img src="/images/spacer.gif" width=' + id1.offsetWidth + ' height=' + id1.offsetHeight + '></a>';
			document.body.appendChild(id2);
			id2.onclick = function () {
				document.location.href='/archivum';
			}
		}
		if (id2) {
			id2.style.zIndex = 7000;
			pos = findPos(id1);
			id2.style.top = pos[1] + 'px';
			id2.style.left = pos[0] + 'px';
		}
	}
	var id1 = document.getElementById('click_right');
	var id2 = document.getElementById('click_right_div');
	if (id1) {
		if (!id2) {
			var id2 = document.createElement('div');
			id2.setAttribute('id', 'click_left_div');
			id2.style.width = id1.offsetWidth + 'px';
			id2.style.height = id1.offsetHeight + 'px';
			id2.style.position = "absolute";
			id2.style.cursor = "pointer";
			id2.innerHTML = '<a href="/future"><img src="/images/spacer.gif" width=' + id1.offsetWidth + ' height=' + id1.offsetHeight + '></a>';
			document.body.appendChild(id2);
			id2.onclick = function () {
				document.location.href='/future';
			}
		}
		if (id2) {
			id2.style.zIndex = 7000;
			pos = findPos(id1);
			id2.style.top = pos[1] + 'px';
			id2.style.left = pos[0] + 'px';
		}
	}
}

function findPos(obj) { 
	var curleft = curtop = 0; 
	if (obj.offsetParent) { 
		do { 
			curleft += obj.offsetLeft; 
			curtop += obj.offsetTop; 
		} while (obj = obj.offsetParent); 
		return [curleft,curtop]; 
	} 
} 


window.onload = function() {
	resize();
}

window.onresize = function() {
	if(/MSIE 6/i.test(navigator.userAgent) || /MSIE 7/i.test(navigator.userAgent) || /MSIE 5/i.test(navigator.userAgent)) {
	}
	else {
		resize();
	}
}

function amg_popgalery(url,name,options) {
    var ContextWindow = window.open(url, name, options);
    ContextWindow.focus();
    return false;
}

