SiteOnLoadOld = document.body.onload
document.body.onload = SiteOnLoad

var SiteItemDlgParam = "WIDTH=650,HEIGHT=450,STATUS=YES,RESIZABLE=YES,SCROLLBARS=NO,MENUBAR=NO,DIRECTORIES=NO,LOCATION=NO,TOOLBAR=NO";

// ==============================================
//  Действия с доп. информацией подразделений
// ==============================================
function SiteItemAddTop   (Id, IdLang)
{ window.open ("/admin/dlg/site.asp?Action=AddTop&IdLang="+IdLang+"&Id=" + Id, "", SiteItemDlgParam) }
function SiteItemAdd      (Id, IdLang)
{ window.open ("/admin/dlg/site.asp?Action=Add&IdLang="+IdLang+"&Id=" + Id, "", SiteItemDlgParam) }
function SiteItemEdit     (Id)
{ window.open ("/admin/dlg/site.asp?Action=Edit&Id=" + Id, "", SiteItemDlgParam) }

function SiteItemImg      (Id)
{ window.open ("/admin/dlg/images.asp?Action=ImgAdd&IdPart=3&IdPart2=0&Id=" + Id + "&IdType=2", "", MakeDlgParam(500,100)) }
function SiteItemDelImg   (Id)
{ if (window.confirm ('Удалить картинку ?'))
  window.location = "/_siteact.asp?Act=SiteItemDelImg&Id=" + Id + "&redir="+escape(window.location) }

function SiteItemFile     (Id)
{ window.open ("/admin/dlg/files.asp?Action=FileAdd&IdPart=3&IdPart2=0&Id=" + Id + "&IdType=2", "", MakeDlgParam(500,100)) }
function SiteItemDelFile  (Id)
{ if (window.confirm ('Удалить картинку ?'))
  window.location = "/_siteact.asp?Act=SiteItemDelFile&Id=" + Id + "&redir="+escape(window.location) }

function SiteItemDel      (Id)
{ if (window.confirm ('Удалить информацию ?'))
  window.location = "/_siteact.asp?Act=SiteItemDel&Id=" + Id + "&redir="+escape(window.location) }
function SiteItemUp       (Id)
{ window.location = "/_siteact.asp?Act=SiteItemUp&Id=" + Id + "&redir="+escape(window.location) }
function SiteItemDown     (Id) 
{ window.location = "/_siteact.asp?Act=SiteItemDown&Id=" + Id + "&redir="+escape(window.location) }

function AdmSiteItemCheck ()
{ AdmCheckDeal ("AdmSiteItem", flgAdmDealSite) }

function AdmSiteItemWrite (Id, i, IdLang, Img, File)
{
//  alert (Img)
  document.write ("<SPAN ID='AdmSiteItem" + i + "' STYLE='display:none'> ")
  document.write ("<A HREF='JavaScript:SiteItemAdd(" +  Id + ","+IdLang+")'><IMG SRC='/images/add.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  document.write ("<A HREF='JavaScript:SiteItemEdit(" + Id + ")'><IMG SRC='/images/edit.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  document.write ("<A HREF='JavaScript:SiteItemDel(" +  Id + ")'><IMG SRC='/images/del.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  document.write ("<A HREF='JavaScript:SiteItemUp(" +   Id + ")'><IMG SRC='/images/up.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  document.write ("<A HREF='JavaScript:SiteItemDown(" + Id + ")'><IMG SRC='/images/down.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  if (String (Img) != "undefined")
  {
    if (Img) document.write ("<A HREF='JavaScript:SiteItemDelImg(" + Id + ")'><IMG SRC='/images/imgdel.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")   
    else     document.write ("<A HREF='JavaScript:SiteItemImg(" + Id + ")'><IMG SRC='/images/img.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  }
  if (String (File) != "undefined")
  {
    if (File) document.write ("<A HREF='JavaScript:SiteItemDelFile(" + Id + ")'><IMG SRC='/images/filedel.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")   
    else      document.write ("<A HREF='JavaScript:SiteItemFile(" + Id + ")'><IMG SRC='/images/file.gif' WIDTH=12 HEIGHT=12 BORDER=0></A> ")
  }
  document.write ("</SPAN>")
}

function ExpandFirst(pre)
{
  id = eval("ul"+pre+"0").childNodes(0).id.substr (5)
  if (document.getElementById ("aa"+pre+id))
    ExpandLI(document.getElementById ("aa"+pre+id));
  for (i = 0; i < eval("ul"+pre+"0").childNodes.length - 1; i++)
  {
    id = eval("ul"+pre+"0").childNodes(i+1).id.substr (5)
    if (document.getElementById ("aa"+pre+id))
      ExpandLI(document.getElementById ("aa"+pre+id));
  }
}

function SiteOnLoad ()
{
  AdmInitDeal ("AdmSiteItem", flgAdmDealSite)

  if (SiteOnLoadOld)
    SiteOnLoadOld ()
}

// ==============================================
//  ***
// ==============================================

function OnChangeLang(Id,IdLang)
{
  window.location="site.asp?Action=Edit&Id="+Id+"&IdLang="+IdLang;
}

function OnConditions(type)
{
  var frm = document.Param
  switch(type)
  {
    case 1:
      trLink.style.display = "none";
      Text.style.visibility = "hidden";
      break;
    case 2:
      trLink.style.display = "none";
      Text.style.visibility = "visible";
      break;
    case 3:
      trLink.style.display = "";
      Text.style.visibility = "hidden";
      break;
    case 4:
      trLink.style.display = "none";
      Text.style.visibility = "hidden";
      break;
    case 5:
      trLink.style.display = "";
      Text.style.visibility = "visible";
      break;
  }
}

