﻿
function SetObjectCollection(key, value) {
    var params = new Object();
    params.sKey = key;
    params.sValue = value;

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CreateObjectCollection",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg.d == "S") {

            }
        }
    });
}

function registrarContacto() {

    var strNombre = '';
    var strApellido = '';
    var strEmail = '';
    var strMotivo = '';
    var strMensaje = '';
    var strTipo = '';
    var strDocumento = '';
    var strCIP = '';
    var strNumero = '';
    var strCI = '';
    var strNroContrato = '';
    var strArea = '';
    var strTituloMotivo = '';

    strApellido = $("[id$=txtApellido]").val();
    strNombre = $("[id$=txtNombre]").val();
    strEmail = $("[id$=txtEmail]").val();
    strMotivo = $('[id$=ddlMotivo]').val();
    strMensaje = $("[id$=txtMensaje]").val();
    strTipo = $("[id$=txtTipo]").val();
    strDocumento = $("[id$=txtDocumento]").val();
    strCIP = $("[id$=txtCIP]").val();
    strNumero = $("[id$=txtNumero]").val();
    strCI = $("[id$=txtCI]").val();
    strNroContrato = $("[id$=txtNroContrato]").val();
    strArea = $("[id$=hfAreaId]").val();
    strTituloMotivo = $(".jqTransformSelectWrapper div span").text();

    //var lugar = lugar || '';

    if (strApellido == '' || strApellido == 'Apellido' || '') {
        strApellido = '';
        $("[id$=txtApellido]").parent(".campo_doble").addClass("campo_doble_error");
    }
    else {
        $("[id$=txtApellido]").parent(".campo_doble").removeClass("campo_doble_error");
    }

    if (strNombre == '' || strNombre == 'Nombre') {
        strNombre = '';
        $("[id$=txtNombre]").parent(".campo_doble").addClass("campo_doble_error");
    }
    else {
        $("[id$=txtNombre]").parent(".campo_doble").removeClass("campo_doble_error");
    }

    if (strEmail == '' || strEmail == 'Email') {
        strEmail = '';
        $("[id$=txtEmail]").parent(".campo_largo").addClass("campo_doble_error_largo");
    }
    else {
        $("[id$=txtEmail]").parent(".campo_largo").removeClass("campo_doble_error_largo");
    }

    if (strMensaje == '' || strMensaje == 'Su consulta') {
        strMensaje = '';
        $("[id$=txtMensaje]").parent(".campo_txtarea").addClass("campo_txtarea_error");
    }
    else {
        $("[id$=txtMensaje]").parent(".campo_txtarea").removeClass("campo_txtarea_error");
    }

    if (strMotivo == '' || strMotivo == 'Seleccione el area de contacto') {
        strMotivo = '';
    }

    if (strApellido != '' && strNombre != '' && strEmail != '' && strMotivo != '' && strMensaje != '') {

        var params = new Object();

        params.Email = strEmail;
        params.Nombre = strNombre;
        params.Apellido = strApellido;
        params.MotivoID = strMotivo;
        params.Mensaje = strMensaje;
        params.TipoDoc = strTipo;
        params.Documento = strDocumento;
        params.CIP = strCIP;
        params.Numero = strNumero;
        params.CI = strCI;
        params.NroContrato = strNroContrato;
        params.Area = strArea;
        params.TituloMotivo = strTituloMotivo;

        var query = $.toJSON(params);

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/RegistrarContacto",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(msg) {
                if (msg.d == "OK") {
                    $("[id$=txtApellido]").val('Apellido');
                    $("[id$=txtNombre]").val('Nombre');
                    $("[id$=txtEmail]").val('Email');
                    $("[id$=txtMensaje]").val('Su consulta');
                    $("[id$=txtTipo]").val('Tipo Doc.');
                    $("[id$=txtDocumento]").val('N° Doc.');
                    $("[id$=txtCIP]").val('CIP');
                    $("[id$=txtNumero]").val('Número');
                    $("[id$=txtCI]").val('CI');
                    $("[id$=txtNroContrato]").val('Nº Contrato');
                    $(".valError").text('')
                }
                else {
                    $(".valError").text('Los datos no han podido ser enviados.')
                }
            }
        });
    }
    else {
        $(".valError").text('Complete los datos resaltados.')
    }
}

