﻿$(document).ready(function() {
    //    $('#ctl00_ContentPlaceHolder1_txtOutroTipo').click(function() {
    //        $('#ctl00_ContentPlaceHolder1_rbTipoConstrucao_2').attr({ checked: true })
    //    });

    //    $('#ctl00_ContentPlaceHolder1_txtOutraSala').click(function() {
    //        $('#ctl00_ContentPlaceHolder1_rbSalaRack_2').attr({ checked: true })
    //    });

    //    $('#ctl00_ContentPlaceHolder1_txtExemplifique').click(function() {
    //        $('#ctl00_ContentPlaceHolder1_rbSecretaria_2').attr({ checked: true })
    //    });

    //    $('#ctl00_ContentPlaceHolder1_txtOutrosProjetos').click(function() {
    //        $('#ctl00_ContentPlaceHolder1_rbProjetos_3').attr({ checked: true })
    //    });


    //    $('#ctl00_ContentPlaceHolder1_txtQual').click(function() {
    //        $('#ctl00_ContentPlaceHolder1_rbAtivo_2').attr({ checked: true })
    //    });

    //    $('#ctl00_ContentPlaceHolder1_txtOutraPeriodicidade').click(function() {
    //        $('#ctl00_ContentPlaceHolder1_rbPeriodicidade_2').attr({ checked: true })
    //    });
    /*
    $('#ctl00_ContentPlaceHolder1_lkEnviar').click(function() {
    //$(this).hide(); 
    alert('teste');
    });
    */
    $('#ctl00_ContentPlaceHolder1_RequiredFieldValidator39').change(function() {
        alert('#ctl00_ContentPlaceHolder1_RequiredFieldValidator39');
    });

    // modal Home
    if ($('.modal').is('div')) {

        var modal = setTimeout(function() {
            $('.modal').appendTo('body').absoluteCenter({ animation: false }).absoluteCenter().show();
        }, 1000);

        $('.modal a.btn-fechar').click(function() { $(this).parent().hide(); })

        if ($.browser.msie && parseInt($.browser.version) == 6) {
            $('.modal').click(function() { $(this).hide(); })
        }

    }

    //Cufon.replace('.box h2', { fontFamily: 'Telefonica Text'}); 
    Cufon.replace('#menuApoio a', { fontFamily: 'Telefonica Text', hover: { color: '#fff'} });
    Cufon.replace('#topo h1 a, .menuRedesSociais a, .modal p, .lnk-dia-voluntarios', { fontFamily: 'Telefonica Headline Light' });

    // Rolagem Videos
    if ($('#listaVideos').is('div'))
        $('#listaVideos').tinyscrollbar({ sizethumb: 60, wheel: 171 });

    if ($('#container-galeria').is('div')) {
    
        $('#container-galeria').tinyscrollbar({ sizethumb: 115, wheel: 15, axis: 'x' });
        var galeriSize = $('#container-galeria .overview li').size();
        $('#container-galeria .overview').css('width', galeriSize * 163);

    }

    $('.lista-destaques li').append('<div class="clear-both">');

    $('.overview ul li:first').addClass('primeiro-item');

    // Twitter
    if ($('.tweet').is('div')) {
        $('.tweet').each(function() {
            var user = $(this).prev().find('span').text().replace('@', '').toLowerCase();
            var qt = user != 'ft_brasil' ? 2 : 1;

            $(this).tweet({
                username: user,
                avatar_size: 32,
                count: qt,
                loading_text: "loading tweets..."
            });
        });
    }

//    //Função select Comitê
//    $('.slc-comites').change(function() {
//        var index = $('.slc-comites option:selected');
//        if (index.text() == "Selecione") return false;
//        $('.box-comites ul').hide();
//        $('.box-comites ul.' + index.attr('value')).show();
//    });

    // Mapa
    if ($('.bullets').is('div')) {

        var img = new Array();
        img[1] = '_img/bullet-mapa-over.png';
        img[2] = '_img/bullet-mapa-over-2.png';
        img[3] = '_img/tooltip-topo.png';
        img[4] = '_img/tooltip-meio.png';
        img[5] = '_img/tooltip-base.png';

        var load = new Array();
        for (var imagem in img) {
            load[imagem] = new Image;
            load[imagem].src = img[imagem];
        }

        var timeBullet;

        $('.bullets a')
        .each(
            function() {
                var pais = $(this).attr('title');
                $(this).removeAttr('title');

                $(this).siblings('.conteudo')
                        .css({ display: 'block' })
                        .wrap('<div class="tooltip"></div>')
                        .parent()
                        .prepend('<div class="topo">' + pais + '</div>')
                        .append('<div class="base"></div>');
            }
        )
        .hover(
            function() {
                clearTimeout(timeBullet);
                var _this = $(this)
                timeBullet = setTimeout(function() {
                    var posicao = $(_this).position();
                    posicao.left += 30;
                    posicao.top += 10;
                    $(_this).siblings('div').css(posicao).show().parent().css({ zIndex: 2 });
                }, 200)
            },
            function() {
                clearTimeout(timeBullet);
                $(this).siblings('div').hide().parent().css({ zIndex: 1 });
            }
        );
    }

    // Abas
    $('.nav-abas').append('<div class="clear-both" />');
    //    $('.nav-abas a:first').addClass('active'); 
    $('.nav-abas a:last').addClass('last'); $('.box-topicos .item-aba:first').show();

    var numAbas = $('.nav-abas a').size();
    $('.nav-abas a').each(function() {
        $(this).css('width', (645 / numAbas) - 18);
        if (numAbas >= 8) {
            $(this).css('width', (645 / (numAbas / 2)) - 18);
            $('.nav-abas a:eq(4)').css('clear', 'both');
        }
    })
    //    .click(function() {
    //        var tarAba = $(this).attr('href');
    //        $(this).addClass('active').siblings().removeClass('active'); ;
    //        $('.box-topicos .' + tarAba).show().siblings().hide();
    //        return false;
    //    });

    $('.nav-abas a[href=tour]').unbind();
    $('.nav-abas a[href=tour]').click(function() {
        window.open('Projetos-Culturais-Tour-Virtual.aspx');
        return false;
    });

    //Margin Subtitulo
    $('.box-conteudo-padrao .sub-titulo:first-child').css("margin-top", "0");

    // FAQ
    $('.box-conteudo-padrao .lista-faq li:last-child').css("padding-bottom", "0");
    $('.box-conteudo-padrao .lista-faq li:last-child').css("border", "0");

    // Mapa do Site
    $('.container-secao:first-child').css("margin-top", "0")

    // Accordion
    $('.accordion li h3 a').click(function() {
        if (!$(this).parent().is(':only-child'))
            $(this).toggleClass('aberto').parent().next().slideToggle('slow');
    })

    // listaDoacoes
    $('.listaDoacoes li a').click(function() {
        if (!$(this).hasClass('aberto'))
            $('.listaDoacoes .aberto').removeClass('aberto').next().slideUp();
        $(this).toggleClass('aberto').next().slideToggle('slow');
    })

    // Tooltip Notas
    var timeOutNotas
    $('.tooltip-nota .verNota').hover(
        function() {
            $(this).siblings().show();
        },
        function() {
            var _this = $(this).siblings()
            timeOutNotas = setTimeout(function() { _this.hide(); }, 100);
        }
    );

    $('.box-tooltip').hover(
        function() {
            clearTimeout(timeOutNotas);
            $(this).show();
        },
        function() {
            $(this).hide();
        }
    )

    // Link Ativo
    paginaAtiva = window.location + '';
    paginaAtiva = paginaAtiva.split('/').pop();
    if (paginaAtiva != '') {

        if ($('a[href="' + paginaAtiva + '"]').parents('ul:eq(0)').hasClass('nivel3')) {

            $('a[href="' + paginaAtiva + '"]').parents('ul:eq(0)').siblings('a').addClass('ativo')
                .parents('ul:eq(0)').show()
                .siblings('a').addClass('ativo');

        } else {

            $('a[href="' + paginaAtiva + '"]').addClass('ativo').siblings('ul:not(.nivel3)').show()
            $('a[href="' + paginaAtiva + '"]').parent().parent().show();
        }
    }

    // supersLeight
    $('.boxMapa, #pesquisar, #banner, .modal, #logo, .lista-posts .img-padrao span, .box-tooltip').supersleight();

    //Ver Regulamento/Edital
    $('.lnk-ver-regulamento').click(function() {
        $('.conteudo-edital').slideToggle('slow');
    });

    //Formulário Edital
    $('.rbNivelEnsino input').click(function() {
        var chk = $('.rbNivelEnsino input:checked').length;
        if (chk == 0) {

        }
        else {

        }
    });

    // Paginacao
    $('.paginacao-blog span').each(function() {

        var numero = $(':not(.seta)', this);
        $(numero).wrapAll('<p />');
    });

    // Show/Hide Imgs
    $('.lnk-image').click(function() {
        $(this).parents('p').next().toggle();
    });
});


