<?php
require_once APPPATH . 'libraries/Facebook/autoload.php';

$fb = new \Facebook\Facebook([
  'app_id' => FACEBOOK_APP_ID,
  'app_secret' => FACEBOOK_APP_SECRET,
  'default_graph_version' => FACEBOOK_DEFAULT_GRAPH_VERSION,
  'default_access_token' => FACEBOOK_DEFAULT_ACCESS_TOLKEN, // optional
]);


$helper = $fb->getRedirectLoginHelper();

$permissions = ['email']; // Optional permissions
$loginUrl = $helper->getLoginUrl( base_url() .'Site/callbackFacebook', $permissions);
?>
<footer>
    <div class="rodape-involucro">
        <div id="row_desk" class="row">
            <div class="col-md-2 col-lg-3 col-xs-3 rodape-esquerdo">
                <ul>
                    <li><a href="<?php echo base_url(); ?>termo">Termo de uso</a></li>
                    <li><a href="<?php echo base_url(); ?>autenticacao">Autenticador</a></li>
                    <li><a href="<?php echo base_url(); ?>pagina_cadastro">Cadastro</a></li>
                    
                </ul>
            </div>
            <div class="col-md-8 col-lg-6 col-xs-6 rodape-centro">
                <ul>
<!--                    <li><a target="_blank" href="https://www.google.com/url?q=https://play.google.com/store/apps/details?id%3Dbr.com.ovumtec.deskcenter&sa=D&source=hangouts&ust=1539106124010000&usg=AFQjCNHD6OC9rhorz5eE28mPsuEJHeQiFg">DeskCenter</a></li>-->
                    <li><a href="<?php echo base_url(); ?>site">Copyright &COPY; Imazon Cursos 2007/<?php echo date("Y") ?></a></li>
                   
                </ul>
            </div>
            <div class="col-md-2  col-lg-3 col-xs-2 rodape-direito">
                <ul>
                    <li><a href="<?php echo base_url(); ?>suporte">Suporte</a></li>
                    <li><a href="<?php echo base_url(); ?>blog">Blog</a></li>
                    <li><a href="<?php echo base_url(); ?>cursos">Cursos</a></li>
                </ul>
            </div>
        </div>


   <!-- Footer Text -->
    <div id="row_mobi" class="container-fluid text-center text-md-left">

      <!-- Grid row -->
      <div class="row">

        <!-- Grid column -->
        <div class="col-md-6 mt-md-0 mt-3">

          <!-- Content -->
          <br><p><a class="itens_footer" href="<?php echo base_url(); ?>termo">Termo de uso</a> |
			  <a class="itens_footer"  href="<?php echo base_url(); ?>autenticacao">Autenticador</a> |
          <a class="itens_footer" id="btn-modal-cadastrar" data-toggle="modal" data-target="#modal-cadastro">Cadastro</a></p>

        </div>
        <!-- Grid column -->

        <hr class="clearfix w-100 d-md-none pb-3">

        <!-- Grid column -->
        <div class="col-md-6 mb-md-0 mb-3">

          <!-- Content -->
          <p><a class="itens_footer" href="<?php echo base_url(); ?>suporte">Suporte</a> |
            <a class="itens_footer" href="<?php echo base_url(); ?>blog">Blog</a> |
            <a class="itens_footer" href="<?php echo base_url(); ?>cursos">Cursos</a></p>

        </div>
        <!-- Grid column -->

      </div>
      <!-- Grid row -->

    </div>
    <!-- Footer Text -->
    <hr class="clearfix w-100 d-md-none pb-3">

    <!-- Copyright -->
<!--    <div class="footer-copyright text-center py-3"><a target="_blank" class="itens_footer" href="https://www.google.com/url?q=https://play.google.com/store/apps/details?id%3Dbr.com.ovumtec.deskcenter&sa=D&source=hangouts&ust=1539106124010000&usg=AFQjCNHD6OC9rhorz5eE28mPsuEJHeQiFg">DeskCenter</a>
    </div>-->
    <div class="footer-copyright text-center py-3"><a class="itens_footer" href="<?php echo base_url(); ?>suporte">E-mail: atendimento@imazoncursos.com.br</a>
    </div>
    <div class="footer-copyright text-center py-3"><a class="itens_footer" href="<?php echo base_url(); ?>site">Copyright © Imazon Cursos 2007/<?php echo date("Y");?></a>
    </div>
    <!-- Copyright -->

