/* Скприты отображения блоков и всякое другое разное*/

var BrowserId = 2;
if (navigator.appName == "Netscape") BrowserId = 1;
else if  (navigator.appName == "Microsoft Internet Explorer") BrowserId = 2;
else BrowserId = 3;



if (My_AccId != '0' && stop_refresh == 0) {
 Mark_for_update_all_Blocks();
 timer = setInterval('Update_all_Blocks()', 3000);
}

var Http_readyState = 0;

var deltax = 0;
var deltay = 0;

var isobject = false;
var ActionMode = '';
var Array_Id;
var MaxZIndex = 2;

var mouse_x = 0;
var mouse_y = 0;

var menu_x = 0;
var menu_y = 0;

var CloneBlock;

var CurXIndex = 0;
var CurYIndex = 0;

var TopMargin = 3; /* отступ сверху */
var LeftMargin = 5; /* отступ слева */
var CellSpc = 10; /* отступ между ячейками */
var LeftPanelWidth = 230;

var TempContent;
var NewCell;

var isUnLoad = false;

var http_request = null;

var ConfBlock;

var ConfBlockContent;



function SetDefault()
{
  for (i=1; block_rows>=i; i++)
    {
      TopOffset = TopMargin;
      elem = "Table_"+i;
      tbl = document.getElementById(elem);
      for (j=1; tbl.rows.length>=j; j++)
        {
          /* вычисляем по ячейки название блока */
          CurCell = tbl.rows[j-1].cells[0];
          c_Name = CurCell.getAttribute("id");
          b_Name = c_Name.substring(0, c_Name.length-5);
          Ind = -1;
          /* ищем такой блок в массиве */
          for (k=0; BlockPropCount>k; k++)
            {
              if (b_Name == BlockProp[k][0])
                {
                  Ind = k;
                  break;
                }
            }
          if (Ind != -1) /* если есть */
            {
              document.getElementById(BlockProp[Ind][0]).style.width = BlockProp[Ind][7];
              BlockProp[Ind][7] = document.getElementById(BlockProp[Ind][0]).clientWidth;
              BlockProp[Ind][8] = document.getElementById(BlockProp[Ind][0]).clientHeight;
              if (BlockProp[Ind][12] == '1') {RollUpBlock(Ind, 1);}
              document.getElementById(BlockProp[Ind][0]).style.visibility = "visible";

              /* Top */
              BlockProp[Ind][6] = TopOffset;
              /* XIndex и YIndex */
              BlockProp[Ind][16] = i;
              BlockProp[Ind][17] = j;
              /* смещаем */
              TopOffset = TopOffset + BlockProp[Ind][8] + CellSpc;
              /* вычисляем Left */
              if (BlockProp[Ind][16] == 1)
                {
                  BlockProp[Ind][5] = LeftMargin;
                }
              if (BlockProp[Ind][16] == 2)
                {
                  BlockProp[Ind][5] = LeftPanelWidth + CellSpc;
                }
              if (BlockProp[Ind][16] == 3)
                {
                  BlockProp[Ind][5] = LeftPanelWidth + CellSpc*2 + document.getElementById("Table_2").clientWidth;
                }
            }
        }
    }
  isUnLoad = true;
}

