function subgoogle()
{				
	formulario = document.getElementById("formg");				
	caminho = "q="+encodeURI(formulario.w.value) + " site:itajai.sc.gov.br"
	formulario.w.value = "";				
	caminho = "http://www.google.com/search?hl=en&"+caminho;
	janelaa = window.open(caminho, "janelaa", "");
	janelaa.focus();
}

function tamanhoTela()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
	    winW = window.innerWidth;
	    winH = window.innerHeight;
	}
	else if( document.documentElement &&
	      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
	 /* IE 6+ in 'standards compliant mode' */
	    winW = document.documentElement.clientWidth;
	    winH = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
	 /*IE 4 compatible*/
	    winW = document.body.clientWidth;
	    winH = document.body.clientHeight;
	}
	
	if (winW < 955 )
	{
		document.getElementById('padraoPMI').style['visibility']='hidden';
		document.getElementById('padraoPMI').style.display='none';
		document.getElementById('padraoPMI').style['width']='0px';
		document.getElementById('padraoPMI').style['height']='0px';
		
		
		document.getElementById('tbPrincipalP').style['width']='0';	
		document.getElementById('tbPrincipalP').style['height']='0';
		document.getElementById('r1c1').style['height']='160';
		document.getElementById('r1c2').style['height']='160';
		document.getElementById('tbPrincipal').style['width']='756';
		
	}
}

function FiltraCampo(codigo) {
    var s = "";
	
	tam = codigo.length;
	for (i = 0; i < tam ; i++) {  
		if (codigo.substring(i,i + 1) == "0" || 
           	codigo.substring(i,i + 1) == "1" ||
            codigo.substring(i,i + 1) == "2" ||
            codigo.substring(i,i + 1) == "3" ||
            codigo.substring(i,i + 1) == "4" ||
            codigo.substring(i,i + 1) == "5" ||
            codigo.substring(i,i + 1) == "6" ||
            codigo.substring(i,i + 1) == "7" ||
            codigo.substring(i,i + 1) == "8" ||
            codigo.substring(i,i + 1) == "9"  )
		 		s = s + codigo.substring(i,i + 1);
	}
	return s;
}

function DvCnpjOk(e) {
    var dv = false;
    controle = "";
    s = FiltraCampo(e.value);
    tam = s.length
    if ( tam  == 14 ) {
        dv_cnpj = s.substring(tam-2,tam);
        for ( i = 0; i < 2; i++ ) {
            soma = 0;
            for ( j = 0; j < 12; j++ ) 
                soma += s.substring(j,j+1)*((11+i-j)%8+2);
            if ( i == 1 ) soma += digito * 2;
            digito = 11 - soma  % 11;
            if ( digito > 9 ) digito = 0;
            controle += digito;
        }
        if ( controle == dv_cnpj )
            dv = true;
     }
     if ( ! dv && tam > 0) {
         mensagem = "           Erro de digitação:\n";
         mensagem+= "          ===============\n\n";
         mensagem+= " O CNPJ: " + e.value + " não existe!!\n";
         alert(mensagem);
     }
     return dv;
}

function DvCpfOk(e) {
    var dv = false;

    controle = "";
    s = FiltraCampo(e.value);
    tam = s.length;
    if ( tam == 11 ) {
        dv_cpf = s.substring(tam-2,tam);
        for ( i = 0; i < 2; i++ ) {
            soma = 0;
            for ( j = 0; j < 9; j++ )
                soma += s.substring(j,j+1)*(10+i-j);
            if ( i == 1 ) soma += digito * 2;
            digito = (soma * 10) % 11;
            if ( digito == 10 ) digito = 0;
            controle += digito;
        }
        if ( controle == dv_cpf )
            dv = true;
    }
     if ( ! dv && tam > 0) {
         mensagem = "           Erro de digitação:\n";
         mensagem+= "          ===============\n\n";
         mensagem+= " O CPF: " + e.value + " não existe!!\n";
         alert(mensagem);
         e.value = "";
     }
    return dv;
}

function addSel( campo, valor, texto )
{
	obj = document.getElementById( campo );
	novoIndice = obj.options.length;
	obj.options[novoIndice] = new Option( texto );
	opcao = obj.options[novoIndice];
	opcao.value = valor;
	opcao.selected = true;
}

function addVal( campo, valor )
{
	obj = document.getElementById( campo );
	obj.value = valor;
}


function openPage(url_pagina, nome_pagina, largura, altura, scroll, top, left)
{
	janela = window.open(url_pagina,  nome_pagina, largura, altura, top, left, statusbar=scroll);
	janela.focus();
}
		
function verificaTamanhoEmail(campo, e)
{
	if( typeof window.event != "undefined" )
	{
		if(window.event.keyCode != 13 && window.event.keyCode != 8 && window.event.keyCode != 32)
		{
			if(document.getElementById(campo).value.length>16)
			{
				alert("Excedido número maximo de caracteres, por favor use no máximo e 16 caracteres!");
			}
		}
		
	}
	else
	{
		if(e.which != 13 && e.which != 8 && e.which != 32)
		{
			if(document.getElementById(campo).value.length>16)
			{
				alert("Excedido número maximo de caracteres, por favor use no máximo e 16 caracteres!");
			}
		}
	}
}
