// JavaScript Document

// ########################################################################################################################################################
function ajustarDivs(){
	
	// Definindo variáveis
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	// Final da declaração das variáveis

}
// Fim das funções utilizadas em todas as páginas
// ########################################################################################################################################################


// ########################################################################################################################################################
// Funções utilizadas na página SUBPAGINAS/HOME.PHP
function rodarImagens(id,qtd){
	$('.imagenshome').fadeOut(0, function() {});
	$('#img_home_'+id).fadeIn(500, function() {});
	setInterval(function() {
		
		if(id < qtd) {
			anterior = id;
			id++;
		} else {
			anterior = id;
			id = 1;
		}
		
		$('#img_home_'+anterior).fadeOut(500, function() {
			$('#img_home_'+id).fadeIn(500, function() {});
		});
		
	}, 7000);

}
// Fim das funções utilizadas na página SUBPAGINAS/HOME.PHP
// ########################################################################################################################################################


// ########################################################################################################################################################
// Funções utilizadas na página SUBPAGINAS/TRABALHOS.PHP
function aparece(id){
	$(id).fadeTo('fast', 1, function() {});
}
function desaparece(id){
	$(id).fadeTo('fast', 0.5, function() {});
}
function selecionaTrabalho(acao,menu,id){
	$('#cima').animate({
		opacity: "0.1"
	}, 500)
	//$('#cima').fadeTo('slow', 0, function() {});
	//$('#cima').fadeTo('slow', 0, function() {});
	pagina = 'ajax/troca_trabalho.php?acao='+acao+'&menu='+menu+'&id='+id;
	ajaxGet(pagina,document.getElementById('cima'),true);
}
function TrabalhoSelecionado(altura){
	$('#cima').animate({
	    height: altura+"px",
		opacity: "1"
	},500)
	//$('#cima').fadeTo('slow', 1, function() {});
	//$('#cima').fadeTo('slow', 0, function() {});
}
function rolarJobsDir(maximo){
	var Pos = document.getElementById('lista_fotos').style.marginLeft;
	var Larg = document.getElementById('fotos').style.width;
	Pos = Pos.replace("px","");
	Larg = Larg.replace("px","");
	var PosMax = Number(maximo * (-130));
	var PosMax = Number(PosMax + Number(Larg));
	if((Pos-122) > PosMax) {
		$("#lista_fotos").animate({
			marginLeft: Number(Pos) - 122,
		},
		750, function() {
		// Animation complete.
		});
	}
}
function rolarJobsEsq(maximo){
	var Pos = document.getElementById('lista_fotos').style.marginLeft;
	Pos = Pos.replace("px","");
	var PosMax = 0;
	if(Pos < PosMax) {
		$("#lista_fotos").animate({
			marginLeft: Number(Pos) + 122,
		},
		750, function() {
		// Animation complete.
		});	
	}
}
// Fim das funções utilizadas na página SUBPAGINAS/TRABALHOS.PHP
// ########################################################################################################################################################


// ########################################################################################################################################################
// Funções utilizadas na página SUBPAGINAS/CONTATO.PHP
function validaForm(lingua){
	
	// definindo textos de acordo com a lingua
	switch (lingua) {
		case "txt_pt":
			var alertNome = "O campo nome deve ser preenchido!";
			var alertEmail = "O campo e-mail deve ser preenchido!";
			var alertEmail2 = "Preencha um e-mail valido!";
			var alertAssunto = "O campo assunto deve ser preenchido!";
			var alertTexto = "O campo texto deve ser preenchido!";
			break;
		case "txt_fr":
			var alertNome = "Le champ Nom doit être rempli! ";
			var alertEmail = "Le champ e-mail doit être rempli! ";
			var alertEmail2 = "Remplissez un e-mail valide! ";
			var alertAssunto = "Le champ de l'objet doit être rempli!";
			var alertTexto = "Le champ de texte doit être rempli";
			break;
		case "txt_en":
			var alertNome = "The name field must be filled!";
			var alertEmail = "The email field must be filled!";
			var alertEmail2 = "Fill a valid e-mail!";
			var alertAssunto = "The subject field must be filled!";
			var alertTexto = "The text field must be filled!";
			break;
		default:
			var alertNome = "O campo nome deve ser preenchido!";
			var alertEmail = "O campo e-mail deve ser preenchido!";
			var alertEmail2 = "Preencha um e-mail valido!";
			var alertAssunto = "O campo assunto deve ser preenchido!";
			var alertTexto = "O campo texto deve ser preenchido!";
	}
	
	// definindo a variável geral
	d = document.enviaremail;
	
	// validar nome
	if (d.nome.value == "") {
		alert(alertNome);
		d.nome.focus();
		return false;
	}
	
	// validar email
	if (d.email.value == ""){
		alert(alertEmail);
		d.email.focus();
		return false;
	}
	
	// validar email(verificao de endereco eletronico)
	parte1 = d.email.value.indexOf("@");
	parte2 = d.email.value.indexOf(".");
	parte3 = d.email.value.length;
	if (!(parte1 >= 3 && parte3 >= 6)) {
		alert(alertEmail2);
		d.email.focus();
		return false;
	}
	
	// validar assunto
	if (d.assunto.value == "") {
		alert(alertAssunto);
		d.assunto.focus();
		return false;
	}
	
	// validar texto
	if (d.texto.value == "") {
		alert(alertTexto);
		d.texto.focus();
		return false;
	}
	
	return true;
}
// Fim das funções utilizadas na página ADMIN/SUBPAGINAS/LINGUAS.PHP
// ########################################################################################################################################################