function blockaction(event)
{
          if (BrowserId == 1)
            {
              menu_x = event.pageX;
              menu_y = event.pageY;
            }
          else if (BrowserId == 2)
            {
              menu_x = event.x;
              menu_y = event.offsetY;
            }

  if (isobject != false)
    {
      if (ActionMode == "move")
        {
          if (BrowserId == 1)
            {
              mouse_x = event.pageX;
              mouse_y = event.pageY;
            }
          else if (BrowserId == 2)
            {
              mouse_x = event.x;
              mouse_y = event.y;
            }
          CloneBlock.style.left = mouse_x - deltax;
          CloneBlock.style.top = mouse_y - deltay;
          if (My_AccId != '0') { /*Ежели мы не вошли то и нефиг перемещать*/
          /* перебираем все и смотрим над каким мы блоком */
          for (i=0; BlockPropCount>i; i++)
            {
              if ((Array_Id != i) && (mouse_x > BlockProp[i][5]) && (mouse_x < BlockProp[i][5]+BlockProp[i][7]) && (mouse_y > BlockProp[i][6]) && (mouse_y < BlockProp[i][6] + BlockProp[i][8]) && (BlockProp[i][16] != 2))
                {
                //document.getElementById("InfoBlock").innerHTML="Мы наехали на блок: "+BlockProp[i][0]+" CurXIndex:"+CurXIndex+" CloseMode: "+BlockProp[i][15]+" XIndex: "+BlockProp[i][16]+"i:"+i+"BlockProp[i][2]"+BlockProp[i][2];
                  /* если это спец. блок и мы наехали на него из того же столбца */
                  /* глюк с первым блоком слева пофисен довольно левым методом но хотя бы так */
                  if ((BlockProp[i][15] == 0) || BlockProp[i][2]==0)
                  {
                   Direction = 4;
                  }
                  else
                    {
                      /* если блок нужно разместить сверху но в нашей колонке */
                      if ((mouse_y <= BlockProp[i][6] + BlockProp[i][8]/2) && (BlockProp[i][17] != CurYIndex+1) && (BlockProp[i][16] == CurXIndex))
                        {
                          Direction = 1;
                        }
                      /* если блок нужно разместить снизу но в нашей колонке */
                      else if ((mouse_y > BlockProp[i][6] + BlockProp[i][8]/2) && (BlockProp[i][17] != CurYIndex-1) && (BlockProp[i][16] == CurXIndex))
                        {
                          Direction = 2;
                        }
                      /* если блок нужно разместить сверху но в чужой колонке */
                      else if ((mouse_y <= BlockProp[i][6] + BlockProp[i][8]/2) && (BlockProp[i][16] != CurXIndex))
                        {
                          Direction = 3;
                        }
                      /* если блок нужно разместить снизу но в чужой колонке */
                      else if ((mouse_y > BlockProp[i][6] + BlockProp[i][8]/2) && (BlockProp[i][16] != CurXIndex))
                        {
                          Direction = 4;
                        }
                      else
                        {
                          break;
                        }
                    }
                   // document.getElementById("InfoBlock").innerHTML+="Direction: "+Direction;
                  /* удаляем старый блок */
                  elem = "Table_"+CurXIndex;
                  document.getElementById(elem).deleteRow(CurYIndex-1);

                  CurXIndex = BlockProp[i][16];
                  /* добавляем новый */
                  elem = "Table_"+BlockProp[i][16];
                  if (Direction == 1 || Direction == 2 || Direction == 3)
                    {
                      NewRow = document.getElementById(elem).insertRow(BlockProp[i][17]-1);
                      CurYIndex = BlockProp[i][17];
                    }
                  else if (Direction == 4)
                    {
                      NewRow = document.getElementById(elem).insertRow(BlockProp[i][17]);
                      CurYIndex = BlockProp[i][17]+1;
                    }
                  NewCell = NewRow.insertCell(0);
                  NewCell.setAttribute("id", BlockProp[Array_Id][0]+"_cell");
                  NewCell.innerHTML = "<table style='border: dotted red'><tr><td><img src=i/e.gif width="+(BlockProp[Array_Id][7]-14)+" style='height: 1px' alt='-'/><br><img src=i/e.gif width=1 style='height: "+(BlockProp[Array_Id][8] - 14)+"px' alt='-'/></td></tr></table>";
                  /* пересчитываем все блоки и меняем им YIndex и их координаты */
                  CalcBlockPos();
                  break;
                }
            }
        }
    }
}
}
function getobject(event, mode, arrayId)
{
  Array_Id = arrayId;
  
  if (mode == 1)
    {
      isobject = true;
      ActionMode = 'move';
      if (BrowserId == 1)
        {
          mouse_x = event.pageX;
          mouse_y = event.pageY;
        }
      else if (BrowserId == 2)
        {
          mouse_x = event.x;
          mouse_y = event.y;
        }
      TempContent = document.getElementById(BlockProp[Array_Id][0]+"_cell").innerHTML;
      <!-- создаем клон нашего блока -->
      CloneBlock = document.getElementById(BlockProp[Array_Id][0]).cloneNode(true);
      document.body.appendChild(CloneBlock);
      CloneBlock.style.position = "absolute";
      CloneBlock.style.left = BlockProp[Array_Id][5];
      CloneBlock.style.top = BlockProp[Array_Id][6];
      
      CurXIndex = BlockProp[Array_Id][16];
      CurYIndex = BlockProp[Array_Id][17];

      deltax = mouse_x - parseInt(CloneBlock.style.left);
      deltay = mouse_y - parseInt(CloneBlock.style.top);
      
      <!--  рисуем рамочку вместо блока  -->
      NewCell = document.getElementById(BlockProp[Array_Id][0]+"_cell");
      NewCell.innerHTML = "<table style='border: dotted red'><tr><td><img src=i/e.gif width="+(parseInt(CloneBlock.style.width)-14)+" style='height: 1px' alt='-'/><br><img src=i/e.gif width=1 style='height: "+(CloneBlock.clientHeight - 14)+"px' alt='-'/></td></tr></table>";

      MaxZIndex++;
      document.getElementById(BlockProp[Array_Id][0]).style.zIndex = MaxZIndex;
    }
}

