function imprimir(tipo, id) {
	window
			.open(
					'/paginas/imprimir/' + tipo + '/' + id,
					'_blank',
					'scrollbars=yes,location=no,width=700, height=' + (screen.availHeight - 100) + ',top=0,left=0');
}
function abreFoto(caminho) {
	window.open(caminho, '_blank', 'scrollbars=yes,location=no,width='
			+ (screen.availWidth) + ', height=' + (screen.availHeight)
			+ ',top=0,left=0');
}
function cadastranewsletter() {
	$.post("/paginas/cadastranewsletter/", {
		email : $("#news_email").val()
	}, function(data) {
		$("#dialog").html(data);
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		$('#mask').css( {
			'width' : maskWidth,
			'height' : maskHeight
		});
		$('#mask').fadeIn(1000);
		$('#mask').fadeTo("slow", 0.8);
		var winH = $(window).height();
		var winW = $(window).width();
		$('#dialog').css('top', '20px');
		$('#dialog').css('left', winW / 2 - $('#dialog').width() / 2);
		$('#dialog').fadeIn(2000);
	});
}
function envieparaumamigo(tipo, url, titulo) {
	$('#frmAmigosTipo').val(tipo);
	$('#frmAmigosUrl').val(url);
	$('#frmAmigosTitulo').val(titulo);
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	$('#mask').css( {
		'width' : maskWidth,
		'height' : maskHeight
	});
	$('#mask').fadeIn(1000);
	$('#mask').fadeTo("slow", 0.8);
	var winH = $(window).height();
	var winW = $(window).width();
	$('#dialogconvide').css('top', '20px');
	$('#dialogconvide').css('left', winW / 2 - $('#dialogconvide').width() / 2);
	$('#dialogconvide').fadeIn(2000);
}
function validaEnvieAmigo() {
	hasError = false;
	$("#respostaenvieamigo").html('');
	$("#respostaenvieamigo").removeClass("error");
	$("#respostaenvieamigo").removeClass("success");
	$("#respostaenvieamigo").removeClass("info");
	$("#respostaenvieamigo").slideUp("normal", function() {
	});
	var erros = '';
	var nomeVal = $("#nomede").val();
	var emailVal = $("#emailde").val();
	var nomeamigoVal = $("#nomepara").val();
	var emailamigoVal = $("#emailpara").val();
	if (nomeVal == '') {
		erros += '<li>Informe seu nome</li>';
		hasError = true;
	}
	if (emailVal == '') {
		erros += '<li>Informe seu email</li>';
		hasError = true;
	}
	if (nomeamigoVal == '') {
		erros += '<li>Informe o nome do seu amigo</li>';
		hasError = true;
	}
	if (emailamigoVal == '') {
		erros += '<li>Informe o email do amigo</li>';
		hasError = true;
	}
	if (hasError == true) {
		$("#respostaenvieamigo").addClass("error");
		$("#respostaenvieamigo").html('<ul>' + erros + '</ul>');
		$("#respostaenvieamigo").slideDown("normal", function() {
		});
	} else {
		salvaEnvieAmigo();
	}
}
function salvaEnvieAmigo() {
	$("#respostaenvieamigo").html('');
	$("#respostaenvieamigo").removeClass("error");
	$("#respostaenvieamigo").removeClass("success");
	$("#respostaenvieamigo").removeClass("info");
	$("#respostaenvieamigo").slideUp("normal", function() {
	});
	$
			.post(
					'/paginas/enviarporemail/',
					$('#frmAmigos').serializeArray(),
					function(data) {
						if (data != '') {
							$("#respostaenvieamigo").addClass("error");
							$("#respostaenvieamigo").html(data);
							$("#respostaenvieamigo").slideDown("normal",
									function() {
									});
						} else {
							$('#dialogconvide')
									.html(
											'<div class="success">Mensagem enviada com sucesso!</div><input type="button" name="Fechar" value="Fechar" onclick="javasript:$(\'#mask, .window\').hide();" />');
						}
					});
}
function enviarcomentario() {
	$.post($('#frmPostComment').attr('action'), $("#frmPostComment")
			.serialize(), function(data) {
		mostramensagem(data);
	});
}
function mostramensagem(data) {
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	$('#mask').css( {
		'width' : maskWidth,
		'height' : maskHeight
	});
	$('#mask').fadeIn(1000);
	$('#mask').fadeTo("slow", 0.8);
	$("#dialogmensagem").html(data);
	var winH = $(window).height();
	var winW = $(window).width();
	$('#dialogmensagem').css('top', '20px');
	$('#dialogmensagem').css('left',
			winW / 2 - $('#dialogmensagem').width() / 2);
	$('#dialogmensagem').fadeIn(2000);
}
function abreenviecomentario(tipo) {
	$('#imgMensagemEnvia').attr('style', 'display: none;');
	$('#imgVideoEnvia').attr('style', 'display: none;');
	$('#imgFotoEnvia').attr('style', 'display: none;');
	$('#imgAudioEnvia').attr('style', 'display: none;');
	$('#img' + tipo + 'Envia').attr('style', '');
	$('#tipoComentario').val(tipo);
	$('#dataComentarioTexto').val($('#txtComentario').val());
	if (tipo != 'Mensagem') {
		$('#containerArquivo').attr('style', '');
		$('#containerTexto').attr('style', 'display: none;');
	} else {
		$('#containerArquivo').attr('style', 'display: none;');
		$('#containerTexto').attr('style', '');
	}
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	$('#mask').css( {
		'width' : maskWidth,
		'height' : maskHeight
	});
	$('#mask').fadeIn(1000);
	$('#mask').fadeTo("slow", 0.8);
	var winH = $(window).height();
	var winW = $(window).width();
	$('#dialogenviecomentario').css('top', '20px');
	$('#dialogenviecomentario').css('left',
			winW / 2 - $('#dialogenviecomentario').width() / 2);
	$('#dialogenviecomentario').fadeIn(2000);
}
function validaEnvieComentarioConfirmado() {
	$('#dialogconfirmaComentario').hide();
	salvaEnvieComentario('');
}
function validaEnvieComentarioContato() {
	$('#dialogconfirmaComentario').hide();
	salvaEnvieComentarioContato();
}
function validaEnvieComentario() {
	hasError = false;
	$("#respostaenviecomentario").html('');
	$("#respostaenviecomentario").removeClass("error");
	$("#respostaenviecomentario").removeClass("success");
	$("#respostaenviecomentario").removeClass("info");
	$("#respostaenviecomentario").slideUp("normal", function() {
	});
	var erros = '';
	var nomeVal = $("#nome").val();
	var emailVal = $("#email").val();
	var comentarioVal = $("#dataComentarioTexto").val();
	if (nomeVal == '') {
		erros += '<li>Informe seu nome</li>';
		hasError = true;
	}
	if (emailVal == '') {
		erros += '<li>Informe seu email</li>';
		hasError = true;
	}
	if ($('#tipoComentario').val() != "Mensagem") {
		if ($('#fileQueue').html() == '') {
			erros += '<li>Selecione um arquivo</li>';
			hasError = true;
		}
	} else {
		if (comentarioVal == '') {
			erros += '<li>Informe seu comentário</li>';
			hasError = true;
		}
	}
	if (hasError == true) {
		$("#respostaenviecomentario").addClass("error");
		$("#respostaenviecomentario").html('<ul>' + erros + '</ul>');
		$("#respostaenviecomentario").slideDown("normal", function() {
		});
	} else {
		if ($('#tipoComentario').val() == 'Mensagem') {
			abreConfirmaEnvieComentario();
			return;
		}
		if ($('#arquivo').val() != '') {
			salvaEnvieComentario('');
		} else {
			if ($('#fileQueue').html() != '') {
				$('#arquivo').uploadifyUpload();
				$("#respostaenviecomentario").addClass("info");
				$("#respostaenviecomentario").html('Enviando arquivo...');
				$("#respostaenviecomentario").slideDown("normal", function() {
				});
			} else {
				salvaEnvieComentario('');
			}
		}
	}
}
function abreConfirmaEnvieComentario() {
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	$('#mask').css( {
		'width' : maskWidth,
		'height' : maskHeight
	});
	$('#mask').fadeIn(1000);
	$('#mask').fadeTo("slow", 0.8);
	var winH = $(window).height();
	var winW = $(window).width();
	$('#dialogconfirmaComentario').css('top', '50px');
	$('#dialogconfirmaComentario').css('left',
			winW / 2 - $('#dialogconfirmaComentario').width() / 2);
	$('#dialogconfirmaComentario').fadeIn(2000);
}
function salvaEnvieComentario(arquivo) {
	$("#respostaenviecomentario").html('');
	$("#respostaenviecomentario").removeClass("error");
	$("#respostaenviecomentario").removeClass("success");
	$("#respostaenviecomentario").removeClass("info");
	$("#respostaenviecomentario").slideUp("normal", function() {
	});
	$('#nomearquivo').val(arquivo);
	$
			.post(
					$('#frmEnvieComentario').attr('action'),
					$('#frmEnvieComentario').serialize(),
					function(data) {
						if (data != '') {
							$("#respostaenviecomentario").addClass("error");
							$("#respostaenviecomentario").html(data);
							$("#respostaenviecomentario").slideDown("normal",
									function() {
									});
						} else {
							$('#dialogenviecomentario')
									.html(
											'<div class="success">Mensagem enviada com sucesso!</div><input type="button" name="Fechar" value="Fechar" onclick="javasript:$(\'#mask, .window\').hide();" />');
						}
					});
}
function salvaEnvieComentarioContato() {
	$("#respostaenviecomentario").html('');
	$("#respostaenviecomentario").removeClass("error");
	$("#respostaenviecomentario").removeClass("success");
	$("#respostaenviecomentario").removeClass("info");
	$("#respostaenviecomentario").slideUp("normal", function() {
	});
	$
			.post(
					'/paginas/enviarcomentariocontato',
					$('#frmEnvieComentario').serialize(),
					function(data) {
						if (data != '') {
							$("#respostaenviecomentario").addClass("error");
							$("#respostaenviecomentario").html(data);
							$("#respostaenviecomentario").slideDown("normal",
									function() {
									});
						} else {
							$('#dialogenviecomentario')
									.html(
											'<div class="success">Mensagem enviada com sucesso!</div><input type="button" name="Fechar" value="Fechar" onclick="javasript:$(\'#mask, .window\').hide();" />');
						}
					});
}

