//window.onload = function()
//{
//  var coll = document.getElementsByTagName("input");
//  for(var i=0; i<coll.length; i++)
//  {
//     if(coll[i].type == "text" || coll[i].type == "password")
//     {
//		if (coll[i].id == "uscNavega_txtBusca")
//			coll[i].className = "busca";
//		else
//			coll[i].className = "input";
//     }
//     
//  }
//}

function printer()
{
  var content=document.getElementById('divArea').innerHTML;
  document.getElementById('area').contentWindow.document.open();
  document.getElementById('area').contentWindow.document.write('<html><link href="/shared/css/global.css" rel="stylesheet" type="text/css"><body style="background-image:none;">'+content+'</body></html>');
  document.getElementById('area').contentWindow.document.close();
  document.getElementById('area').contentWindow.focus();
  document.getElementById('area').contentWindow.print();
}

var tamanhos = new Array( '11px', '13px','14px','15px','16px');
var itm = 0;
function AumentarFonte()
{
    if (itm < tamanhos.length - 1)
    {   
        itm += 1;             
        document.getElementById("txt").style.fontSize = tamanhos[itm];                
    }
}

function DiminuirFonte()
{
    if (itm > 0)
    {
        itm = itm - 1;                
        document.getElementById("txt").style.fontSize = tamanhos[itm];
    }
}


function ExluirItem()
{
	var ex = 0;
	if(typeof(document.forms[0].ckItem)=='object')
	{
		if (document.forms[0].ckItem.length > 0)
		{
			
			for(var i=0;i < document.forms[0].ckItem.length; i++)
			{
				if (document.forms[0].ckItem[i].checked)
					ex = 1;
			}	 
			
			if (ex==1)	
			{
				if(!confirm('ATENÇÃO!!\n\nDeseja excluir o(s) iten(s) selecionado(s)?'))
					return false;
			}		
			else
			{
				alert('Nenhum item foi selecionado!');
				return false;
			}			
		}
		else
		{
			if (document.forms[0].ckItem.checked)
			{
				if(!confirm('Deseja excluir o(s) iten(s) selecionado(s)?'))
					return false;	
			}
			else
			{
				alert('Nenhum item foi selecionado!');
				return false;
			}	
		}
	}		
	else
	{
		return false;
	}
}

function RestaurarItem()
{
	var ex = 0;
	if(typeof(document.forms[0].ckItem)=='object')
	{
		if (document.forms[0].ckItem.length > 0)
		{
			
			for(var i=0;i < document.forms[0].ckItem.length; i++)
			{
				if (document.forms[0].ckItem[i].checked)
					ex = 1;
			}	 
			
			if (ex==1)	
			{
				if(!confirm('ATENÇÃO!!\n\nDeseja restaurar o(s) iten(s) selecionado(s)?'))
					return false;
			}		
			else
			{
				alert('Nenhum item foi selecionado!');
				return false;
			}			
		}
		else
		{
			if (document.forms[0].ckItem.checked)
			{
				if(!confirm('Deseja restaurar o(s) iten(s) selecionado(s)?'))
					return false;	
			}
			else
			{
				alert('Nenhum item foi selecionado!');
				return false;
			}	
		}
	}		
	else
	{
		return false;
	}
}

function atualiza()
{
	if (document.getElementById("fieldOpcao"))
		document.getElementById("fieldOpcao").style.width = (document.body.offsetWidth-(22)).toString()+"px";
	
	if (document.getElementById("fieldSaudacao"))
	{
		document.getElementById("fieldSaudacao").style.width = (document.body.offsetWidth-(22)).toString()+"px";
		document.getElementById("fieldSaudacao").style.height = "100%";	
	}	
	
	if (document.getElementById("fieldMenu"))
		document.getElementById("fieldMenu").style.height = "100%";	
	
	if (document.getElementById("fieldUsuario"))  
	{  
		document.getElementById("fieldUsuario").style.width = (document.body.offsetWidth-(22)).toString()+"px";
		
		if (document.getElementById("fieldOpcao") && document.getElementById("fieldAtencao")) 
			document.getElementById("fieldUsuario").style.height = "100%";
		else if (document.getElementById("fieldOpcao"))
			document.getElementById("fieldUsuario").style.height = "100%";	
	}	
}