<!--        <hr>-->
        <div id="row-img" class="row">
           <div class="col-md-12 col-lg-12 col-xs-12" style="margin-left: 87px;">


                 <a href="https://www.tray.com.br/" target="_blank">
					 <img src="<?php echo ROOT_URL; ?>imgs/TrayCheckout.png" style="width:65px; margin-right: 1%;">
				 </a>
                <a href="http://lattes.cnpq.br/" target="_blank">
                    <img src="<?php echo ROOT_URL; ?>imgs/cnpq-lattes.jpeg" style="width:89px; margin-right:1%;"/>
                </a>
                <a href="http://di.cnpq.br/di/cadi/infoInstituicao.do?acao=buscaDadosInst&nroIdInst=744645" target="_blank">
                    <img src="<?php echo ROOT_URL; ?>imgs/cadi.jpg" style="width:226px; margin-right:1%;"/>
                </a>
                
                <a href="https://cidadeaprendizagem.com.br" target="_blank">
                    <img src="<?php echo ROOT_URL; ?>imgs/logo-cidade.jpg" style="width:158px; margin-right:1%;"/>
                </a>
               
               <a href="https://www.shopify.com.br/burst" target="_blank">
                    <img src="<?php echo ROOT_URL; ?>imgs/shopify.png" style="width:120px; margin-right:1%;"/>
                </a>
                <a href="https://www.google.com/transparencyreport/safebrowsing/diagnostic/?hl=pt-BR#url=imazoncursos.com.br" target="_blank">
                    <img src="<?php echo ROOT_URL; ?>imgs/icone-google.png" style="width:140px; margin-right:1%;"/>
                </a>
                <span id="ss_img_wrapper_115-55_image_en"><a href="http://www.alphassl.com/ssl-certificates/wildcard-ssl.html" target="_blank" title="SSL Certificates"><img alt="Wildcard SSL Certificates" border=0 id="ss_img" src="//seal.alphassl.com/SiteSeal/images/alpha_noscript_115-55_en.gif" title="SSL Certificate"></a></span><script type="text/javascript" src="//seal.alphassl.com/SiteSeal/alpha_image_115-55_en.js"></script>
           </div>
        </div>
    </div>
</div>
</footer>
<!--<script src="<?php echo ROOT_URL; ?>template/js/script-min.js"></script>-->
<script src="<?php echo ROOT_URL; ?>template/js/script.js"></script>
<section>
    <div class="modal fade" id="modal-cadastro" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-body modal-body-cadastro">
                    <p>Primeiro digite seu email<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></p>
                    <form class="frm-modal-cadastro" method="post" onsubmit="return false;">
                        <div class="container-fluid">
                        <div class="form-group">
<!--                            <input type="hidden" name="curso" value="" id="curso-id">-->
                            <div class="ui-widget">
                                <input id="tags" type="email" class="form-control" id="email_login_usuario" min="3" required value="" name="email" placeholder="Digite seu email">
                            </div>
                            <br />
<!--                            <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark" data-width="370" data-height="50" data-longtitle="true" data-lang="pt-BR"></div>-->

<input type="submit" id="btn-continuar" class="btn btn-success" value="Continuar" onclick="logarExterno()">
<br><hr>

                                <div class="row">
                                    <div class="col-md-12">
                                        <a href="<?php echo htmlspecialchars($loginUrl); ?>" id="fb-login" class="btn btn-facebook"><i class="fx fa fa-facebook"></i> Login</a>
                                    </div>
                                </div><br>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <!--<div  onclick="onSignIn" class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>-->
                                            <div class="g-signin2 social_signin" onclick="ClickLogin()" data-onsuccess="onSignIn" data-theme="dark">Login</div>

                                        </div>
                                    </div>
                            </div>
                            <!--<div style="display:inline-flex">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div onclick="onSignIn" class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
                                    </div>
                                </div>
                                <div class="container-fluid">
                                    <div class="row">
                                        <div style="padding-left: 47px" class="style-facebook"><?php echo '<a  style="height: 37px" class="btn btn-block btn-social btn-facebook" href="' . htmlspecialchars($loginUrl) . '"><span class="fx fa fa-facebook"></span>Login</a>'; ?></div>
                                    </div>
                                </div>
                            </div>-->
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>