function acaoEdicao() {

    if ($('#container-galeria').is('div')) {
    
        $('#container-galeria li a').click(function() {
            var image_galeria = $(this).attr('href');
            $('.box-imagem-ampliada img').attr('src', image_galeria);
            return false;
        });

    
        $('#container-galeria').tinyscrollbar({ sizethumb: 115, wheel: 15, axis: 'x' });
        var galeriSize = $('#container-galeria .overview li').size();
        $('#container-galeria .overview').css('width', galeriSize * 163);
    }
}


/*
Masked Input plugin for jQuery
Copyright (c) 2007-2009 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license) 
Version: 1.2.2 (03/09/2009 22:39:06)
*/

(function(a) { var c = (a.browser.msie ? "paste" : "input") + ".mask"; var b = (window.orientation != undefined); a.mask = { definitions: { "9": "[0-9]", a: "[A-Za-z]", "*": "[A-Za-z0-9]"} }; a.fn.extend({ caret: function(e, f) { if (this.length == 0) { return } if (typeof e == "number") { f = (typeof f == "number") ? f : e; return this.each(function() { if (this.setSelectionRange) { this.focus(); this.setSelectionRange(e, f) } else { if (this.createTextRange) { var g = this.createTextRange(); g.collapse(true); g.moveEnd("character", f); g.moveStart("character", e); g.select() } } }) } else { if (this[0].setSelectionRange) { e = this[0].selectionStart; f = this[0].selectionEnd } else { if (document.selection && document.selection.createRange) { var d = document.selection.createRange(); e = 0 - d.duplicate().moveStart("character", -100000); f = e + d.text.length } } return { begin: e, end: f} } }, unmask: function() { return this.trigger("unmask") }, mask: function(j, d) { if (!j && this.length > 0) { var f = a(this[0]); var g = f.data("tests"); return a.map(f.data("buffer"), function(l, m) { return g[m] ? l : null }).join("") } d = a.extend({ placeholder: "_", completed: null }, d); var k = a.mask.definitions; var g = []; var e = j.length; var i = null; var h = j.length; a.each(j.split(""), function(m, l) { if (l == "?") { h--; e = m } else { if (k[l]) { g.push(new RegExp(k[l])); if (i == null) { i = g.length - 1 } } else { g.push(null) } } }); return this.each(function() { var r = a(this); var m = a.map(j.split(""), function(x, y) { if (x != "?") { return k[x] ? d.placeholder : x } }); var n = false; var q = r.val(); r.data("buffer", m).data("tests", g); function v(x) { while (++x <= h && !g[x]) { } return x } function t(x) { while (!g[x] && --x >= 0) { } for (var y = x; y < h; y++) { if (g[y]) { m[y] = d.placeholder; var z = v(y); if (z < h && g[y].test(m[z])) { m[y] = m[z] } else { break } } } s(); r.caret(Math.max(i, x)) } function u(y) { for (var A = y, z = d.placeholder; A < h; A++) { if (g[A]) { var B = v(A); var x = m[A]; m[A] = z; if (B < h && g[B].test(x)) { z = x } else { break } } } } function l(y) { var x = a(this).caret(); var z = y.keyCode; n = (z < 16 || (z > 16 && z < 32) || (z > 32 && z < 41)); if ((x.begin - x.end) != 0 && (!n || z == 8 || z == 46)) { w(x.begin, x.end) } if (z == 8 || z == 46 || (b && z == 127)) { t(x.begin + (z == 46 ? 0 : -1)); return false } else { if (z == 27) { r.val(q); r.caret(0, p()); return false } } } function o(B) { if (n) { n = false; return (B.keyCode == 8) ? false : null } B = B || window.event; var C = B.charCode || B.keyCode || B.which; var z = a(this).caret(); if (B.ctrlKey || B.altKey || B.metaKey) { return true } else { if ((C >= 32 && C <= 125) || C > 186) { var x = v(z.begin - 1); if (x < h) { var A = String.fromCharCode(C); if (g[x].test(A)) { u(x); m[x] = A; s(); var y = v(x); a(this).caret(y); if (d.completed && y == h) { d.completed.call(r) } } } } } return false } function w(x, y) { for (var z = x; z < y && z < h; z++) { if (g[z]) { m[z] = d.placeholder } } } function s() { return r.val(m.join("")).val() } function p(y) { var z = r.val(); var C = -1; for (var B = 0, x = 0; B < h; B++) { if (g[B]) { m[B] = d.placeholder; while (x++ < z.length) { var A = z.charAt(x - 1); if (g[B].test(A)) { m[B] = A; C = B; break } } if (x > z.length) { break } } else { if (m[B] == z[x] && B != e) { x++; C = B } } } if (!y && C + 1 < e) { r.val(""); w(0, h) } else { if (y || C + 1 >= e) { s(); if (!y) { r.val(r.val().substring(0, C + 1)) } } } return (e ? B : i) } if (!r.attr("readonly")) { r.one("unmask", function() { r.unbind(".mask").removeData("buffer").removeData("tests") }).bind("focus.mask", function() { q = r.val(); var x = p(); s(); setTimeout(function() { if (x == j.length) { r.caret(0, x) } else { r.caret(x) } }, 0) }).bind("blur.mask", function() { p(); if (r.val() != q) { r.change() } }).bind("keydown.mask", l).bind("keypress.mask", o).bind(c, function() { setTimeout(function() { r.caret(p(true)) }, 0) }) } p() }) } }) })(jQuery);
jQuery(function($) {
    $(".maskDDD").mask("99", { placeholder: " " });
    $(".ddd").mask("99", { placeholder: " " });
    $(".maskTel").mask("9999-9999", { placeholder: " " });
    $(".maskCEP").mask("99999", { placeholder: " " });
    $(".maskDig").mask("999", { placeholder: " " });
    $(".maskcnpj").mask("99.999.999/9999-99", { placeholder: " " });
    $(".date").mask("99/99/9999", { placeholder: " " });

});