function registrarContactoART() {

    var strNombre = '';
    var strApellido = '';
    var strEmail = '';
    var strMotivo = '';
    var strMensaje = '';
    var strTipo = '';
    var strDocumento = '';
    var strCIP = '';
    var strNumero = '';
    var strCI = '';
    var strNroContrato = '';
    var strTituloMotivo = '';

    strApellido = $("[id$=txtApellido]").val();
    strNombre = $("[id$=txtNombre]").val();
    strEmail = $("[id$=txtEmail]").val();
    strMotivo = $('[id$=ddlMotivo]').val();
    strMensaje = $("[id$=txtMensaje]").val();
    strTipo = $("[id$=txtTipo]").val();
    strDocumento = $("[id$=txtDocumento]").val();
    strCIP = $("[id$=txtCIP]").val();
    strNumero = $("[id$=txtNumero]").val();
    strCI = $("[id$=txtCI]").val();
    strNroContrato = $("[id$=txtNroContrato]").val();
    strTituloMotivo = $(".jqTransformSelectWrapper div span").text();

    //var lugar = lugar || '';

    if (strApellido == '' || strApellido == 'Apellido' || '') {
        strApellido = '';
        $("[id$=txtApellido]").parent(".campo_doble").addClass("campo_doble_error");
    }
    else {
        $("[id$=txtApellido]").parent(".campo_doble").removeClass("campo_doble_error");
    }

    if (strNombre == '' || strNombre == 'Nombre') {
        strNombre = '';
        $("[id$=txtNombre]").parent(".campo_doble").addClass("campo_doble_error");
    }
    else {
        $("[id$=txtNombre]").parent(".campo_doble").removeClass("campo_doble_error");
    }

    if (strEmail == '' || strEmail == 'Email') {
        strEmail = '';
        $("[id$=txtEmail]").parent(".campo_largo").addClass("campo_doble_error_largo");
    }
    else {
        $("[id$=txtEmail]").parent(".campo_largo").removeClass("campo_doble_error_largo");
    }

    if (strMensaje == '' || strMensaje == 'Su consulta') {
        strMensaje = '';
        $("[id$=txtMensaje]").parent(".campo_txtarea").addClass("campo_txtarea_error");
    }
    else {
        $("[id$=txtMensaje]").parent(".campo_txtarea").removeClass("campo_txtarea_error");
    }

    if (strMotivo == '' || strMotivo == 'Seleccione el area de contacto') {
        strMotivo = '';
    }

    if (strApellido != '' && strNombre != '' && strEmail != '' && strMotivo != '' && strMensaje != '') {

        var params = new Object();

        params.Email = strEmail;
        params.Nombre = strNombre;
        params.Apellido = strApellido;
        params.MotivoID = strMotivo;
        params.Mensaje = strMensaje;
        params.TipoDoc = strTipo;
        params.Documento = strDocumento;
        params.CIP = strCIP;
        params.Numero = strNumero;
        params.CI = strCI;
        params.NroContrato = strNroContrato;
        params.TituloMotivo = strTituloMotivo;

        var query = $.toJSON(params);

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/RegistrarContactoART",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(msg) {
                if (msg.d == "OK") {
                    $("[id$=txtApellido]").val('Apellido');
                    $("[id$=txtNombre]").val('Nombre');
                    $("[id$=txtEmail]").val('Email');
                    $("[id$=txtMensaje]").val('Su consulta');
                    $("[id$=txtTipo]").val('Tipo Doc.');
                    $("[id$=txtDocumento]").val('N° Doc.');
                    $("[id$=txtCIP]").val('CIP');
                    $("[id$=txtNumero]").val('Número');
                    $("[id$=txtCI]").val('CI');
                    $("[id$=txtNroContrato]").val('Nº Contrato');
                    $(".valError").text('')
                }
                else {
                    $(".valError").text('Los datos no han podido ser enviados.')
                }
            }
        });
    }
    else {
        $(".valError").text('Complete los datos resaltados.')
    }
}

function consultarSiniestro() {

    var strTelefono = $("[id$=txtTelefono]").val() || '';
    var strCelular = $("[id$=txtCelular]").val() || '';
    var strNombre = $("[id$=txtNombre]").val() || '';
    var strHorarioContacto = $("[id$=txtHorarioContacto]").val() || '';
    var strPolizaPatente = $("[id$=txtPolizaPatente]").val() || '';
    var strEmail = $("[id$=txtEmail]").val() || '';

    var strAbreviatura = $("#hfSiniestroIdiomaAbr").val() || '';

    var listaErrores = $(".listaErrores");

    $(".listaErrores #telefono").remove();
    $(".listaErrores #celular").remove();
    $(".listaErrores #nombre").remove();
    $(".listaErrores #horariocontacto").remove();
    $(".listaErrores #polizapatente").remove();

    if (strTelefono == '') {
        if (strAbreviatura == 'EN') {
            listaErrores.append('<li id="telefono" type="circle" class="itemError">• Telephone required.</li>');
        }
        else if (strAbreviatura == 'PR') {
            listaErrores.append('<li id="telefono" type="circle" class="itemError">• Telefone requerido.</li>');
        }
        else {
            listaErrores.append('<li id="telefono" type="circle" class="itemError">• Telefono requerido.</li>');
        }
    }
    if (strCelular == '') {
        if (strAbreviatura == 'EN') {
            listaErrores.append('<li id="celular" type="circle" class="itemError">• Mobile phone required.</li>');
        }
        else if (strAbreviatura == 'PR') {
            listaErrores.append('<li id="celular" type="circle" class="itemError">• Celular requerido.</li>');
        }
        else {
            listaErrores.append('<li id="celular" type="circle" class="itemError">• Celular requerido.</li>');
        }
    }
    if (strNombre == '') {
        if (strAbreviatura == 'EN') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Name required.</li>');
        }
        else if (strAbreviatura == 'PR') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Nome requerido.</li>');
        }
        else {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Nombre requerido.</li>');
        }
    }
    if (strEmail == '') {
        if (strAbreviatura == 'EN') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Email required.</li>');
        }
        else if (strAbreviatura == 'PR') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Email requerido.</li>');
        }
        else {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Email requerido.</li>');
        }
    }
    if (strHorarioContacto == '') {
        if (strAbreviatura == 'EN') {
            listaErrores.append('<li id="horariocontacto" type="circle" class="itemError">• Contact hours required.</li>');
        }
        else if (strAbreviatura == 'PR') {
            listaErrores.append('<li id="horariocontacto" type="circle" class="itemError">• Horário de contato requerido.</li>');
        }
        else {
            listaErrores.append('<li id="horariocontacto" type="circle" class="itemError">• Horario de contacto requerido.</li>');
        }
    }
    if (strPolizaPatente == '') {
        if (strAbreviatura == 'EN') {
            listaErrores.append('<li id="polizapatente" type="circle" class="itemError">• Policy or license plate required.</li>');
        }
        else if (strAbreviatura == 'PR') {
            listaErrores.append('<li id="polizapatente" type="circle" class="itemError">• Apólice ou placa requerida.</li>');
        }
        else {
            listaErrores.append('<li id="polizapatente" type="circle" class="itemError">• Poliza o patente requerido.</li>');
        }
    }

    if (strTelefono == '' || strCelular == '' || strNombre == '' || strHorarioContacto == '' || strPolizaPatente == '') {
        $(".errorContainer").fadeIn("slow");
        $(".successContainer").fadeOut("fast");
        return false;
    }
    else {
        $(".errorContainer").fadeOut("slow");
        return true;
    }
}

