  

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 go( url ) {
								document.location = url;
							}
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 formataIdFederal(campo, e)
{
	if(campo.value.length > 13)
	{
		if( typeof window.event != "undefined" )
		{
			if (window.event.keyCode != 45 && window.event.keyCode != 46 && window.event.keyCode != 8 && window.event.keyCode != 0 )
			{
				var str = campo.value;
				str = str.replace('.','');
				str = str.replace('.','');
				str = str.replace('-','');
				str = str.replace('/','');
				temp = str.substr(0,2);
				if(temp.length == 2)
					temp += '.';
				temp += str.substr(2,3);
				if(temp.length == 6)
					temp += '.';
				temp += str.substr(5,3);
				if(temp.length == 10)
					temp += '/';
				temp += str.substr(8,4);
				if(temp.length == 15)
					temp += '-';
				temp += str.substr(12,2);
				campo.value= temp;
			}

		}else
		{
			if (e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 && e.which != 0    )
			{

				var str = campo.value;
				str = str.replace('.','');
				str = str.replace('.','');
				str = str.replace('-','');
				str = str.replace('/','');

				temp = str.substr(0,2);
				if(temp.length == 2)
					temp += '.';
				temp += str.substr(2,3);
				if(temp.length == 6)
					temp += '.';
				temp += str.substr(5,3);
				if(temp.length == 10)
					temp += '/';
				temp += str.substr(8,4);
				if(temp.length == 15)
					temp += '-';
				temp += str.substr(12,2);
				campo.value= temp;
			}

		}
	}else
	{
		if( typeof window.event != "undefined" )
		{
			if (window.event.keyCode != 45 && window.event.keyCode != 46 && window.event.keyCode != 8 && window.event.keyCode != 0 )
			{
				var str = campo.value;
				str = str.replace('.','');
				str = str.replace('.','');
				str = str.replace('/','');
				str = str.replace('-','');

				temp = str.substr(0,3) ;
				if(temp.length == 3)
					temp += '.';
				temp += str.substr(3,3);
				if(temp.length == 7)
					temp += '.';
				temp += str.substr(6,3);
				if(temp.length == 11)
					temp += '-';
				temp += str.substr(9,2);
				campo.value= temp;
			}
		}else
		{

			if (e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 &&  e.which != 0  )
			{
				var str = campo.value;
				str = str.replace('.','');
				str = str.replace('.','');
				str = str.replace('/','');
				str = str.replace('-','');
				temp = str.substr(0,3) ;
				if(temp.length == 3)
					temp += '.';
				temp += str.substr(3,3);
				if(temp.length == 7)
					temp += '.';
				temp += str.substr(6,3);
				if(temp.length == 11)
					temp += '-';
				temp += str.substr(9,2);
				campo.value= temp;
			}
		}
	}
}
function FormataCpfCnpj(e) {
    var s = "";
    s = FiltraCampo(e.value);
    if ( s.length == 11 ) {
       if (!DvCpfOk(e)) {
			for (var sch = 0; sch < e.form.length; sch++) {
	    		if (e.form.elements[sch].name.toLowerCase() == "bt_validar") e.form.elements[sch].disabled = true;
   			}
		}
		else {
			for (var sch = 0; sch < e.form.length; sch++) {
	    		if (e.form.elements[sch].name.toLowerCase() == "bt_validar") e.form.elements[sch].disabled = false;
   			}
		}
        s=FormataCpf(e);

		return s;
    }
    else if ( s.length == 14 ) {
        DvCnpjOk(e);
        s=FormataCnpj(e);
		return s;
    }
    else {
		for (var sch = 0; sch < e.form.length; sch++) {
	   		if (e.form.elements[sch].name.toLowerCase() == "bt_validar") e.form.elements[sch].disabled = true;
		}
         mensagem = "           Erro de digita\347\343o:\n";
         mensagem+= "          ===============\n\n";
         mensagem+= " O CNPJ ou CPF: " + e.value + " n\343o existe!!\n";
         alert(mensagem);
		 return s='';
     }

}
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('padraoPMI2').innerHTML = document.getElementById('padraoPMI').innerHTML;
		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 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 cor(obj,novacor)
{
	obj.style.backgroundColor = novacor;
}
function verificaCPF(obj)
{
	 if( obj.value.length == 14)
	 {
		obj.id = obj.name;
		return validaCPF(obj.id);
	 }
	 return false;
}
function validaCPF(idCPF)
{
	 cpf = document.getElementById(idCPF).value;
	 cpf = cpf.charAt(0)+cpf.charAt(1)+cpf.charAt(2)+cpf.charAt(4)+cpf.charAt(5)+cpf.charAt(6)+cpf.charAt(8)+cpf.charAt(9)+cpf.charAt(10)+cpf.charAt(12)+cpf.charAt(13);
	 erro = new String;
	 if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n";
	 var nonNumbers = /\D/;
	 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";
	 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
	        erro += "Numero de CPF invalido!"
	 }
	 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 +="Digito verificador de CPF incorreto!";
	 }
	 if (erro.length > 0){
		   document.getElementById(idCPF).value = "";
	       alert(erro);
	       document.getElementById(idCPF).focus();
	       return false;
	 }
	 return true;
}

function changeBanner()
{
	var numRand = (Math.round((Math.random()*arrBanners.length)+1));
	if(numRand > arrBanners.length)
	{
		numRand = arrBanners.length;
	}
	numRand = numRand - 1;
	if(arrBanners[numRand][2])
	{
		if(document.getElementById('anuncio')) 
		{
			document.getElementById('anuncio').href = arrBanners[numRand][3];
			document.getElementById('anuncio').title = arrBanners[numRand][1];
		}
		//alert(document.getElementById('bannerImg').title);
		if(document.getElementById('bannerImg'))
		{
			document.getElementById('bannerImg').alt = arrBanners[numRand][1];
			document.getElementById('bannerImg').title = arrBanners[numRand][1];
			document.getElementById('bannerImg').src = 'http://intranet.itajai.sc.gov.br/fotos/imgs/'+arrBanners[numRand][0];
		}
	}
	
}

var xmlHttp

function getVote(int, enquete)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="voto.php"
url=url+"?vote="+int
url=url+"&id_enquete="+enquete
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("poll").
 innerHTML=xmlHttp.responseText;
 } 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
 {
 objXMLHttp=new XMLHttpRequest()
 }
else if (window.ActiveXObject)
 {
 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
 }
return objXMLHttp
}

function colocaVideo(){
  
}

//funcao que fecha a tela
function fechaTelaD(){
  document.getElementById('tlSobre').style.visibility = "hidden";
  document.getElementById('miniT').style.visibility = "hidden";
  document.getElementById('player').src = '';  
}
