/**
 * @author Romel
 */
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function setPos() {
	if (document.getElementById) {
		var windowWidth = getWindowWidth();
		if (windowWidth > 0) {

			var leftTreeElement = document.getElementById('tree_l');
			var rightTreeElement = document.getElementById('tree_r');
			var plateElement = document.getElementById('plate_main');
			var leftTreeWidth = leftTreeElement.offsetWidth;
			var rightTreeWidth = rightTreeElement.offsetWidth;
			var plateWidth = plateElement.offsetWidth;

			if ((windowWidth - (leftTreeWidth + plateWidth + rightTreeWidth)) >= 0) {
				leftTreeElement.style.left = '-2px';
				rightTreeElement.style.right = '-2px';
			} else {
				leftTreeElement.style.left = ((windowWidth - plateWidth) / 2)
						- leftTreeWidth + 'px';
				rightTreeElement.style.right = ((windowWidth - plateWidth) / 2)
						- rightTreeWidth + 'px';
			}
		}
	}
}

window.onload = function() {
	setPos();
}
window.onresize = function() {
	setPos();
}
