/**
 * Se utiliza como sistema de template, que muestre las acciones de los botones.
 *
 * @category   Funciones_Sitios_Institucionales
 * @package    Sitios_Institucionales
 * @copyright  2010 KIRKE
 * @license    GPL
 * @version    Release: 2.0
 * @link       http://kirke.ws
 * @since      Function available since Release 1.0
 * @deprecated
 */

function formulario(){

    $(".VC_error").hide();

    $('textarea[maxlength]').keyup(function(){
        var max = parseInt($(this).attr('maxlength'));
        if($(this).val().length > max){
            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
            $("#VC_"+this.name).html('No puede ingresar mas caracteres');
            $("#VC_"+this.name).show('slow');
        }else{
            $("#VC_"+this.name).hide('slow');
            $("#VC_"+this.name).html('');
        }
    });


    $("form").submit(function() {

        var enviar = true;
        var valor = true;
        var errores = '';
        var texto = '';
        var etiqueta = '';

        var fields = $(this).serializeArray();
        jQuery.each(fields, function(i, field) {

            texto = '';
            etiqueta = '';

			if( $('#'+field.name).attr("id") == 'captcha' ){
                if( !control_captcha(field.name,'El codigo ingresado de la imagen es incorrecto','Ha hecho mas de 10 intentos, debe refrescar la imagen.','Ingresá un dato') ){
                    etiqueta = $('#'+field.name).attr("etiqueta")
                    errores = errores + 'El codigo ingresado de la imagen es incorrecto<br />';
                    valor = false;
                }
			}
            if( $('#'+field.name).attr("tipo") == 'obligatorio' ){
                if( !no_nulo(field.name,'Ingresá un dato') ){
                    etiqueta = $('#'+field.name).attr("etiqueta");
                    errores = errores + 'Debe ingresar un dato en '+etiqueta+'<br />';
                    valor = false;
                }
            }
            if( $('#'+field.name).attr("valor") == 'mail' ){
                if( !es_mail(field.name,'Debés ingresar un mail válido') ){
                    etiqueta = $('#'+field.name).attr("etiqueta")
                    errores = errores + 'Debe ingresar un mail válido en '+etiqueta+'<br />';
                    valor = false;
                }
            }

            if( (valor==false) || (enviar==false) ){
                enviar = false;
            }

        });

        $("#VF_todos").html(errores);
        $("#VF_todos").show('slow');

        return enviar;

    });

}

