
var isIE = 0;      // MS IE
var isMozilla = 0; // Mozilla, Firefox, ..
var isOpera = 0;   // Opera
var isOther = 0;   // Other Browsers

var user_agent = navigator.userAgent.toLowerCase();

if(user_agent.indexOf('opera') != -1) {
	isOpera = 1;
} else if(user_agent.indexOf('msie') != -1) {
	isIE = 1;
} else if(user_agent.indexOf('compatible') != -1) {
	isOther = 1;
} else {
	isMozilla = 1;
}

var image_win = null;
var units_info = new Array();

function get_win_left(width)
{
	var left = Math.floor((screen.availWidth - width) / 2);
	if(left < 0) left = 0;
	return left;
}

function get_win_top(height)
{
	var top = Math.floor((screen.availHeight - height) / 3);
	if(top < 0) top = 0;
	return top;
}

function open_image(url, width, height)
{
	if(image_win) {
		image_win.close();
		image_win = null;
	}
	var left = get_win_left(width);
	var top = get_win_top(height);
	image_win = window.open(url, 'image', 'top='+top+',left='+left+',width='+width+',height='+height+',location=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes');
}

function open_win(url, win_id, width, height)
{
	var left = get_win_left(width);
	var top = get_win_top(height);
	window.open(url, win_id, 'top='+top+',left='+left+',width='+width+',height='+height+',location=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=no');
}

function open_scroll_win(url, win_id, width, height)
{
	var left = get_win_left(width);
	var top = get_win_top(height);
	window.open(url, win_id, 'top='+top+',left='+left+',width='+width+',height='+height+',location=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes');
}

function init_units_info(ids)
{
	var i;

	for(i=0;i<ids.length;i++) {
		units_info['info_'+ids[i]] = false;
		document.getElementById('info_'+ids[i]).style.display='none';
	}
}

function change_unit_info_visibility(id)
{
	sid = 'info_'+id;
	if(units_info[sid]) {
		units_info[sid] = false;
		document.getElementById(sid).style.display='none';
	} else {
		units_info[sid] = true;
		document.getElementById(sid).style.display='';
	}
}