function consultarExperto() {

    var strNombre = $("[id$=txtNombre]").val() || '';
    var strApellido = $("[id$=txtApellido]").val() || '';
    var strEmail = $("[id$=txtEmail]").val() || '';
    var strCelular = $("[id$=txtCelular]").val() || '';
    var strConsulta = $("[id$=txtConsulta]").val() || '';

    var listaErrores = $(".listaErrores");

    $(".listaErrores #nombre").remove();
    $(".listaErrores #apellido").remove();
    $(".listaErrores #email").remove();
    $(".listaErrores #celular").remove();
    $(".listaErrores #consulta").remove();

    if (strNombre == '') {
        listaErrores.append('<li id="nombre" type="circle" class="itemError">• Nombre requerido.</li>');
    }
    if (strApellido == '') {
        listaErrores.append('<li id="apellido" type="circle" class="itemError">• Apellido requerido.</li>');
    }
    if (strEmail == '') {
        listaErrores.append('<li id="email" type="circle" class="itemError">• Email requerido.</li>');
    }
    else {
        if (!validarEmail(strEmail)) {
            listaErrores.append('<li id="email" type="circle" class="itemError">• Email incorrecto.</li>');
            strEmail = '';
        }
    }
    if (strCelular == '') {
        listaErrores.append('<li id="celular" type="circle" class="itemError">• Celular requerido.</li>');
    }
    if (strConsulta == '') {
        listaErrores.append('<li id="consulta" type="circle" class="itemError">• Consulta requerida.</li>');
    }

    if (strNombre == '' || strApellido == '' || strEmail == '' || strCelular == '' || strConsulta == '') {
        $(".errorContainer").fadeIn("slow");
        $(".successContainer").fadeOut("fast");
        return false;
    }
    else {
        $(".errorContainer").fadeOut("slow");
        return true;
    }
}

function consultarCotizacion() {

    var strRazonSocial = $("[id$=txtRazonSocial]").val() || '';
    var strCodigoActividad = $("[id$=txtCodigoActividad]").val() || '';
    var strCUIT = $("[id$=txtCUIT]").val() || '';
    var strCodigoPostal = $("[id$=txtCodigoPostal]").val() || '';
    var strLocalidad = $("[id$=txtLocalidad]").val() || '';
    var strCantEmpleados = $("[id$=txtCantEmpleados]").val() || '';
    var strMasaSalarial = $("[id$=txtMasaSalarial]").val() || '';
    var strNombre = $("[id$=txtNombre]").val() || '';
    var strEnviar = $("[id$=txtEnviar]").val() || '';
    var bProductor = false;

    var listaErrores = $(".listaErrores");

    $(".listaErrores #razonsocial").remove();
    $(".listaErrores #codigoactividad").remove();
    $(".listaErrores #cuit").remove();
    $(".listaErrores #codigopostal").remove();
    $(".listaErrores #localidad").remove();
    $(".listaErrores #cantempleados").remove();
    $(".listaErrores #masasalarial").remove();
    $(".listaErrores #nombre").remove();
    $(".listaErrores #enviar").remove();
    $(".listaErrores #productor").remove();

    if (strRazonSocial == '') {
        listaErrores.append('<li id="razonsocial" type="circle" class="itemError">• Razón Social requerido.</li>');
    }
    if (strCodigoActividad == '') {
        listaErrores.append('<li id="codigoactividad" type="circle" class="itemError">• Código Actividad requerido.</li>');
    }
    if (strCUIT == '') {
        listaErrores.append('<li id="cuit" type="circle" class="itemError">• CUIT requerido.</li>');
    }
    if (strCodigoPostal == '') {
        listaErrores.append('<li id="codigopostal" type="circle" class="itemError">• Código Postal requerido.</li>');
    }
    if (strLocalidad == '') {
        listaErrores.append('<li id="localidad" type="circle" class="itemError">• Localidad requerido.</li>');
    }
    if (strCantEmpleados == '') {
        listaErrores.append('<li id="cantempleados" type="circle" class="itemError">• Cantidad de empleados requerido.</li>');
    }
    if (strMasaSalarial == '') {
        listaErrores.append('<li id="masasalarial" type="circle" class="itemError">• Masa Salarial requerido.</li>');
    }
    if (strNombre == '') {
        listaErrores.append('<li id="nombre" type="circle" class="itemError">• Nombre y Apellido requerido.</li>');
    }
    if (strEnviar == '') {
        listaErrores.append('<li id="enviar" type="circle" class="itemError">• Email requerido.</li>');
    }
    else {
        if (!validarEmail(strEnviar)) {
            listaErrores.append('<li id="enviar" type="circle" class="itemError">• Email incorrecto.</li>');
            strEnviar = '';
        }
    }
    if (strNombre == '') {
        listaErrores.append('<li id="nombre" type="circle" class="itemError">• Nombre y Apellido requerido.</li>');
    }

    if (document.getElementById("ctl00_ContentPlaceHolder1_rdSi").checked == true) {
        bProductor = true;
    }
    else if (document.getElementById("ctl00_ContentPlaceHolder1_rdNo").checked == true) {
        bProductor = true;
    }
    else {
        listaErrores.append('<li id="productor" type="circle" class="itemError">• Debe seleccionar si es o no Productor/Asesor de Seguro.</li>');
    }

    if (strRazonSocial == '' || strCodigoActividad == '' || strCUIT == '' || strCodigoPostal == '' || strLocalidad == '' || strCantEmpleados == '' || strMasaSalarial == '' || strNombre == '' || strEnviar == '' || bProductor == false) {
        $(".errorContainer").fadeIn("slow");
        $(".successContainer").fadeOut("fast");
        return false;
    }
    else {
        $(".errorContainer").fadeOut("slow");
        return true;
    }
}

function cargarConsultas(acc) {

    if (acc != '') {
        var params = new Object();

        params.accion = acc;

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/CargarConsultas",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(list) {
                if (list.d[0] != null) {
                    $("#consultas").html(list.d[0]);
                    $("#totalConsultas").html(list.d[3]);

                    if (list.d[1] == 0) {
                        $(".anterior").attr("disabled", "disabled");
                        if (list.d[2] < list.d[3]) {
                            $(".siguiente").removeAttr("disabled");
                        }
                    }
                    else if (list.d[2] == list.d[3]) {
                        $(".siguiente").attr("disabled", "disabled");
                        $(".anterior").removeAttr("disabled");
                    }
                    else if (list.d[1] < list.d[2]) {
                        $(".siguiente").removeAttr("disabled");
                        $(".anterior").removeAttr("disabled");
                    }
                }
            }
        });
    }
}