function dropobject(event)
{
  if (isobject == true)
    {
      isobject = false;
      NewCell.innerHTML = TempContent;
      CloneBlock.innerHTML = '';
      SaveParamToDB();
    }
}

function MySleep(m_sec)
{
  mSec=m_sec;
  date=new Date();
  startTime=date.getTime();
  while (true)
    if (new Date().getTime()-startTime >= mSec) break;
}

function SaveParamToDB()
{
  if (My_AccId != '0')
    {
      for (i=0; BlockPropCount>i; i++)
        {
          SpecText = "<img src=/b.asp?LUID="+My_LUID+"&Block_to_acc_ID="+BlockProp[i][2]+"&Block_ID="+BlockProp[i][3]+"&Acc_ID="+My_AccId+"&X_pos="+BlockProp[i][5]+"&Y_pos="+BlockProp[i][6]+"&X_size="+BlockProp[i][7]+"&Y_size="+BlockProp[i][8]+"&zIndex="+BlockProp[i][11]+"&RollUp="+BlockProp[i][12]+"&is_visible="+BlockProp[i][13]+"&closemode="+BlockProp[i][15]+"&xindex="+BlockProp[i][16]+"&yindex="+BlockProp[i][17]+" width=1 height=1 />";
          document.getElementById("SecretPanel").innerHTML = SpecText;
          MySleep(50);
        }
    }
}

function RollUpBlock(arrayId, dontsave)
{
	if (document.getElementById)
    {
      Array_Id = arrayId;
      if (dontsave == 1)
        {
          BlockProp[Array_Id][14] = document.getElementById(BlockProp[Array_Id][0]+"_cell").innerHTML;
          document.getElementById(BlockProp[Array_Id][0]+"_cnt").innerHTML = '';
          document.getElementById(BlockProp[Array_Id][0]).style.height = 26;
          CalcBlockPos();
        }
      else
        {
          if (BlockProp[Array_Id][12] == '0')
            {
              BlockProp[Array_Id][14] = document.getElementById(BlockProp[Array_Id][0]+"_cell").innerHTML;
              document.getElementById(BlockProp[Array_Id][0]+"_cnt").innerHTML = '';
              document.getElementById(BlockProp[Array_Id][0]).style.height = 26;
              BlockProp[Array_Id][12] = '1';
              BlockProp[Array_Id][8] = document.getElementById(BlockProp[Array_Id][0]).clientHeight;
              CalcBlockPos();
              SaveParamToDB();
            }
          else
            {
              document.getElementById(BlockProp[Array_Id][0]+"_cell").innerHTML = BlockProp[Array_Id][14];
              BlockProp[Array_Id][12] = '0';
              MaxZIndex++;
              document.getElementById(BlockProp[Array_Id][0]).style.zIndex = MaxZIndex;
              BlockProp[Array_Id][8] = document.getElementById(BlockProp[Array_Id][0]).clientHeight;
              CalcBlockPos();
              SaveParamToDB();
            }
        }
    }
}

