// JavaScript Document

// ########################################################################################################################################################
// Funções utilizadas em todas as paginas
function Carrega() {
	$('#loading').animate({opacity: 0,}, 300, function() {
		document.getElementById("loading").style.visibility = "hidden";
		$('#logo').animate({opacity: 1,}, 700, function() {});
		$('#faixa_branca').animate({opacity: 1,}, 700, function() {});
		$('#copyright').animate({opacity: 1,}, 700, function() {});
	});
}
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
	
	// Ajustando as DIVs
	document.getElementById('faixa_branca').style.marginTop = (h - 370) / 2 + 'px';
	document.getElementById('logo').style.marginTop = (h / 2) - 250  + 'px';
	document.getElementById('logo').style.marginLeft = (w - 770) / 2  + 'px';
	document.getElementById('copyright').style.marginLeft = (w - 770) / 2  + 'px';
	// Final do ajuste das DIVs
}
// Fim das funções utilizadas em todas as páginas
// ########################################################################################################################################################


// ########################################################################################################################################################
// Funções utilizadas na página INDEX.PHP

var varInitPort = 1;
var varInitImg = 1;

function rolarJobsBaixo(maximo){
	var Pos = document.getElementById('jobs').style.marginTop;
	Pos = Pos.replace("px","");
	if(Pos == 0 || Pos == -90 || Pos == -180 || Pos == -270 || Pos == -360 || Pos == -450) {
		var PosMax = Number(maximo * (-90) + 90);
		if(Pos > PosMax) {
			$("#jobs").animate({
				marginTop: Number(Pos) - 90,
			},
			750, function() {
			// Animation complete.
			});
		varInitPort++;
		document.getElementById('qtdpags').innerHTML = varInitPort + "/" + maximo;
		}
	}
}
function rolarJobsCima(maximo){
	var Pos = document.getElementById('jobs').style.marginTop;
	Pos = Pos.replace("px","");
	if(Pos == 0 || Pos == -90 || Pos == -180 || Pos == -270 || Pos == -360 || Pos == -450) {
		var PosMax = 0;
		if(Pos < PosMax) {
			$("#jobs").animate({
				marginTop: Number(Pos) + 90,
			},
			750, function() {
			// Animation complete.
			});	
		varInitPort--;
		document.getElementById('qtdpags').innerHTML = varInitPort + "/" + maximo;
		}
	}
}
function rolarJobsEsq(maximo){
	var Pos = document.getElementById('job').style.marginLeft;
	Pos = Pos.replace("px","");
	if(Pos == 0 || Pos == -280 || Pos == -560 || Pos == -840 || Pos == -1120 || Pos == -1400 || Pos == -1680 || Pos == -1960 || Pos == -2240 || Pos == -2520 || Pos == -2800) {
		var PosMax = Number(maximo * (-280));
		if((Pos-280) > PosMax) {
			$("#job").animate({
				marginLeft: Number(Pos) - 280,
			},
			750, function() {
			// Animation complete.
			});
		varInitImg++;
		document.getElementById('qtdimgs').innerHTML = varInitImg + "/" + maximo;
		}
	}
}
function rolarJobsDir(maximo){
	var Pos = document.getElementById('job').style.marginLeft;
	Pos = Pos.replace("px","");
	if(Pos == 0 || Pos == -280 || Pos == -560 || Pos == -840 || Pos == -1120 || Pos == -1400 || Pos == -1680 || Pos == -1960 || Pos == -2240 || Pos == -2520 || Pos == -2800) {
		var PosMax = 0;
		if(Pos < PosMax) {
			$("#job").animate({
				marginLeft: Number(Pos) + 280,
			},
			750, function() {
			// Animation complete.
			});	
		varInitImg--;
		document.getElementById('qtdimgs').innerHTML = varInitImg + "/" + maximo;
		}
	}
}
function abrirCategoria(categoria){
	pagina = 'ajax/home_portfolio.php?categoria='+categoria;
	ajaxGet(pagina,document.getElementById('jobs'),true);
}
function carregarBotoes(qtd){
	document.getElementById('botoes_portfolio').innerHTML = "<img src='img/bt_seta_esq.png' width='20' height='20' border='0' align='left' onclick='rolarJobsCima(" + qtd + ");' style='cursor:pointer;' /><p align='center' style='float:left; width:40px; margin-top:3px;' id='qtdpags'>1/" + qtd + "</p><img src='img/bt_seta_dir.png' width='20' height='20' border='0' align='right' onclick='rolarJobsBaixo(" + qtd + ");' style='cursor:pointer;' />";
	varInitPort = 1;
	$("#jobs").animate({
		marginTop: 0,
	},
	750, function() {
	// Animation complete.
	});
}
function verDescricao(acao,descricao){
	if(acao == "in"){
		document.getElementById('descricao').innerHTML = descricao;
	} else {
		document.getElementById('descricao').innerHTML = "";
	}
}
// Fim das funções utilizadas na página ADMIN/SUBPAGINAS/LINGUAS.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 SUBPAGINAS/CONTATO.PHP
// ########################################################################################################################################################
