if (top.location != location) {
    top.location.href = document.location.href ;
}

function loginComun(htmlresponse) {
    if (htmlresponse) {
        pintaLogin(htmlresponse);
        pintaOfertasInscritas(htmlresponse);
    }
}

function pintaLogin(htmlresponse) {
    var sHtml = '<ul class="navi2 list inline fontmedium color00">' +
    '<li class="color06"><span class="hidden">{0}</span> {1}</li>';
    if (htmlresponse.tipo == 'E') {
        sHtml = sHtml +
        '<li><a id="empresaaccede" accesskey="1" rel="me" href="{2}" title="{3}">{4}</a></li>' +
        '<li class="nomar"><a id="empresacerrar" accesskey="2" rel="me" href="{5}" title="{6}">{7}</a></li></ul>';
        $('#loginUsuarios').html(jQuery.format(
                sHtml, aVarios['VAR0001'], htmlresponse.data.empresa.EMAIL_LOGIN, htmlresponse.urls.empresas_acceso, aVarios['VAR0006'],
                aVarios['VAR0003'], htmlresponse.urls.empresas_logout, aVarios['VAR0007'], aVarios['VAR0005']));
    } else if (htmlresponse.tipo == 'C') {
        sHtml = sHtml +
        '<li><a id="candidatoaccede" accesskey="1" rel="me" href="{2}" title="{3}">{4}</a></li>' +
        '<li class="nomar"><a id="candidatocerrar" accesskey="2" rel="me" href="{5}" title="{6}">{7}</a></li></ul>';
        $('#loginUsuarios').html(jQuery.format(
                sHtml, aVarios['VAR0001'], htmlresponse.data.usuario.EMAIL, htmlresponse.urls.candidatos_acceso, aVarios['VAR0002'],
                aVarios['VAR0003'], htmlresponse.urls.candidatos_logout, aVarios['VAR0004'], aVarios['VAR0005']));
        // Si esta logueado no mostramos los enlace a recibir ofertas por e-mail
        // El superior del listado de ofertas
        if($("#recibir_mail_top")){
            $("#recibir_mail_top").html("");
        }
        // El inferior del paginador
        if($("#recibir_mail_bottom")){
            $("#recibir_mail_bottom").html("");
        }
    }
}

function pintaOfertasInscritas(htmlresponse) {
    if (htmlresponse.tipo == 'C') {
        var ofertas = htmlresponse.ofertas;
        for (i=0;i<ofertas.length;i++){
            var oferta = $("#"+'id-'+ofertas[i])
            if(oferta.length > 0 ){
                oferta
                .addClass("back03");
            }
        }
    }
}

function checkOfertaYaInscrito(htmlresponse) {
    if (htmlresponse.tipo == 'C') {
        var ofertas = htmlresponse.ofertas;
        for (i=0;i<ofertas.length;i++){
            var oferta = $("#"+ 'id_form-' +ofertas[i])
            if(oferta.length > 0 ){
                oferta
                .html('<div class=\"blockform back01\"><p class=\"fontmedium nomar\">'+aVarios['VAR0104']+'</p></div>');
                return true;
            }
        }
    }
}