﻿function txtMarcaAgua_onFocus(o) {
  if (o.value == o.title) {
    o.value = '';
  }
}
function txtMarcaAgua_onBlur(o) {
  if (o.value == '') {
    o.value = o.title;
  }
}
function imposeMaxLength(Object, MaxLen) {
  return (Object.value.length <= MaxLen);
}

var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

if (sPage != "Login.aspx") {

    $(function() {
        $.superbox();
    });

    $.superbox.settings = {
        boxId: "superbox", // Id attribute of the "superbox" element
        boxClasses: "", // Class of the "superbox" element
        overlayOpacity: .6, // Background opaqueness
        boxWidth: "530", // Default width of the box
        boxHeight: "550", // Default height of the box
        loadTxt: "<img src='/App_Themes/Site/Images/prettyPopin/loader.gif' alt='Carregando' />", // Loading text
        closeTxt: "<img src='/App_Themes/Site/Images/geral/x.png' alt='Fechar' />", // "Close" button text
        prevTxt: "Anterior", // "Previous" button text
        nextTxt: "Próxima" // "Next" button text
    };
}

function CPF_Validator(sender, args) {
  args.IsValid = validaCPF(args.Value);
}
function validaCPF(cpf) {
  erro = new String;
  cpf = retiraFormatacao(cpf);
  if (cpf.length == 11) {
    var nonNumbers = /\D/;
    if (nonNumbers.test(cpf)) {
      erro = "A verificacao de CPF suporta apenas números!";
    }
    else {
      if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" ||
					cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
					cpf == "88888888888" || cpf == "99999999999") {
        erro = "Número de CPF inválido!"
      }
      var a = [];
      var b = new Number;
      var c = 11;
      for (i = 0; i < 11; i++) {
        a[i] = cpf.charAt(i);
        if (i < 9) b += (a[i] * --c);
      }
      if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11 - x }
      b = 0;
      c = 11;
      for (y = 0; y < 10; y++) b += (a[y] * c--);
      if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11 - x; }
      if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])) {
        erro = "Número de CPF inválido.";
      }
    }
  }
  else {
    if (cpf.length == 0)
      return false
    else
      erro = "Número de CPF inválido.";
  }
  if (erro.length > 0) {
    //alert(erro);
    return false;
  }
  return true;
}
function retiraFormatacao(CPF) {
  CPF = CPF.replace(".", "");
  CPF = CPF.replace(",", "");
  CPF = CPF.replace("-", "");
  CPF = CPF.replace("/", "");
  CPF = CPF.replace(".", "");
  return CPF;
}
function hidePopup(modal) {
  var modalPopup = $find(modal);
  modalPopup.hide();
}
function showPopup(modal) {
  var modalPopup = $find(modal);
  modalPopup.show();
}

function facebook_onlogin_ready() {
    //window.top.location.reload();
    window.top.location = "/LoginFacebook.aspx"
}