function CloseBlock(arrayId)
{
	if (document.getElementById)
    {
      Array_Id = arrayId;
      if (BlockProp[Array_Id][15] == '1')
      {
        if (BlockProp[Array_Id][13] == '1')
          {
            elem = "Table_"+BlockProp[Array_Id][16];
            document.getElementById(elem).deleteRow(BlockProp[Array_Id][17]-1);
            BlockProp[Array_Id][13] = '0';
            BlockProp[Array_Id][2] = '0';
            BlockProp[Array_Id][1] = '0';
            CalcBlockPos();
            SaveParamToDB();
          }
      }
    }
}

/* перерасчет местоположения всех блоков */
function CalcBlockPos()
{
  if (isUnLoad) /* если загрузка страницы уже прошла */
  {
  for (i=1; block_rows>=i; i++)
    {
      TopOffset = TopMargin;
      elem = "Table_"+i;
      tbl = document.getElementById(elem);
      for (j=1; tbl.rows.length>=j; j++)
        {
          /* вычисляем по ячейки название блока */
          CurCell = tbl.rows[j-1].cells[0];
          c_Name = CurCell.getAttribute("id");
          b_Name = c_Name.substring(0, c_Name.length-5);
          Ind = -1;
          /* ищем такой блок в массиве */
          for (k=0; BlockPropCount>k; k++)
            {
              if (b_Name == BlockProp[k][0])
                {
                  Ind = k;
                  break;
                }
            }
          if (Ind != -1) /* если есть */
            {
              /* Top */
              BlockProp[Ind][6] = TopOffset;
              /* XIndex и YIndex */
              BlockProp[Ind][16] = i;
              BlockProp[Ind][17] = j;
              /* смещаем */
              TopOffset = TopOffset + BlockProp[Ind][8] + CellSpc;
              /* вычисляем Left */
              if (BlockProp[Ind][16] == 1)
                {
                  BlockProp[Ind][5] = LeftMargin;
                }
              if (BlockProp[Ind][16] == 2)
                {
                  BlockProp[Ind][5] = LeftPanelWidth + CellSpc;
                }
              if (BlockProp[Ind][16] == 3)
                {
                  BlockProp[Ind][5] = LeftPanelWidth + CellSpc*2 + document.getElementById("Table_2").clientWidth;
                }
            }
        }
    }
  }
}

function ProcessPage()
{
  if (http_request.readyState == 4 )
    {
      ConfBlockContent = http_request.responseText;
      if (ConfBlockContent != "")
        {
/*
          ConfBlock = document.getElementById("PopUpConfigBlock");
          ConfBlock.style.left = mouse_x;
          ConfBlock.style.top = mouse_y;
          ConfBlock.style.visibility = "visible";
          ConfBlock.innerHTML = ConfBlockContent;
          document.getElementById("InfoBlock").innerHTML=ConfBlockContent+Array_Id;
*/          
          document.getElementById(BlockProp[Array_Id][0]+"_body").innerHTML=ConfBlockContent;
        }
    }
}

function ShowConfigBlock(event, arrayId)
{
 Array_Id = arrayId;

  ConfBlockContent = "";
  if (BrowserId == 1)
    {
      mouse_x = event.pageX - 5;
      mouse_y = event.pageY - 5;
    }
  else if (BrowserId == 2)
    {
      mouse_x = event.x;
      mouse_y = event.y;
    }

  http_request.onreadystatechange = ProcessPage;
//  http_request.open("GET", "/s.asp?id="+BlockProp[arrayId][3], true);
  http_request.open("GET", "/k.asp?id="+BlockProp[arrayId][2], true);
  http_request.send(null);
}

