function loadPage() {
	$("#newsletter_form").submit(newsletterSend);
	if (anuncio == 1)
		createAnuncio();
}
function newsletterSend() {
	var msg = '';

	if (this.nome.value == '') {
		msg += 'O campo "nome" é obrigatório!\n';
	}
	if (this.email.value == '') {
		msg += 'O campo "e-mail" é obrigatório!\n';
	}

	if (msg == '') {
		var data = {
			mailNew : this.email.value,
			nomeNew : this.nome.value
		};
		$.post(this.action, data, newsletterSendOk);
	} else {
		alert(msg);
	}

	return false;
}
function newsletterSendOk(data, textStatus, XMLHttpRequest) {
	alert('Seus dados foram cadastrados com sucesso!');
	$("#newsletter_form input[type='text']").val('').eq(0).focus();
}
function createAnuncio() {
	var content = $(document.body);

	var div = $(document.createElement('div'));
	div.addClass('anuncio');

	var img = $(document.createElement('img'));
	img.attr('id', 'anuncioImg');
	img.attr('src', './imagens/anuncio.jpg');
	img.load(anuncioLoad);
	div.append(img);

	var close = $(document.createElement('a'));
	close.attr('href', 'javascript:void(0);');
	close.click(anuncioClose);
	close.append(document.createTextNode('[x] fechar'))
	div.append(close);

	content.append(div);
}
function anuncioLoad() {
	$('.anuncio').show();
	$('.anuncio').css('margin-left',
			'-' + (($('#anuncioImg').width() / 2) + 10) + 'px');
	$('.anuncio').css('margin-top',
			'-' + (($('#anuncioImg').height() / 2) + 10) + 'px');

//	anuncioTimeout = setTimeout('anuncioClose()', 7000);
}
function anuncioClose() {
	$('.anuncio').remove();
	clearInterval(anuncioTimeout);
}