function cargarAbecedario(letra) {

    if (letra != '') {
        var params = new Object();

        params.letra = letra;

        var query = $.toJSON(params);

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/CargarAbecedario",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(list) {
                if (list.d[0] != "") {
                    $("#abecedario").html(list.d[0]);
                    $("#abcdarioDesde").html("1")
                    $("#abcdarioHasta").html(list.d[1])
                    $("#abcdarioTotal").html(list.d[2])
                }
                else {
                    $("#abecedario").html("");
                    $("#abcdarioDesde").html("0")
                    $("#abcdarioHasta").html("0")
                    $("#abcdarioTotal").html("0")
                }

                if (list.d[1] == list.d[2]) {
                    $("#abecedarioSig").css("display", "none");
                }
                else {
                    $("#abecedarioSig").css("display", "block");
                }

                $("#abecedarioAnt").css("display", "none");
            }
        });
    }
}

function CargarAbecedarioSig(acc) {

    if (acc != '') {
        var params = new Object();

        params.accion = acc;

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/CargarAbecedarioSig",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(list) {
                if (list.d[0] != null) {
                    $("#abecedario").html(list.d[0]);
                    $("#abcdarioDesde").html(list.d[1])
                    $("#abcdarioHasta").html(list.d[2])

                    if (list.d[1] == 1) {
                        $("#abecedarioAnt").css("display", "none");
                    }
                    else if (list.d[1] == list.d[2]) {
                        $("#abecedarioSig").css("display", "none");
                    }
                    else if (list.d[1] < list.d[2]) {
                        $("#abecedarioSig").css("display", "block");
                        $("#abecedarioAnt").css("display", "block");
                    }
                }
            }
        });
    }
}

function registrarSuscripto() {

    var ListaSuscripcionId = new Array();
    var listaCheckbox = null;

    var strNombre = $("[id$=txtNombre]").val() || '';
    var strApellido = $("[id$=txtApellido]").val() || '';
    var strEmail = $("[id$=txtEmail]").val() || '';
    var strDomicilio = $("[id$=txtDomicilio]").val() || '';
    var strCodigoPostal = $("[id$=txtCodigoPostal]").val() || '';
    var strProvincia = $("[id$=txtProvincia]").val() || '';
    var strLocalidad = $("[id$=txtLocalidad]").val() || '';

    listaCheckbox = $("input:checked");

    var listaErrores = $(".listaErrores");

    $(".listaErrores #nombre").remove();
    $(".listaErrores #apellido").remove();
    $(".listaErrores #email").remove();
    $(".listaErrores #domicilio").remove();
    $(".listaErrores #codigopostal").remove();
    $(".listaErrores #provincia").remove();
    $(".listaErrores #localidad").remove();
    $(".listaErrores #news").remove();

    var strAbreviatura = $("#hfLetterIdiomaAbr").val() || '';

    if (strAbreviatura == 'EN') {
        if (strNombre == '') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Name required.</li>');
        }

        if (strApellido == '') {
            listaErrores.append('<li id="apellido" type="circle" class="itemError">• Surname required.</li>');
        }

        if (strEmail == '') {
            listaErrores.append('<li id="email" type="circle" class="itemError">• Email required.</li>');
        }
        else {
            if (!validarEmail(strEmail)) {
                listaErrores.append('<li id="email" type="circle" class="itemError">• Invalid Email.</li>');
                strEmail = '';
            }
        }

        if (strDomicilio == '') {
            listaErrores.append('<li id="domicilio" type="circle" class="itemError">• Address required.</li>');
        }

        if (strCodigoPostal == '') {
            listaErrores.append('<li id="codigopostal" type="circle" class="itemError">• Zip Code required.</li>');
        }

        if (strProvincia == '') {
            listaErrores.append('<li id="provincia" type="circle" class="itemError">• Province required.</li>');
        }

        if (strLocalidad == '') {
            listaErrores.append('<li id="localidad" type="circle" class="itemError">• Location required.</li>');
        }

        if (listaCheckbox.length > 0) {
            for (i = 0; i < listaCheckbox.length; i++) {
                ListaSuscripcionId[i] = listaCheckbox[i].value;
            }
        }
        else {
            listaErrores.append('<li id="news" type="circle" class="itemError">• You must select an item of the list.</li>');
            ListaSuscripcionId = null;
        }
    }
    else if (strAbreviatura == 'PR') {
        if (strNombre == '') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Name required.</li>');
        }

        if (strApellido == '') {
            listaErrores.append('<li id="apellido" type="circle" class="itemError">• Surname required.</li>');
        }

        if (strEmail == '') {
            listaErrores.append('<li id="email" type="circle" class="itemError">• Email required.</li>');
        }
        else {
            if (!validarEmail(strEmail)) {
                listaErrores.append('<li id="email" type="circle" class="itemError">• Invalid Email.</li>');
                strEmail = '';
            }
        }

        if (strDomicilio == '') {
            listaErrores.append('<li id="domicilio" type="circle" class="itemError">• Address required.</li>');
        }

        if (strCodigoPostal == '') {
            listaErrores.append('<li id="codigopostal" type="circle" class="itemError">• Zip Code required.</li>');
        }

        if (strProvincia == '') {
            listaErrores.append('<li id="provincia" type="circle" class="itemError">• Province required.</li>');
        }

        if (strLocalidad == '') {
            listaErrores.append('<li id="localidad" type="circle" class="itemError">• Location required.</li>');
        }

        if (listaCheckbox.length > 0) {
            for (i = 0; i < listaCheckbox.length; i++) {
                ListaSuscripcionId[i] = listaCheckbox[i].value;
            }
        }
        else {
            listaErrores.append('<li id="news" type="circle" class="itemError">• You must select an item of the list.</li>');
            ListaSuscripcionId = null;
        }
    }
    else {
        if (strNombre == '') {
            listaErrores.append('<li id="nombre" type="circle" class="itemError">• Nombre requerido.</li>');
        }

        if (strApellido == '') {
            listaErrores.append('<li id="apellido" type="circle" class="itemError">• Apellido requerido.</li>');
        }

        if (strEmail == '') {
            listaErrores.append('<li id="email" type="circle" class="itemError">• Email requerido.</li>');
        }
        else {
            if (!validarEmail(strEmail)) {
                listaErrores.append('<li id="email" type="circle" class="itemError">• Email incorrecto.</li>');
                strEmail = '';
            }
        }

        if (strDomicilio == '') {
            listaErrores.append('<li id="domicilio" type="circle" class="itemError">• Domicilio required.</li>');
        }

        if (strCodigoPostal == '') {
            listaErrores.append('<li id="codigopostal" type="circle" class="itemError">• Código Postal required.</li>');
        }

        if (strProvincia == '') {
            listaErrores.append('<li id="provincia" type="circle" class="itemError">• Provincia required.</li>');
        }

        if (strLocalidad == '') {
            listaErrores.append('<li id="localidad" type="circle" class="itemError">• Localidad required.</li>');
        }

        if (listaCheckbox.length > 0) {
            for (i = 0; i < listaCheckbox.length; i++) {
                ListaSuscripcionId[i] = listaCheckbox[i].value;
            }
        }
        else {
            listaErrores.append('<li id="news" type="circle" class="itemError">• Debe seleccionar una lista.</li>');
            ListaSuscripcionId = null;
        }
    }

    if (strApellido == '' || strNombre == '' || strEmail == '' || ListaSuscripcionId == null) {
        $(".errorContainer").fadeIn("slow");
        $(".successContainer").fadeOut("fast");
        return false;
    }
    else {
        $(".errorContainer").fadeOut("slow");
        return true;
    }
}

