
	function show_hp(x, info) {
		if (info["hp_max"] == 0) return;
		d = document.getElementById("hp_cont_"+x);
		if (!d) return;
		
		c = info["hp"] / info["hp_max"];
		if (c > 1) c = 1;
		if (c < 0.33) {
			img = "images/bar_red.gif";
		} else if (c < 0.66) {
			img = "images/bar_yellow.gif";
		} else {
			img = "images/bar_green.gif";
		}
		
		hp_len = Math.round(155*c);
		hp_gr_len = Math.round(155 - hp_len);
		
		str = "<div style='width:30px;float:left;' align='center'><img src='images/hp.gif' height=12></div>";
		str = str + "<div style='width:" + hp_len + "px;height:12px;float:left;background:url(" + img + ") 50% repeat-x;'>&nbsp;</div>";
		if (hp_gr_len > 0) {
			str = str + "<div style='width:" + hp_gr_len + "px;height:12px;float:left;background:url(images/bar_grey.gif) 50% repeat-x;'>&nbsp;</div>";
		}
		str = str + "<div style='width:70px;float:right;font-size:11px;color:#ffffff;' align='right'>" + info["hp"] + " / " + info["hp_max"] + "</div>";

		d.innerHTML = str;
	}
	function show_mana(x, info) {
		if (info["mana_max"] == 0) return;
		d = document.getElementById("mana_cont_"+x);
		if (!d) return;
		
		c = info["mana"] / info["mana_max"];
		if (c > 1) c = 1;

		mana_len = Math.round(155*c);
		mana_gr_len = Math.round(155 - mana_len);
		
		str = "<div style='width:30px;float:left;' align='center'><img src='images/mana.gif' height=12></div>";
		str = str + "<div style='width:" + mana_len + "px;height:12px;float:left;background:url(images/bar_blue.gif) 50% repeat-x;'>&nbsp;</div>";
		if (mana_gr_len > 0) {
			str = str + "<div style='width:" + mana_gr_len + "px;height:12px;float:left;background:url(images/bar_grey.gif) 50% repeat-x;'>&nbsp;</div>";
		}
		str = str + "<div style='width:70px;float:right;font-size:11px;color:#ffffff;' align='right'>" + info["mana"] + " / " + info["mana_max"] + "</div>";
		
		d.innerHTML = str;
	}
	
	
	function show_stat(x, info) {
		show_hp(x, info);
		show_mana(x, info);

		
		return true;
		
		info["hp"] = Math.round(info["hp"] + info["hp"]*info["hp_reg"]/100/12);
		if (info["hp"] > info["hp_max"]) {
			info["hp"] = info["hp_max"];
		}
		
		if (info["mana_max"] > 0) {
			info["mana"] = Math.round(info["mana"] + info["hp"]*info["mana_reg"]/100/12);
			if (info["mana"] > info["mana_max"]) {
				info["mana"] = info["mana_max"];
			}
		}
		
		//timeout_id = window.setTimeout(info["call_line"], 5000)
	}
	
	
	
function show_popup(x,str) {
	var t = document.getElementById("popup");
	if (!t) return false;
	
	var m = document.getElementById(str);
	if (m) {
		text = m.innerHTML;
	} else {
		text = str;
	}
	
	t.innerHTML = text;
	t.style.display = "block";


	top_pos =  Math.round(getY(x) - t.clientHeight - 30);
	left_pos = Math.round(getX(x) + Math.round(x.clientWidth)+2);
	
	
	b = document.getElementById("main_body");
	if (b) {
		if (left_pos > b.clientWidth - t.clientWidth) {
			left_pos = left_pos - t.clientWidth - 30;
		}
		
	}
	
	if (left_pos < 0) {
		left_pos = 10;
	}
	if (top_pos < 20) {
		top_pos = 20;
	}
	
	//if (top_pos - t.clientHeight < getY(x) && left_pos + t.clientWidth < getX(x)) {
	
	
	if (top_pos < getY(x) && top_pos + t.clientHeight > getY(x) && left_pos < getX(x) && left_pos + t.clientWidth > getX(x)) {
		top_pos = getY(x) + 30;
	}
	
	
	
	
	t.style.left = left_pos;
	t.style.top = top_pos;
}


function set_enemy(x) {
	parent.frames["enemy_info"].location.href = "f_enemy_info.php?enemy="+x;
	parent.frames["main"].location.href = "battle2.php?enemy="+x;
}	


function fix_frames_width() {
	var b = document.getElementById("main_body");
	if (b.clientWidth < 510) {
		parent.document.getElementById('bfs').cols = '510,*';
	} 
	
	
	var b = parent.frames["enemy_info"].document.getElementById("body_enemy_info");
	if (b.clientWidth > 345) {
		parent.document.getElementById('bfs').cols = '*,345';
	} 
}


function hide_enemy_info() {
	var b = parent.frames["enemy_info"].document.getElementById("hide_link");
	
	if (parent.document.getElementById('bfs').cols == "*,100") {
		parent.document.getElementById('bfs').cols = '*,345';
		if (b) {
			b.innerHTML = "Скрыть инфомрацию";
		}
	} else {
		parent.document.getElementById('bfs').cols = '*,100';
		if (b) {
			b.innerHTML = "Открыть";
		}
	}
	
}

function show_promt(x) {
	var t = document.getElementById("promt_cont_"+x);
	if (!t) return false;
	
	t.style.display = "block";
}

function hide_promt(x) {
	var t = document.getElementById("promt_cont_"+x);
	if (!t) return false;
	
	t.style.display = "none";
}


function show_window_popup(url) {
	window.open("http://dotaonline.net/"+url,"window_popup","location=0,status=0,scrollbars=0,width=300,height=400");
}


function hide_popup() {
	var t = document.getElementById("popup");
	if (!t) return false;
	
	t.style.display = "none";
}

function getX(obj){
        return obj.offsetLeft + (obj.offsetParent ? getX(obj.offsetParent) : obj.x ? obj.x : 0);
    }        
function getY(obj){
        return (obj.offsetParent ? obj.offsetTop + getY(obj.offsetParent) : obj.y ? obj.y : 0);
}
    
    
function reload_chat() {
	var d = parent.frames['msg'].document.getElementById("messages");
	d.innerHTML = '';
	
	refresh_chat();
}
	
function refresh_chat() {
	parent.frames["ref"].location.reload(true);
	parent.frames["ftop"].location.reload(true);
}
   
function reload_info() {
	parent.frames["info"].location.reload(true);
}
    

function reload_page(x) {
	top.location.href=x;
}
    

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var mouseX = 0
var tempY = 0
function getMouseXY(e) {
  if (IE) {
    mouseX = event.clientX + document.body.scrollLeft
    mouseY = event.clientY + document.body.scrollTop
  } else {
    mouseX = e.pageX
    mouseY = e.pageY
  }  

  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}  
  
  return true;
}
