// JavaScript Document

var myGlobalHandlers = {
	onCreate: function(){
		Element.show('loader');
	},
	onComplete: function() {
		Element.hide('loader');
	}
};

// Funes para o formulrio de contato
  function enviarContato() {
  	var mensagem = '';
  	if ($('nome').value.length == 0) mensagem += "- Nome:\n";
  	if ($('email').value.length == 0) mensagem += "- E-mail:\n";
  	else if ($('email').value.indexOf('@') == -1) mensagem += "- E-mail inválido:\n";
  	if ($('assunto').value.length == 0) mensagem += "- Assunto:\n";
  	if ($('mensagem').value.length == 0) mensagem += "- Mensagem:\n";

	if (mensagem) alert("Campos de preenchimento obrigatrio:\n"+mensagem)
	else
	{
		params = Form.serialize('form_contato');
		oAjax = new Ajax.Request('contato_envia.php',{parameters:params,onComplete:mostracontato})
	}
  }

  function mostracontato(r) {
  	alert(r.responseText);
	window.location = 'index.php';
  }
//-----------------------------------------------------------------------------------------


// AJAX
CarregaPortfolio = function(id) {
 pars = "id="+id;
 new Ajax(id,{update: $('portfolio_cont'),evalScripts:true,data:pars}).request();
}

CarregaInformacoes = function(id) {
 pars = "id="+id;
 new Ajax(id,{update: $('informacoes_cont'),evalScripts:true,data:pars}).request();
}
// AJAX

// FUNÇÕES PARA OS CAMPOS APAGAR O VALOR QUANDO SE CLICAR DENTRO
function apaga(valor)
	{
	if (valor == 1 && document.getElementById('nome').value == " ")
		document.getElementById('nome').value = "";
	
	if (valor == 2 && document.getElementById('email').value == " ")
		document.getElementById('email').value = "";
		
	if (valor == 3 && document.getElementById('assunto').value == " ")
		document.getElementById('assunto').value = "";	
	
	if (valor == 4 && document.getElementById('mensagem').value == " ")
		document.getElementById('mensagem').value = "";	
	}
	
function restaura(valor)
	{
	if (valor == 1 && document.getElementById('nome').value == "")
		document.getElementById('nome').value = " ";
	
	if (valor == 2 && document.getElementById('email').value == "")
		document.getElementById('email').value = " ";
		
	if (valor == 3 && document.getElementById('assunto').value == "")
		document.getElementById('assunto').value = " ";	
	
	if (valor == 4 && document.getElementById('mensagem').value == "")
		document.getElementById('mensagem').value = " ";	
	}
// FUNÇÕES PARA OS CAMPOS APAGAR O VALOR QUANDO SE CLICAR DENTRO


