//<script language="JavaScript"><!--
  var change=0;
  var lech_value='change#';
  var obm_value='change#';
  function lechenie(id)
  {
  
    if (document.getElementById(id).name>'')
    {
      var num=id.charAt(6);
      var type=id.charAt(4);
      var hp=document.getElementById('sol_lech_hp'+num).firstChild.nodeValue;
      var pos_hp=hp.indexOf('/');
      var hp_now=hp.substr(0,pos_hp);
      var hp_full=hp.substr(pos_hp+1,hp.length-pos_hp);
      var hp_raz=parseInt(hp_full)-parseInt(hp_now);
      if (hp_raz>0)
      {
        lech_value=lech_value+'l'+num+type;
        var sum=document.getElementById('lech_sum').firstChild.nodeValue;
        var sum1=parseInt(sum.substr(6,sum.length-5))+parseInt(document.getElementById(id).name);
        document.getElementById('lech_sum').firstChild.nodeValue='Сумма '+sum1;
      } else
      if (type=='2')
      {
        lech_value=lech_value+'l'+num+type;
        var sum=document.getElementById('lech_sum').firstChild.nodeValue;
        var sum1=parseInt(sum.substr(6,sum.length-5))+parseInt(document.getElementById(id).name);
        document.getElementById('lech_sum').firstChild.nodeValue='Сумма '+sum1;
      }
      if (type=='1') {
        //alert(hp_full);
        hp_now=parseInt(hp_now)+5;
        if (hp_now>hp_full) {hp_now=hp_full};
      } else if (type=='3')
      {
        hp_now=hp_full;
      }
      document.getElementById('sol_lech_hp'+num).firstChild.nodeValue=hp_now+'/'+hp_full;
      var hp_color='';
      if ((hp_now/hp_full)<0.3)
      {
        hp_color='red';
      } else if ((hp_now/hp_full)<0.7)
      {
        hp_color='orange';
      } else if ((hp_now/hp_full)<1)
      {
        hp_color='yellow';
      } else
      {
        hp_color='#97e600';
      }
      document.getElementById('sol_lech_hp'+num).style.color=hp_color;
    }
  }
  function obmen1(id)
  {
    var num=0;
    var num1=0;
    if (change==0)
    {
      num=id.substr(4,id.length-1);
      change=num;
      document.getElementById(id).style.border="1px solid red";
    } else
    {
      num=change;
      num1=id.substr(4,id.length-1);
      change=0;
      if (parseInt(num1)==parseInt(num))
      {
        document.getElementById('sol_'+num).style.border="0px";
      } else {
      pos1=sol_curr_pos[num];
      pos2=sol_curr_pos[num1];

      


      r1=document.getElementById('sol_'+num);
      r2=document.getElementById('sol_'+num1);
      r1.parentNode.removeChild(r1);
      r2.parentNode.removeChild(r2);

     
      document.getElementById('dsol_'+pos2).appendChild(r1);
      document.getElementById('dsol_'+pos1).appendChild(r2);

      sol_curr_pos[num1]=pos1;
      sol_curr_pos[num]=pos2;

      document.getElementById('sol_'+num).style.border="0px";


      obm_value=obm_value+'o'+pos1+pos2;
      if ((parseInt(num)>5|parseInt(num1)>5)&&num_rez<1)
      {
        var sum=document.getElementById('obmen_sum').firstChild.nodeValue;
        var sum1=parseInt(sum.substr(6,sum.length-5))+150;
        document.getElementById('obmen_sum').firstChild.nodeValue='Сумма '+sum1;
      } else if (parseInt(num)>5|parseInt(num1)>5)
      {
        num_rez=num_rez-1;
        document.getElementById('num_rez').firstChild.nodeValue=num_rez;
      }
      }
    }
  }
  function sub(a)
  {
    lech_value=lech_value+'#';
    perehodprm('ch_sol',lech_value);
  }
  function sub_o(a)
  {
    obm_value=obm_value+'#';
    perehodprm('ch_sol',obm_value);
  }
  function mclose_w(a)
  {
    document.getElementById(a).style.display='none';
    if (a=="perest")
    { 
      for (var i=1; i<(nsol_ob+1); i++)
      {
        //var el1=document.getElementById('sol_'+i);
        //document.getElementById(document.getElementById('sol_'+i).parentNode.id).replaceChild(sol_ob[i],el1);
        document.getElementById('sol_'+i).style.border="0 solid red";
      }
      num_rez=num_rez1;
      document.getElementById('num_rez').firstChild.nodeValue=num_rez;
      document.getElementById('obmen_sum').firstChild.nodeValue='Сумма 0';
      obm_value='change#';
      change=0;
    }
  }
  function mopen_w(a)
  {
    if (vopen_w>"")
    {
      close_w(vopen_w);
      vopen_w="";
    }
    document.getElementById(a).style.display='block';
    vopen_w=a;
  }
 function ShowPopup(hoveritemid,from)
    {
			if (loaded==0 && MSIEWIN)
			{
				makepopup();
				loaded=1;
			}  
		  hp = document.getElementById("hoverp");
 		  hoveritem=document.getElementById("topframe");
  		headobj=document.getElementById("ptext");
      if (from=='1')
      {
  	  	headobj.innerHTML="<font class='popuptext' style='align:center'>Арена</font>";
        hp.style.top=hoveritem.offsetTop+140+70;
        hp.style.left=hoveritem.offsetLeft+430+120;
      }
      if (from=='4')
      {
  			headobj.innerHTML="<font class='popuptext' style='align:center'>Башня мага</font>";
        hp.style.top=hoveritem.offsetTop+130;
        hp.style.left=hoveritem.offsetLeft+430+390;
      }
      if (from=='3')
      {
  			headobj.innerHTML="<font class='popuptext' style='align:center'>Оружейная</font>";
        hp.style.top=hoveritem.offsetTop+140;
        hp.style.left=hoveritem.offsetLeft+430+330;
      }
      if (from=='2')
      {
   			headobj.innerHTML="<font class='popuptext' style='align:center'>Мастерская</font>";
        hp.style.top=hoveritem.offsetTop+140;
        hp.style.left=hoveritem.offsetLeft+430+280;
      }
      if (from=='5')
      {
 		 		headobj.innerHTML="<font class='popuptext' style='align:center'>Зал совета</font>";
        hp.style.top=hoveritem.offsetTop+140+25;
        hp.style.left=hoveritem.offsetLeft+430+430;
      }
      if (from=='6')
      {
   			headobj.innerHTML="<font class='popuptext' style='align:center'>Таверна</font>";
        hp.style.top=hoveritem.offsetTop+140+110;
        hp.style.left=hoveritem.offsetLeft+430+170;
      }
      if (from=='7')
      {
  			headobj.innerHTML="<font class='popuptext' style='align:center'>Базар</font>";
        hp.style.top=hoveritem.offsetTop+140+220;
        hp.style.left=hoveritem.offsetLeft+430+370;
      }
      if (from=='8')
      {
   			headobj.innerHTML="<font class='popuptext' style='align:center'>Выход из города</font>";
        hp.style.top=hoveritem.offsetTop+140;
        hp.style.left=hoveritem.offsetLeft+430+170;
      }
      if (from=='9')
      {
  	 		headobj.innerHTML="<font class='popuptext' style='align:center'>Алтарь</font>";
        hp.style.top=hoveritem.offsetTop+140+260;
        hp.style.left=hoveritem.offsetLeft+430+140;
      }
   		hp.style.visibility = "Visible";
   }
    function HidePopup()
    {
  		hp = document.getElementById("hoverp");
 			hp.style.visibility = "Hidden";
    }



//--></script>