/////// FUNCOES

// supersLeight
jQuery.fn.supersleight = function(settings) {
    settings = jQuery.extend({
        imgs: true,
        backgrounds: true,
        shim: '../_img/blank.gif',
        apply_positioning: true
    }, settings);

    return this.each(function() {
        if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
            jQuery(this).find('*').andSelf().each(function(i, obj) {
                var self = jQuery(obj);
                // background pngs
                if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
                    var bg = self.css('background-image');
                    var src = bg.substring(5, bg.length - 2);
                    var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
                    var styles = {
                        'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
                        'background-image': 'url(' + settings.shim + ')'
                    };
                    self.css(styles);
                };
                // image elements
                if (settings.imgs && (self.is('img[src$=png]') || self.is('input[src$=png][type=image]'))) {
                    var styles = {
                        'width': self.width() + 'px',
                        'height': self.height() + 'px',
                        'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
                    };
                    self.css(styles).attr('src', settings.shim);
                };
                // apply position to 'active' elements
                if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')) {
                    self.css('position', 'relative');
                };
            });
        };
    });
};

//////////////
// No Label //
//////////////
noLabel = {
    init: function(vazio) {
        $('.noLabel').each(function() {
            if (Get_Cookie($(this).attr('id')) != null) {
                if (Get_Cookie($(this).attr('id')) == $(this).val()) {
                    $(this).addClass('vazio');
                    noLabel.buffer[$(this).attr('id')] = $(this).val();
                }
                else {
                    noLabel.buffer[$(this).attr('id')] = Get_Cookie($(this).attr('id'));
                }
            }
            else {
                $(this).addClass('vazio');
                noLabel.buffer[$(this).attr('id')] = $(this).val();
                Set_Cookie($(this).attr('id'), $(this).val(), 360, '/', '', '');
            }

            $(this).unbind('focus', noLabel.foco).unbind('blur', noLabel.desfoco).bind('focus', noLabel.foco).bind('blur', noLabel.desfoco);
        }).parents('form:eq(0)').unbind('submit', noLabel.formulario).bind('submit', noLabel.formulario);
    },

    buffer: {},

    foco: function(obj) {


        obj = typeof ($(obj).attr('id')) == 'undefined' ? this : obj;

        if ($(obj).hasClass('vazio')) {
            if ($(obj).is('textarea')) {
                $(obj).html('');
            } else {
                $(obj).val('');
            }
            $(obj).removeClass('vazio');
        }
    },

    desfoco: function() {

        if ($.trim($(this).val()) == '') {
            if ($(this).is('textarea')) {
                $(this).html(noLabel.buffer[$(this).attr('id')]);
            } else {
                $(this).val(noLabel.buffer[$(this).attr('id')]);
            }
            $(this).addClass('vazio');
        }
    },

    formulario: function() {
        $('.vazio', this).each(function() {
            noLabel.foco(this);
        });
        return true;
    }



}




function validarExtencao(oSrc, args) {
    return args.IsValid = verificaExtencao(args.Value);
}

