// JavaScript Document

$(document).ready(function(){

	//$("a[href^='http://']").attr("target","_blank");

	$("li:first-child").addClass("firstChild");
	$("li:last-child").addClass("lastChild");

	$(".pt-br").addClass("ativo");
	
	$("#mediabox").cycle({timeout: 5000});

	$("#topo #menu li").hover(function() {
		$(this).toggleClass("hover");
    });

	$(".galeria li a").colorbox({current:"foto {current} de {total}"});

});


function validaCampoObrigatorio(form){
            var erro=0;
            var legenda;
            var obrigatorio;           
            for (i=0;i<form.length;i++){
                        obrigatorio = form[i].lang;
                        if (obrigatorio==1){
                                   if (form[i].value == ""){
                                               var nome = form[i].name;
                                               mudarCorCampo(form[i], '#FF4040');
                                               legenda=document.getElementById(nome);
                                               legenda.style.color="#FF4040";
                                               erro++;
                                   }
                        }
            }
            if(erro>=1){
                        if(erro>1)
						{
						alert("Existem " + erro + " campos a serem preenchidos.\nIdentificados com fundo vermelho.")
                        return false;
						}
						if(erro=1)
						{
						alert("Existe 1 campo a ser preenchido.\nIdentificado com fundo vermelho.")
                        return false;
						}
            } else
                        return true;
}

function mudarCorCampo(elemento, cor){
            elemento.style.backgroundColor=cor;
}
