﻿function abrirJanela(strUrl, strNomeJanela, strWidth, strHeight) {
  var WIDTH = strWidth;
  var HEIGHT = strHeight;
  var x = (screen.width - WIDTH) / 2;
  var y = (screen.height - HEIGHT) / 2;


  var windowprops = "dependent=yes, toolbar=no, menubar=no, statusbar=no, scrollbars=auto, resizable=no, titlebar=no, copyhistory=yes, maximized=yes, width=" + WIDTH + ",height=" + HEIGHT + ",top=" + y + ",left=" + x + "";

  var janela = window.open(strUrl, strNomeJanela, windowprops);

  if (janela && typeof (janela) != 'undefined' && janela != null) {
    janela.resizeTo(WIDTH + 10, HEIGHT + 35);
    janela.focus();
  }
}

var timerID
function startClock(campo) {
  //alert('Start..1');
  timerID = window.setTimeout("showClock('" + campo + "')", 2000); // 1-second interval
  // alert('Start..');
}

function stopClock() {
  window.clearTimeout(timerID);
  //alert('Fim');
}

function showClock(campo) {

  // This function actually displays the time. 

  //alert('Oi..');

  var ObjId = eval('window.document.forms[0].' + campo);

  if (ObjId != null) {
    if (ObjId.value == '1') {
      stopClock();
      window.document.forms[0].submit();
    }
    else {
      timerID = window.setTimeout("showClock('" + campo + "')", 1500); // repeat call	
    }
  }
  else {
    stopClock();
  }
}