function verificaExtencao(valor) {
    try {
        var extensao = "";
        var bValida = false;
        if (valor != "") {
            var iLength = valor.length;
            var iPosicao = valor.lastIndexOf(".");
            if (iPosicao != "-1") {
                extensao = valor.substring(parseInt(iPosicao) + 1, parseInt(iLength));
            }
            else {
                return false;
            }

            var arExtensoes = new Array("AVI", "MPG", "MPEG", "WMV", "MP4", "M4V", "ASF", "MOV", "3GP", "RM", "RMVB", "FLV", "MKV", "RM", "FLV", "SWF", "JPG", "JPEG", "GIF", "PNG", "BMP", "PSD", "CDR", "TIF", "DOC", "DOCX", "XLS", "PDF", "MP3", "WMV", "XLSX");
            for (i = 0; i < arExtensoes.length; i++) {
                if (extensao.toLowerCase() == arExtensoes[i].toLowerCase()) {
                    bValida = true;
                }
            }
        }
        else {
            return true;
        }
        if (bValida == false) {
            return false;
        }
        else {
            return true;
        }
    }
    catch (e) {
        alert("Erro em validar Arquivo.");
    }
}

function validarExtencaoPDF(oSrc, args) {
    return args.IsValid = verificaExtencaoPDF(args.Value);
}

function verificaExtencaoPDF(valor) {
    try {
        var extensao = "";
        var bValida = false;
        if (valor != "") {
            var iLength = valor.length;
            var iPosicao = valor.lastIndexOf(".");
            if (iPosicao != "-1") {
                extensao = valor.substring(parseInt(iPosicao) + 1, parseInt(iLength));
            }
            else {
                return false;
            }

            var arExtensoes = new Array("PDF", "XLS", "XLSX");
            for (i = 0; i < arExtensoes.length; i++) {
                if (extensao.toLowerCase() == arExtensoes[i].toLowerCase()) {
                    bValida = true;
                }
            }
        }
        else {
            return true;
        }
        if (bValida == false) {
            return false;
        }
        else {
            return true;
        }
    }
    catch (e) {
        alert("Erro em validar Arquivo.");
    }
}


function validarExtencaoExcel(oSrc, args) {
    return args.IsValid = verificaExtencaoExcel(args.Value);
}

function verificaExtencaoExcel(valor) {
    try {
        var extensao = "";
        var bValida = false;
        if (valor != "") {
            var iLength = valor.length;
            var iPosicao = valor.lastIndexOf(".");
            if (iPosicao != "-1") {
                extensao = valor.substring(parseInt(iPosicao) + 1, parseInt(iLength));
            }
            else {
                return false;
            }

            var arExtensoes = new Array("XLS", "XLSX");
            for (i = 0; i < arExtensoes.length; i++) {
                if (extensao.toLowerCase() == arExtensoes[i].toLowerCase()) {
                    bValida = true;
                }
            }
        }
        else {
            return true;
        }
        if (bValida == false) {
            return false;
        }
        else {
            return true;
        }
    }
    catch (e) {
        alert("Erro em validar Arquivo.");
    }
}

function validarExtencaoOrcamento(oSrc, args) {
    return args.IsValid = verificaExtencaoOrcamento(args.Value);
}

function verificaExtencaoOrcamento(valor) {
    try {
        var extensao = "";
        var bValida = false;
        if (valor != "") {
            var iLength = valor.length;
            var iPosicao = valor.lastIndexOf(".");
            if (iPosicao != "-1") {
                extensao = valor.substring(parseInt(iPosicao) + 1, parseInt(iLength));
            }
            else {
                return false;
            }

            var arExtensoes = new Array("PDF", "JPEG", "JPG", "DOC", "DOCX", "XLS", "XLSX");
            for (i = 0; i < arExtensoes.length; i++) {
                if (extensao.toLowerCase() == arExtensoes[i].toLowerCase()) {
                    bValida = true;
                }
            }
        }
        else {
            return true;
        }
        if (bValida == false) {
            return false;
        }
        else {
            return true;
        }
    }
    catch (e) {
        alert("Erro em validar Arquivo.");
    }
}

// Formata o campo valor monetário
function formataValor(campo, evt) {
    //1.000.000,00
    var xPos = PosicaoCursor(campo);
    evt = getEvent(evt);
    var tecla = getKeyCode(evt);
    if (!teclaValida(tecla))
        return;

    vr = campo.value = filtraNumeros(filtraCampo(campo));
    if (vr.length > 0) {
        vr = parseFloat(vr.toString()).toString();
        tam = vr.length;

        if (tam == 1)
            campo.value = "0,0" + vr;
        if (tam == 2)
            campo.value = "0," + vr;
        if ((tam > 2) && (tam <= 5)) {
            campo.value = vr.substr(0, tam - 2) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 6) && (tam <= 8)) {
            campo.value = vr.substr(0, tam - 5) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 9) && (tam <= 11)) {
            campo.value = vr.substr(0, tam - 8) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 12) && (tam <= 14)) {
            campo.value = vr.substr(0, tam - 11) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 15) && (tam <= 18)) {
            campo.value = vr.substr(0, tam - 14) + '.' + vr.substr(tam - 14, 3) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
    }
    MovimentaCursor(campo, xPos);
}

//descobre qual a posição do cursor no campo
function PosicaoCursor(textarea) {
    var pos = 0;
    if (typeof (document.selection) != 'undefined') {
        //IE
        var range = document.selection.createRange();
        var i = 0;
        for (i = textarea.value.length; i > 0; i--) {
            if (range.moveStart('character', 1) == 0)
                break;
        }
        pos = i;
    }
    if (typeof (textarea.selectionStart) != 'undefined') {
        //FireFox
        pos = textarea.selectionStart;
    }

    if (pos == textarea.value.length)
        return 0; //retorna 0 quando não precisa posicionar o elemento
    else
        return pos; //posição do cursor
}

// move o cursor para a posição pos
function MovimentaCursor(textarea, pos) {
    if (pos <= 0)
        return; //se a posição for 0 não reposiciona

    if (typeof (document.selection) != 'undefined') {
        //IE
        var oRange = textarea.createTextRange();
        var LENGTH = 1;
        var STARTINDEX = pos;

        oRange.moveStart("character", -textarea.value.length);
        oRange.moveEnd("character", -textarea.value.length);
        oRange.moveStart("character", pos);
        //oRange.moveEnd("character", pos);
        oRange.select();
        textarea.focus();
    }
    if (typeof (textarea.selectionStart) != 'undefined') {
        //FireFox
        textarea.selectionStart = pos;
        textarea.selectionEnd = pos;
    }
}


