
var RWRinit = 0;
var PRNinit = 0;
var DRCinit = 0;
var DELinit = 0;
var WRCinit = 0;
var SLVinit = 0;
var COEinit = 0;
var EMEinit = 0;
var DPTinit = 0;
var CLPinit = 0;
var OldX = -1;
var OldY = -1;
var OldX2 = -1;
var OldY2 = -1;

function ClickLink() {}

function RWRresize()
{
  var x, y;

  if(!RWRinit) return;

  x = (window.pxWidth() - cssLayers.RWR.pxWidth())/2 + window.offsetLeft();
  y = (window.pxHeight() - cssLayers.RWR.pxHeight())/2  + window.offsetTop();
  if(x != OldX || y != OldY)
  {
    OldX=x; OldY=y;
    cssLayers.RWR.moveTo(x,y);
  }

}

function RWRLayer()
{
  cbSetup();
  cssLayers.RWR.pxWidth(450).pxHeight(70);
  RWRinit = 1;
  RWRresize();
  setInterval("RWRresize()", 20);
}

function PRNresize()
{
  var x2, y2;

  if(!PRNinit) return;

  x2 = (window.pxWidth() - cssLayers.PRN.pxWidth())/2 + window.offsetLeft();
  y2 = (window.pxHeight() - cssLayers.PRN.pxHeight())/2  + window.offsetTop();
  if(x2 != OldX2 || y2 != OldY2)
  {
    OldX2=x2; OldY2=y2;
    cssLayers.PRN.moveTo(x2,y2);
  }

}

function PRNLayer()
{
  cbSetup();
  cssLayers.PRN.pxWidth(390).pxHeight(150);
  PRNinit = 1;
  PRNresize();
  setInterval("PRNresize()", 20);
}

function DRCresize()
{
  var x, y;

  if(!DRCinit) return;

  x = (window.pxWidth() - cssLayers.DRC.pxWidth())/2 + window.offsetLeft();
  y = (window.pxHeight() - cssLayers.DRC.pxHeight())/2  + window.offsetTop();
  if(x != OldX || y != OldY)
  {
    OldX=x; OldY=y;
    cssLayers.DRC.moveTo(x,y);
  }

}

function DRCLayer()
{
  cbSetup();
  cssLayers.DRC.pxWidth(650).pxHeight(90);
  DRCinit = 1;
  DRCresize();
  setInterval("DRCresize()", 20);
}

function DELresize()
{
  var x2, y2;

  if(!DELinit) return;

  x2 = (window.pxWidth() - cssLayers.DEL.pxWidth())/2 + window.offsetLeft();
  y2 = (window.pxHeight() - cssLayers.DEL.pxHeight())/2  + window.offsetTop();
  if(x2 != OldX2 || y2 != OldY2)
  {
    OldX2=x2; OldY2=y2;
    cssLayers.DEL.moveTo(x2,y2);
  }

}

function DELLayer()
{
  cbSetup();
  cssLayers.DEL.pxWidth(460).pxHeight(70);
  DELinit = 1;
  DELresize();
  setInterval("DELresize()", 20);
}

function WRCresize()
{
  var x2, y2;

  if(!WRCinit) return;

  x2 = (window.pxWidth() - cssLayers.WRC.pxWidth())/2 + window.offsetLeft();
  y2 = (window.pxHeight() - cssLayers.WRC.pxHeight())/2  + window.offsetTop();
  if(x2 != OldX2 || y2 != OldY2)
  {
    OldX2=x2; OldY2=y2;
    cssLayers.WRC.moveTo(x2,y2);
  }

}

function WRCLayer()
{
  cbSetup();
  cssLayers.WRC.pxWidth(450).pxHeight(110);
  WRCinit = 1;
  WRCresize();
  setInterval("WRCresize()", 20);
}

function SLVresize()
{
  var x2, y2;

  if(!SLVinit) return;

  x2 = (window.pxWidth() - cssLayers.SLV.pxWidth())/2 + window.offsetLeft();
  y2 = (window.pxHeight() - cssLayers.SLV.pxHeight())/2  + window.offsetTop();
  if(x2 != OldX2 || y2 != OldY2)
  {
    OldX2=x2; OldY2=y2;
    cssLayers.SLV.moveTo(x2,y2);
  }

}

function SLVLayer()
{
  cbSetup();
  cssLayers.SLV.pxWidth(460).pxHeight(70);
  SLVinit = 1;
  SLVresize();
  setInterval("SLVresize()", 20);
}

function COEresize()
{
  var x2, y2;

  if(!COEinit) return;

  x2 = (window.pxWidth() - cssLayers.COE.pxWidth())/2 + window.offsetLeft();
  y2 = (window.pxHeight() - cssLayers.COE.pxHeight())/2  + window.offsetTop();
  if(x2 != OldX2 || y2 != OldY2)
  {
    OldX2=x2; OldY2=y2;
    cssLayers.COE.moveTo(x2,y2);
  }

}

function COELayer()
{
  cbSetup();
  cssLayers.COE.pxWidth(390).pxHeight(70);
  COEinit = 1;
  COEresize();
  setInterval("COEresize()", 20);
}

