// validações
/*/////////////////////////////////////////////////////////////////////////////////

- Função para array
isArray - verifica se é um array

- prototype Array
inArray - verifica se o item existe no array
indexOf - retorna i indice do item no array
isEmpty - verifica se o array está vazio

- prototype Object
isChecked - verifica se um objeto radio ou chekbox em especial está marcado
isCep - verifica se é um cep válido
isDate - varifica se é uma data válida
isHour - verifica se é uma hora válida
isFone - verifica se é um telefone valido

- prototype String
isEmpty - indica se a string está vazia
trim - retorna o valor aplicando trim na string
isCep - verifica se é um cep válido
isMail - verifica se é um email válido
isDate - varifica se é uma data válida
isSelected - verifica em um valor de um campo select se não está em branco ou null
isHour - verifica se é uma hora válida
isCnpj - verifica se é um cnpj valido
isCpf - verifica se é um cpf valido
isInt - verifica se é um inteiro
isDDD - verifica se é ddd
isFone - verifica se é um telefone valido
isNumero - verifica se é numero formato pt-Br
isNumeric - verifica se é numero formato en-Us
isUrl - verifica se é uma url valida
isMoeda - verifica se é formatado como moeda pt-Br
isMoney - verifica se é formatado como moeda en-Us

/////////////////////////////////////////////////////////////////////////////////*/


