﻿/******************************************************

autor: INPUT CENTER INFORMÁTICA
versão: 1.0.0
atualizado em: 11/02/2010

******************************************************/

function popup(url, largura, altura, scroll, resizable) {
    var posicaoX = (screen.availWidth - largura) / 2;
    var posicaoY = (screen.availHeight - altura) / 2;

    janelaPopup = window.open(url, 'popup', 'status=no,resizable=' + resizable + ',scrollbars=' + scroll + ',menubar=no,width=' + largura + ',height=' + altura + ',left=' + posicaoX + ',top=' + posicaoY);
    janelaPopup.focus();
}

function initCheckBox(destino) {
  verificaCheckBox(destino);

  $('#checkAll').click(function() {
    $(destino).attr("checked", "checked");
    $(this).hide();
    $('#unCheckAll').show();
  });
  $('#unCheckAll').click(function() {
    $(destino).attr("checked", "");
    $(this).hide();
    $('#checkAll').show();
  });
  $(destino).click(function() {
    verificaCheckBox(destino);
  });
}

function verificaCheckBox(destino) {
  var allCheck = true;

  for (i = 0; i < $(destino).length; i++) {
    if ($(destino)[i].checked == false) {
      allCheck = false;
    }
  }
  if (allCheck) {
    $('#checkAll').hide();
    $('#unCheckAll').show();
  }
  else {
    $('#unCheckAll').hide();
    $('#checkAll').show();
  }
}
