// center popup images on-screen ?
var centerpop=1;

// --------------------------------------------------
// previewpage() - page preview window
// --------------------------------------------------
function previewpage(pid) {
  if (pid!='') {
    var stat = 'dependent,resizable,status=0,scrollbars,width=900,height=620';
    pwin = window.open('pview.php?pid='+pid+'&edit=1','',stat);
  }
} // previewpage()

// --------------------------------------------------
// preview() - page preview window
// --------------------------------------------------
function preview() {
  with (document.selform) {
    var pid = pageid.value;
    if (pid!='') {
      var stat = 'dependent,resizable,status=0,scrollbars,width=900,height=620';
      pwin = window.open('pview.php?pid='+pid,'',stat);
    }
  }
} // preview()

// --------------------------------------------------
// pview() - template preview window
// --------------------------------------------------
function pview(formname) {
  form = eval("document."+formname);
  idx = form.template.selectedIndex;
  var val = form.template[idx].value;
  if (val!='') {
    var stat = 'dependent,resizable,status=0,scrollbars,width=900,height=620';
    jwin = window.open('tplview.php?fn='+val,'',stat);
  }
}

// --------------------------------------------------
// getpic()
// --------------------------------------------------
function getpic(pageid,blockid,side,w,h,psize,edit) {
  w = parseInt(w);
  h = parseInt(h);

  w0 = w + 30;
  h0 = h + 60;
  w1 = w0 - 10;
  h1 = h0 - 30;

  var wx=(screen.width/2)-(w0/2)-20
  var wy=(screen.height/2)-(h0/2)-20

  if (edit==false || edit=='false' || edit=='' || edit=='undefined') edit = 0;
  else edit = 1;

  var stat = 'dependent,resizable=no,status=0,scrollbars=no,width='+w1+',height='+h1;
  var params = 'pid='+pageid+'&bid='+blockid+'&edit='+edit+'&side='+side+'&psize='+psize;
  //alert(params+'; w='+w+'; h='+h)
  iwin = window.open('/db/imgview.php?'+params,'',stat);

  if (centerpop) {
    if (mybw.ie5up && !mybw.ie5) {
      iwin.blur()
      window.focus()
    }
    iwin.moveTo(wx,wy)
    iwin.resizeTo(w0,h0)
    iwin.focus()
  }

} // getpic()

// --------------------------------------------------
// gopage()
// --------------------------------------------------
function gopage(pno) {
  with (document.catform) {
    page.value=pno
    submit()
  }
} // gopage()

// --------------------------------------------------
// cktd()
// --------------------------------------------------
function cktd(tdname,mode) {
  var td = document.getElementById(tdname);
  if (!td) return;
  if (!td.style) return;

  if (mode) {
    td.style.background = "#888888";
  }
  else {
    if (tdname=='cat') td.style.background = "url(/images/menufon1.gif) #ff7700 top left repeat-x";
    else td.style.background = "url('/images/menufon.gif') ";
  }
} // cktd()

// --------------------------------------------------
// randomimage()
// --------------------------------------------------
function randomimage(condition,sect) {
  var m = Math.floor(Math.random()*0x7FFFF);  // avoid caching

  if (sect=='undefined' || sect=='') sect=0;
  document.write('<script language=javascript src=/grim.php?m='+m+'&c='+condition+'&s='+sect+'></scr'+'ipt>')
} // randomimage()

