	/**
	*	Prototype
	*	Verificando se a biblioteca Prototype foi carregada
	*/
	if(typeof(Prototype) == 'undefined' || parseFloat(Prototype.Version) < 1.5) {
		 document.write('<script type="text/javascript" src="http://labonnevie.com.br/mail/prototype.pack.js"></script>');		
	}

function isEditor(){
	if(document.location.host.indexOf('editor.') != -1) {
		return true;
	}
	return false;
}
function formatSend(form){
	var form = $(form);
	var query = form.getInputs().map( function (item) {
		return ["input[" + item.name + "][alt]=" +
			encodeURIComponent(item.alt)];
	}).join('&');
	return query;
}
function sendMessage(valid, form){
	if(isEditor()){
		$('message').className = 'validation-advice';
		$('message').update('Modo Editor! Envio desativado!').show();
		return false;
	}
	if(valid) {
		var url = 'mail/sendMessage.php';
		new Ajax.Request(url, {
			method : 'post',
			postBody : /*formatSend(form) + '&' + */form.serialize(),
			onLoading : function(){
				$('message').className = 'message';
				$('message').update('Enviando...').show();
			},
			onSuccess : function(transport) {
				var json = transport.responseText.evalJSON();
				if(json.send) {
					$('message').className = 'message-passed';
					$('message').update('Enviado com sucesso!').show();
					form.reset();
				} else {
					$('message').className = 'validation-advice';
					$('message').update('Error ao tentar enviar!').show();
				}
			}
		});
	}
}