function validarEmail(valor) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)) {
        return (true);
    } else {
        return (false);
    }
}

function SetListadoComparacion(pNombreSession, pNumPagina) {
    var listaComparacion = null;
    var object = null;

    key = pNombreSession;
    object = $('input:checked');
    listaComparacion = new Array();

    for (i = 0; i < object.length; i++) {
        listaComparacion[i] = object[i].id;
    }

    res = GetDataWithAjax.SetSessionComparacion(key, listaComparacion, pNumPagina, OnCompleteSetListadoComparacion, OnTimeOut, OnError);
    return true;
}

function cargarVinculosDeInteres(acc) {

    var params = new Object();

    params.acc = acc;
    params.pais = $("[id$=ddlPais]").val();
    params.texto = $("[id$=txtTexto]").val();

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarVinculosDeInteres",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg.d != "") {
                $("#vinculosDeInteres").html(msg.d);
            }
            else {
                $("#vinculosDeInteres").html("");
            }
        }
    });
}

function cargarNumerosUtiles(acc, indice, pag, paisid) {

    var params = new Object();

    params.acc = acc;
    params.indice = indice;
    params.pag = pag;
    params.paisid = paisid;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarNumerosUtiles",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {
                if (msg.d[0] != "") {
                    $("#numerosUtiles").html(msg.d[0]);

                    $(".nuPaginador a").removeAttr("disabled");
                    $("." + msg.d[4]).attr("disabled", "disabled");

                    if (msg.d[1] == 0) {
                        $(".atras").attr("disabled", "disabled");
                        $(".atras").addClass("disabled");

                        if (msg.d[2] < msg.d[3]) {
                            $(".adelante").removeAttr("disabled");
                            $(".adelante").removeClass("disabled");
                        }
                        else {
                            $(".adelante").attr("disabled", "disabled");
                            $(".adelante").addClass("disabled");
                        }
                    }
                    else if (msg.d[2] >= msg.d[3]) {
                        $(".atras").removeAttr("disabled");
                        $(".atras").removeClass("disabled");
                        $(".adelante").attr("disabled", "disabled");
                        $(".adelante").addClass("disabled");
                    }
                    else if (msg.d[1] < msg.d[3]) {
                        $(".atras").removeAttr("disabled");
                        $(".atras").removeClass("disabled");
                        $(".adelante").removeAttr("disabled");
                        $(".adelante").removeClass("disabled");
                    }
                }
                else {
                    $("#numerosUtiles").html("");
                    $(".adelante").attr("disabled", "disabled");
                    $(".adelante").addClass("disabled");
                    $(".atras").attr("disabled", "disabled");
                    $(".atras").addClass("disabled");
                }
            }
            else {
                $("#numerosUtiles").html("");
                $(".adelante").attr("disabled", "disabled");
                $(".adelante").addClass("disabled");
                $(".atras").attr("disabled", "disabled");
                $(".atras").addClass("disabled");
            }
        }
    });
}

function cargarNumerosUtilesPaginador(acc, paisid) {

    var params = new Object();

    params.acc = acc;
    params.paisid = paisid;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarNumerosUtilesPaginador",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {
                if (msg.d[0] != "") {
                    $(".numerosUtilesPaginador").html(msg.d[0]);
                    $(".Pag1").attr("disabled", "disabled");
                    $(".atras").attr("disabled", "disabled");
                    $(".atras").addClass("disabled");

                    if (msg.d[1] == 1) {
                        $(".adelante").attr("disabled", "disabled");
                        $(".adelante").addClass("disabled");
                    }
                }
                else {
                    $(".numerosUtilesPaginador").html("");
                }
            }
            else {
                $(".numerosUtilesPaginador").html("");
            }
        }
    });
}

function cargarTemasDeInteres(acc) {

    var params = new Object();

    params.acc = acc;
    params.categoria = $("[id$=ddlCategoria]").val();
    params.texto = $("#txtTexto").val();

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarTemasDeInteres",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de la busqueda
                if (msg.d[0] != "") {
                    $("#litTemaInteres").html(msg.d[0]);
                }
                else {
                    $("#litTemaInteres").html("");
                }

                //Muestro los resultados de la busqueda
                if (msg.d[1] != "") {
                    $(".resultados").html(msg.d[1]);
                }
                else {
                    $(".resultados").html("");
                }

                //Habilito la paginacion
                if (msg.d[1] == "") {
                    $(".siguiente").attr("disabled", "disabled");
                    $(".anterior").attr("disabled", "disabled");
                }
                else {
                    if (msg.d[2] == 1) {
                        $(".anterior").attr("disabled", "disabled");
                        if (msg.d[2] < msg.d[3]) {
                            $(".siguiente").removeAttr("disabled");
                        }
                    }
                    else if (msg.d[2] == msg.d[3]) {
                        $(".siguiente").attr("disabled", "disabled");
                        $(".anterior").removeAttr("disabled");
                    }
                    else if (msg.d[2] < msg.d[3]) {
                        $(".siguiente").removeAttr("disabled");
                        $(".anterior").removeAttr("disabled");
                    }
                }
            }
        }
    });
}