<!--modal matricular-->

<section>
    <div class="modal fade" id="modal-cadastro-matricular" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-body modal-body-cadastro-matricula">
                    <p>Matricular - Digite seu email<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></p>
                    <form class="frm-modal-matricular" method="post" onsubmit="return false;">
                        <div class="container-fluid">
                        <div class="form-group">
<!--                            <input type="hidden" name="curso" value="" id="curso-id">-->
                            <input type="email" class="form-control" id="email_login_usuario_matricula" min="3" required value="" name="email_login_usuario_matricula" placeholder="Digite seu email">
                            <br />
<!--                            <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark" data-width="370" data-height="50" data-longtitle="true" data-lang="pt-BR"></div>-->

                            <input type="submit" id="btn-continuar-matricula" class="btn btn-success mais-carga-horaria" value="Continuar" >
<br><hr>
                                <div class="row">
                                    <div class="col-md-12">
                                        <a href="<?php echo htmlspecialchars($loginUrl); ?>" id="fb-login" class="btn btn-facebook"><i class="fx fa fa-facebook"></i> Login</a>
                                    </div>
                                </div><br>
                                    <div class="row">
                                        <div class="col-md-12">
                            <!--<div  id="target-google" class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>-->
                            <div class="g-signin2 social_signin" onclick="ClickLogin()" data-onsuccess="onSignIn" data-theme="dark">Login</div>
                                        </div>
                                    </div>
                            </div>
                            <!--<div style="display:inline-flex">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div onclick="onSignIn" class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
                                    </div>
                                </div>
                                <div class="container-fluid">
                                    <div class="row">
                                        <div style="padding-left: 47px" class="style-facebook"><?php echo '<a  style="height: 37px" class="btn btn-block btn-social btn-facebook" href="' . htmlspecialchars($loginUrl) . '"><span class="fx fa fa-facebook"></span>Login</a>'; ?></div>
                                    </div>
                                </div>
                            </div>-->
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>


</body>

<script>
	function ClickLogin() {
                console.log('222');
		clicked = true;
	}

	function onSignIn(googleUser) {
		//console.log(clicked);
		//console.log('Google.onSignIn called');
		//console.log('GoogleUser:');
		//console.table(googleUser);
		if (typeof clicked !== 'undefined') {

			var profile = googleUser.getBasicProfile();
			var email = profile.getEmail();

			$.post('<?php echo base_url(); ?>verifica_cadastro', {
				email: email
			}, function(e) {

				if (e == "true") {

					$.post('<?php echo base_url(); ?>site/logar_google', {
						email: email
					}, function(login) {
						if (login == 'ok') {
							window.location.href = "cursos_matriculados";
						} else {
							window.location.href = "cursos";
						}
					});
				} else {

					$.post('<?php echo base_url(); ?>site/cadastrar_google', {
						email: email
					}, function(add) {
						window.location.href = "cursos_matriculados";
					});

				}

			});

		}
	}
</script>
<script>
	function renderButton() {
		gapi.signin2.render('top-button', {
			'scope': 'email profile https://www.googleapis.com/auth/plus.login', // solicitando acesso ao profile e ao e-mail do usuário
			'width': 20,
			'height': 20,
			'longtitle': true,
			'theme': 'dark',
			'onsuccess': onSuccess,
			'onfailure': onFailure,
			'onSignIn': onSignIn
		});
	}
</script>

