Opine = {

    enviarEmail: function(){

        var effect = Validacao.initEffect( "msg_envio" );
         
       /* if( !this.validaFormEmpty() ){
            Validacao.showMsg( effect, "msg_envio", "Todos os campos são de preenchimento obrigatório" );
            return false;
        }

        if( !this.validaFormValid() ){
            Validacao.showMsg( effect, "msg_envio", "Endereço fornecido no campo e-mail é invalido" );
            return false;
        }*/


		var nome_anuncio 			= $('nome_anuncio').value;
		var email_anuncio			= $('email_anuncio').value;
		var cidade_anuncio			= $('cidade_anuncio').value;
		var estado_anuncio			= $('estado_anuncio').value;
		var ddd_anuncio				= $('ddd_anuncio').value;
		var telefone_anuncio		= $('telefone_anuncio').value;
		var comentario_anuncio		= $('comentario_anuncio').value;
		
		if(nome_anuncio == "")
		{
			Aviso('Digite seu nome');
			return false;
		}
		
		if(email_anuncio.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			Aviso('Email inválido');
			return false;
		}
		
		if(cidade_anuncio == "")
		{
			Aviso('Digite a sua cidade');
			return false;
		}
		
		if(estado_anuncio == "")
		{
			Aviso('Digite o seu estado')
			return false;
		}
		
		if(ddd_anuncio == "00")
		{
			Aviso('Digite o DDD');
			return false;
		}
		
		if(telefone_anuncio == '0000-0000')
		{
			Aviso('Digite seu telefone');
			return false;
		}
		
		if(comentario_anuncio == '')
		{
			Aviso('Digite o comentario');
			return false;
		}
		
        var url = 'index.php?option=com_anuncio&tmpl=component';

        var pars = serialize( $( 'formAnuncio' ) );

        var request = new Request(
            {
                url: url,

                method: 'post',

                data: pars,

                onSuccess: function( txt ){
                    //Aviso( txt );
                    Aviso( "E-mail enviado com sucesso" );
                }
            }
        );

        request.send();
		document.formAnuncio.reset();
    },

    validaFormEmpty: function(){

        if( !Validacao.isEmpty( $( "nome_anuncio" ) ) ){
            return false;
        }
        else if( !Validacao.isEmpty( $( "email_anuncio" ) ) ){
            return false;
        }
        else if( !Validacao.isEmpty( $( "cidade_anuncio" ) ) ){
            return false;
        }
        else if( !Validacao.isEmpty( $( "estado_anuncio" ) ) ){
            return false;
        }
		else if( !Validacao.isEmpty( $( "telefone_anuncio" ) ) ){
            return false;
        }
		else if( !Validacao.isEmpty( $( "comentario_anuncio" ) ) ){
            return false;
        }
        
        return true;

    },

    validaFormValid: function(){

        if( !Validacao.isValid( $( "email_anuncio" ) ) ){
            return false;
        }
        
        return true;
		
    }

}