function cargarUltimasNoticias(acc) {

    if (acc != '') {
        var params = new Object();

        params.accion = acc;

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/CargarUltimasNoticias",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(list) {
                if (list.d[0] != null) {
                    $("#ultimaNoticiaTodos").html(list.d[0]);

                    if (list.d[1] == 0) {
                        $(".anterior").css("display", "none");
                        if (list.d[2] < list.d[3]) {
                            $(".siguiente").css("display", "block");
                        }
                        else {
                            $(".siguiente").css("display", "none");
                        }
                    }
                    else if (list.d[2] == list.d[3]) {
                        $(".siguiente").css("display", "none");
                        $(".anterior").css("display", "block");
                    }
                    else if (list.d[1] < list.d[2]) {
                        $(".siguiente").css("display", "block");
                        $(".anterior").css("display", "block");
                    }
                }
                else {
                    $("#ultimaNoticiaTodos").html("");
                    $(".siguiente").css("display", "none");
                    $(".anterior").css("display", "none");
                }
            }
        });
    }
}

function cargarParteDePrensa(acc) {

    if (acc != '') {
        var params = new Object();

        params.accion = acc;

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/CargarParteDePrensa",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(list) {
                if (list.d[0] != null) {
                    $("#partePrensaTodos").html(list.d[0]);

                    if (list.d[1] == 0) {
                        $(".anterior").css("display", "none");
                        if (list.d[2] < list.d[3]) {
                            $(".siguiente").css("display", "block");
                        }
                        else {
                            $(".siguiente").css("display", "none");
                        }
                    }
                    else if (list.d[2] == list.d[3]) {
                        $(".siguiente").css("display", "none");
                        $(".anterior").css("display", "block");
                    }
                    else if (list.d[1] < list.d[2]) {
                        $(".siguiente").css("display", "block");
                        $(".anterior").css("display", "block");
                    }
                }
                else {
                    $("#partePrensaTodos").html("");
                    $(".siguiente").css("display", "none");
                    $(".anterior").css("display", "none");
                }
            }
        });
    }
}

function cargarTemasDeInteresId(id) {

    var params = new Object();

    params.id = id;

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarTemasDeInteresId",
        data: $.toJSON(params),
        contentType: "application/json"
    });
}

function cargarCapitulos() {

    var nombre = $(".conteninfo .jNiceWrapper .jNiceWrapper .jNiceSelectWrapper .jNiceSelectText").text();
    $(".color").text(nombre);

    var params = new Object();

    params.legislacion = $("[id$=ddlLey]").val();
    params.texto = $("[id$=txtTexto]").val();

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarCapitulos",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg.d != "") {
                $("#legislaciones").html(msg.d);
            }
            else {
                $("#legislaciones").html("");
            }
        }
    });
}

function cargarArticulos(capitulo) {

    var nombre = $(".conteninfo .jNiceWrapper .jNiceWrapper .jNiceSelectWrapper .jNiceSelectText").text();

    var params = new Object();

    params.capitulo = capitulo;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarArticulos",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg.d != "") {
                $("#legislaciones").html(msg.d);
                $(".color").text(nombre);
            }
            else {
                $("#legislaciones").html("");
                $(".color").text(nombre);
            }
        }
    });
}

function cargarArticuloDescripcion(articulo, capitulo, legislacion) {

    $('#idArticulo').val(articulo);
    
    var params = new Object();

    params.articulo = articulo;
    params.capitulo = capitulo;
    params.legislacion = legislacion;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarArticuloDescripcion",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg.d != "") {
                $("#legislaciones").html(msg.d);
                $("#enviarLegislacion").colorbox({ width: "500", height: "570", iframe: false });
            }
            else {
                $("#legislaciones").html("");
            }
        }
    });
}

function cargarVademecum(acc) {

    var params = new Object();

    params.accion = acc;
    params.texto = $("#txtMonodroga").val();

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarVademecum",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de la busqueda
                if (msg.d[0] != "") {
                    $("#grillaVademecum").html(msg.d[0]);
                }
                else {
                    $("#grillaVademecum").html("");
                }

                //Muestro los resultados de la busqueda
                if (msg.d[1] != "") {
                    $(".encontrados").html(msg.d[1]);
                }
                else {
                    $(".encontrados").html("");
                }
            }
        }
    });
}

function cargarVademecumOncologico(acc) {

    var params = new Object();

    params.accion = acc;
    params.texto = $("#txtVademecumOncologico").val();

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarVademecumOncologico",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de la busqueda
                if (msg.d[0] != "") {
                    $("#grillaVademecumOncologico").html(msg.d[0]);

                    if (msg.d[1] == 1) {
                        $("#anteriorOncologico").css("display", "none");
                        if (msg.d[2] < msg.d[3]) {
                            $("#siguienteOncologico").css("display", "block");
                        }
                        else {
                            $("#siguienteOncologico").css("display", "none");
                        }
                    }
                    else if (msg.d[2] == msg.d[3]) {
                        $("#siguienteOncologico").css("display", "none");
                        $("#anteriorOncologico").css("display", "block");
                    }
                    else if (msg.d[1] < msg.d[2]) {
                        $("#siguienteOncologico").css("display", "block");
                        $("#anteriorOncologico").css("display", "block");
                    }
                }
                else {
                    $("#grillaVademecumOncologico").html("");
                    $("#siguienteOncologico").css("display", "none");
                    $("#anteriorOncologico").css("display", "none");
                }

                //Muestro los resultados de la busqueda
                if (msg.d[1] != "") {
                    if (msg.d[2] > 0) {
                        $("#encontradosOncologico").html("Encontrados " + msg.d[1] + " a " + msg.d[2] + " de " + msg.d[3]);
                    }
                    else {
                        $("#encontradosOncologico").html("Encontrados " + msg.d[2] + " a " + msg.d[2] + " de " + msg.d[3]);
                    }
                }
                else {
                    $("#encontradosOncologico").html("");
                }
            }
        }
    });
}

