﻿var imagem = /^[\s\S]+\.(png|jpg|jpeg|gif|bmp)$/i;
var png = /^[\s\S]+\.(png)$/i;
var email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
var url = /^(http[s]?:\/\/)?(www\.)?[a-z0-9]+\.([a-z]{2}\.)?([a-z]{3})(\.[a-z]{2})?(\S*)?$/;


function Validacao() {

    var msg = "";
    var retorno = true;

    $("input:text[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    
    $("textarea[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    
    $("input:file[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });

    $("select[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "0") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });

    if (!retorno) {
        Abrir(msg);
    }

    return retorno;
}
//Usado quando tem Edicao de file upload
function Validacao2() {

    var msg = "";
    var retorno = true;

    $("input:text[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    
    $("textarea[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });    
    
    if($("#ctl00_cphConteudo_hdnArquivo").val() == "")
    {
         $("input:file[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    }
    else
    {
        $("#ctl00_cphConteudo_fulArquivo").removeClass('borda');
    }   

    $("select[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "0") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });

    if (!retorno) {
        Abrir(msg);
    }

    return retorno;
}

//function ValidacaoFoto() {

//    var msg = "";
//    var retorno = true;

//    $("input:text[jtype='obrigatorio']").each(function() {
//        if ($(this).val() == "") {
//            $(this).addClass("borda");
//            $(this).focus();
//            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
//            retorno = false;
//        }
//        else {
//            $(this).removeClass("borda");
//        }
//    });
//    
//    $("textarea[jtype='obrigatorio']").each(function() {
//        if ($(this).val() == "") {
//            $(this).addClass("borda");
//            $(this).focus();
//            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
//            retorno = false;
//        }
//        else {
//            $(this).removeClass("borda");
//        }
//    });
//    
//    
//    if($("#ctl00_cphConteudo_hdnArquivo").val() == "")
//    {
//         $("input:file[jtype='obrigatorio']").each(function() {
//        if ($(this).val() == "") {
//            $(this).addClass("borda");
//            $(this).focus();
//            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
//            retorno = false;
//        }
//        else {
//            $(this).removeClass("borda");
//        }
//    });
//    }
//    else
//    {
//        $("#ctl00_cphConteudo_fulArquivo").removeClass('borda');
//    }  
//    
//   

//    $("select[jtype='obrigatorio']").each(function() {
//        if ($(this).val() == "0") {
//            $(this).addClass("borda");
//            $(this).focus();
//            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
//            retorno = false;
//        }
//        else {
//            $(this).removeClass("borda");
//        }
//    });

//    if (!retorno) {
//        Abrir(msg);
//    }

//    return retorno;
//}
function ValidacaoNoticia() {

    var msg = "";
    var retorno = true;

    $("input:text[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    
    $("textarea[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    
    $("input:file[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });

    $("select[jtype='obrigatorio']").each(function() {
        if ($(this).val() == "0") {
            $(this).addClass("borda");
            $(this).focus();
            msg = "<p style='color:Blue;'>Preencha corretamente os campos em vermelho.</p>";
            retorno = false;
        }
        else {
            $(this).removeClass("borda");
        }
    });
    
    var editor = FCKeditorAPI.GetInstance('ctl00_cphConteudo_txtConteudoNoticia');
    var conteudo = editor.GetXHTML();
    var conteudo = conteudo.replace(/<[^>]*>/g, "");
    
    if(conteudo == "")
    {
        $("#ctl00_cphConteudo_txtConteudoNoticia").css({"border":"solid 1px Red"});
        $("#ctl00_cphConteudo_txtConteudoNoticia").focus();
       // msg += "<p style='color:Blue;'>Preencha o campo Descrição.</p>";
        retorno = false;
    }
    else
    {
        $("#ctl00_cphConteudo_txtConteudoNoticia").css({"border":"solid 0px Red"});
    }       

    if (!retorno) {
        Abrir(msg);
    }

    return retorno;
}