function DPTresize()
{
  var x, y;

  if(!DPTinit) return;

  x = (window.pxWidth() - cssLayers.DPT.pxWidth())/2 + window.offsetLeft();
  y = (window.pxHeight() - cssLayers.DPT.pxHeight())/2  + window.offsetTop();
  if(x != OldX || y != OldY)
  {
    OldX=x; OldY=y;
    cssLayers.DPT.moveTo(x,y);
  }

}

function DPTLayer()
{
  cbSetup();
  cssLayers.DPT.pxWidth(450).pxHeight(90);
  DPTinit = 1;
  DPTresize();
  setInterval("DPTresize()", 20);
}

function EMEresize()
{
  var x, y;

  if(!EMEinit) return;

  x = (window.pxWidth() - cssLayers.EME.pxWidth())/2 + window.offsetLeft();
  y = (window.pxHeight() - cssLayers.EME.pxHeight())/2  + window.offsetTop();
  if(x != OldX || y != OldY)
  {
    OldX=x; OldY=y;
    cssLayers.EME.moveTo(x,y);
  }

}

function EMELayer()
{
  cbSetup();
  cssLayers.EME.pxWidth(450).pxHeight(90);
  EMEinit = 1;
  EMEresize();
  setInterval("EMEresize()", 20);
}

function CLPresize()
{
  var x, y;

  if(!CLPinit) return;

  x = (window.pxWidth() - cssLayers.CLP.pxWidth())/2 + window.offsetLeft();
  y = (window.pxHeight() - cssLayers.CLP.pxHeight())/2  + window.offsetTop();
  if(x != OldX || y != OldY)
  {
    OldX=x; OldY=y;
    cssLayers.CLP.moveTo(x,y);
  }

}

function CLPLayer()
{
  cbSetup();
  cssLayers.CLP.pxWidth(450).pxHeight(90);
  CLPinit = 1;
  CLPresize();
  setInterval("CLPresize()", 20);
}

function LOAresize()
{
  var x, y;

  if(!LOAinit) return;

  x = (window.pxWidth() - cssLayers.LOA.pxWidth())/2 + window.offsetLeft();
  y = (window.pxHeight() - cssLayers.LOA.pxHeight())/2  + window.offsetTop();
  if(x != OldX || y != OldY)
  {
    OldX=x; OldY=y;
    cssLayers.LOA.moveTo(x,y);
  }

}

function LOALayer()
{
  cbSetup();
  cssLayers.LOA.pxWidth(450).pxHeight(70);
  LOAinit = 1;
  LOAresize();
  setInterval("LOAresize()", 20);
}

function det_adv(ref)
{
 myWin=open(ref,"_blank", "width=780,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
}

function det_3d(ref)
{
 myWin=open(ref,"_blank", "width=550, height=400,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes, top=100, left=200");
}

function det_pic(ref)
{
 myWin=open(ref,"_blank", "width=150,height=150,top=" + (event.screenY - 190) + ",left=" + (event.screenX - 180) + ",status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes");
}

function print_adv(ref)
{
 myWin=open(ref,"_blank", "width=600,status=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes");
}

function search_rub(page)
{
 document.choose.page.value=page;
 return document.choose.submit();
}

function search_rub_d(page)
{
 document.choose.dpage.value=page;
 return document.choose.submit();
}

function details(row,ni)
{
 document.choose.row.value = row;
 document.choose.ni.value = ni;
 return document.choose.submit();
}

function check_author() {
 if(passwdform.mode.value == 'edit.cgi' || passwdform.mode.value == 'delete.cgi' || passwdform.mode.value == 'chrub.cgi') {
  return;
 }
 if(passwdform.firm_id.value != passwdform.authoriz.value) {
  if(cssLayers.COE) {
   cssLayers.COE.Visibility('hidden');
  }
  cssLayers.RWR.Visibility('visible');
 }
 else {
  if(checkmode()) {
   passwdform.submit();
  }
 }
}

function checkmode() {
 cssLayers.RWR.Visibility('hidden');
 if(document.choose!= null) {
  document.choose.mode.value = passwdform.mode.value;
  document.choose.passwd.value = passwdform.passwd.value;
  document.choose.submit();
  return false;
 }
 return true;
}

function add_to_order()
{
 document.mainform.back.value=1;
 document.mainform.ato.value=1;
 return document.mainform.submit();
}

function clrubvisibility() {
 if(document.query.subrub.value == 0) {
  clrub1.style.visibility = 'hidden';
  clrub2.style.visibility = 'hidden';
 }
 else {
  clrub1.style.visibility = 'visible';
  clrub2.style.visibility = 'visible';
 }
}

function gotorubpage(ccounter,pages)
{
 eval('var newpage = document.choose.npage' + ccounter + '.value');
 if(newpage < 1 || newpage > pages || Math.floor(newpage) != newpage)
 {
  alert('Нет такой страницы');
  eval('document.choose.npage' + ccounter + '.value = ""');
  return;
 }
 document.choose.page.value = newpage;
 return document.choose.submit();
}
