Cufon.replace('.swis', { hover: true });
$(document).ready(function()
{
	$('form#newsletter').validationEngine({
		ajaxSubmit: false,
		success : function()
		{
			var boxy = new Boxy("<div class='loading_box'><img src='/fcinco/_imagens/loading.gif' align='absmiddle' />&nbsp;<strong>&nbsp;&nbsp;cadastrando seu e-mail, aguarde...</strong></div>", { modal: true });
			
			$.ajax({
				type: "POST",
				url: '/newsletter/cadastrar',
				data: $('form#newsletter').serialize(),
				beforeSend: function()
				{ 
					
				},
				success: function(resposta)
				{
					//if( Boxy.isModalVisible() ) return false;
					boxy.hide();
					new Boxy("<div class='loading_box' style='color: green; text-align: center;'><strong>Seu e-mail foi cadastrado com sucesso!</strong></div>", { modal: true, title: 'Cadastro de Newsletter', closeable: true, closeText: '[fechar]' });
				},
				error: function( resposta )
				{
					//if( Boxy.isModalVisible() ) return false;
					boxy.hide();
					new Boxy("<div class='loading_box'>Houve um erro de conexão, tente novamente ...</div>", { modal: true, title: 'Mensagem de Erro', closeable: true, closeText: '[fechar]' })
				}
			});
			
			$('form#newsletter').each (function()
			{
				this.reset();
			});
		},
		failure : function(){}
	});
	$('form#newsletter input#nome').focus(function(){ if( $(this).val() == 'NOME' ){ $(this).val(''); } });
	$('form#newsletter input#nome').blur(function(){ if( $(this).val() == 'NOME' || $(this).val() == '' ){ $(this).val('NOME'); }else{ $(this).val(); } });
	$('form#newsletter input#email').focus(function(){ if( $(this).val() == 'EMAIL' ){ $(this).val(''); } });
	$('form#newsletter input#email').blur(function(){ if( $(this).val() == 'EMAIL' || $(this).val() == '' ){ $(this).val('EMAIL'); }else{ $(this).val(); } });
	$('form#newsletter input#nome').keypress(function(event){ if (event.keyCode == '13'){ $('form#newsletter').submit(); } });
	$('form#newsletter input#email').keypress(function(event){ if (event.keyCode == '13'){ $('form#newsletter').submit(); } });
	$("form#newsletter a").click( function(){ $('form#newsletter').submit(); });
});
