Xoffset=-15;Yoffset=-180;
var nav,old,iex=(document.all),yyy=-1000;

if(navigator.appName== "Netscape"){(document.layers)?nav=true:old=true;}

var skn=(nav)?document.dek:document.getElementById("dek").style;
document.onmousemove=get_mouse;
skn.visibility="hidden";

function popup(msg)
{
if(skn.visibility=="hidden")
	{
	var content="<table id=dt style='filter:alpha(opacity=45);' cellpadding=0 cellspacing=0 border=0><td>";
	content+="<table cellpadding=0 cellspacing=0 border=0><tr><td width=16><img src='/img/nd/main/popup_lu.png' border=0></td><td width=100% background='/img/nd/main/popup_up.png'></td><td width=16><img src='/img/nd/main/popup_ru.png' border=0></td></tr>";
	content+="<tr><td height=100% width=16 background='/img/nd/main/popup_left.png'></td><td style='background:#DBC7A8;'>";
	content+=msg;
	content+="</td><td height=100% width=16 background='/img/nd/main/popup_right.png'></td></tr>";
	content+="<tr><td width=16><img src='/img/nd/main/popup_lb.png' border=0></td><td width=100% background='/img/nd/main/popup_bottom.png'></td><td width=16><img src='/img/nd/main/popup_rb.png' border=0></td></tr>";
	content+="</td></tr></table>";
	yyy=Yoffset;
	if(nav){ skn.document.write(content);skn.document.close(); skn.visibility="visible";}
	document.getElementById("dek").innerHTML= content;skn.visibility="visible";
	var IE='\v'=='v'; if(IE) {setalpha(20);}
	}

}

function get_mouse(event){
if (!event)event=window.event;
var x=(nav)?e.pageX:event.clientX+document.body.scrollLeft;
if(x>670) osn=x-280;
else osn=x+30;
skn.left=osn;
var y=(nav)?e.pageY:event.clientY+document.body.scrollTop;
chy=y+Yoffset;
if(skn.visibility=='visible')
{
if(chy-document.body.scrollTop<10)chy=10+document.body.scrollTop;
skn.top=chy;
skn.width=275;
}
}

function kill(){
yyy=-1000;skn.visibility="hidden";
}

var dttime=0;

function setalpha(time)
{
var opst=document.getElementById('dt').filters.alpha.opacity; 
var delta=5;
var source=95;
document.getElementById('dt').filters.alpha.opacity+=delta;

if(opst<source)
dttime=setTimeout("setalpha("+time+")",time);
else
clearTimeout(dttime);
}

var hp,max_d,timer_d=0;lifelineID=0;mplineID=0;

function lifeline2(now,max,timer,who)
{
hp_add=1;
st_timer=timer;
if(max>0)
{
if(timer && timer<5000)
{
while(timer<5000)
{
timer=timer+st_timer;
hp_add+=1;
}
}

if(who>0)
h_w=251;
else h_w=220;
if(!who || who==1){var ls=document.getElementById('lifespace2');}
if(who==2){var ls=document.getElementById('lifespace2opp');}

var grn_life_pr=(now*100)/max;
var grn_life_width=(grn_life_pr*h_w)/100;    
if(grn_life_width>h_w) grn_life_width=h_w;
var red_life_width=h_w-grn_life_width;
if(red_life_width>0 && grn_life_width>0) red_life_width+=1;

    ls.innerHTML='';
    ls.innerHTML='<img width=2 height=8 src=/img/nd/main/hp_l.gif border=0>';
          if(grn_life_width>0){
	ls.innerHTML+='<img title='+now+'/'+max+' src=/img/nd/main/hp_gr.gif width='+grn_life_width+' height=8>';
    		}
          if(red_life_width>0){
    ls.innerHTML+='<img title='+now+'/'+max+' src=/img/nd/main/hp_red.gif width='+red_life_width+' height=8>';
		}
    ls.innerHTML+='<img width=2 height=8 src=/img/nd/main/hp_r.gif border=0>';

if(timer){
    hp=now; max_d=max; timer_d=timer;  
    lifelineID=setTimeout("counter2()", timer);
}
}
}

function counter2()
{
  if(hp<max_d)
  {    hp+=hp_add;    
if(hp>max_d) hp=max_d;
var grn_life_pr=(hp*100)/max_d;    
if(grn_life_pr>100) grn_life_pr=100;

var grn_life_width=(grn_life_pr*h_w)/100;
if(grn_life_width>h_w) grn_life_width=h_w;
var red_life_width=h_w-grn_life_width;
if(red_life_width>0 && grn_life_width>0) red_life_width+=1;

var ls=document.getElementById('lifespace2');
    ls.innerHTML='';
    ls.innerHTML='<img width=2 height=8 src=/img/nd/main/hp_l.gif border=0>';
          if(grn_life_width>0){
	ls.innerHTML+='<img title='+hp+'/'+max_d+' src=/img/nd/main/hp_gr.gif width='+grn_life_width+' height=8>';
    		}
          if(red_life_width>0){
	ls.innerHTML+='<img title='+hp+'/'+max_d+' src=/img/nd/main/hp_red.gif width='+red_life_width+' height=8>';
		}
ls.innerHTML+='<img width=2 height=8 src=/img/nd/main/hp_r.gif border=0>';
lifelineID=setTimeout("counter2()", timer_d);
  }
else lifelineID=clearTimeout(lifelineID);
}