function cargarListadoFarmacias(acc) {

    var params = new Object();

    params.accion = acc;
    params.texto = $("#txtListadoFarmacias").val() || '';
    params.provincia = $("#ddlFarProvincia").val() || '';
    params.localidad = $("#ddlFarLocalidad").val() || '';

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarListadoFarmacias",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de la busqueda
                if (msg.d[0] != "") {
                    $("#grillaListadoFarmacias").html(msg.d[0]);

                    if (msg.d[1] == 1) {
                        $("#anteriorFarmacia").css("display", "none");
                        if (msg.d[2] < msg.d[3]) {
                            $("#siguienteFarmacia").css("display", "block");
                        }
                        else {
                            $("#siguienteFarmacia").css("display", "none");
                        }
                    }
                    else if (msg.d[2] == msg.d[3]) {
                        $("#siguienteFarmacia").css("display", "none");
                        $("#anteriorFarmacia").css("display", "block");
                    }
                    else if (msg.d[1] < msg.d[2]) {
                        $("#siguienteFarmacia").css("display", "block");
                        $("#anteriorFarmacia").css("display", "block");
                    }
                }
                else {
                    $("#grillaListadoFarmacias").html("");
                    $("#siguienteFarmacia").css("display", "none");
                    $("#anteriorFarmacia").css("display", "none");
                }

                //Muestro los resultados de la busqueda
                if (msg.d[1] != "") {
                    if (msg.d[2] > 0) {
                        $("#encontradosFarmacia").html("Encontrados " + msg.d[1] + " a " + msg.d[2] + " de " + msg.d[3]);
                    }
                    else {
                        $("#encontradosFarmacia").html("Encontrados " + msg.d[2] + " a " + msg.d[2] + " de " + msg.d[3]);
                    }
                }
                else {
                    $("#encontradosFarmacia").html("");
                }
            }
        }
    });
}

function cargarFarProvincia() {

    var params = new Object();

    params.accion = "Load";

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarFarProvincia",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg.d != "") {
                $(".farProvincias").html(msg.d);
            }
            else {
                $(".farProvincias").html("");
            }
        }
    });
}

function cargarFarLocalidad() {

    var params = new Object();

    if ($("#ddlFarProvincia").val() != null && $("#ddlFarProvincia").val() != "") {
        params.provincia = $("#ddlFarProvincia").val();

        var query = $.toJSON(params);

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/CargarFarLocalidad",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(msg) {
                if (msg.d != "") {
                    $(".farLocalidades").html(msg.d);
                }
                else {
                    $(".farLocalidades").html("");
                }
            }
        });
    }
    else {
        $(".farLocalidades").html("<select id=\"ddlFarLocalidad\" class=\"localidades\"><option></option></select>");
    }
}

function cargarVademecumMedicamentos(acc) {

    var params = new Object();

    params.accion = acc;
    params.texto = $("#txtVademecumMedicamentos").val();

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarVademecumMedicamentos",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de la busqueda
                if (msg.d[0] != "") {
                    $("#grillaVademecumMedicamentos").html(msg.d[0]);

                    if (msg.d[1] == 1) {
                        $("#anteriorMedicamentos").css("display", "none");
                        if (msg.d[2] < msg.d[3]) {
                            $("#siguienteMedicamentos").css("display", "block");
                        }
                        else {
                            $("#siguienteMedicamentos").css("display", "none");
                        }
                    }
                    else if (msg.d[2] == msg.d[3]) {
                        $("#siguienteMedicamentos").css("display", "none");
                        $("#anteriorMedicamentos").css("display", "block");
                    }
                    else if (msg.d[1] < msg.d[2]) {
                        $("#siguienteMedicamentos").css("display", "block");
                        $("#anteriorMedicamentos").css("display", "block");
                    }
                }
                else {
                    $("#grillaVademecumMedicamentos").html("");
                    $("#siguienteMedicamentos").css("display", "none");
                    $("#anteriorMedicamentos").css("display", "none");
                }

                //Muestro los resultados de la busqueda
                if (msg.d[1] != "") {
                    if (msg.d[2] > 0) {
                        $("#encontradosMedicamentos").html("Encontrados " + msg.d[1] + " a " + msg.d[2] + " de " + msg.d[3]);
                    }
                    else {
                        $("#encontradosMedicamentos").html("Encontrados " + msg.d[2] + " a " + msg.d[2] + " de " + msg.d[3]);
                    }
                }
                else {
                    $("#encontradosMedicamentos").html("");
                }
            }
        }
    });
}

function CargarResultados(LayerName, TotalLayers, Idioma, Area) {

    var temp = new Array();
    temp = LayerName.split('_');
    ReLayerName = temp[0];
    var strRespuesta = $("#encuesta_1 input:radio:checked").val();
    var strEncuesta = $("#ctl00_ContentPlaceHolder1_Encuesta1_hfEncuesta").val() || '';
    var iIdioma = Idioma;
    var iArea = Area;

    var params = new Object();

    params.strRespuesta = strRespuesta;
    params.strEncuesta = strEncuesta;
    params.iIdioma = iIdioma;
    params.iArea = iArea;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/CargarResultados",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {
                $("#resultados").html(msg.d);

                for (i = 1; i <= TotalLayers; i++) {
                    document.getElementById(ReLayerName + '_' + i).style.display = 'none';
                }
                document.getElementById(LayerName).style.display = 'block';
            }
        }
    });
}


function MostrarResultados(Idioma, Area) {

    var iIdioma = Idioma;
    var iArea = Area;

    var params = new Object();

    params.iIdioma = iIdioma;
    params.iArea = iArea;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/MostrarResultados",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {
                $("#resultados").html(msg.d);
            }
            else {
            }
        }
    });
}

$(document).ready(function() {
    $("#ctl00_ContentPlaceHolder1_FiltroEventos1_ddlPais").change(function() {
        var paisID = $(this).val();

        if (paisID > 0) {
            var params = new Object();
            params.PaisID = paisID;

            $.ajax({
                type: "POST",
                url: "../GetDataWithAjax.asmx/GetProvincias",
                data: $.toJSON(params),
                contentType: "application/json",
                dataType: "json",
                async: true,
                success: function(msg) {
                    if (msg.d != null) {
                        $("#ctl00_ContentPlaceHolder1_FiltroEventos1_ddlProvincia").html(msg.d);
                    }
                    else {
                        $("#ctl00_ContentPlaceHolder1_FiltroEventos1_ddlProvincia").html('');
                    }

                    $(function() { $("#Provincia").jqTransform({ imgPath: '/imagenes/general/layout/form/' }); });
                }
            });
        }
        else {
            $("#preview").html('');
        }
    });
});