// limpa todos os caracteres especiais do campo solicitado
function filtraCampo(campo) {
    var s = "";
    var cp = "";
    vr = campo.value;
    tam = vr.length;
    for (i = 0; i < tam; i++) {
        if (vr.substring(i, i + 1) != "/"
            && vr.substring(i, i + 1) != "-"
            && vr.substring(i, i + 1) != "."
            && vr.substring(i, i + 1) != "("
            && vr.substring(i, i + 1) != ")"
            && vr.substring(i, i + 1) != ":"
            && vr.substring(i, i + 1) != ",") {
            s = s + vr.substring(i, i + 1);
        }
    }
    return s;
    //return campo.value.replace("/", "").replace("-", "").replace(".", "").replace(",", "")
}

// limpa todos caracteres que não são números
function filtraNumeros(campo) {
    var s = "";
    var cp = "";
    vr = campo;
    tam = vr.length;
    for (i = 0; i < tam; i++) {
        if (vr.substring(i, i + 1) == "0" ||
            vr.substring(i, i + 1) == "1" ||
            vr.substring(i, i + 1) == "2" ||
            vr.substring(i, i + 1) == "3" ||
            vr.substring(i, i + 1) == "4" ||
            vr.substring(i, i + 1) == "5" ||
            vr.substring(i, i + 1) == "6" ||
            vr.substring(i, i + 1) == "7" ||
            vr.substring(i, i + 1) == "8" ||
            vr.substring(i, i + 1) == "9") {
            s = s + vr.substring(i, i + 1);
        }
    }
    return s;
    //return campo.value.replace("/", "").replace("-", "").replace(".", "").replace(",", "")
}

// limpa todos caracteres que não são letras
function filtraCaracteres(campo) {
    vr = campo;
    for (i = 0; i < tam; i++) {
        //Caracter
        if (vr.charCodeAt(i) != 32 && vr.charCodeAt(i) != 94 && (vr.charCodeAt(i) < 65 ||
        (vr.charCodeAt(i) > 90 && vr.charCodeAt(i) < 96) ||
            vr.charCodeAt(i) > 122) && vr.charCodeAt(i) < 192) {
            vr = vr.replace(vr.substr(i, 1), "");
        }
    }
    return vr;
}

// limpa todos caracteres que não são números, menos a vírgula
function filtraNumerosComVirgula(campo) {
    var s = "";
    var cp = "";
    vr = campo;
    tam = vr.length;
    var complemento = 0; //flag paga contar o número de virgulas
    for (i = 0; i < tam; i++) {
        if ((vr.substring(i, i + 1) == "," && complemento == 0 && s != "") ||
            vr.substring(i, i + 1) == "0" ||
            vr.substring(i, i + 1) == "1" ||
            vr.substring(i, i + 1) == "2" ||
            vr.substring(i, i + 1) == "3" ||
            vr.substring(i, i + 1) == "4" ||
            vr.substring(i, i + 1) == "5" ||
            vr.substring(i, i + 1) == "6" ||
            vr.substring(i, i + 1) == "7" ||
            vr.substring(i, i + 1) == "8" ||
            vr.substring(i, i + 1) == "9") {
            if (vr.substring(i, i + 1) == ",")
                complemento = complemento + 1;
            s = s + vr.substring(i, i + 1);
        }
    }
    return s;
}


function formataDouble(campo, evt) {
    //18,53012
    var xPos = PosicaoCursor(campo);
    evt = getEvent(evt);
    var tecla = getKeyCode(evt);
    if (!teclaValida(tecla))
        return;

    campo.value = filtraNumerosComVirgula(campo.value);
    MovimentaCursor(campo, xPos);
}



function formataTexto(campo, evt, sMascara) {
    //Nome com Inicial Maiuscula.
    evt = getEvent(evt);
    xPos = PosicaoCursor(campo);
    var tecla = getKeyCode(evt);
    if (!teclaValida(tecla))
        return;
    vr = campo.value = filtraCaracteres(filtraCampo(campo));
    tam = vr.length;

    if (sMascara == "Aa" || sMascara == "Xx") {
        var valor = campo.value.toLowerCase();
        var count = campo.value.split(" ").length - 1;
        var i;
        var pos = 0;
        var valorIni;
        var valorMei;
        var valorFim;
        valor = valor.substring(0, 1).toUpperCase() + valor.substring(1, valor.length);
        for (i = 0; i < count; i++) {
            pos = valor.indexOf(" ", pos + 1);
            valorIni = valor.substring(0, valor.indexOf(" ", pos - 1)) + " ";
            valorMei = valor.substring(valor.indexOf(" ", pos) + 1, valor.indexOf(" ", pos) + 2).toUpperCase();
            valorFim = valor.substring(valor.indexOf(" ", pos) + 2, valor.length);
            valor = valorIni + valorMei + valorFim;
        }
        campo.value = valor;
    }
    if (sMascara == "Aaa" || sMascara == "Xxx") {
        var valor = campo.value.toLowerCase();
        var count = campo.value.split(" ").length - 1;
        var i;
        var pos = 0;
        var valorIni;
        var valorMei;
        var valorFim;
        var ligacao = false;
        var chrLigacao = Array("de", "da", "do", "para", "e")
        valor = valor.substring(0, 1).toUpperCase() + valor.substring(1, valor.length);
        for (i = 0; i < count; i++) {
            ligacao = false;
            pos = valor.indexOf(" ", pos + 1);
            valorIni = valor.substring(0, valor.indexOf(" ", pos - 1)) + " ";
            for (var a = 0; a < chrLigacao.length; a++) {
                if (valor.substring(valorIni.length, valor.indexOf(" ", valorIni.length)).toLowerCase() == chrLigacao[a].toLowerCase()) {
                    ligacao = true;
                    break;
                }
                else if (ligacao == false && valor.indexOf(" ", valorIni.length) == -1) {
                    if (valor.substring(valorIni.length, valor.length).toLowerCase() == chrLigacao[a].toLowerCase()) {
                        ligacao = true;
                        break;
                    }
                }
            }
            if (ligacao == true) {
                valorMei = valor.substring(valor.indexOf(" ", pos) + 1, valor.indexOf(" ", pos) + 2).toLowerCase();
            }
            else {
                valorMei = valor.substring(valor.indexOf(" ", pos) + 1, valor.indexOf(" ", pos) + 2).toUpperCase();
            }
            valorFim = valor.substring(valor.indexOf(" ", pos) + 2, valor.length);
            valor = valorIni + valorMei + valorFim;
        }

        campo.value = valor;
    }
    MovimentaCursor(campo, xPos);
    return true;
}