var mp,maxmp_d,timermp_d=0;
function mpline(nowmp,maxmp,timermp,who)
{
mp_add=1;
st_timer=timermp;
if(maxmp>0)
{
if(timermp && timermp<5000)
{
while(timermp<5000)
{
timermp=timermp+st_timer;
mp_add+=1;
}
}

if(who>0)
m_w=251;
else m_w=220;
if(!who || who==1){var ms=document.getElementById('mpspace');}
if(who==2){var ms=document.getElementById('mpspaceopp');}

   var grn_mp_pr=(nowmp*100)/maxmp;
    var grn_mp_width=(grn_mp_pr*m_w)/100;
    if(grn_mp_width>m_w) grn_mp_width=m_w;
    var red_mp_width=m_w-grn_mp_width;
if(red_mp_width>0 && grn_mp_width>0) red_mp_width+=1;

    ms.innerHTML='';
    ms.innerHTML='<img width=2 height=8 src=/img/nd/main/hp_l.gif border=0>';
          if(grn_mp_width>0){
	ms.innerHTML+='<img title='+nowmp+'/'+maxmp+' src=/img/nd/main/mp_gr.gif width='+grn_mp_width+' height=8>';
    		}
          if(red_mp_width>0){
	ms.innerHTML+='<img title='+nowmp+'/'+maxmp+' src=/img/nd/main/hp_red.gif width='+red_mp_width+' height=8>';
		}
ms.innerHTML+='<img width=2 height=8 src=/img/nd/main/hp_r.gif border=0>';

if(timermp){
    mp=nowmp; maxmp_d=maxmp; timermp_d=timermp;  
    mplineID=setTimeout("countermp()", timermp);}
}
}

function countermp()
{
  if(mp<maxmp_d)
  {    mp+=mp_add;   
if(mp>maxmp_d) mp=maxmp_d; 
var grn_mp_pr=(mp*100)/maxmp_d;
var grn_mp_width=(grn_mp_pr*m_w)/100;
if(grn_mp_width>m_w) grn_mp_width=m_w;
var red_mp_width=m_w-grn_mp_width;
if(red_mp_width>0 && grn_mp_width>0) red_mp_width+=1;

var ms=document.getElementById('mpspace');

    ms.innerHTML='';
    ms.innerHTML='<img width=2 height=8 src=/img/nd/main/hp_l.gif border=0>';
          if(grn_mp_width>0){
	ms.innerHTML+='<img title='+mp+'/'+maxmp_d+' src=/img/nd/main/mp_gr.gif width='+grn_mp_width+' height=8>';
    		}
          if(red_mp_width>0){
	ms.innerHTML+='<img title='+mp+'/'+maxmp_d+' src=/img/nd/main/hp_red.gif width='+red_mp_width+' height=8>';
		}
ms.innerHTML+='<img width=2 height=8 src=/img/nd/main/hp_r.gif border=0>';
mplineID=setTimeout("countermp()", timermp_d);
  }
else mplineID=clearTimeout(mplineID);
}

function vis(txt)
{
document.getElementById("vis").innerHTML = ''+txt;
document.getElementById("vis").style.visibility = "visible";
document.getElementById("vis").focus();
}

function visclose()
{
document.getElementById("vis").innerHTML = "";
document.getElementById("vis").style.visibility="hidden";
}

function create_set()
{var num=prompt("Как назовем комплект? (Не более 15 символов)",""); 
if(num!=null){
var b=confirm('Вы действительно хотите сохранить этот комплект под названием '+num+' ?');
if(b==true)window.location='inv_bag.php?manage_sets=saveset&setname='+num+'';}}

function draw_cast(c_name,c_id,c_script,c_opponent,c_login)
{
if(c_opponent)
wdt=200; else wdt=350;
var content="<table id=ctd width="+wdt+" cellpadding=0 cellspacing=0 border=0><td>";
content+="<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td width=16><img src='/img/nd/main/popup_lu.png' border=0></td><td width=100% background='/img/nd/main/popup_up.png'></td><td width=16><img src='/img/nd/main/popup_ru.png' border=0></td></table>";
content+="<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td height=100% width=16 background='/img/nd/main/popup_left.png'></td><td style='background:#DBC7A8;'>";
content+="<table width=100% border=0 cellpadding=0 cellspacing=0><tr><td align=left><font color=sienna><b>"+c_name+"</b></font></td><td align=right valign=top><a href=# onclick='visclose();'><b>X</b></a></td></tr></table><br><center>"+c_script+"<input name=svidbag type=hidden value="+c_id+">";
if(c_opponent)content+="<input name=opponent type=hidden value="+c_opponent+">";
content+="</form></td><td height=100% width=16 background='/img/nd/main/popup_right.png'></td></table>";
content+="<table cellpadding=0 cellspacing=0 border=0><tr><td width=16><img src='/img/nd/main/popup_lb.png' border=0></td><td width=100% background='/img/nd/main/popup_bottom.png'></td><td width=16><img src='/img/nd/main/popup_rb.png' border=0></td></table>";
content+="</td></table>";
vis(content);
if(c_login)
document.getElementById('target').value=''+c_login+'';
}