<script>




    var cap = Math.floor(Math.random() * 9999);
    var valida_captcha = function(){
                                var ddd = $("#ddd-cadastro").val();
                                var ddd_trim = ddd.trim();

                                var celular = $("#tel-cadastro").val();
                                var celular_trim = celular.trim();

                                var l = Math.pow(10, Math.floor(Math.log(celular_trim)/Math.log(10))-1);
                                var l = l*10;
                                var digit_phone = Math.floor(celular_trim/l);

                                if($("#captcha").val()==cap && isNaN(ddd_trim)==false && isNaN(celular_trim)==false && ddd_trim.length==2 && celular_trim.length==9 ){
                                    var loader_html = '<div class="progress">'+
                                                        '<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">'+
                                                          '<b>Aguarde...</b>'+
                                                        '</div>'+
                                                      '</div>';
                                    $("form.frm-cadastro").submit();
                                    $(".modal-body-cadastro").html('').html(loader_html);
                                    $(".formulario-home").html('').html(loader_html);
                                }
                                /*else if( ( ddd_trim.length!=2 || celular_trim.length!=9 ) || (isNaN(ddd_trim)==true || isNaN(celular_trim)==true) ) {

                                    var loader_html =  '<div class="alert alert-warning">Digite corretamente os dados para o DDD e Celular.</div>';

                                    $(".alert.alert-info").remove();
                                    $('.alert-validate').html(loader_html);
                                    //$(".formulario-home").html('').html(loader_html);
                                }*/
                                else if(ddd_trim.length!=2 || ddd_trim<11 || (isNaN(ddd_trim)==true)  )
                                {
                                    var loader_html =  '<div class="alert alert-warning">O campo ddd deve ter 2 digitos e não pode ser menor do que 11.</div>';

                                    $(".alert.alert-info").remove();
                                    $('.alert-validate').html(loader_html);
                                }
                                else if(celular_trim.length!=9 || digit_phone!=9 || (isNaN(celular_trim)==true) )
                                {
                                    var loader_html =  '<div class="alert alert-warning">O campo celular deve ter 9 digitos e o primeiro digito deve ser o número 9.</div>';

                                    $(".alert.alert-info").remove();
                                    $('.alert-validate').html(loader_html);
                                }
                                else if ($("#captcha").val()!=cap){
                                    var loader_html =  '<div class="alert alert-warning">Preencha o captcha corretamente!</div>';

                                    $(".alert.alert-info").remove();
                                    $('.alert-validate').html(loader_html);

                                    return false;
                                }
                                else{
                                    var loader_html =  '<div class="alert alert-warning">Preencha o captcha corretamente!.</div>';

                                    $(".alert.alert-info").remove();
                                    $('.alert-validate').html(loader_html);

                                    return false;
                                }
                           }

    $(function () {

        $(".btn-logar").click(function () {
            var email1 = $("#email-login").val();

            if (email1.length >= 6)
                $.post('<?php echo base_url(); ?>verifica_cadastro', {email: email1}, function (e) {

                    //console.log(email1);

                    if (e == "true") {
                        var email = $("#email-login").val();
                        $('.formulario-home').html('');
                        $('.formulario-home').append('<div class="alert alert-success">Por favor, digite a sua senha de acesso</div>' +
                                '<form class="frm-inline frm-login" onsubmit="return false">' +
                                '<div class="form-group">' +
                                '<input type="email" class="form-control" id="email-login" name="email" value="' + email + '">' +
                                '</div>' +
                                '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                                '<div class="form-group"><input type="password" class="form-control" id="senha-login" name="senha" placeholder="Digite a sua Senha"></div><button type="submit" class="btn btn-logar btn-logar-home btn-success" onclick="logar()">Entrar</button>' +
                                ' <button type="button" class="btn btn-link" onclick="recuperar_senha()">Esqueci minha senha</button>' +
                                '</form><br />');
                    } else {
                        var email = $("#email-login").val(),
                            formulario_cadastro = '<div class="alert alert-info">Preencha o campo abaixo com o valor informado</div>' +
                                                        '<form action="<?php echo base_url(); ?>cadastrar" class="frm-inline frm-cadastro" method="post">' +
                                                            '<div class="form-group form-group-email">' +
                                                                '<input type="email" class="form-control"  id="email" minlength="6" required  name="email" value="' + email + '">' +
                                                            '</div>' +
                                                            '<pre>Captcha: <b>' + cap + '</b></pre>' +
                                                            '<div class="form-group">' +
                                                                '<input type="text" class="form-control" id="captcha" minlength="6" required>' +
                                                            '</div>' +
                                                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                                                            '<button type="button" class="btn btn-primary" onclick="valida_captcha();">Cadastrar</button>' +
                                                        '</form>' +
                                                        '<br />' +
                                                        '<p style="font-size:12px; font-weight:bold;"><a href="<?php echo base_url(); ?>termo" target="_blank">*Ao clicar em cadastrar você estará concordando com nosso termo de uso</a></p>';
                        $('.frm-inline').removeClass('form-login-chamada').addClass('form-cadastro-chamada');
                        $('.formulario-home').html('');
                        $('.formulario-home').append(formulario_cadastro);
                        $('#captcha').focus();
                    }
                });

            return false;
        });
    });

    $(function () {
        $("#busca-topo").popover({content: '<form class="form-inline" action="<?php echo base_url(); ?>buscar_curso" method="post">' +
                    '<div class="form-group">' +
                    '<div id="btn-busca" class="input-group">' +
                    '<input type="text" class="form-control" name="busca" required placeholder="Digite uma Palavra">' +
                    '<button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-search"></i></button>' +
                    '</div>' +
                    '</div>' +

                    '</form>',
            html: true});
    });

    $(function () {
        $('.btn-matricular-aluno-curso').click(function () {
            var curso = $("#curso-id").attr("value"), ch;

            $('.cursos-mat').each(function () {
                if ($(this).prop("checked") == true) {
                    ch = $(this).val();
                }
            });

            $("#form-matricular-curso").ajaxForm({
                success: function (e) {
                    if (e == "ok") {
                        window.location.href = "<?php echo base_url(); ?>ultimo_curso_matriculado";
                    } else {
                        $('.modal-body-cadastrar-curso').html('');
                        $('.modal-body-cadastrar-curso').append('<div class="alert alert-info">' + e + '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>' +
                                '<form class="frm-inline frm-modal-cadastro-curso-externo" method="post" onsubmit="return false;">' +
                                '<div class="form-group">' +
                                '<div class="input-group">' +
                                '<input type="email" class="form-control" id="email" min="3" required  name="email" placeholder="Digite o seu email">' +
                                '</div>' +
                                '</div>' +
                                '<div class="form-group"><div class="input-group"><button onclick="logarMatricularCurso(\'' + curso + '\', \'' + ch + '\')" class="btn btn-success">Continuar</button></div></div>' +
                                '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                                '</form>');
                    }
                    return false;
                }

            }).submit();
        });
    });

    function logarMatricularCurso(cursoSelecionado, ch) {
        var email1 = $("#email").val();
        if (email1.length >= 6) {
            $.post('<?php echo base_url(); ?>verifica_cadastro', {email: email1}, function (e) {
                if (e == "true") {
                    $('.modal-body-cadastrar-curso').html('');
                    $('.modal-body-cadastrar-curso').append('<div class="alert alert-success">Por favor, digite a sua senha de acesso</div>' +
                            '<form class="frm-inline frm-login" onsubmit="return false">' +
                            '<div class="form-group">' +
                            '<input type="email" class="form-control" id="email-login" name="email" value="' + email1 + '">' +
                            '</div>' +
                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                            '<div class="form-group"><input type="password" class="form-control" id="senha-login" name="senha" placeholder="Digite a sua Senha"></div><button type="submit" class="btn btn-success" onclick="logarMatCurso(\'matricula_curso\', \'' + cursoSelecionado + '\', \'' + ch + '\')">Entrar</button>' +
                            ' <button type="button" class="btn btn-link" onclick="recuperar_senha()">Esqueci minha senha</button>' +
                            '</form>');
                } else {
                    $('.modal-body-cadastrar-curso').html('');
                    $('.modal-body-cadastrar-curso').append('<div class="alert-validate"><div class="alert alert-info">Email válido! Agora digite os seus dados.</div></div>' +
                            '<form action="<?php echo base_url(); ?>cadastrar" class="frm-inline frm-cadastro" method="post">' +
                            '<div class="form-group form-group-email">' +
                            '<input type="email" class="form-control" id="email" min="3" required  name="email" value="' + email1 + '">' +
                            '</div>' +
                            '<pre>Captcha: <b>' + cap + '</b></pre>' +
                            '<div class="form-group">' +
                                '<input type="text" class="form-control" id="captcha" minlength="6" required>' +
                            '</div>' +
                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                            '<button type="button" class="btn btn-primary" onclick="valida_captcha();">Cadastrar</button>' +
                            '<input type="hidden" name="matricular_curso" value="' + cursoSelecionado + ':' + ch + '"/>' +
                            '</form>' +
                            '<p style="font-size:12px; font-weight:bold;">*Ao clicar em cadastrar você estará concordando com nosso <a href="<?php echo base_url(); ?>termo" target="_blank">termo de uso</a></p>'
                            );
                }
            });
        }

    }

    function logarMatCurso(recarrega_pagina, curso, ch) {
        $.post('<?php echo base_url(); ?>logar"', $(".frm-login").serialize(), function (e) {
            if (e == "ok") {
                setTimeout(function () {
                    if (recarrega_pagina !== "undefined") {
                        switch (recarrega_pagina) {
                            case "matricula_curso":
                                $.post('<?php echo base_url(); ?>matricular_curso"', {curso: curso, carga_horaria: ch}, function (e) {
                                    if (e == "ok") {
                                        window.location.href = "<?php echo base_url(); ?>ultimo_curso_matriculado";
                                    } else {
                                        alert("Não foi possível atender a sua requisição. Tente novamente mais tarde.")
                                    }
                                });
                                break;
                            default:
                                window.location.reload();
                                break;
                        }
                    } else {
                        if ($("#fonte").val() != "undefined") {
                            window.location.href = fonte;
                        } else {
                            window.location.href = "./cursos_matriculados/";
                        }
                    }
                }, 1000);

            } else {
                $('#senha-login').val('').focus();
                $('.alert').html('Dados incorretos. Digite novamente sua senha.').removeClass('alert-success').addClass('alert-danger');
            }
        });
    }

    //

    $('[data-id-curso]').click(function () {
            var curso_id = $(this).val();
            var ch = $( ".select-carga-horaria-"+curso_id ).val();

            //logarExternoMatricular(curso_id, ch);

            $("#btn-continuar-matricula").click( function(){

                var email = $('#email_login_usuario_matricula').val();

                if(email!=undefined && email.length>6){
            var email = email;

            if (email.length >= 6 && IsEmail(email)) {

                //var curso_id_v = $("#curso-id-v").val();
                //var curso_id = $(".curso-id").val();
                //var curso_id = $("[data-id-curso]").val();
                //var ch = $( "#c_h option:selected" ).val();


                $.post('<?php echo base_url(); ?>verifica_cadastro"', {email: email}, function (e) {

                    if (e == "true")
                    {
                       $('.modal-body-cadastro-matricula').html('');
                       $('.modal-body-cadastro-matricula').append('<div class="alert alert-success">Por favor, digite a sua senha de acesso para matricula</div>' +
                            '<form method="POST" class="frm-logar-matricular" onsubmit="return false">' +
                            '<div class="form-group">' +
                            '<input type="email" class="form-control email-aluno" id="email-login" name="email" value="' + email + '">' +
                            '</div>' +
                            '<input type="hidden" name="curso" value="'+curso_id+'"/>'+
                            '<input type="hidden" name="carga_horaria" value="'+ch+'"/>'+
                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                            '<div class="form-group"><input required="required" type="password" class="form-control" id="senha-login" name="senha" placeholder="Digite a sua Senha"></div>'+
                            '<button type="submit" class="btn btn-success mais-carga-horaria" onclick="matricula_login_modal()">Matricular</button>' +
                            '<button type="button" class="btn btn-link" onclick="recuperar_senha()">Esqueci minha senha</button>' +
                            '</form>');

                    }
                    else{

                        //matricula_cadastro_modal

                    $('.modal-body-cadastro-matricula').html('');

                    //$('.frm-inline').removeClass('form-login-chamada').addClass('form-cadastro-chamada');
                    //$('.modal-body-cadastro-matricula').html('');
                    $('.modal-body-cadastro-matricula').append('<div class="alert-validate"><div class="alert alert-info">Email válido! Agora digite os seus dados para sua matricula.</div></div>' +
                            '<form action="<?php echo base_url(); ?>site/matricula_cadastro_modal" class="frm-inline frm-cadastro" method="post">' +
                            '<div class="form-group form-group-email">' +
                            '<input type="email" class="form-control" id="email" min="3" required  name="email" value="' + email + '">' +
                            '</div>' +

                            '<div class="row">'+
                                '<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">'+
                                    '<div class="form-group">' +
                                        '<input required="" pattern="\d{2}" title="Digite apenas dois digitos" min="2" maxlength="2"  type="tel" class="form-control ddd-aluno" id="ddd-cadastro" name="ddd" placeholder="DDD">' +
                                    '</div>' +
                                '</div>'+
                                '<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">'+
                                    '<div class="form-group">' +
                                        '<input required="" pattern="\d{9}" title="Digite 9 digitos" min="9" maxlength="9" type="tel" class="form-control tel-aluno" id="tel-cadastro" name="celular" placeholder="Número do Celular">' +
                                    '</div>' +
                                '</div>'+
                            '</div>'+

                            '<pre>Captcha: <b>' + cap + '</b></pre>' +
                            '<div class="form-group">' +
                                '<input type="text" class="form-control" id="captcha" minlength="6" required>' +
                            '</div>' +
                            '<input type="hidden" name="curso" value="'+curso_id+'"/>'+
                            '<input type="hidden" name="carga_horaria" value="'+ch+'"/>'+
                            '<input type="hidden"  id="fonte" value="' + fonte + '"/>' +
                            '<button type="button" class="btn btn-primary mais-carga-horaria" onclick="valida_captcha();">Cadastrar</button>' +
                            '</form>' +
                            '<p style="font-size:12px; font-weight:bold;">*Ao clicar em cadastrar você estará concordando com nosso <a href="<?php echo base_url(); ?>termo" target="_blank">termo de uso</a></p>'
                            );
                    }

                 });

            }


        }

            }


                );

        });
    //



    function logarExternoMatricular(curso_id, ch)
    {

        /*var email = $('#email_login_usuario_matricula').val();
                //alert(ch);

        if(email!=undefined && email.length>6){
            var email = email;

            if (email.length >= 6 && IsEmail(email)) {

                //var curso_id_v = $("#curso-id-v").val();
                //var curso_id = $(".curso-id").val();
                //var curso_id = $("[data-id-curso]").val();
                //var ch = $( "#c_h option:selected" ).val();


                $.post('<?php echo base_url(); ?>verifica_cadastro"', {email: email}, function (e) {

                    if (e == "true")
                    {
                       $('.modal-body-cadastro-matricula').html('');
                       $('.modal-body-cadastro-matricula').append('<div class="alert alert-success">Por favor, digite a sua senha de acesso para matricula</div>' +
                            '<form method="POST" class="frm-logar-matricular" onsubmit="return false">' +
                            '<div class="form-group">' +
                            '<input type="email" class="form-control email-aluno" id="email-login" name="email" value="' + email + '">' +
                            '</div>' +
                            '<input type="hidden" name="curso" value="'+curso_id+'"/>'+
                            '<input type="hidden" name="carga_horaria" value="'+ch+'"/>'+
                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                            '<div class="form-group"><input required="required" type="password" class="form-control" id="senha-login" name="senha" placeholder="Digite a sua Senha"></div>'+
                            '<button type="submit" class="btn btn-success mais-carga-horaria" onclick="matricula_login_modal()">Matricular</button>' +
                            '<button type="button" class="btn btn-link" onclick="recuperar_senha()">Esqueci minha senha</button>' +
                            '</form>');

                    }
                    else{

                        //matricula_cadastro_modal

                    $('.modal-body-cadastro-matricula').html('');

                    //$('.frm-inline').removeClass('form-login-chamada').addClass('form-cadastro-chamada');
                    //$('.modal-body-cadastro-matricula').html('');
                    $('.modal-body-cadastro-matricula').append('<div class="alert alert-info">Email válido! Agora digite os seus dados para sua matricula.</div>' +
                            '<form action="<?php echo base_url(); ?>site/matricula_cadastro_modal" class="frm-inline frm-cadastro" method="post">' +
                            '<div class="form-group form-group-email">' +
                            '<input type="email" class="form-control" id="email" min="3" required  name="email" value="' + email + '">' +
                            '</div>' +
                            '<pre>Captcha: <b>' + cap + '</b></pre>' +
                            '<div class="form-group">' +
                                '<input type="text" class="form-control" id="captcha" minlength="6" required>' +
                            '</div>' +
                            '<input type="hidden" name="curso" value="'+curso_id+'"/>'+
                            '<input type="hidden" name="carga_horaria" value="'+ch+'"/>'+
                            '<input type="hidden"  id="fonte" value="' + fonte + '"/>' +
                            '<button type="button" class="btn btn-primary" onclick="valida_captcha();">Cadastrar</button>' +
                            '</form>' +
                            '<p style="font-size:12px; font-weight:bold;">*Ao clicar em cadastrar você estará concordando com nosso <a href="<?php echo base_url(); ?>termo" target="_blank">termo de uso</a></p>'
                            );
                    }

                 });

            }


        }*/




    }


    function logarExterno(local=null, obj=null) {

        var e1 = $(".email-aluno").val(),
            e2 = $('#email-login').val(),
            e3 = $('[name="email"]').val(),
            e4 = $('#email_login_usuario').val(),
            email1;

        if(e1!=undefined && e1.length>6){
            var email1 = e1;
        }

        if(e2!=undefined && e2.length>6){
            var email1 = e2;
        }

        if(e3!=undefined && e3.length>6){
            var email1 = e3;
        }

        if(e4!=undefined && e4.length>6){
            var email1 = e4;
        }

        if (email1.length >= 6 && IsEmail(email1)) {
            $.post('<?php echo base_url(); ?>verifica_cadastro"', {email: email1}, function (e) {
                if (e == "true") {
                    $('.modal-body-cadastro').html('');
                    $('.modal-body-cadastro').append('<div class="alert alert-success">Por favor, digite a sua senha de acesso</div>' +
                            '<form class="frm-inline frm-login" onsubmit="return false">' +
                            '<div class="form-group">' +
                            '<input type="email" class="form-control email-aluno" id="email-login" name="email" value="' + email1 + '">' +
                            '</div>' +
                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                            '<div class="form-group"><input type="password" class="form-control" id="senha-login" name="senha" placeholder="Digite a sua Senha"></div><button type="submit" class="btn btn-success" onclick="logar()">Entrar</button>' +
                            ' <button type="button" class="btn btn-link" onclick="recuperar_senha()">Esqueci minha senha</button>' +
                            '</form>');
                } else if(e == "Erro login bloqueado"){
                    alert('Sua conta foi bloqueada. Entre em contato com o nosso atendimento.');
                } else {

                    $('#ddd-cadastro').on('input', function () {
                           $(this).val($(this).val().replace(/[^0-9]/g, ""));
                    });

                    $('.frm-inline').removeClass('form-login-chamada').addClass('form-cadastro-chamada');
                    $('.modal-body-cadastro').html('');
                    $('.modal-body-cadastro').append('<div class="alert-validate"><div class="alert alert-info">Email válido! Agora digite os seus dados.</div></div>' +
                            '<form action="<?php echo base_url(); ?>cadastrar" class="frm-inline frm-cadastro" method="post">' +
                            '<div class="form-group form-group-email">' +
                            '<input type="email" class="form-control" id="email" min="3" required  name="email" value="' + email1 + '">' +
                            '</div>' +

                            '<div class="row">'+
                                '<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">'+
                                    '<div class="form-group">' +
                                        '<input required="" pattern="\d{2}" title="Digite apenas dois digitos" min="2" maxlength="2"  type="tel" class="form-control ddd-aluno" id="ddd-cadastro" name="ddd" placeholder="DDD">' +
                                    '</div>' +
                                '</div>'+
                                '<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">'+
                                    '<div class="form-group">' +
                                        '<input required="" pattern="\d{9}" title="Digite 9 digitos" min="9" maxlength="9" type="tel" class="form-control tel-aluno" id="tel-cadastro" name="celular" placeholder="Número do Celular">' +
                                    '</div>' +
                                '</div>'+
                            '</div>'+

                            '<pre>Captcha: <b>' + cap + '</b></pre>' +
                            '<div class="form-group">' +
                                '<input placeholder="Digite o Código do Captcha" type="text" class="form-control" id="captcha" minlength="6" required>' +
                            '</div>' +
                            '<input type="hidden" id="fonte" value="' + fonte + '"/>' +
                            '<button type="button" class="btn btn-primary mais-carga-horaria" onclick="valida_captcha();">Cadastrar</button>' +
                            '</form>' +
                            '<p style="font-size:12px; font-weight:bold;">*Ao clicar em cadastrar você estará concordando com nosso <a href="<?php echo base_url(); ?>termo" target="_blank">termo de uso</a></p>'
                            );
                }
            });
        }

    }


</script>

<?php
 // Código para identificação e captura de conversão por link da ovumlink
 if(isset($_GET['ovl_code'])){
   $this->session->set_userdata(array('ovl_code'=>$_GET['ovl_code']));
 }
?>



</html>