$(document).ready(function() {
    $("#ctl00_ContentPlaceHolder1_FiltroEventos1_ddlProvincia").change(function() {
        var provinciaID = $(this).val();
        provinciaID = provinciaID.replace(/[^0-9]/g, "");

        if (provinciaID > 0) {
            $("#ctl00_ContentPlaceHolder1_FiltroEventos1_hfProvincia").val(provinciaID);
        }
        else {
            $("#ctl00_ContentPlaceHolder1_FiltroEventos1_hfProvincia").val(0);
        }

        $("#ctl00_ContentPlaceHolder1_FiltroEventos1_hfProvinciaCombo").val($("#ctl00_ContentPlaceHolder1_FiltroEventos1_ddlProvincia").html());
    });
});

function cargarConsejos(idioma) {

    var params = new Object();

    params.idioma = idioma;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/cargarConsejos",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de la busqueda
                if (msg.d[0] != "") {
                    $(".Consejos .consejos").html(msg.d[0]);
                    $(".abrir-flash").colorbox({ iframe: true, innerWidth: 520, innerHeight: 400 });
                    $('.CDContenido').pajinate({
                        items_per_page: 5,
                        nav_label_prev: '<< Anterior',
                        nav_label_next: 'Siguiente >>'
                    });
                }
                else {
                    $(".Consejos .consejos").html("");
                }

                //Muestro los resultados de la busqueda
                if (msg.d[1] != "") {
                    $(".encontrados").html(msg.d[1]);
                }
                else {
                    $(".encontrados").html("");
                }
            }
        }
    });
}

function cargarCampana(iCampañaID) {

    var params = new Object();

    params.iCampañaID = iCampañaID;

    var query = $.toJSON(params);

    $.ajax({
        type: "POST",
        url: "../GetDataWithAjax.asmx/cargarCampana",
        data: $.toJSON(params),
        contentType: "application/json",
        dataType: "json",
        async: true,
        success: function(msg) {
            if (msg != null) {

                //Muestro los datos del resultado de grafica
                if (msg.d[0] != null) {
                    $("#ctl00_ContentPlaceHolder1_lit_scroll_grafica").html(msg.d[0]);
                    $(".combo01").show();
                }
                else {
                    $("#ctl00_ContentPlaceHolder1_lit_scroll_grafica").html("");
                    $(".combo01").hide();
                }

                //Muestro los resultados de videos
                if (msg.d[1] != null) {
                    $(".BoxGrafica .thumbs").html(msg.d[1]);
                    $(".BoxGrafica #contenidoPpal").html("<h6 id=\"videoPpal\"></h6>");
                    MostrarVideoDestacado();
                    MostrarTodosVideos();
                    $(".box_muestra").show();
                }
                else {
                    $(".BoxGrafica .thumbs").html("");
                    $(".BoxGrafica #contenidoPpal").html("");
                    $(".box_muestra").hide();
                }

                //Muestro los resultados de audios
                if (msg.d[2] != null) {
                    $("#ctl00_ContentPlaceHolder1_lit_scroll_audio").html(msg.d[2]);
                    $(".combo02").show();
                }
                else {
                    $("#ctl00_ContentPlaceHolder1_lit_scroll_audio").html("");
                    $(".combo02").hide();
                }

                $(".imgColorBox").colorbox();
                CargarGaleria();
                $("div.Scroll2").scrollable({ size: 2 });
                $("div.Scroll3").scrollable({ size: 5 });

            }
        }
    });
}

function enviarArticulo() {

    var strDestinatario = $("#destinatario").val() || '';
    var strRemitente = $("#remitente").val() || '';
    var strEmail = $("#email").val() || '';
    var strComentario = $("#comentario").val() || '';
    var strId = $('#idArticulo').val();

    if (strDestinatario == '' || strDestinatario == 'e-mail *') {
        $("#destinatario").addClass("oblibord");
        $("#obligdes").show();
    }
    else {
        $("#destinatario").removeClass("oblibord");
        $("#obligdes").hide();
    }
    if (strRemitente == '' || strRemitente == 'Nombre/s *') {
        $("#remitente").addClass("oblibord");
        $("#oblignom").show();
    }
    else {
        $("#remitente").removeClass("oblibord");
        $("#oblignom").hide();
    }
    if (strEmail == '' || strEmail == 'e-mail *') {
        $("#email").addClass("oblibord");
        $("#obligmail").show();
    }
    else {
        if (!validarEmail(strEmail)) {
            $("#email").addClass("oblibord");
            $("#obligmail").show();
            $("#obligmail").text('* Email incorrecto');
            return;
        }
        else {
            $("#email").removeClass("oblibord");
            $("#obligmail").hide();
        }
    }

    if (strDestinatario != '' && strDestinatario != 'e-mail *' && strRemitente != '' && strRemitente != 'Nombre/s *' && strEmail != '' && strEmail != 'e-mail *') {

        $('.mensaje').show();
    
        var params = new Object();

        params.strDestinatario = strDestinatario;
        params.strRemitente = strRemitente;
        params.strEmail = strEmail;
        params.strComentario = strComentario;
        params.strId = strId;

        var query = $.toJSON(params);

        $.ajax({
            type: "POST",
            url: "../GetDataWithAjax.asmx/enviarArticulo",
            data: $.toJSON(params),
            contentType: "application/json",
            dataType: "json",
            async: true,
            success: function(msg) {
                if (msg.d != "") {
                    console.log(1);
                    $('.mensaje').hide();
                    $('.enviaremail').hide();
                    $('.mensaje2').show();
                }
                else {
                    console.log(2);
                    $('.enviaremail').show();
                    $('.mensaje').hide();
                    $('.mensaje2').hide();
                }
            }
        });
    }
    else {
        return false;
    }
}
