/* BlackClass 
      BlackClass  v1.0 
	  Last Updated: 13/06/2009 23:18
	  Craft by:     Gilson Silva 
	  Organization: Neocreative Studio
	  Mail:         suporte@neocreative.com.br
*/

// Função para localizar onde se encontra o cod raiz 
function REMOTE_PLACE(){$tags = document.getElementsByTagName('script'); for(var $i=0;$i<$tags.length;$i++){ if($tags[$i].src != ''){	var tmp = $tags[$i].src.indexOf('black_class.js'); if(tmp != -1){ var $pasta = $tags[$i].src.replace(/black_class.js/gi, ""); return $pasta;}}}}

// VARIÁVEIS GLOBAIS DE CONFIGURAÇÃO

$_CONFIG = new Array();
$_CONFIG[  'soms'   ]   = false;
$_CONFIG[  'cursor' ]   = false;
$_CONFIG[  'imgs'   ]   = false;
$_CONFIG[  'Pasta'  ]   = REMOTE_PLACE();




//// -------------------------------------------------------- início da classe -----------------------------------------------------
function Objeto($id){
	
	// Funções disponíveis	
	this.get              = get              // Carrega um objeto e retorna o mesmo
	this.css              = css;             // Seta um estilo css 
	this.GotoX            = GotoX;           // Espande o objeto a posição X
	this.GotoY            = GotoY;	         // Espande o objeto a posição Y
	this.mask_value       = mask_value;      // Mascara um valor de Imput ou Text area   
	this.mask_money       = mask_money;      // Mascara o valor do imput para valor monetario 
	this.mask_cep         = mask_cep         // Mascara de CEP
	this.opacit           = opacit;          // Seta Opacidade no objeto
	this.v_email          = v_email;         // Veirifica se o campo possui um e-mail válido
	this.criar_get_enviar = criar_get_enviar;// Criar um GET para url a partir de um objeto e seus filhos 
	this.get_values       = get_values;      // Varre o objeto atrás de valores 
    this.aleatorio        = aleatorio;       // Cria um número aleatório 
	this.RemoveAtributo   = RemoveAtributo;  // Remove Um atributo do objeto
    this.atributo         = atributo;        // Seta Um atributo para o objeto
	this.hide             = hide;	         // Esconde o objeto
	this.show             = show;		     // Mostra o objeto
	this.ShowFND          = ShowFND;         // função para mostrar o fundo lightbox
	this.HideFND          = HideFND;         // função para esconder o fundo lightbox
	this.Preload          = Preload;         // Função carrega a imagem
	this.Numerico         = Numerico         // Permite a digitação de apenas numeros
	this.isset            = isset;           // Função verifica se o objeto ou variável existe
	this.openajax         = openajax		 // Função resposável por criar a conecção ajax  	
	this.Ajax             = Ajax			 // Função responsável por enviar e receber dados via ajax 
	this.novoJS           = novoJS;          // Função insere objetos antes da instancia
	this.addFlash         = addFlash         // Adiciona um arquivo flash onde quiser
	this.FLUpload         = FLUpload;        // Transforma o imput em uma area de upload
	this.LimpaNumero      = LimpaNumero;     // Função limpar as vigulas e pontos do número;
	this.Formata_moeda    = Formata_moeda;   // Função Formatar numero p/ Moeda

	
	// Variáveis Diposníveis
    if($id != '' || undefined || null){ this.obj = get($id); }else{ this.obj = ''; }	
	this.w          = '';
	this.h          = '';
	this.maxX	    = '';
	this.maxY	    = '';	
	this.intervaloX = '';
	this.intervaloY = '';
	this.idd        = aleatorio(1,100000);
	this.Nocache    = true;	
	this.valor      = '';
	
	// variáveis para o uploads  
	this.pasta      = $_CONFIG['Pasta']+'tmp/';
	this.upload     = 'upload.php';
	this.extencao   = new Array();
	
/// Função retorna objeto ///////////////////////////////////////////////////////////////////////////////////////////////////////////
function get($id){ 	 return   document.getElementById($id);  }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função css //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function css($estilo,$valor){
	if($estilo == 'bg_cor')       { $estilo    = 'backgroundColor';                              }
	if($estilo == 'cor')          { $estilo    = 'color';                                        }
	if($estilo == 'bg')           { $estilo    = 'background';                                   }
	if($estilo == 'bg_img')       { $estilo    = 'backgroundImage';  $valor = 'url('+$valor+')'; }
	if($estilo == 'bg_img_pos')   { $estilo    = 'backgroundPosition';                           } 
	if($estilo == 'bg_img_repet') { $estilo    = 'backgroundRepeat';  							 } 
	if($estilo == 'borda_cor')    { $estilo    = 'borderColor';                                  } 
	if($estilo == 'borda')        { $estilo    = 'border';                                       }
	if($estilo == 'w')            { $estilo    = 'width';   this.w = $valor;  $valor +='px';     }
	if($estilo == 'h')            { $estilo    = 'height';  this.h = $valor;  $valor +='px';     }
	if($estilo == 'mouse')        { $estilo    = 'cursor';   								     }

	 
	$txt = 'this.obj.style.'+$estilo+'="'+$valor+'"';
	eval($txt);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função value objeto txt /////////////////////////////////////////////////////////////////////////////////////////////////////////
function mask_value($ini_txt){
 var $obj = this.obj;
 $obj.onfocus = function(){ if(this.value == $ini_txt){ this.value = '';} } 
 $obj.onblur  = function(){ if(this.value == ''){ this.value = $ini_txt;} } 
 if($obj.value.length == 0){
 $obj.value   = $ini_txt;
 } 
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função GotoX //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GotoX($div,$max,$delay,$ac){
	//	Uso GotoX(Objeto_clas,tamanhoMaximo_minimo,tempo,se deseja almetar use '+' se não use '-')
	if($ac == '+'){ var $operador = '>='; }
	if($ac == '-'){ var $operador = '<='; }
	this.maxX = $max;
	this.intervaloX = window.setInterval(function(){
						 if(eval($div.w + $operador + $div.maxX)  || $div.w < 1){
							 clearInterval($div.intervaloX); $div.css('w',$div.maxX); $div.w = $div.maxX;
							 }else{ 
							 $div.w = (eval($div.w+$ac+10));	 $div.css('w',($div.w)); 
							 }
							 },$delay);	
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função GotoY //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GotoY($div,$max,$delay,$ac){
	//	Uso GotoY(Objeto_clas,tamanhoMaximo_minimo,tempo,se deseja almetar use '+' se não use '-')
	if($ac == '+'){ var $operador = '>='; }
	if($ac == '-'){ var $operador = '<='; }
	
	this.maxY = $max;
	
	this.intervaloY = window.setInterval(function(){ 
		if(eval($div.h + $operador + $div.maxY)){
			clearInterval($div.intervaloY); $div.css('h',$div.maxY); $div.h = $div.maxY;
			}else{ 
			$div.h = (eval($div.h+$ac+10));	 $div.css('h',$div.h); 
			}
			},$delay);	
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função ShowHide //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function opacit(){
//	alert('s');
	this.obj.style.opacity         = '0.50';
	this.obj.filters.alpha.opacity = '50'; 
} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função Verifica E-mail //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function v_email(){
	//var $valor = this.obj.value;
    var $obj = this.obj;
      $obj.onblur  = function(){ if(this.value == ''){ 
	  $obj.style.border = '1px solid #FF9595';
	 }else{
		  var $erro = false;
		  if($obj.value.indexOf('@') == -1){ $erro = true;}
		  if($obj.value.indexOf('.') == -1){ $erro = true;}
	
	if($erro == true){
		$obj.style.border = '1px solid #FF9595';
	}else{
		$obj.style.border = '1px solid #009700';
		
	}
 }}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Função criar get e enviar //////////////////////////////////////////////////////////////////////////////////////////////////////
function criar_get_enviar($quem) {
	  $url_GET_ENVIAR = '';
	  var $tabela          = document.getElementById($quem);
	  var $todos_elementos = $tabela.getElementsByTagName('input');
	  // alert($todos_elementos.length);
	  for($i=0;$i<$todos_elementos.length;$i++){
	  $url_GET_ENVIAR += '&'+$todos_elementos[$i].name+'='+$todos_elementos[$i].value.replace(/&/g, "#");
	  }
	  $todos_elementos = $tabela.getElementsByTagName('textarea');
	  // alert($todos_elementos.length);
	  for($i=0;$i<$todos_elementos.length;$i++){
	  $url_GET_ENVIAR += '&'+$todos_elementos[$i].name+'='+$todos_elementos[$i].innerHTML.replace(/&/g, "#");
	  }
	  return $url_GET_ENVIAR;
} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função ler valores ///////////////////////////////////////////////////////////////////////////////////////////////////////////
function get_values($quem) {
	  $url_GET_ENVIAR = '';
	  var $tabela          = document.getElementById($quem);
	  var $todos_elementos = $tabela.getElementsByTagName('input');
	  // alert($todos_elementos.length);
	  for($i=0;$i<$todos_elementos.length;$i++){
	  if($url_GET_ENVIAR != ''){
	  $url_GET_ENVIAR += '&'+$todos_elementos[$i].value.replace(/&/g, "#");
	  }else{
		$url_GET_ENVIAR += $todos_elementos[$i].value.replace(/&/g, "#");    
	  }
	  }
	  $todos_elementos = $tabela.getElementsByTagName('textarea');
	  // alert($todos_elementos.length);
	  for($i=0;$i<$todos_elementos.length;$i++){
	  $url_GET_ENVIAR += '&'+$todos_elementos[$i].innerHTML.replace(/&/g, "#");
	  }
	  return $url_GET_ENVIAR;
} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função setar atributos ao campo /////////////////////////////////////////////////////////////////////////////////////////////////
function atributo($atr, $valor) {
    var newAttr = document.createAttribute($atr);
    newAttr.nodeValue = $valor;
    this.obj.setAttributeNode(newAttr);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função remover atributos ao campo /////////////////////////////////////////////////////////////////////////////////////////////////
function RemoveAtributo($atr) {
    var m = this.obj.removeAttribute($atr);
        if (m != true) {
           // alert("Erro na remoção do atributo no objeto"+$obj+' atributo '+$atr);
        }
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função gera numero aleatorio /////////////////////////////////////////////////////////////////////////////////////////////////
function aleatorio(i, f){
	if(arguments[0] == null){
			return Math.random();
	}else{
		if (i > f) {numInicial = f;numFinal = i+1;}else{numInicial = i;numFinal = f+1;}
		numRandom = Math.floor((Math.random()*(numFinal-numInicial))+numInicial);
		return numRandom;
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função remover atributos ao campo /////////////////////////////////////////////////////////////////////////////////////////////////
function hide(){
this.obj.style.display = 'none';	
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função remover atributos ao campo /////////////////////////////////////////////////////////////////////////////////////////////////
function show(){
this.obj.style.display = 'inline';	
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Mostra o fundo LIGHT BOX /////////////////////////////////////////////////////////////////////////////////////////////////
function ShowFND(){
	this.get('Style_FND').style.display = 'inline';
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Esconde o fundo LIGHT BOX /////////////////////////////////////////////////////////////////////////////////////////////////
function HideFND(){
	this.get('Style_FND').style.display = 'none';
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Carrega a imagem quando quiser  /////////////////////////////////////////////////////////////////////////////////////////////////
function Preload() { 
	// uso $opcoes.Preload('img/aqui a 01','img/aqui a 02');
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Perminte apenas Números  /////////////////////////////////////////////////////////////////////////////////////////////////
function Numerico($txt){
	$aceitos  = '1234567890';
	$ok = true;
	$txt = $txt+'';
	$nums = $txt.split('');
	
	for($i = 0; $i<$nums.length;$i++){
		
		if($aceitos.indexOf($nums[$i]) == -1){ $nums[$i] = ''; }
		
		
	}
    $nums = $nums.join('');
	 return $nums;
	
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função verifica se o objeto ou variável existe  /////////////////////////////////////////////////////////////////////////////////
function isset(o) {   if (o != undefined && o != null){  return true; }else{  return false; }}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função Mascara o valor Monetário  ///////////////////////////////////////////////////////////////////////////////////////////////
function mask_money(){
	this.obj.onkeyup = function (){   monetario (this);}
	this.obj.onblur = function (){    monetario (this);}
	this.obj.onmouseup = function (){ monetario (this);}
	this.obj.onkeypress= function (){ monetario (this);}
	this.atributo('maxlength', '12');
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função Mascara de cep ///////////////////////////////////////////////////////////////////////////////////////////////////////////

function mask_cep(){
	this.obj.onblur     = function(){ Cep_(this); if(this.value.length < 9){ this.value = '';}}
	this.obj.onmouseup  = function(){ Cep_(this);}
	this.obj.onkeyup    = function(){ Cep_(this);}
	this.atributo('maxlength', '9');
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// função ajax para a classe  =D ///////////////////////////////////////////////////////////////////////////////////////////////////
function openajax(){
var ajax; /* Defini a Variável */
try{ ajax = new XMLHttpRequest(); /* Tenta Instanciar o Objeto */}
catch(ee){ try {
ajax = new ActiveXObject("Msxm12.XMLHTTP"); /* Se Nao Conseguiu o Anterior Tenta esse*/
}catch(e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP"); /* E o memso se repete aqui*/
}catch(E){
ajax = false; /* Se nao conseguiu em Nenhum retorna False pois o Navegador Usado nao Suporta Ajax*/
}
}
}
return ajax; /* Retorna um Boleano*/
}
// segunda parte 
function Ajax($link,$func){ /*Recebe parâmetro o Link a Pagina Solicitada */
var ajax = this.openajax(); /* Chama a Função que Instancia o AJAX */
// retito o cache ^^ 
if(this.Nocache == true){ $verif = $link.indexOf('?'); if($verif == -1){ $link+= '?NO_CACHE_sess='+Math.random();}else{ $link+= '&NO_CACHE_sess='+Math.random(); } } 
ajax.open("GET",$link,true);
/* ajax.open = Abri uma Solicitação ao Navegador */
/* GET = Método Usado */
/* plink = pagina que tratara o solicitado */
/* true = Assicrono ou não = Dando o Refresh no Browser ou Nao*/
ajax.onreadystatechange = function()
/* ajax.onreadystatechange = O que ele fara de acordo com o tempo de execuação*/
{
if (ajax.readyState < 4){}/* ajax.readystate = Estado que se encontra a Requisição*/

if (ajax.readyState == 4){
if (ajax.status == 200){
/* Estado de Carregamento*/
$func(ajax.responseText);
}else{ $func('404'); }
}
}
ajax.send(null);
/* Muito Importante Envia o Resultado para o Navegador */
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// função carrega js  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function novoJS($js){
this.Ajax($js,function($codigo){
novo = document.createElement("script");
novo.type         = 'text/javascript';
novo.language     = 'javascript';
novo.text = $codigo;
document.body.appendChild(novo);
});
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// função novo flash  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function addFlash($swf,$div,$tamanhoX,$tamanhoY,$fundo){
	$idd  = 10;
	$swff = $swf;
	$divv = $div;
	$X    = $tamanhoX;
	$Y    = $tamanhoY;
	$BG   = $fundo;
	if($X == undefined){ $X = 200; } if($Y == undefined){ $Y = 100; } if($BG == undefined){ $BG = "#336699"; }
    this.novoJS($_CONFIG['Pasta']+'swfs/swfobject.js');
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// add Upload 1.0  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function FLUpload($type,$div){
    var $extension   = '';
	var $description = '';
	var url = $_CONFIG['Pasta']+'swfs/upload.swf?$pasta='+this.pasta+'&$upload='+this.upload+'&$div='+$div+'&sess='+Math.random();
	this.addFlash(url,$div,450,110,'#fff');
	 // alert(url);

}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função limpar as vigulas e pontos do número ///////////////////////////////////////////////////////////////////////////////////
function LimpaNumero($NUM){
// exemplo limpanumero('1.200,00');
// Retiro o ponto  
$NUM = $NUM+'';
var $LIMP  =  $NUM.split(".");
$count = $LIMP.length;
$TEXT  = '';
for($i = 0; $i < $count; $i++){
  if($TEXT == ""){
  $TEXT = $LIMP[$i];
  }else{
   $TEXT = $TEXT+$LIMP[$i];
  }
}
//  Retiro a virgula e substituo as variáveis 
$NUM   = $TEXT;
$LIMP  = $NUM.split(",");
$count = $LIMP.length;
$TEXT  = '';
for($i = 0; $i < $count; $i++){ // faço o for para juntar a array 
  if($TEXT == ""){
  $TEXT    = $LIMP[$i];
  }else{
   $TEXT   = $TEXT+=$LIMP[$i];
  }
}

return eval($TEXT);
}// fim da função de limpar números 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Função Formatar numero p/ Moeda /////////////////////////////////////////////////////////////////////////////////////////////////
function Formata_moeda($NUM){

$NUM = $NUM.toString();
var $LIMP  =  $NUM.split('');
$count = $LIMP.length;
$count -= 2;
$TEXT  = '';
for($i=0;$i<$count;$i++){
//AQUI ELE ME DEVOLVE O NUMERO SEM A VIRGULA 
  if($TEXT == ""){
  $TEXT    = $LIMP[$i];
  }else{
   $TEXT   = $TEXT+=$LIMP[$i];
  }	
}
//AQUI ELE SOMA OS VALORES COM A VIRGULA
//$count += 2;
$TEXT += ',';
for($i=$count;$i<$LIMP.length;$i++){

		$TEXT   = $TEXT+=$LIMP[$i];
}

$NUM   = $TEXT.split('');
$count = $NUM.length;
if($count >= 7){
$count = $NUM.length;
$TEXT  = $NUM[0]+'.';
for($i=1;$i<$count;$i++){

if($TEXT == ""){
  $TEXT   = $NUM[$i];
  }else{
  $TEXT  = $TEXT+=$NUM[$i];
}}
}

return $TEXT;
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}// fim da classe 

/// -----------------------------------------------------------------------------------------------------------------------------
function onload(func){
//by Micox - based in jquery bindReady and Diego Perini IEContentLoaded
    //flag global para indicar que já rodou e function que roda realmente
    done = false
    init = function(){ if(!done) { done=true; func() } }
    var d=document; //apelido para o document
    //pra quem tem o DOMContent (FF)
    if(document.addEventListener){ d.addEventListener("DOMContentLoaded", init, false );}
    
    if( /msie/i.test( navigator.userAgent ) ){ //IE
        (function () {
            try { // throws errors until after ondocumentready                
                d.documentElement.doScroll("left");
            } catch (e) {
                setTimeout(arguments.callee, 10); return;
            }
            // no errors, fire
            init();
        })();
    }
    if ( window.opera ){
        d.addEventListener( "DOMContentLoaded", function () {
            if (done) return;
            //no opera, os estilos só são habilitados no fim do DOMready
            for (var i = 0; i < d.styleSheets.length; i++){
                if (d.styleSheets[i].disabled)
                    setTimeout( arguments.callee, 10 ); return;
            }
            // fire
            init();
        }, false);
    }
    if (/webkit/i.test( navigator.userAgent )){ //safari's
        if(done) return;
        //testando o readyState igual a loaded ou complete
        if ( /loaded|complete/i.test(d.readyState)===false ) {
            setTimeout( arguments.callee, 10 );    return;
        }
        init();
    }
    //se nada funfou eu mando a velha window.onload lenta mesmo
    if(!done) window.onload = init
}
/// -----------------------------------------------------------------------------------------------------------------------------

/// aqui o fundo ligth 
FND_STYLE = new Array();
FND_STYLE['z-index'] = 1;
FND_STYLE['color']   = '#666666';
FND_STYLE['opacity'] = 30;
function FND_LIGTH(){
	
document.write('<style>'
				+'#Style_FND {'
				+'	position:fixed;'
				+'	left:0;'
				+'	top:0;'
				+'	width:100%;'
				+'	height:100%;'
				+'	z-index:'+FND_STYLE['z-index']+';'
				+'	background-color: '+FND_STYLE['color']+';'
				+'	filter:alpha(opacity='+FND_STYLE['opacity']+');'
				+'  opacity:0.'+FND_STYLE['opacity']+';'
				+'  -moz-opacity: 0.'+FND_STYLE['opacity']+';'
				+'	display:none;'
				+'}'
				+'</style> '
				+'<div id="Style_FND"></div>');
}

// aqui conteudo do alert
function MAKE_ALERTA(){
	document.write('<div id="dialog_alerta" style="position:fixed; left: 50%; top: 50%; width: 370px; height: 140px;layer-background-color: #FF0000; border: 1px none #000000; display:none; z-index:1000; background:url('+$_CONFIG['Pasta']+'/img/alerta.png) left no-repeat;" > <table width="100%" height="135" border="0" cellpadding="0" cellspacing="0"><tr><td height="19" colspan="2" id="titulo_alerta">Console do sistema</td></tr><tr><td width="19%" height="76" align="center"><img id="IMG_display" src="'+$_CONFIG['Pasta']+'/img/icon-warning.gif" style="margin-left:20px;" /></td><td width="81%" align="left" valign="middle"><div id="txt_alerta"></div></td></tr><tr><td height="40" colspan="2" align="center" valign="top"></td></tr></table></div>'+
		
		'<style type="text/css"><!-- #dalog_informativo{ font-family:Verdana, Geneva, sans-serif;font-size:12px;	color:#333;	font-weight:bold;	cursor:default; } #titulo_alerta{	font-family:Verdana, Geneva, sans-serif;	font-size:12px;	color:#333;	padding-left:30px; padding-top:3px;	cursor:default;}#txt_alerta{ max-height:100px; width:260px; overflow:hidden; margin-left:8px; font-family:Verdana, Geneva, sans-serif;	font-size:12px;color:#000;	padding-left:30px; padding-top:3px;	cursor:default; } --></style>');	
}
// AQUI O SCONTROLE DO SOM APENAS PARA IE 
if(navigator.userAgent.indexOf("MSIE") != -1){
document.writeln ('<bgsound src="" id="PG_SOUND" loop="0" hidden="true" volume="100">');
}else{
//document.writeln ('<embed src="" id="PG_SOUND" loop=true autostart=true volume=100 hidden=true>');
}

FND_LIGTH();
MAKE_ALERTA();
//aqui o código para deichar o html 100% no browser 
document.write('<style>'
+' html, body {'
+'	height: 99%; '
+'  }'
+'</style>');

// função para carregar o objeto
function get($id){ return document.getElementById($id); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ShowFND(){
	get('Style_FND').style.display = 'inline';
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Esconde o fundo LIGHT BOX /////////////////////////////////////////////////////////////////////////////////////////////////
function HideFND(){
	get('Style_FND').style.display = 'none';
}
// função para substituir o alert do javascript 
function alerta($txt){
	if(!$txt){ $txt = '';}
	var $obj = get('dialog_alerta');
	get('txt_alerta').innerHTML = $txt;
	var $x = $obj.style.width.replace('px','');
	var $y = $obj.style.height.replace('px','');
	$obj.style.marginLeft   = '-'+($x / 2)+'px';
	$obj.style.marginTop    = '-'+($y / 2)+'px';
	$obj.style.display = 'inline';
    ShowFND();
	
	
	//get('dialog_bot_ok').focus();
	get('dialog_bot_ok').onclick = function(){ 
    close_alert(); 
	}
	if($_CONFIG['soms']){	
	get('PG_SOUND').src = $_CONFIG['Pasta']+'/media/alerta.wav';
	}
}
// função para fechar o dialog de alerta 
function close_alert(){
	var $obj = get('dialog_alerta');
	$obj.style.display = 'none';
	
	HideFND();
	if($_CONFIG['soms']){	
	get('PG_SOUND').src = '';
}}

function console($txt){
	if(!$txt){ $txt = '';}
	var $obj = get('dialog_alerta');
	get('IMG_display').src= $_CONFIG['Pasta']+'/img/38.gif';
	get('txt_alerta').innerHTML = $txt;
	var $x = $obj.style.width.replace('px','');
	var $y = $obj.style.height.replace('px','');
	$obj.style.marginLeft   = '-'+($x / 2)+'px';
	$obj.style.marginTop    = '-'+($y / 2)+'px';
	$obj.style.display = 'inline';
    ShowFND();
	
	
	//get('dialog_bot_ok').focus();
}

//// função validar numero /////
function monetario($obj){
$numeros = Numerico($obj.value);
$numeros = sem_zeros($numeros);


$txt2 = $numeros+'';
$txt2 = $txt2.split('');
var $final = $numeros;
var $total =  $txt2.length;

if($total == 1){
$final = '0,0'+$numeros;
}

if($total == 2){
$final = '0,'+$numeros;
}

if($total == 3){
 $final = '';
 for($i=0;$i < $total; $i++ ) {
 
 if($i == 0){
 $final += $txt2[$i]+',';
 }else{
 $final += $txt2[$i];
 }
 }

}
if($total == 4){
 $final = '';
 for($i=0;$i < $total; $i++ ) {
 
 if($i == 1){
 $final += $txt2[$i]+',';
 }else{
 $final += $txt2[$i];
 }
 }

}

if($total == 5){
$final = '';
 for($i=0;$i < $total; $i++ ) {
 
 if($i == 2){
 $final += $txt2[$i]+',';
 }else{
 $final += $txt2[$i];
 }
 }
}

if($total == 6){
$final = '';
var $conf  = ($total-2);
 for($i=0;$i < $total; $i++ ) {
 
 if($i == $conf){
 $final += ',';
 }
 if($i == 0){
 $final += $txt2[$i]+'.';
 }else{
 $final += $txt2[$i];
 }
 }
}

if($total == 7){
$final = '';
var $conf  = ($total-2);
 for($i=0;$i < $total; $i++ ) {
 
 if($i == $conf){
 $final += ',';
 }
 if($i == 1){
 $final += $txt2[$i]+'.';
 }else{
 $final += $txt2[$i];
 }
 }
}

if($total == 8){
$final = '';
var $conf  = ($total-2);
 for($i=0;$i < $total; $i++ ) {
 
 if($i == $conf){
 $final += ',';
 }
 if($i == 2){
 $final += $txt2[$i]+'.';
 }else{
 $final += $txt2[$i];
 }
 }
}

if($total == 9){
$final = '';
var $conf  = ($total-2);
 for($i=0;$i < $total; $i++ ) {
 
 if($i == $conf){
 $final += ',';
 }
 if($i == 3){
 $final += $txt2[$i]+'.';
 }else{
 $final += $txt2[$i];
 }
 }
}

if($total == 9){
$final = '';
var $conf  = ($total-2);
 for($i=0;$i < $total; $i++ ) {
 
 if($i == $conf){
 $final += ',';
 }
 if($i == 1){
 $final += '.';
 }
 if($i == 3){
 $final += $txt2[$i]+'.';
 }else{
 $final += $txt2[$i];
 }
 }
}

if($total > 9){
$final = '';
var $conf  = ($total-2);
 for($i=0;$i < $total; $i++ ) {
 
 if($i == $conf){
 $final += ',';
 }
  $final += $txt2[$i];
 }
}

$obj.value = $final;
}
//////////////////////////////////////////////////////////////////////////////////////////

//função make cep
function Cep_($obj){
		var $num       = $obj.value + '';
		var $numeros   = Numerico($num);
		$numeros       = $numeros.split('');
		var $total     = $numeros.length;
		var $resultado = '';
		for ($i = 0; $i<$total; $i ++){
			
			$resultado += $numeros[$i];
			if ($i == 4){
				$resultado += '-';
				}	
		}
		
		$obj.value = $resultado;
}
//

///////////////////////////////////////////////////////////////////////////////////////////
function Numerico($txt){
	$aceitos  = '1234567890';
	$ok = true;
	$txt = $txt+'';
	$nums = $txt.split('');
	
	for($i = 0; $i<$nums.length;$i++){
		
		if($aceitos.indexOf($nums[$i]) == -1){ $nums[$i] = ''; }
		
		
	}
    $nums = $nums.join('');
	 return $nums;
	
}

///////////////////////////////////////////////////////////////////////////////////////////
function sem_zeros($caracteres){
var $found    = false;
var $caracter = $caracteres.split('');
//alert('Total = '+$caracter.length);
 for($i=0;$i < $caracter.length; $i++ ) {
	
	$caracter[$i] = eval($caracter[$i]);
	if($caracter[$i] != 0){
	  $found = true;	
	  
	}
	
	 //aqui se for zero antes do primeiro numero
	  if($found != true){
	  if($caracter[$i] == 0){
	    $caracter[$i] = '';
	  }
	}
	
}
$caracter = $caracter.join("");
return $caracter ;
}
/// 
function uploadOK($div,$nome){
	
	get($div).value = $nome;
	confere_arquivo($div);
	
	
	
}