//recupera tecla

//evita criar mascara quando as teclas são pressionadas
function teclaValida(tecla) {
    if (tecla == 8 //backspace
    //Esta evitando o post, quando são pressionadas estas teclas.
    //Foi comentado pois, se for utilizado o evento texchange, é necessario o post.
        || tecla == 9 //TAB
        || tecla == 27 //ESC
        || tecla == 16 //Shif TAB 
        || tecla == 45 //insert
        || tecla == 46 //delete
        || tecla == 35 //home
        || tecla == 36 //end
        || tecla == 37 //esquerda
        || tecla == 38 //cima
        || tecla == 39 //direita
        || tecla == 40)//baixo
        return false;
    else
        return true;
}

// recupera o evento do form
function getEvent(evt) {
    if (!evt) evt = window.event; //IE
    return evt;
}
//Recupera o código da tecla que foi pressionado
function getKeyCode(evt) {
    var code;
    if (typeof (evt.keyCode) == 'number')
        code = evt.keyCode;
    else if (typeof (evt.which) == 'number')
        code = evt.which;
    else if (typeof (evt.charCode) == 'number')
        code = evt.charCode;
    else
        return 0;

    return code;
}

function validarCNPJ(oSrc, args) {

    return args.IsValid = valida_cnpj(args.Value);

}


