var noticia ={
		filtrarNoticias: function()
		{
			var categoria = $("cboCategoria").value;
			return{
				cboCategoria: categoria
		    };
		},
		filtrarCategoria: function(cbo)
		{
			var categoria = cbo.value;
			var nome = $("txtNome").value;
			window.location.href="?acao=listaNoticias&categoria="+categoria+"&txtNome="+nome;
		},
		
		verificaComentario: function()
		{
			if($("txtEnviado").value == '') {
				Mensagem.exibir("false", 'Favor digitar o seu nome!');
				return false;
			}
			if($("txtComentarioNoticia").value == '') {
				Mensagem.exibir("false", 'Favor digitar o seu coment&aacute;rio!');
				return false;
			}
			return true;
		},
		
		validarEuLivreiro: function()
		{
			if($("txtTitulo").value == '') {
				Mensagem.exibir("false", 'Favor digitar o título da notícia!');
				return false;
			}
			if($("txtTexto").value == '') {
				Mensagem.exibir("false", 'Favor digitar o conteúdo da notícia!');
				return false;
			}
			/*
			if($("realupload").value == '') {
				Mensagem.exibir("false", 'Favor informar a foto da notícia!');
				return false;
			}
			*/
			return true;
		},
		
		paramsEnviarEuLivreiro: function()
		{
			var txtTitulo = $("txtTitulo").value;
			var txtTexto = $("txtTexto").value;
			var realupload = $("realupload").value;
			var cboCategoria = $("cboCategoria").value;
			return {
				//Wizard
				cboCategoria : cboCategoria,
				txtTitulo  : txtTitulo,
				txtTexto   : txtTexto,
				realupload : realupload				
			};
		},
		postar:function(){
			$("gravar").submit();
		},
		uploadForm: function(valor){
			
			var ext = noticia.strrchr(valor,'.');
			
			if(ext.toLowerCase() != '.gif' && ext.toLowerCase() != '.jpg' && ext.toLowerCase() != '.png')
			{
				Mensagem.exibir("false","Imagem com extens&atilde;o inv&aacute;lida!");
				return false;
			}
			
			/*var oas = new ActiveXObject("Scripting.FileSystemObject");
			var d = $("realupload").value;
			var e = oas.getFile(d);
			var f = e.size;
			var mb=f/(1024);
			if (mb >= 500){
				Mensagem.exibir("false","A Imagem n&atilde;o pode ter mais do que 500Kb!");
				return false;
			}else{
				Mensagem.exibir("false","A Imagem passou no teste!");
				return false;
			}*/
			
			$("formUpload").submit();
			noticia.submitUpload($("formUpload"));
			return true;
			
		},
		
		strrchr:function(haystack, needle) {
		    // http://kevin.vanzonneveld.net
		    // +   original by: Brett Zamir (http://brett-zamir.me)
		    // +   input by: Jason Wong (http://carrot.org/)
		    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
		    // *     example 1: strrchr("Line 1\nLine 2\nLine 3", 10).substr(1)
		    // *     returns 1: 'Line 3'
		 
		    var pos = 0;
		 
		    if (typeof needle !== 'string') {
		        needle = String.fromCharCode(parseInt(needle, 10));
		    }
		    needle = needle.charAt(0);
		    pos = haystack.lastIndexOf(needle);
		    if (pos === -1) {
		        return false;
		    }
		 
		    return haystack.substr(pos);
		},
		
		submitUpload: function(form){
			inicioLoading();
			  form.request({
		          onComplete: function(transport){
		              /*
		            se o retorno for diferente de -1, entende-se que não houve problemas, então apaga-se
		            os campos do formulário usando o método reset() da classe Form
		            */
		            if(transport.responseText!=-1)
		            	fechaDiv();
		            }
		        });
		        return false;

			
		},
		
		limpaEnviarEuLivreiro : function()
		{
			$("txtTitulo").value = "";
			$("txtTexto").value = "";
			$("realupload").value = "";				
			
		},
		
		validarPesquisa: function(){
			if($("txtNome").value.length < 3) {
				Mensagem.exibir("false", 'Favor digitar ao menos 3 letras!');
				return false;
			}
			return true;
		},
		
		paramsPesquisarNoticias: function(){
			var txtNome = document.getElementById("txtNome").value;
			//var cboCategoria = document.getElementById("cboCategoria").value;
			//var Calendario = document.getElementById("Calendario").value;
			//var tela = document.getElementById("tela").value;
			return {
				txtNome : txtNome
				//cboCategoria : cboCategoria,
				//Calendario : Calendario,
				//tela : tela
			};
		},
		
		paramsFiltrarNoticias: function(){
			var txtNome = document.getElementById("txtNome").value;
			var cboCategoria = document.getElementById("cboCategoria").value;
			var Calendario = document.getElementById("Calendario").value;
			var tela = document.getElementById("tela").value;
			return {
				txtNome : txtNome,
				cboCategoria : cboCategoria,
				Calendario : Calendario,
				tela : tela
			};
		},
		
		paramsNoticiaComentario: function(){
			var nome = $("txtEnviado").value;
			var comentario= $("txtComentarioNoticia").value;
			return {
				nome : nome,
				comentario : comentario,
				acao : 'cadastraComentarioNoticia'
			};
		},
		
		verificaEnviaNoticia: function()
		{
			
			if($("txtNomeUsu").value == '') {
				Mensagem.exibir("false", 'Favor digitar o seu nome!');
				return false;
			}
			if($("txtEmail").value == '') {
				Mensagem.exibir("false", 'Favor digitar o seu email!');
				return false;
			}
			if($("txtPara").value == '') {
				Mensagem.exibir("false", 'Favor digitar o email do destinat&aacute;rio!');
				return false;
			}
			return true;
		},
		
		paramsEnviaNoticia: function(){
			var nome = $("txtNomeUsu").value;
			var email = $("txtEmail").value;
			var para = $("txtPara").value;
			var comentario = $("txtComentario").value;
			return {
				nome : nome,
				email : email,
				para : para,
				comentario : comentario,
				acao : 'enviarNoticia'
			};
		},
		
		limpaEnviaNoticia : function(texto)
		{
			if(texto.responseText == "email"){
				Mensagem.exibir("false", 'Favor digitar um email v&aacute;lido!');
			}else{	
				document.getElementById("txtNomeUsu").value = "";
				document.getElementById("txtEmail").value = "";
				document.getElementById("txtPara").value = "";
				document.getElementById("txtComentario").value = "";
				mostraEnviarAmigo(false);
				Mensagem.exibir("true", texto.responseText);
			}	
			
		},
		paramsPesquisar: function(){
			return{
				Local: $("txtLocalEvento").value,
				TipoEvento: $("cboTipoEvento").value,
				Periodo:$("cboTipoPeriodo").value
			}
		},
		paramsComentarioEvento: function(){
			return{
				Comentario: $("txtComentario_Evento").value,
				idEvento: $("hidEvento").value,
				opcao: 'N'
			}
		}
		
}