// Personalizados
function setColor(b,a){if(b.style){b.style.borderColor=a}}

// Validando formulario de contato
function validacontato(){
	var f="#FF0000"; //#F4B3B3
	var e="white";
	var c;
	var b=0;
	d=document.contato;

if((d.nome.value=="")||(d.nome.value=="Nome Completo")){
	c=false;
	setColor(d.nome,f);
	b++;
	d.nome.focus()}
	else{setColor(d.nome,e)}
	
if(!(isNaN(d.nome.value))){
	c=false;
	setColor(d.nome,f);
	b++;
	d.nome.focus()}
	else{setColor(d.nome,e)}
		
if((d.email.value=="")||(d.email.value=="Email Válido")){
	c=false;
	setColor(d.email,f);
	b++;
	d.email.focus()}
	var a=/^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	if(a.test(d.email.value)){
		setColor(d.email,e)}
	else{
		c=false;
		setColor(d.email,f);
		b++;
		d.email.focus()}
		
if((d.telefone.value.length<14)){
	c=false;
	setColor(d.telefone,f);
	b++;
	d.telefone.focus()}
	else{setColor(d.telefone,e)}
	
if((d.assunto.value=="")||(d.assunto.value=="Assunto")){
	c=false;
	setColor(d.assunto,f);
	b++;
	d.assunto.focus()}
	else{setColor(d.assunto,e)}
	
if (document.getElementById("cod_estados").value == "") {
    c=false;
	setColor(d.cod_estados,f);
	b++;
	d.cod_estados.focus()}
	else{setColor(d.cod_estados,e)}
	
if (document.getElementById("cod_cidades").value == "") {
    c=false;
	setColor(d.cod_cidades,f);
	b++;
	d.cod_cidades.focus()}
	else{setColor(d.cod_cidades,e)}

if((d.mensagem.value=="")||(d.mensagem.value=="Digite aqui sua mensagem.")){
	c=false;
	setColor(d.mensagem,f);
	b++;
	d.mensagem.focus()}
	else{setColor(d.mensagem,e)}
	if(b>0){return false}else{return true}}
	
	
// Função Valor dentro de input Sumir onfocus
function valor(ob, txt){if(ob.value == txt) ob.value = "";ob.onblur = function (){  if (ob.value == "") ob.value = txt;}}

// Marcara para telefones com ddd
function mascara(b,a){
	v_obj=b;
	v_fun=a;
	setTimeout("execmascara()",1)}
	function execmascara(){v_obj.value=v_fun(v_obj.value)}
	function tel(a){a=a.replace(/\D/g,"");a=a.replace(/^(\d\d)(\d)/g,"($1) $2");a=a.replace(/(\d{4})(\d)/,"$1-$2");return a}
	startList = function() {
		if (document.all&&document.getElementById) {navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {node.onmouseover=function() {this.className+=" over";}
		node.onmouseout=function() {this.className=this.className.replace(" over", "");
}}}}} 



function blocTexto(valor, limite){
    quant = limite;
    total = valor.length;
    if(total <= quant){
        resto = quant - total;
        document.getElementById('cont').innerHTML = 'Caracteres restantes: ' +resto;
    }else{
        document.getElementById('txtcoment').value = valor.substr(0,quant);
    }
}


$(document).ready(function(){ 
	$("a[rel='img']").colorbox();
	$("a[rel='pdf']").colorbox({width:"80%", height:"80%", iframe:true});

	$('.tabs-widget-content-widget-themater_tabs-2047490811-id').hide();
	$('ul.tabs-widget-widget-themater_tabs-2047490811-id li:first a').addClass('tabs-widget-current').show();
	$('.tabs-widget-content-widget-themater_tabs-2047490811-id:first').show();
	$('ul.tabs-widget-widget-themater_tabs-2047490811-id li a').click(function() {
		$('ul.tabs-widget-widget-themater_tabs-2047490811-id li a').removeClass('tabs-widget-current a'); 
		$(this).addClass('tabs-widget-current'); 
		$('.tabs-widget-content-widget-themater_tabs-2047490811-id').hide(); 
		var activeTab = $(this).attr('rel'); 
		$(activeTab).fadeIn();
		return false;
	});
	
	$("#escolher").click(function () {$("#avtr").fadeIn();});
	$(".avs").click(function () {$("#avtr").fadeOut();});
});