function valida_cnpj(cnpj) {

    cnpj = cnpj.replace("/", "");
    cnpj = cnpj.replace("/", "");
    cnpj = cnpj.replace("/", "");
    cnpj = cnpj.replace(",", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace(".", "");
    cnpj = cnpj.replace("-", "");
    cnpj = cnpj.replace("-", "");
    cnpj = cnpj.replace("-", "");
    cnpj = cnpj.replace("-", "");
    cnpj = cnpj.replace("-", "");

    var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
    digitos_iguais = 1;
    if (cnpj.length < 14 && cnpj.length < 15)
        return false;
    for (i = 0; i < cnpj.length - 1; i++)
        if (cnpj.charAt(i) != cnpj.charAt(i + 1)) {
        digitos_iguais = 0;
        break;
    }
    if (!digitos_iguais) {
        tamanho = cnpj.length - 2
        numeros = cnpj.substring(0, tamanho);
        digitos = cnpj.substring(tamanho);
        soma = 0;
        pos = tamanho - 7;
        for (i = tamanho; i >= 1; i--) {
            soma += numeros.charAt(tamanho - i) * pos--;
            if (pos < 2)
                pos = 9;
        }
        resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
        if (resultado != digitos.charAt(0)) {
            return false;
        }

        tamanho = tamanho + 1;
        numeros = cnpj.substring(0, tamanho);
        soma = 0;
        pos = tamanho - 7;
        for (i = tamanho; i >= 1; i--) {
            soma += numeros.charAt(tamanho - i) * pos--;
            if (pos < 2)
                pos = 9;
        }
        resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
        if (resultado != digitos.charAt(1)) {
            return false;
        }
        return true;
    }
    else
        return false;
}

function SoNumeros(event)//Aceita apenas números
{
    var tecla;

    tecla = event.keyCode ? event.keyCode : event.which;

    var teclaAux = String.fromCharCode(tecla);

    if (!((teclaAux >= 0) && (teclaAux <= 9)) || teclaAux == ' ') {
        if (tecla == 13 || tecla == 8) {
            return true;
        } else {

            if (window.event) {
                window.event.keyCode = 0;

            }
            event.returnValue = false;
            return false;
        }
    }
}

function validarData(oSrc, args) {
    return args.IsValid = validaData(args.Value);
}

function validaData(_data) {
    if (_data.length < 10) {
        return false;
    }

    var dia = _data.substr(0, 2);
    var mes = _data.substr(3, 2);
    var ano = _data.substr(6, 4);

    if (dia > 0 && dia < 32 && mes > 0 && mes < 13 && ano > 1900) {
        data = new Date(ano, mes - 1, dia);
        if (!isDate(ano, mes, dia)) {
            return false;
        }
        if (data >= new Date()) {
            return false;
        }
    }
    else {
        return false;
    }
    return true;
}

function isDate(year, month, day) {

    // month argument must be in the range 1 - 12
    month = month - 1; // javascript month range : 0- 11
    var tempDate = new Date(year, month, day);
    if ((getYear(tempDate.getYear()) == year) && (month == tempDate.getMonth()) && (day == tempDate.getDate()))
        return true;
    else
        return false
} // Função para Bloquear o text area
function bloquear_textarea(field, maxlength, txtcontador) {

    if (field.value.length > maxlength) {
        field.value = field.value.substring(0, maxlength);

        alert("Quantidade de caracteres acima do permitido!");

    }
    countfieldvalue = maxlength - field.value.length;
    // document.aspnetForm.txtcontador.value = countfieldvalue;


    if (document.getElementById(txtcontador) != null) {
        document.getElementById(txtcontador).innerHTML = countfieldvalue;
    }

}

function formcontato() {
    (function(a) { var c = (a.browser.msie ? "paste" : "input") + ".mask"; var b = (window.orientation != undefined); a.mask = { definitions: { "9": "[0-9]", a: "[A-Za-z]", "*": "[A-Za-z0-9]"} }; a.fn.extend({ caret: function(e, f) { if (this.length == 0) { return } if (typeof e == "number") { f = (typeof f == "number") ? f : e; return this.each(function() { if (this.setSelectionRange) { this.focus(); this.setSelectionRange(e, f) } else { if (this.createTextRange) { var g = this.createTextRange(); g.collapse(true); g.moveEnd("character", f); g.moveStart("character", e); g.select() } } }) } else { if (this[0].setSelectionRange) { e = this[0].selectionStart; f = this[0].selectionEnd } else { if (document.selection && document.selection.createRange) { var d = document.selection.createRange(); e = 0 - d.duplicate().moveStart("character", -100000); f = e + d.text.length } } return { begin: e, end: f} } }, unmask: function() { return this.trigger("unmask") }, mask: function(j, d) { if (!j && this.length > 0) { var f = a(this[0]); var g = f.data("tests"); return a.map(f.data("buffer"), function(l, m) { return g[m] ? l : null }).join("") } d = a.extend({ placeholder: "_", completed: null }, d); var k = a.mask.definitions; var g = []; var e = j.length; var i = null; var h = j.length; a.each(j.split(""), function(m, l) { if (l == "?") { h--; e = m } else { if (k[l]) { g.push(new RegExp(k[l])); if (i == null) { i = g.length - 1 } } else { g.push(null) } } }); return this.each(function() { var r = a(this); var m = a.map(j.split(""), function(x, y) { if (x != "?") { return k[x] ? d.placeholder : x } }); var n = false; var q = r.val(); r.data("buffer", m).data("tests", g); function v(x) { while (++x <= h && !g[x]) { } return x } function t(x) { while (!g[x] && --x >= 0) { } for (var y = x; y < h; y++) { if (g[y]) { m[y] = d.placeholder; var z = v(y); if (z < h && g[y].test(m[z])) { m[y] = m[z] } else { break } } } s(); r.caret(Math.max(i, x)) } function u(y) { for (var A = y, z = d.placeholder; A < h; A++) { if (g[A]) { var B = v(A); var x = m[A]; m[A] = z; if (B < h && g[B].test(x)) { z = x } else { break } } } } function l(y) { var x = a(this).caret(); var z = y.keyCode; n = (z < 16 || (z > 16 && z < 32) || (z > 32 && z < 41)); if ((x.begin - x.end) != 0 && (!n || z == 8 || z == 46)) { w(x.begin, x.end) } if (z == 8 || z == 46 || (b && z == 127)) { t(x.begin + (z == 46 ? 0 : -1)); return false } else { if (z == 27) { r.val(q); r.caret(0, p()); return false } } } function o(B) { if (n) { n = false; return (B.keyCode == 8) ? false : null } B = B || window.event; var C = B.charCode || B.keyCode || B.which; var z = a(this).caret(); if (B.ctrlKey || B.altKey || B.metaKey) { return true } else { if ((C >= 32 && C <= 125) || C > 186) { var x = v(z.begin - 1); if (x < h) { var A = String.fromCharCode(C); if (g[x].test(A)) { u(x); m[x] = A; s(); var y = v(x); a(this).caret(y); if (d.completed && y == h) { d.completed.call(r) } } } } } return false } function w(x, y) { for (var z = x; z < y && z < h; z++) { if (g[z]) { m[z] = d.placeholder } } } function s() { return r.val(m.join("")).val() } function p(y) { var z = r.val(); var C = -1; for (var B = 0, x = 0; B < h; B++) { if (g[B]) { m[B] = d.placeholder; while (x++ < z.length) { var A = z.charAt(x - 1); if (g[B].test(A)) { m[B] = A; C = B; break } } if (x > z.length) { break } } else { if (m[B] == z[x] && B != e) { x++; C = B } } } if (!y && C + 1 < e) { r.val(""); w(0, h) } else { if (y || C + 1 >= e) { s(); if (!y) { r.val(r.val().substring(0, C + 1)) } } } return (e ? B : i) } if (!r.attr("readonly")) { r.one("unmask", function() { r.unbind(".mask").removeData("buffer").removeData("tests") }).bind("focus.mask", function() { q = r.val(); var x = p(); s(); setTimeout(function() { if (x == j.length) { r.caret(0, x) } else { r.caret(x) } }, 0) }).bind("blur.mask", function() { p(); if (r.val() != q) { r.change() } }).bind("keydown.mask", l).bind("keypress.mask", o).bind(c, function() { setTimeout(function() { r.caret(p(true)) }, 0) }) } p() }) } }) })(jQuery);
    jQuery(function($) {
        $(".maskDDD").mask("99", { placeholder: " " });
        $(".maskTel").mask("9999-9999", { placeholder: " " });
        $(".maskCEP").mask("99999", { placeholder: " " });
        $(".maskDig").mask("999", { placeholder: " " });
    });
}


function campoTextError(idRadio, idTxt, validator) {

    var radio = document.forms[0].elements[idRadio];

    if (radio[radio.length - 1].checked) {

        ValidatorEnable(document.getElementById(validator), true);

        var campoTxt = document.getElementById(idTxt).value;

        if (campoTxt == "") {
            $('#' + idTxt).addClass("error");
            //$('#' + idTxt).removeAttr('disabled');                                                                                                                     
        }
    }
    else {
        $('#' + idTxt).removeClass("error");
        document.getElementById(idTxt).value = ""
        //$('#' + idTxt).not(this).attr('disabled', 'disabled');
        ValidatorEnable(document.getElementById(validator), false);
    }
}



function EventoOnkeyup(campoID) {

    var campo = document.getElementById(campoID).value;
    if (campo != "") {
        $('#' + campoID).removeClass("error");
    }
    else {
        $('#' + idTxt).addClass("error");
    }
}

function EventoOnblur(campoID, validator) {

    var campo = document.getElementById(campoID).value;

    if (campo == "") {
        $('#' + campoID).addClass("error");

        ValidatorEnable(document.getElementById(validator), true);
    }
    else {
        ValidatorEnable(document.getElementById(validator), false);
    }
}

function VerificaCheck() {
    var chk = $('.Check3 input:checked').length;
    if (chk > 3) {
        alert("Selecione apenas 3 Tipos de equipamentos que sua escola necessita que a Fundação Telefônica disponibilize");
        $('.Check3').addClass("error");
        return false;
    }
    else {
        $('.Check3').removeClass("error");
    }

    return true;
}


////////////
//	Função que centraliza um objeto na tela.
//	ex:
//	$("#teste").absoluteCenter({limit:[0,10,0,10]});
////////////////////////////////////////////////////
$.fn.extend({
    absoluteCenter: function(options, speed, callback) {
        var defaults = {
            dellay: 100,
            limitTop: 0,
            limitRight: 0,
            limitBottom: 0,
            limitLeft: 0,
            limit: null,
            animation: true
        }
        options = $.extend({}, defaults, options);

        if (options.limit != null) {
            if (typeof (options.limit) == "object") {
                options.limitTop = typeof (options.limit[0]) != "undefined" ? options.limit[0] : options.limitTop;
                options.limitRight = typeof (options.limit[1]) != "undefined" ? options.limit[1] : options.limitRight;
                options.limitBottom = typeof (options.limit[2]) != "undefined" ? options.limit[2] : options.limitBottom;
                options.limitLeft = typeof (options.limit[3]) != "undefined" ? options.limit[3] : options.limitLeft;
            } else {
                options.limitTop = options.limit;
                options.limitRight = options.limit;
                options.limitBottom = options.limit;
                options.limitLeft = options.limit;
            }
        }

        speed = typeof (speed) == "undefined" ? "fast" : speed;

        return this.each(function() {

            var obj = this;
            var timeOut = null;

            var ajustaScroll = function() {

                if ($(obj).css("display") == "none") $(window).unbind("scroll", ajustaScroll).unbind("resize", ajustaScroll);

                var altura = parseInt($(obj).outerHeight());
                var largura = parseInt($(obj).outerWidth());

                var limiteC = parseInt($(obj).css("top"));
                var limiteB = limiteC + altura;
                var limiteE = parseInt($(obj).css("left"));
                var limiteD = limiteE + largura;

                var scrollTop = parseInt($(window).scrollTop());
                var scrollLeft = parseInt($(window).scrollLeft());
                var janelaAltura = parseInt($(window).height());
                var janelaLargura = parseInt($(window).width());

                var documentoAltura = parseInt($("body").outerHeight());
                var documentoLargura = parseInt($(document).width());

                var top = janelaAltura > altura
					? parseInt(scrollTop + ((janelaAltura / 2) - parseInt(altura / 2)))
					: scrollTop < (limiteC - options.limitTop)
						? scrollTop + options.limitTop
						: (scrollTop + janelaAltura) > (limiteB + options.limitBottom)
							? scrollTop - (altura - janelaAltura) - options.limitBottom
							: limiteC
				;
                top = (top + altura) > documentoAltura ? documentoAltura - altura : top;

                var left = janelaLargura > largura
					? parseInt(scrollLeft + ((janelaLargura / 2) - parseInt(largura / 2)))
					: scrollLeft < (limiteE - options.limitLeft)
						? scrollLeft + options.limitLeft
						: (scrollLeft + janelaLargura) > (limiteD + options.limitRight)
							? scrollLeft - (largura - janelaLargura) - options.limitRight
							: limiteE
				;
                left = (left + largura) > documentoLargura ? documentoLargura - largura : left;
                left = isNaN(left) ? 0 : left;

                if (options.animation) {
                    clearTimeout(timeOut);
                    timeOut = setTimeout(function() {
                        $(obj).animate({ top: top + "px", left: left + "px" }, speed, function() { if (typeof (callback) != "undefined") callback(); });
                    }, options.dellay);
                } else {
                    $(obj).css({ top: top + "px", left: left + "px" });
                }

            }
            ajustaScroll();

            if (options.animation) $(window).scroll(ajustaScroll).resize(ajustaScroll);
        });



    }


});



//Formulário Edital
$(document).ready(function() {


    $('.rbNivelEnsino input').click(function() {
        var chk = $('.rbNivelEnsino input:checked').length;
        if (chk == 0) {
            $('#ctl00_ContentPlaceHolder1_txtrbNivelEnsino').val(null);
        }
        else {
            $('#ctl00_ContentPlaceHolder1_txtrbNivelEnsino').val('rbNivelEnsino');
            $('.rbNivelEnsino').removeClass("error");
        }
    })

    $('.rbPeriodo input').click(function() {
        var chk = $('.rbPeriodo input:checked').length;
        if (chk == 0) {
            $('.Periodo').val(null);
        }
        else {
            $('.Periodo').val('rbPeriodo');
            $('.rbPeriodo').removeClass("error");
        }
    })

    $('.chkListSeries input').click(function() {
        var chk = $('.chkListSeries input:checked').length;
        if (chk == 0) {
            $('.ListSeries').val(null);
        }
        else {
            $('.ListSeries').val('chkListSeries');
            $('.chkListSeries').removeClass("error");
        }
    })

    $('.chkListArea input').click(function() {
        var chk = $('.chkListArea input:checked').length;
        if (chk == 0) {
            $('.ListArea').val(null);
        }
        else {
            $('.ListArea').val('chkListArea');
            $('.chkListArea').removeClass("error");
        }
    })

});
function validarCheckBoxNivelEnsino(oSrc, args) {
    var valor = args.Value;
    if (valor == '' || valor == null) {
        $('.rbNivelEnsino').addClass("error");
        return args.IsValid = false;
    }
    else {
        $('.rbNivelEnsino').removeClass("error");
    }
    return args.IsValid = true;
}
function validarCheckBoxPeriodo(oSrc, args) {
    var valor = args.Value;
    if (valor == '' || valor == null) {
        $('.rbPeriodo').addClass("error");
        return args.IsValid = false;
    }
    else {
        $('.rbPeriodo').removeClass("error");
    }
    return args.IsValid = true;
}
function validarCheckBoxListSeries(oSrc, args) {
    var valor = args.Value;
    if (valor == '' || valor == null) {
        $('.chkListSeries').addClass("error");
        return args.IsValid = false;
    }
    else {
        $('.chkListSeries').removeClass("error");
    }
    return args.IsValid = true;
}
function validarCheckBoxListArea(oSrc, args) {
    var valor = args.Value;
    if (valor == '' || valor == null) {
        $('.chkListArea').addClass("error");
        return args.IsValid = false;
    }
    else {
        $('.chkListArea').removeClass("error");
    }
    return args.IsValid = true;
}