// Обновляем все блоки кроме незаданных - впрочем в будущем возможно стоит добавить флажек необходимости обновления     
function Mark_for_update_all_Blocks()
{
  for (i=0; BlockPropCount>i; i++)
   {     	
      if (BlockProp[i][2]!=0 && BlockProp[i][18]!=0)
            {     
            	BlockProp[i][1]=1;       	
            };            
   };            
}
 
function Update_all_Blocks()
{
//	document.getElementById("InfoBlock").innerHTML+=Http_readyState;
	if (Http_readyState==0 || Http_readyState==4)
	{
		Cur_Array_Id=0;
  for (i=0; BlockPropCount>i; i++)
   {     	
      if (BlockProp[i][1]==1 && BlockProp[i][12]==0)
            {            	
//            	document.getElementById("InfoBlock").innerHTML+=BlockProp[i][18];
		   Cur_Array_Id=i;
		   BlockProp[i][1]=0;
            Refresh_Block(i);
            break;
            //MySleep(50);            
            };            
   };
   if (Cur_Array_Id==0)
   {
   	Mark_for_update_all_Blocks();
  }
  }            
}


function Refresh_Block(arrayId)
{
	if (window.XMLHttpRequest)
  { // Mozilla, Safari, ...
    http_request = new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  { // IE
    http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
  }
    
  http_request.onreadystatechange = Show_Block;
/*  http_request.justGiveMeHTML= true; */
  http_request.open("GET", "/k.asp?id="+BlockProp[arrayId][2], true);
  http_request.send(null);
}

function Show_Block()
{
  Http_readyState=http_request.readyState;	
  if (Http_readyState == 4)
    {
    if (http_request.status == 200) 
     {
     if ( document.getElementById(BlockProp[Cur_Array_Id][0]+"_body") != undefined ){
          document.getElementById(BlockProp[Cur_Array_Id][0]+"_body").innerHTML=http_request.responseText;
       }
      } else
      {
         if ( document.getElementById(BlockProp[Cur_Array_Id][0]+"_body") != undefined ){
      document.getElementById(BlockProp[Cur_Array_Id][0]+"_body").innerHTML="Ошибка обновления данных: "+http_request.status;
      }
      }
    }
}

function Show_Main(Page_ID)
{
document.getElementById("main_title").innerHTML="<font class=block_head>Обновляем...</font>";
if (window.XMLHttpRequest)
  { // Mozilla, Safari, ...
    http_request2 = new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  { // IE
    http_request2 = new ActiveXObject("Microsoft.XMLHTTP"); 
  }
  http_request2.onreadystatechange = function() { 
  if (http_request2.readyState == 4)
    {
    if (http_request2.status == 200) 
     {
          document.getElementById("main_body_cell").innerHTML=http_request2.responseText;
      } else
      {
      document.getElementById("main_body_cell").innerHTML="Ошибка обновления данных: "+http_request2.status;
      }
    }
  };
  http_request2.open("GET", "/m.asp?pid="+Page_ID, true);
  http_request2.send(null);

}



var mTitle = document.title;
var start_time	= new Date();
var countTimeout	= null;
var start_timeSale	= new Date();
var countTimeoutSale	= null;


function countTime(obj_id,left_time){
	clearTimeout(countTimeout);
	var obj	 = document.getElementById(obj_id);

	var now = new Date();

	var left = left_time - Math.round((now.getTime()- start_time.getTime()) /1000.0);

	// time out
	if (left<0) {
		obj.innerHTML	='00:00:00';

		var addr	= document.location;

		addr += '?&r2='+ Math.floor(Math.random()*1000);

		setTimeout("document.location='"+addr+"'",1000);
		return;
	}

	var hour = min	=0;
	if (left > 59) {
		min	 =	Math.floor(left / 60);
		left =	left %60;
	}
	if (min > 59) {
		hour =	Math.floor(min / 60);
		min =	min %60;
	}

	if(left<10)
		left	= "0"+ left;

	if(min<10)
		min		= "0"+ min;

	var stamp		= hour +":"+min +":"+ left;
	obj.innerHTML	= ' ' + stamp+' ';

	document.title	=' [' + stamp + ']    ' + mTitle;

	countTimeout	= window.setTimeout("countTime('"+obj_id+"',"+left_time+");",1000);
}

function countTimeSale(obj_id,left_time){
	clearTimeout(countTimeoutSale);
	var obj	 = document.getElementById(obj_id);

	var now = new Date();

	var left = left_time - Math.round((now.getTime()- start_timeSale.getTime()) /1000.0);

	// time out
	if (left<0) {
		obj.innerHTML	='00:00:00';
        start_timeSale = new Date();
        countTimeoutSale = null;
        UpdateDiscount();
		return;
	}

	var hour = min	=0;
	if (left > 59) {
		min	 =	Math.floor(left / 60);
		left =	left %60;
	}
	if (min > 59) {
		hour =	Math.floor(min / 60);
		min =	min %60;
	}

	if(left<10)
		left	= "0"+ left;

	if(min<10)
		min		= "0"+ min;

	var stamp		= hour +":"+min +":"+ left;
	obj.innerHTML	= ' ' + stamp+' ';

	countTimeoutSale	= window.setTimeout("countTimeSale('"+obj_id+"',"+left_time+");",1000);
}


 function UpdateDiscount()
  {
   var http_request_DC = new Subsys_JsHttpRequest_Js();
   http_request_DC.onreadystatechange = function() { 
   if (http_request_DC.readyState == 4)
    {
    if (http_request_DC.status == 200) 
     {
          document.getElementById("verticalblock").innerHTML=http_request_DC.responseText;
          countTimeSale('disc_time_left_for_blocks',document.getElementById("disc_time_left").value);
      } else
      {
      document.getElementById("verticalblock").innerHTML="<font color=red>Ошибка обновления данных: "+http_request_DC.status+"</font>";
      }
    }
   }; 
   request_string="/s_discount.asp";
   http_request_DC.justGiveMeHTML= true; 
   http_request_DC.open("GET",request_string , true);
   http_request_DC.send(null);
  }


  function SubUnsub_Comments()
  {
   var http_request_chat = new Subsys_JsHttpRequest_Js();

   document.getElementById("reply_to_text").innerHTML="Обновляем состояние подписки на ветку...";
   http_request_chat.onreadystatechange = function() { 
     document.getElementById("reply_to_text").innerHTML=http_request_chat.responseText;
   }; 
   request_string="/subscribe-to-comments.asp"
   http_request_chat.justGiveMeHTML= true; 
   http_request_chat.open("GET",request_string , true);
   var Obj_type = '' + document.getElementById('Obj_type').value;
   var Obj_ID = '' + document.getElementById('Obj_ID').value;
   var subs_now = '' + document.getElementById('subs_now').value;
   http_request_chat.send( { Obj_type: Obj_type, Obj_ID: Obj_ID, subs_now: subs_now } );
  }
  
    function Update_Comment(Comment_ID)
  {
   var http_request_chat = new Subsys_JsHttpRequest_Js();

   document.getElementById("reply_to_text").innerHTML="Записываем комментарий...";
   http_request_chat.onreadystatechange = function() { 
   if (http_request_chat.readyState == 4)
    {
    if (http_request_chat.status == 200) 
     {
      if  (http_request_chat.responseText == "ok")
      {
          document.getElementById("reply_to_text").innerHTML="Комментарий обновлен.";
          document.getElementById("comment_textarea").value="";
        } else
        {
           document.getElementById("reply_to_text").innerHTML=http_request_chat.responseText;
        }
      Update_Comments(0);      
      } else
      {
      document.getElementById("reply_to_text").innerHTML="<font color=red>Ошибка обновления данных: "+http_request_chat.status+"</font>";
      }
    }
   }; 
   request_string="/u_comment.asp"
   http_request_chat.justGiveMeHTML= true; 
   http_request_chat.open("GET",request_string , true);
   var msg_str = '' + document.getElementById("e_comment_textarea").value;
   msg_str=msg_str.replace(/\r\n|\r|\n/g,"<br />");
   http_request_chat.send( { chat_msg: msg_str , Comment_ID: Comment_ID } );
  }

  function Add_Comment()
  {
   var http_request_chat = new Subsys_JsHttpRequest_Js();

   document.getElementById("reply_to_text").innerHTML="Записываем комментарий...";
   http_request_chat.onreadystatechange = function() { 
   if (http_request_chat.readyState == 4)
    {
    if (http_request_chat.status == 200) 
     {
      if  (http_request_chat.responseText == "ok")
      {
          document.getElementById("reply_to_text").innerHTML="Комментарий добавлен.";
          document.getElementById("comment_textarea").value="";
        } else
        {
           document.getElementById("reply_to_text").innerHTML=http_request_chat.responseText;
        }
      Update_Comments(0);      
      } else
      {
      document.getElementById("reply_to_text").innerHTML="<font color=red>Ошибка обновления данных: "+http_request_chat.status+"</font>";
      }
    }
   }; 
   request_string="/s_comment.asp"
   http_request_chat.justGiveMeHTML= true; 
   http_request_chat.open("GET",request_string , true);
   var msg_str = '' + document.getElementById("comment_textarea").value;
   msg_str=msg_str.replace(/\r\n|\r|\n/g,"<br />");
   var Obj_type = '' + document.getElementById('Obj_type').value;
   var Obj_ID = '' + document.getElementById('Obj_ID').value;
   var subscribe = '' + document.getElementById('subscribe').checked;
   http_request_chat.send( { chat_msg: msg_str , Obj_type: Obj_type, Obj_ID: Obj_ID, subscribe: subscribe } );
  }
  
    function Mod_Act(Comment_ID,Mod_Status_ID,set_how_many,rec_to_skip)
  {
   var http_request_DC = new Subsys_JsHttpRequest_Js();
   http_request_DC.onreadystatechange = function() { 
   if (http_request_DC.readyState == 4)
    {
    if (http_request_DC.status == 200) 
     {
          document.getElementById("reply_to_text").innerHTML=http_request_DC.responseText;
          Update_Comments(set_how_many,rec_to_skip); 
      } else
      {
      document.getElementById("reply_to_text").innerHTML="<font color=red>Ошибка обновления данных: "+http_request_DC.status+"</font>";
      }
    }
   }; 
   request_string="/mod_comment.asp?Comment_ID="+Comment_ID+"&Mod_Status_ID="+Mod_Status_ID;
   http_request_DC.justGiveMeHTML= true; 
   http_request_DC.open("GET",request_string , true);
   http_request_DC.send(null);
  }
  
    function Edit_Comment(Comment_ID)
  {
    document.getElementById("reply_to_text").innerHTML="Редактируем...";
	FT="<form name='commentForm' action='?' method=post onsubmit='return false;' enctype='windows-1251'>";
    FT=FT+"<textarea rows='5' cols='30' id='e_comment_textarea'>"+document.getElementById("CTID"+Comment_ID).innerHTML+"</textarea>";
    FT=FT+"<input type=image src='/i/sb/6/send.gif' Alt='Послать' Title='Послать' onClick='Update_Comment("+Comment_ID+");return false;'></form>";
	document.getElementById("CID"+Comment_ID).innerHTML=FT;
  }

function fixPNG(element)
{
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;	
   	  
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1]; 
        element.runtimeStyle.backgroundImage="none"; 
      }
   
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  }
}

function showCloud (objectID) {
	document.getElementById(objectID).style.display='block';
}

function hideCloud (objectID) {
	document.getElementById(objectID).style.display='none';
}