function Mascara(o,f)
{
    v_obj=o;
    v_fun=f;
    setTimeout("execmascara()",1)
}

function execmascara()
{
    v_obj.value=v_fun(v_obj.value)
}

function soNumeros(v)
{
    return v.replace(/\D/g,"");
}

function NumerosPonto(event)
{
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if ((keyCode >= 48 && keyCode <= 57) || keyCode == 44)
		return true;
	else
		return false;
}

function moeda(v){
    v=v.replace(/\D/g,"")                 
    if(v.length == 1)
		v=v.replace(/(\d{1})(\d)/,"$1,$2")
		
	if(v.length == 2)
		v=v.replace(/(\d{2})(\d)/,"$1,$2")
		
	if(v.length == 3 || v.length == 4)
		v=v.replace(/(\d{2})(\d)/,"$1,$2")
	
	if(v.length == 5)
		v=v.replace(/(\d{3})(\d)/,"$1,$2")		
		
	if(v.length == 6)
		v=v.replace(/^(\d{1})(\d{3})(\d)/,"$1.$2,$3")
		
	if(v.length == 7)
		v=v.replace(/^(\d{2})(\d{3})(\d)/,"$1.$2,$3")
			
	return v
}

function data(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca um barra entre o segundo e o terceiro dígitos
    v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca um barra entre o segundo e o terceiro dígitos novamente
    return v
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") 
    return v
}

function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

function Timeout(url)
{
    alert("ELOGIEAKI.\n\nSua sessão no Administrador atingiu o limite.\n\nDesconecte-se e faça o login novamente.");
	top.location.href=url;
}

function Permissao(url)
{
	alert("ELOGIEAKI.\n\nAcesso Restrito.\n\nEntre em contato com o Administrador");
	history.back();
	//top.location.href=url;
}

function BuscaAvancada(obj)
{
	document.getElementById('BuscaTexto').style.display = "none";
	document.getElementById('BuscaData').style.display = "none";
	
	document.getElementById(obj).style.display = "inline";
}

function ExpandirGrupoMaterialCor(obj)
{
	 var table = document.getElementById('dtgMaterial');
	 var rows = table.getElementsByTagName("TR");
	 for(var i = 0;i < rows.length; i++)
	 {
		if (obj==rows[i].Name)
		{	
			if (rows[i].style.display=='none')
				rows[i].style.display = 'inline';
			else	
				rows[i].style.display = 'none';
		}
	 }
}


function ExpandirFechar(obj,img)
{
	 var div = document.getElementById(obj);
	 var img = document.getElementById(img);
	 if ((div) && (img))
	 {
		if (div.style.display=='none')
		{
			div.style.display = 'inline';
			img.src = '/Shared/img/fechar.gif';
		}	
		else
		{	
			div.style.display = 'none';
			img.src = '/Shared/img/visualizar.gif';
		}	
	 }
}

function AbrirPagina(pagina, nome, largura, altura)
{
	var p = window.open(pagina, nome, 'width=' + largura + ',height=' + altura + '');
}

function MensagemContato()
{
    var resposta = confirm("Mensagem enviado com sucesso.\\nDeseja cadastrar-se no site e receber info e novidades do ElogieAki e seus parceiros?")
    if (resposta)
        location.href='/cadastro/';
    else
        location.href='/contato.aspx';
}

function FecharBannerPop(div1, div2)
{
    if (document.getElementById(div1))
        document.getElementById(div1).style.display = 'none';
   
    if (document.getElementById(div2))     
        document.getElementById(div2).style.display = 'none'
}

var disabledOnSubmitBlockButton = false;
function OnSubmitBlockButton(p_value)
{
    if (!disabledOnSubmitBlockButton)
    {
        if (typeof(ValidatorOnSubmit) == 'function' && ValidatorOnSubmit() == false)
            return false;         
        else 
        {
            var myCtl = document.getElementById(p_value); 
            if(myCtl) myCtl.disabled = true;               
        }
    }
}