isArray = function ( value ) { if ( value != null && typeof( value ) == "object") { return( value.constructor.toString().indexOf( "Array" ) != -1 ); } else { return false; } };
Array.prototype.inArray = function ( value ) { var z; for ( z = 0; z < this.length; z++ ) { if ( this[ z ] === value) { return true; } } return false; };
Array.prototype.indexOf = function ( value ) { var z; for ( z = 0; z < this.length; z++ ) { if (this[ z ] === value ) { return z; } } return -1; };
Array.prototype.isEmpty = function () { return( this.length == 0 ) };
Object.prototype.isChecked = function () { var z; for ( z = 0; z < this.length; z++ ) { if( this[ z ].checked ) { return true; } } return false; };
Object.prototype.isCep = function () { return ( ( this.length == 2 ) ? ( ( /[0-9]{5}/ ).test( this[ 0 ].value ) && ( /[0-9]{3}/ ).test( this[ 1 ].value ) ) : false ); };
Object.prototype.isDate = function () { if ( this.length != 3 ) { return false; } if ( !( ( /[0-9]{2}/ ).test( this[ 0 ].value ) && ( /[0-9]{2}/ ).test( this[ 1 ].value ) && ( /[0-9]{4}/ ).test( this[ 2 ].value ) ) ) { return false; } var iDay = this[ 0 ].value; var iMonth = this[ 1 ].value; var iYear = this[ 2 ].value; if ( iDay < 1 || iMonth < 1 || iMonth > 12 || iYear < 1900 || iYear > 2100 ) { return false; } aLastDays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; if ( ( ( iYear % 4 == 0 ) && iYear % 100 != 0 ) || iYear % 400 == 0 ) { aLastDays[ 1 ] = 29; } if ( iDay > aLastDays[ iMonth - 1 ] ) { return false; } return true; };
Object.prototype.isHour = function () { if ( !( this.length == 2 ) ) { return false; } var iHour = this[ 0 ].value; var iMinute = this[ 1 ].value; return ( iHour > - 1 && iHour < 24 && iMinute > - 1 && iMinute < 60 ); };
Object.prototype.isFone = function () { if ( !( this.length == 2 ) ) { return false; } return( ( /[0-9]{2}/ ).test( this[ 0 ].value ) && ( /[0-9]{6,8}/ ).test( this[ 1 ].value ) ); };
String.prototype.isEmpty = function () { return( this == null || this.trim() == "" ) };
String.prototype.trim = function () { return ( this.replace( /^(\s*)/, "" ).replace( /(\s*$)/, "" ) ); };
String.prototype.isCep = function () { return ( ( this.length == 8 || this.length == 9 ) && ( ( /[0-9]{8}/ ).test( this ) || ( /[0-9]{5}-[0-9]{3}/ ).test( this ) ) ); };
String.prototype.isMail = function () { return ( /^[a-zA-Z0-9]{1}[\w\.\-]{2,63}@[a-zA-Z0-9]{1}[\w\.\-]{2,63}\.[a-zA-Z]{2,4}$/ ).test( this ); };
String.prototype.isDate = function () { var aTmp, iDay, iMonth, iYear, aDays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; if ( ( /[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}/ ).test( this ) || ( /[0-9]{1,2}\-[0-9]{1,2}\-[0-9]{4}/ ).test( this ) ) { aTmp = ( this.indexOf( "/" ) != -1 ) ? this.split( "/" ) : aTmp = this.split( "-" ); iYear = Number( aTmp[ 2 ] ); iMonth = Number( aTmp[ 1 ] ); iDay = Number( aTmp[ 0 ] ); if ( ( ( iYear % 4 == 0 ) && iYear % 100 != 0 ) || iYear % 400 == 0 ) { aDays[1] = 29; } return ( iYear > 1900 && iYear <= 2100 && iMonth > 0 && iMonth <= 12 && iDay > 0 && iDay <= aDays[ iMonth - 1 ] ); } else { return false; } };
String.prototype.isSelected = function () { return ( this != '' && this != null ) };
String.prototype.isHour = function () { return ( /[0-23]{2}\:[0-59]{2}/ ).test( this ); };
String.prototype.isCnpj = function () { if ( !( /^\$?(?:\d+|\d{1,3}(?:.\d{3})*)(?:\/\d{4}\-\d{1,2}){0,1}$/ ).test( this ) ) { return false; } value = this.replace(/ /g,"").replace(/\./g,"").replace(/\//g,"").replace(/-/g,"").replace(/,/g,"").replace(/\\/g,""); if ( value.length == 14 ) { var iFator = 6; var iVerificador = Array( 0, 0 ); for ( z = 0; z < 13; z++ ) { if ( z > 0 ) { iVerificador[ 0 ] += Number( value.substring( z - 1, z ) ) * iFator; } iVerificador[ 1 ] += Number( value.substring( z, z + 1 ) ) * iFator; iFator --; if ( iFator == 1 ) iFator = 9; } for ( z = 0; z < iVerificador.length; z++ ) { iVerificador[ z ] = ( iVerificador[ z ] % 11 < 2 ) ? 0 : 11 - ( iVerificador[ z ] % 11 ); } return ( Number( value.substring( 12, 13 ) ) == iVerificador[0] && Number( value.substring( 13, 14 ) ) == iVerificador[1] ); } else { return false; } };
String.prototype.isCpf = function () { if ( !( /^\$?(?:\d+|\d{1,3}(?:.\d{3})*)(?:\-\d{1,2}){0,1}$/ ).test( this ) ) { return false; } value = this.replace(/ /g,"").replace(/\./g,"").replace(/\//g,"").replace(/-/g,"").replace(/,/g,"").replace(/\\/g,""); if ( value != "00000000000" && value != "11111111111" && value != "22222222222" && value != "33333333333" && value != "44444444444" && value != "55555555555" && value != "66666666666" && value != "77777777777" && value != "88888888888" && value != "99999999999" && value.length == 11 ) { var iFator = 11; var iVerificador = Array( 0, 0 ); for ( z = 0; z < 10; z++ ) { if ( z > 0 ){ iVerificador[ 0 ] += Number( value.substring( z - 1, z ) ) * iFator; } iVerificador[ 1 ] += Number( value.substring( z, z + 1 ) ) * iFator; iFator --; } for ( z = 0; z < iVerificador.length; z++ ) { iVerificador[ z ] = ( iVerificador[ z ] % 11 < 2 ) ? 0 : 11 - ( iVerificador[ z ] % 11 ); } return ( Number( value.substring( 9, 10 ) ) == iVerificador[0] && Number( value.substring( 10, 11 ) ) == iVerificador[1] ); } else { return false; } };
String.prototype.isInt = function () { return ( /(^-?\d\d*$)/ ).test( this ); };
String.prototype.isDDD = function () { return ( ( /[0-9]{3}/ ).test( this ) || ( /[0-9]{2}/ ).test( this ) ); };
String.prototype.isFone = function () { return ( ( /^[0-9]{2,4}[||\ |\-][0-9]{4}$/ ).test( this ) || ( /^[0-9]{6,8}$/ ).test( this ) ); };
String.prototype.isFone2 = function () { return ( ( /^[0-9]{2,4}[||\ |\-][0-9]{4}$/ ).test( this ) || ( /^[0-9]{6,8}$/ ).test( this ) ||( /^[0-9]{2,3}[||\ |\-][0-9]{2,4}[||\ |\-][0-9]{4}$/ ).test( this ) || ( /^[0-9]{6,11}$/ ).test( this ) ); };
String.prototype.isNumero = function () { return( ( /^\$?(?:\d+|\d{1,3}(?:.\d{3})*)(?:\,\d{}){0,1}$/ ).test( this ) || ( /^\$?(?:\d+|\d{1,3}(?:.\d{3})*)(?:\,\d{1,}){0,1}$/ ).test( this ) ); };
String.prototype.isNumeric = function () {  return( ( /^\$?(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{}){0,1}$/ ).test( this ) || ( /^\$?(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{1,}){0,1}$/ ).test( this ) ); };
String.prototype.isUrl = function () { return ( /^(ht|f)tp\:\/\/[a-zA-Z0-9]{1}[\w\.\-]{2,63}\.[a-zA-Z]{2,4}/ ).test( this ) ; };
String.prototype.isMoeda = function() { return( ( /^\$?(?:\d+|\d{1,3}(?:.\d{3})*)(?:\,\d{1,2}){0,1}$/ ).test( this ) ); };
String.prototype.isMoney = function() { return( ( /^\$?(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{1,2}){0,1}$/ ).test( this ) ); };