var PaginaNoticia = Class.create( {});

PaginaNoticia.tamanhoFonte = 14;
PaginaNoticia.containerTexto = 'texto_materia';
PaginaNoticia.label_fonte = 'label_fonte';
PaginaNoticia.arrayCidades = null;
PaginaNoticia.jaAvaliada = 0;

PaginaNoticia.upFonte = function()
{
	if (this.tamanhoFonte < 18)
	{
		this.tamanhoFonte++;
		$(this.containerTexto).style.fontSize = this.tamanhoFonte + 'px';
		$(this.label_fonte).innerHTML = this.tamanhoFonte;
	}
}

PaginaNoticia.downFonte = function()
{
	if (this.tamanhoFonte > 10)
	{
		this.tamanhoFonte--;
		$(this.containerTexto).style.fontSize = this.tamanhoFonte + 'px';
		$(this.label_fonte).innerHTML = this.tamanhoFonte;
	}
}

PaginaNoticia.cadComentario = function(objLink)
{
	$('formCommentNoticia').action = ConfigSite.URL_APP_HOME;
	$('formCommentNoticia').request();
}

PaginaNoticia.pubMensagemErro = function(objLink)
{
	$('formMensagemErroNoticia').action = ConfigSite.URL_APP_HOME;
	$('formMensagemErroNoticia').request();
}

PaginaNoticia.enviarNoticia = function()
{
	$('formSendNoticia').action = ConfigSite.URL_APP_HOME;
	$('formSendNoticia').request();
}

PaginaNoticia.loadCidades = function(uf)
{
		
	ajaxOptions = {
		parameters :"ACTION=LoadCidadesAction&idUf="
				+ uf
				+ "&idSelect=formCommentNoticia_cidade&arrayName=PaginaNoticia.arrayCidades"
	}
	
	$('formCommentNoticia_cidade').disabled = "";

	new Ajax.Request(ConfigSite.URL_APP_HOME, ajaxOptions);
}

PaginaNoticia.showOpcaoNoticia = function(obj)
{
	jQuery('.lista_opc_news > li > a').each( function(i)
	{
		this.className = '';
	});
	jQuery('.painel').each( function(i)
	{
		jQuery(this).hide("slow");
		jQuery(this).height(jQuery(this).height());
	});

	obj.className = 'selected';
	jQuery('#painel_' + obj.id).animate( {
		"height" :"toggle",
		"opacity" :"toggle"
	}, {
		duration :"fast"
	});
}

PaginaNoticia.deselectNota = function()
{
	var listaLinks = $('container_notas').getElementsByTagName('a');

	for ( var i = 0; i < listaLinks.length; i++)
	{
		listaLinks[i].className = "Dê sua nota";
	}

	$('avaliado').innerHTML = '';
}

PaginaNoticia.selectNota = function(nota)
{
	this.deselectNota();
	
	if (this.jaAvaliada == 1)
	{
		return;
	}

	var listaLinks = $('container_notas').getElementsByTagName('a');

	for ( var i = 0; i < nota; i++)
	{
		listaLinks[i].className = "selected";
	}

	listaLinks[nota - 1].className = "selected";
	$('avaliado').innerHTML = listaLinks[nota - 1].title;
}

PaginaNoticia.avaliar = function(idNoticia, nota)
{
	ajaxOptions = {
		parameters :"ACTION=ExecAvaliacaoNoticiaAction&idNoticia=" + idNoticia
				+ "&nota=" + nota
	}

	new Ajax.Request(ConfigSite.URL_APP_HOME, ajaxOptions);
}

PaginaNoticia.showAval = function()
{
	if (this.jaAvaliada == 0)
	{
		clearTimeout(this.timeOut);
		$('media_noticia').style.display = 'none';
		$('container_notas').style.display = 'block';
	}
}

PaginaNoticia.avalOK = function(params)
{
	$('num_votos').innerHTML = params.numVotos;
	$('msg_avaliacao').innerHTML = params.msg;
	$('msg_avaliacao').style.color = "#0066ff";
	$('msg_avaliacao').style.fontWeight = "bold";
	$('media_votos').style.width = params.pxMedia + 'px';
}

PaginaNoticia.avalErro = function(params)
{
	$('msg_avaliacao').innerHTML = params.msg;
	$('msg_avaliacao').style.color = "#ff0000";
	$('msg_avaliacao').style.fontWeight = "bold";
}