function tamanhoFonte(id) {
	$('.boxfontes ul li *').removeClass('ativo');
	$('.boxfontes ul li:eq(' + id + ') a').addClass('ativo');

	tamanhoFontes = Array('7', '9', '11', '13');
	tamanhoLHeight = Array('10', '12', '14', '16');

	var cssObj = {
		'font-size' : tamanhoFontes[id] + 'pt',
		'line-height' : tamanhoLHeight[id] + 'pt'
	}

	$('#mudaFonte').css(cssObj);
}

function configuraShareIt()
{
	//grab all the anchor tag with rel set to shareit
	$('a[rel=shareit], #shareit-box').mouseenter(function() {

		//get the height, top and calculate the left value for the sharebox
		var height = $(this).height();
		var top = $(this).offset().top;

		//get the left and find the center value
		var left = $(this).offset().left + ($(this).width() /2) - ($('#shareit-box').width() / 2);

		//grab the href value and explode the bar symbol to grab the url and title
		//the content should be in this format url|title
		var value = $(this).attr('href').split('|');

		//assign the value to variables and encode it to url friendly
		var field = value[0];
		var url = encodeURIComponent(value[1]);
		var title = encodeURIComponent(value[2]);
		var arquivo = value[3];

		//assign the height for the header, so that the link is cover
		$('#shareit-header').height(height);

		//display the box
		$('#shareit-box').show();

		//set the position, the box should appear under the link and centered
		$('#shareit-box').css({'top':top, 'left':left});

		//assign the url to the textfield
		$('#shareit-field').val(field);

		//make the bookmark media open in new tab/window
		$('a.shareit-sm').attr('target','_blank');

		//Setup the bookmark media url and title
		$('a[rel=shareit-mail]').attr('href', 'mailto:?subject=' + title + '&body=' + url);
		$('a[rel=shareit-delicious]').attr('href', 'http://del.icio.us/post?v=4&noui&jump=close&url=' + url + '&title=' + title);
		$('a[rel=shareit-orkut]').attr('href', 'http://promote.orkut.com/preview?nt=orkut.com&du='  + url + '&title=' + title);
		$('a[rel=shareit-facebook]').attr('href', 'http://www.facebook.com/share.php?u=' + url);
		$('a[rel=shareit-stumbleupon]').attr('href', 'http://www.stumbleupon.com/submit?url=' + url + '&title=' + title);
		$('a[rel=shareit-twitter]').attr('href', 'http://twitter.com/home?status=' + title + '%20-%20' + url);
		$('a[rel=shareit-download]').attr('href', arquivo);
//http://promote.orkut.com/preview?nt=orkut.com&du=http%3A%2F%2Fesportes.terra.com.br%2Ffutebol%2Fcopa%2F2010%2Fnoticias%2F0%2C%2COI4558927-EI15652%2C00-Larissa%2BRiquelme%2Bira%2Bcorrer%2Bnua%2Bem%2BAssuncao%2Bneste%2Bdomingo.html&tt=Larissa%20Riquelme%20ir%C3%A1%20correr%20nua%20em%20Assun%C3%A7%C3%A3o%20neste%20domingo&cn=%20A%20modelo%20paraguaia%20Larissa%20Riquelme%2C%20musa%20da%20Copa%20do%20Mundo%20da%20%C3%81frica%20do%20Sul%2C%20ir%C3%A1%20cumprir%20uma%20de%20suas%20promessas%20neste%20domingo%2C%20em%20Assun%C3%A7%C3%A3o.%20Larissa%20ir%C3%A1%20correr%20nua%20pelas%20ruas%20da%20capital%20paraguaia.%0A%0A%20...
//http://www.facebook.com/share.php?u=http%3A%2F%2Fesportes.terra.com.br%2Ffutebol%2Fcopa%2F2010%2Fnoticias%2F0%2C%2COI4558927-EI15652%2C00-Larissa%2BRiquelme%2Bira%2Bcorrer%2Bnua%2Bem%2BAssuncao%2Bneste%2Bdomingo.html
	});

	//onmouse out hide the shareit box
	$('#shareit-box').mouseleave(function () {
		$('#shareit-field').val('');
		$(this).hide();
	});

	//hightlight the textfield on click event
	$('#shareit-field').click(function () {
		$(this).select();
	});
}