var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var screenW = 800;
var screenH = 600;
var winW = screenW;
var winH = screenH;



function autoCenter() {
	if (winW > 850) {
		var margin = Math.round((winW-850)/2);

		var elem = document.getElementById('container');
		if (elem) elem.style.left = '' + margin + 'px';
    return;

    elem = document.getElementById('leftcol');
		if (elem) elem.style.left = '' + margin + 'px';

		elem = document.getElementById('midcol');
		if (elem) elem.style.left = '' + (margin+200) + 'px';

		elem = document.getElementById('hdl');
		if (elem) elem.style.left = '' + (margin+600) + 'px';

		elem = document.getElementById('rightcol');
		if (elem) elem.style.left = '' + (margin+600) + 'px';

	}
}

function autoHeight() {
	if (winH > 600) {
		var naviHeight = winH - 2;

		var elem = document.getElementById('leftcol');
		if (elem) elem.style.height = '' + naviHeight + 'px';

		elem = document.getElementById('midcol');
		if (elem) elem.style.height = '' + (naviHeight-172) + 'px';

		elem = document.getElementById('rightcol');
		if (elem) elem.style.height = '' + (naviHeight-152) + 'px';

	}
}

function init() {
	screenW = screen.width;
	screenH = screen.height;

	if (typeof( window.innerWidth ) == 'number') {
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}

	autoCenter();
	//autoHeight();
}

window.onresize = init;

function openWin(url) {
	var popwin = window.open(url);
	if(popwin == null) {
		return true; // href can be used, as without onclick
	}
	else {
		popwin.focus();
	}
	return false; // window opened, no need to use href atribute
}

