﻿/// <reference name="MicrosoftAjax.js"/>

var idioma = 'es';
var strMsj = 'es';
var PageName = '';
var isFirstBread = true;
var mKey = new Array();

$(document).ready(function() {
    try {
        idioma = getCookieIdioma();
    } catch (e) {
        idioma = 'es';
        alert("@idioma definido: " + idioma);
    }

    if (!$.browser.msie) {
        try {
            var headID = document.getElementsByTagName("head")[0];
            var cssNode = document.createElement('link');
            cssNode.type = 'text/css';
            cssNode.rel = 'stylesheet';
            cssNode.href = 'Pics.css';
            cssNode.media = 'screen';
            headID.appendChild(cssNode);
        } catch (e) {
            alert("Error al intentar añadir fichero css: " + e.description);
        }
    }

    PageName = GetPageName();//Establecendo el valor a la Variable Global PageName

    loadmKey();
    RemoveClassCurrent()

    try {
        configMenu();
    } catch (err) {
        strMsj = err.description;
        alert("@strMsj configMenu(): " + strMsj);
    }

    try {
        SetBreadCrumb();
    } catch (err) {
        strMsj = err.description;
        alert("@strMsj SetBreadCrumb(): " + strMsj);
    }

    if ($("#imgContent").length > 0) {
        var imgNombre = 'images/barra/' + PageName.toLowerCase().split(".")[0] + '.jpg';

        try {
            switch (PageName.toLowerCase()) {
                case 'info.aspx':
                    var cod = getUrlVars()["cod"];
                    cod = cod;
                    imgNombre = 'images/barra/' + cod + '.jpg';

                    $.ajaxSetup({ async: false,
                        beforeSend: function() {
                            $.ajaxSetup({
                                async: false,
                                cache: true
                            });
                        },
                        complete: function() {
                            $.ajaxSetup({
                                async: false,
                                cache: true
                            });
                        }
                    });

                    $.ajax({
                        url: imgNombre
                        , type: 'HEAD'
                        , error: function() {
                            imgNombre = 'images/barra/default.jpg';
                            $("#imgContent").attr('src', imgNombre);
                        }
                        , success: function() { $("#imgContent").attr('src', imgNombre); }
                    });
                    break;
                case 'galeria.aspx':
                    /*$("#imgContent").attr('src', imgNombre);*/
                    $("#imgContent").hide();

                    $("#page").css('position', 'absolute');
                    $("#page").css('top', '20px');
                    $("#page").css('left', '0px');
                    break;
                default:
                    $("#imgContent").attr('src', 'images/barra/default.jpg');
                    break;
            }
        } catch (err) {
            var msj = err.description;
            msj = err.description;
            alert("@imgContent : " + msj);
        }
    }

    try {
        if ($("#breadCrumb_escm_ul").length > 0) {
            jQuery("#breadCrumb_escm").jBreadCrumb({ easing: 'linear' });
            jQuery.fn.jBreadCrumb.defaults.minimumCompressionElements = 10;
        }
    } catch (err) {
        var msj = err.description;
        msj = err.description;
        alert("@breadCrumb_escm : " + msj);
    }

    try {
        var busq = getUrlVars()["busq"];
        if (busq !== undefined && busq !== null && busq.length > 0) {
            $('input[id$="TxtBusq"]')[0].value = busq;
        }
    } catch (err) {
        var msj = err.description;
        msj = err.description;
        alert("@busq : " + msj);
    }

});

function configMenu() {
    if (idioma == 'es') {
        try {
            $("#LnkP01").text('Erasmus');
            $("#LnkP02").text('Ingreso al Centro');
            $("#LnkP03").text('Galería');
            $("#LnkP04").text('Contacto');

            $('#LnkMnuEspanol').hide();
            $('#LnkMnuIngles').show();

            $("#LnkMnuEscuela").text('Escuela');
            $("#LnkMnuInstalaciones").text('Instalaciones');
            $("#LnkMnuEdificio").text('Edificio');
            $("#LnkMnuTeatro").text('Teatro');
            $("#LnkMnuSalaCoros").text('Sala de Coros');
            $("#LnkMnuBoletin").text('Boletin');
			$("#LnkMnuReferencias").text('Referencias');
			
            $("#LnkMnuBiblioteca").text('Biblioteca');

            $("#LnkMnuEnsenanzas").text('Enseñanzas');
            $("#LnkMnuLOGSE").text('LOGSE');
            $("#LnkMnuLOGSECantoTeatroLirico").text('Canto Teatro Lírico');            
            $("#LnkMnuLOGSECantoConciertoOratorio").text('Canto Concierto y Oratorio');
            $("#LnkMnuLOGSEPedagogiaDelCanto").text('Pedagogía del Canto');
            
            $("#LnkMnuLOE").text('LOE');
            $("#LnkMnuLOECantoTeatroLirico").text('Canto Teatro Lírico');
            $("#LnkMnuLOECantoConciertoOratorio").text('Canto Concierto y Oratorio');
            $("#LnkMnuLOEPedagogiaDelCanto").text('Pedagogía del Canto');

            $("#LnkMnuPosgrado").text('Posgrado');
            $("#LnkMnuMaster").text('Máster');
            $("#LnkMnuDoctorado").text('Doctorado');

            $("#LnkMnuOrganigrama").text('Organigrama');
            $("#LnkMnuClaustro").text('Claustro de Profesores');
            $("#LnkMnuAdmin").text('Administración');
			$("#LnkMnuCoordinadoresdearea").text('Coordinadores de Área');
			$("#LnkMnuOrganoscolegiados").text('Órganos Colegiados');
			$("#LnkMnuRepresentantesdealumnos").text('Representantes de Alumnos');
			

            $("#LnkMnuSecretaria").text('Secretaría Académica');
            $("#LnkMnuPreinscripcion").text('Preinscripción');
			$("#LnkMnuMatricula").text('Matrícula');
            $("#LnkMnuCalendarioLectivo").text('Calendario Lectivo');
            $("#LnkMnuExamenes").text('Exámenes');
            $("#LnkMnuLelislacion").text('Legislación');
            $("#LnkMnuInfoGeneral").text('Información General');
            $("#LnkMnuRegInterno").text('Reglamento Régimen Interno');

            $("#LnkMnuNoticia").text('Noticias');
            $("#LnkMnuEventos").text('Eventos');
            $("#LnkMnuEventosListado").text('Listado');
            $("#LnkMnuEventosGaleria").text('Galería de Imágenes');
            $("#LnkMnuEnlaces").text('Enlaces');
            $("#LnkMnulogin").text('Acceso');

        } catch (err) {
            strMsj = err.description;
            alert("@err 1: " + strMsj);
        }

        try {
            $("#LnkMnuIngles").show();
            $("#LnkMnuEspanol").hide();

        } catch (err) {
            strMsj = err.description;
            alert("@err 2: " + strMsj);
        }
    } else {
        try {

            $("#LnkP01").text('Erasmus');
            $("#LnkP02").text('Join the Center');
            $("#LnkP03").text('Gallery');
            $("#LnkP04").text('Contact');

            $('#LnkMnuIngles').hide();
            $('#LnkMnuEspanol').show();

            $("#LnkMnuEscuela").text('The School');
            $("#LnkMnuInstalaciones").text('Facilities');
            $("#LnkMnuEdificio").text('The Building');
            $("#LnkMnuTeatro").text('The Theatre');
            $("#LnkMnuSalaCoros").text('The Choir Room');
            $("#LnkMnuBoletin").text('Newsletter');
			$("#LnkMnuReferencias").text('References');

            $("#LnkMnuBiblioteca").text('The Library');

            $("#LnkMnuEnsenanzas").text('Lessons'); /*Education / Teachings*/
            $("#LnkMnuLOGSE").text('LOGSE');
            $("#LnkMnuLOGSECantoTeatroLirico").text('Vocal Performance');
            $("#LnkMnuLOGSECantoConciertoOratorio").text('Voice Concert and Oratorio');
            $("#LnkMnuLOGSEPedagogiaDelCanto").text('Vocal Pedagogy');

            $("#LnkMnuLOE").text('LOE');
            $("#LnkMnuLOECantoTeatroLirico").text('Vocal Performance');
            $("#LnkMnuLOECantoConciertoOratorio").text('Voice Concert and Oratorio');
            $("#LnkMnuLOEPedagogiaDelCanto").text('Vocal Pedagogy');

            $("#LnkMnuPosgrado").text('Postgraduate Courses');
            $("#LnkMnuMaster").text('Master’s Degree');
            $("#LnkMnuDoctorado").text('PhD');

            $("#LnkMnuOrganigrama").text('Faculty');
            $("#LnkMnuClaustro").text('Teaching Staff');
            $("#LnkMnuAdmin").text('Board of Directors');
			<!--estos códigos son provisionales. Falta traducción-->
			$("#LnkMnuCoordinadoresdearea").text('Coordinadores de Área');
			$("#LnkMnuOrganoscolegiados").text('Órganos Colegiados');
			$("#LnkMnuRepresentantesdealumnos").text('Representantes de Alumnos');
            
            $("#LnkMnuSecretaria").text('Academic Secretary');

            $("#LnkMnuPreinscripcion").text('Pre-registration');
			$("#LnkMnuMatricula").text('Registration');
            $("#LnkMnuCalendarioLectivo").text('Academic calendar');
            $("#LnkMnuExamenes").text('Exams');
            $("#LnkMnuLelislacion").text('Legislation');
            $("#LnkMnuInfoGeneral").text('General Information');
            $("#LnkMnuRegInterno").text('School Policies');

            $("#LnkMnuNoticia").text('News');
            $("#LnkMnuEventos").text('Events');
            $("#LnkMnuEventosListado").text('List');
            $("#LnkMnuEventosGaleria").text('Image Gallery');
            $("#LnkMnuEnlaces").text('Links');
            $("#LnkMnulogin").text('Login');
        } catch (err) {
            strMsj = err.description;
            alert("@err 3: " + strMsj);
        }

        try {
            $("#LnkMnuEspanol").show();
            $("#LnkMnuIngles").hide();
        } catch (err) {
            strMsj = err.description;
            alert("@err 4: " + strMsj);
        }
    }

    try {
        configMenuHRef();
    } catch (err) {
        strMsj = err.description;
    }
}
function configMenuHRef() {
    if (idioma == 'es') {
        try {
            $("#LnkMnuIngles").show();
            $("#LnkMnuEspanol").hide();

        } catch (err) {
            strMsj = err.description;
            alert("@err 5: " + strMsj);
        }
    } else {
        try {
            $("#LnkMnuEspanol").show();
            $("#LnkMnuIngles").hide();
        } catch (err) {
            strMsj = err.description;
            alert("@err 6: " + strMsj);
        }
    }

    try {
        
        $("#LnkMnuSobreNosotros").attr('href', "info.aspx?cod=es&mnu=4");
        $("#LnkMnuInstalaciones").attr('href', "info.aspx?cod=inst&mnu=4");
        $("#LnkMnuEdificio").attr('href', "info.aspx?cod=ed&mnu=4");
        $("#LnkMnuTeatro").attr('href', "info.aspx?cod=te&mnu=4");
        $("#LnkMnuSalaCoros").attr('href', "info.aspx?cod=sc&mnu=4");
        $("#LnkMnuBoletin").attr('href', "boletin.aspx?mnu=4");
		$("#LnkMnuReferencias").attr('href', "info.aspx?cod=ref&mnu=4");

        
        $("#LnkMnuLOGSECantoTeatroLirico").attr('href', "info.aspx?cod=logse-ctl&mnu=12,32");
        $("#LnkMnuLOGSECantoConciertoOratorio").attr('href', "info.aspx?cod=logse-cco&mnu=12,32");
        $("#LnkMnuLOGSEPedagogiaDelCanto").attr('href', "info.aspx?cod=logse-pc&mnu=12,32");
        
        $("#LnkMnuLOE").attr('href', "info.aspx?cod=loe&mnu=12");
        
        $("#LnkMnuMaster").attr('href', "info.aspx?cod=master&mnu=12,16");
        $("#LnkMnuDoctorado").attr('href', "info.aspx?cod=doctorado&mnu=12,16");
        
        $("#LnkMnuClaustro").attr('href', "claustro.aspx?mnu=19");
        $("#LnkMnuAdmin").attr('href', "info.aspx?cod=adm&mnu=19");
		$("#LnkMnuCoordinadoresdearea").attr('href', "info.aspx?cod=coo&mnu=19");
		$("#LnkMnuOrganoscolegiados").attr('href', "info.aspx?cod=org&mnu=19");
		$("#LnkMnuRepresentantesdealumnos").attr('href', "info.aspx?cod=rep&mnu=19");
        
        $("#LnkMnuPreinscripcion").attr('href', "info.aspx?cod=preinsc&mnu=22");
		$("#LnkMnuMatricula").attr('href', "info.aspx?cod=mat&mnu=22");
        $("#LnkMnuCalendarioLectivo").attr('href', "info.aspx?cod=cl&mnu=22");
        $("#LnkMnuExamenes").attr('href', "info.aspx?cod=ex&mnu=22");
        $("#LnkMnuLelislacion").attr('href', "info.aspx?cod=legislacion&mnu=22");
        $("#LnkMnuInfoGeneral").attr('href', "info.aspx?cod=ig&mnu=22");
        $("#LnkMnuRegInterno").attr('href', "rri.aspx?mnu=22");
    } catch (err) {
        strMsj = err.description;
        alert("@err 7: " + strMsj);
    }
} /*fin configMenuHRef*/


function getmKey(cod) {
    if (isInteger(cod) && cod < mKey.length)
        return mKey[cod];
    else
        return "";
}

function isInteger(s) {
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}

function RemoveClassCurrent() {
    $("#LnkP01").removeClass("current");
    $("#LnkP02").removeClass("current");
    $("#LnkP03").removeClass("current");
    $("#LnkP04").removeClass("current");
}

function GetIdioma() {
    var aux = '';
    PageName = GetPageName();
    try {

        $.ajax({
            async: false,
            type: "POST",
            url: (PageName + "/GetIdioma"),
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(result) {
                idioma = result.d;
                aux = result.d;
            }
            , error: function(result) {
                strMsj = result.d;
                aux = 'es';
            }
        });
    } catch (Error) {
        aux = Error.description;
        aux = 'es';
        alert("@err 8: " + Error.description);
    }

    aux = aux;
    return aux;
}

function SetIdiomaEspanhol() {
    try {
        ChangeIdioma('es');
    }
    catch (err) {
        PageName = err.description;
        alert("@err 9: " + err.description);
    }
}

function SetIdiomaIngles() {
    try {
        ChangeIdioma('en');
    }
    catch (err) {
        PageName = err.description;
        alert("@err 10: " + err.description);
    }

}

function ChangeIdioma(value) {
    var Func = '';
    PageName = GetPageName();
    var ok = false;
    if (value != idioma) {
        if (value == "es") {
            Func = PageName + "/SetIdiomaEspanol";
        } else {
            Func = PageName + "/SetIdiomaIngles";
        }

        $.ajax({
            async: false,
            type: "POST",
            url: Func,
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(result) {
                ok = true;
                idioma = result.d;

                try {
                    loadmKey();
                    configMenu();
                } catch (err) {
                    PageName = err.description;
                }
            }
            , error: function(xhr, text, err) {
                var msj = err;
                if (msj == undefined || msj == null || msj == '')
                    msj = text;

                if (msj == undefined || msj == null || msj == '')
                    msj = xhr.responseText;

                //alert('Error Calling ChangeIdioma: ' + msj + '\n\n Func: ' + Func);
                try {
                    if (idioma == "es")
                        idioma = "en";
                    else
                        idioma = "es";

                    loadmKey();
                    configMenu();

                    if (PageName == "Default.aspx") {
                        //1º  Carga Galeria de Imagenes
                        loadHomeGallery();

                        //2º  Carga Texto de "Bienvenido"(Texto al lado de la galeria de imagenes)
                        loadBienBenido();

                        $("#DivTbContenidoPrincipal").show(1000, function() {
                            setArrowsPosition();
                            loadNoticia();
                            loadEvento();
                        });
                    }
                } catch (err) {
                    PageName = err.description;
                }

            },
            complete: function(result, tStatus) {
                try {
                    if (ok) {
                        try {
                            SetBreadCrumb();
                        } catch (err) {
                            strMsj = err.description;
                        }
                        switch (PageName.toLowerCase()) {
                            case 'default.aspx':
                                configDefaultHtmlByIdioma();
                                break;
                            case 'info.aspx':
                                LoadPageInfo(); /*esta en wtexto.js*/
                                break;
                            case 'contacto.aspx':
                                configByIdioma();
                                break;
                            case 'boletin.aspx':
                                configByIdioma();
                                break;
                            case 'evento.aspx':
                                location = "evento.aspx";
                                /*isNecesarioVolverCargar();*/
                                /*configByIdioma();*/
                                break;
                            case 'noticia.aspx':
                                window.location = 'noticia.aspx';
                                break;
                            case 'galeria.aspx':
                                /*configByIdioma();*/
                                location = "galeria.aspx";
                                break;
                            case 'busqueda.aspx':
                                location = "busqueda.aspx";
                                break;
                            case 'enlaces.aspx':
                                configByIdioma();
                                break;
                            case 'claustro.aspx':
                                /*configByIdioma();*/
                                location = "claustro.aspx";
                                break;
                            case 'rri.aspx':
                                configByIdioma();
                                break;
                            case 'login.aspx':
                                configByIdioma();
                                break;
                        }
                        setCookieIdioma();
                    }

                } catch (err) {
                    PageName = err.description;
                }

            }
        });
    }
}

function setCookieIdioma() {
    try {
        $.getScript('js/jquery.cookie.js', function() {
            $.cookie("idioma", idioma, { expires: 7 });
        });
    } catch (err) {
        var msj = err.description;
        alert("@err 11: " + err.description);
    }
}

function getCookieIdioma() {
    var aux = 'es';
    try {

        $.ajaxSetup({ async: false,
            beforeSend: function() {
                $.ajaxSetup({
                    async: false,
                    cache: true
                });
            },
            complete: function() {
                $.ajaxSetup({
                    async: false,
                    cache: true
                });
            }
        });

        $.getScript('js/jquery.cookie.js', function() {
            aux = $.cookie("idioma");
            if (aux !== "es" && aux !== "en") {
                aux = GetIdioma();
            }
        });
    } catch (err) {
        aux = 'es';
        aux = GetIdioma();
        aux = aux;
       // alert("@err 12: " + err.description);
    }
    return aux;
}

function configDefaultHtmlByIdioma() {
    $('#intro')[0].innerHTML = '';

    $.getScript('jsAjax/default.js', 
        function() {
            try {$("#datepicker").datepicker($.datepicker.regional["es"]);}
            catch (err) {
                alert("@err 13: " + err.description);
            }

            loadNoticia();
                
            loadBienBenido();
    });
}

function FailedCallback(error) {
    alert("Service Error: " + error.get_message());
}



function validateEmail(elementValue) {
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return emailPattern.test(elementValue);
}

function GetPageName() {

    var UrlCompleta = $(location).attr('href');
    var AbsolutePath = '';
    var PageName = ''
    var indexOfIniParams = 0;


    var loc = window.location;
    var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
    AbsolutePath = loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));

    PageName = UrlCompleta.replace(AbsolutePath, "");

    PageName = PageName;

    indexOfIniParams = PageName.indexOf("?");
    if (indexOfIniParams > 0) {
        PageName = PageName.substring(0, indexOfIniParams);
    }

    indexOfIniParams = PageName.indexOf("#");
    if (indexOfIniParams > 0) {
        PageName = PageName.substring(0, indexOfIniParams);
    }
    return PageName;
}

function getUrlVars() {
    var vars = [], hash;
    var ruta = window.location.href.replace("#", "");
    var hashes = ruta.slice(ruta.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function getUrlVarsOld() {
    var vars = [], hash;
    var ruta = window.location.href.replace("#", "");
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function SetBreadCrumb() {
    if ($("#breadCrumb_escm_ul").length > 0) {
        try {
            $("#breadCrumb_escm_ul").html('<li><a id="LnkBreadCrumbHome" href="default.aspx">Home</a></li>');
            var mnu = getUrlVars()["mnu"];
            var opc = "";
            if (mnu !== null && mnu !== undefined) {
                if (mnu.indexOf(',') > 0) {
                    var strSplit = mnu.split(",");
                    for (i = 0; i < strSplit.length; i++) {
                        /*$("#breadCrumb_escm_ul").append('<li><a href="#">' + strSplit[i] + '</a></li>');*/
                        opc = getmKey(strSplit[i]);
                        $("#breadCrumb_escm_ul").append('<li><a href="#">' + opc + '</a></li>');
                    }
                } else {
                    /*$("#breadCrumb_escm_ul").append('<li><a href="#">' + mnu + '</a></li>');*/
                    $("#breadCrumb_escm_ul").append('<li><a href="#">' + getmKey(mnu) + '</a></li>');
                }
            }

        } catch (e) {
            alert("@err 14: " + e.description);
            mnu = '';
        }

        /* if (idioma == 'es') {*/
        try {
            switch (PageName.toLowerCase()) {
                case 'default.aspx':
                    break;
                case 'contacto.aspx':
                    $("#LnkP04").addClass("current");
                    $("#breadCrumb_escm_ul").append('<li>' + $("#LnkP04").text() + '</li>');
                    break;
                case 'boletin.aspx':
                    $("#breadCrumb_escm_ul").append('<li>' + $("#LnkMnuBoletin").text() + '</li>');
                    break;
                case 'claustro.aspx':
                    $("#breadCrumb_escm_ul").append('<li>' + $("#LnkMnuClaustro").text() + '</li>');
                    break;
                case 'noticia.aspx':
                    $("#breadCrumb_escm_ul").append('<li><a href="noticia.aspx">' + $("#LnkMnuNoticia").text() + '</a></li>');
                    break;
                case 'evento.aspx':
                    $("#breadCrumb_escm_ul").append('<li><a href="evento.aspx">' + $("#LnkMnuEventos").text() + '</a></li>');
                    break;
                case 'galeria.aspx':
                    $("#LnkP03").addClass("current");
                    if (idioma == 'es')
                        $("#breadCrumb_escm_ul").append('<li><a href="galeria.aspx">Galeria de Imagenes</a></li>');
                    else
                        $("#breadCrumb_escm_ul").append('<li><a href="galeria.aspx">Image Gallery</a></li>');

                    break;
                case 'busqueda.aspx':
                    if (idioma == 'es')
                        $("#breadCrumb_escm_ul").append('<li><a href="#">Búsqueda</a></li>');
                    else
                        $("#breadCrumb_escm_ul").append('<li><a href="#">Search</a></li>');
                    break;
                case 'enlaces.aspx':
                    $("#breadCrumb_escm_ul").append('<li>' + $("#LnkMnuEnlaces").text() + '</li>');
                    break;
                case 'rri.aspx':
                    $("#breadCrumb_escm_ul").append('<li>' + mKey[27] + '</li>');
                    break;
                case 'login.aspx':
                    $("#breadCrumb_escm_ul").append('<li>' + mKey[31] + '</li>');
                    break;

            }
            jQuery("#breadCrumb_escm").jBreadCrumb();
            jQuery.fn.jBreadCrumb.defaults.easing = 'linear';

            isFirstBread = true;
        }
        catch (err) {
            PageName = err.description;
            alert("@err 15: " + err.description);
        }
    }
} /*Fin SetBreadCrumb*/

function addBreadCrumbItem(isFirst, value) {
    var bCrumb = $("#breadCrumb_escm_ul");
    if (bCrumb !== undefined && bCrumb !== null && bCrumb.length > 0) {
        
        if (!isFirst) {
            try {
                /*alert("bCrumb[0].innerHTML: " + bCrumb[0].innerHTML +
                "\n\n\n bCrumb[0].lastChild: " + bCrumb[0].lastChild.innerHTML +
                "\n\n\n\n\n\n bCrumb[0].lastChild.lastChild: " + bCrumb[0].lastChild.lastChild);
                */

                var p = bCrumb[0].lastChild; //.lastChild;
                if (p == null || p == undefined) {
                    p = bCrumb[0].lastChild;
                }
                if (p == null || p == undefined) {
                    p = bCrumb[0].firstChild;
                }

                var pp = p.parentNode;
                // alert("bCrumb[0].all.length: " + bCrumb[0].all.length);
                //if (bCrumb[0].all !== undefined && bCrumb[0].all !== null &&  bCrumb[0].all.length > 3 && pp !== null && pp !== undefined) {
                if (bCrumb[0].children.length > 1 && pp !== null && pp !== undefined) {
                    pp.removeChild(p);
                } /*else {
                    alert("pp es nulo");
                }*/
            }
            catch (e) {
                var msj = e.description;
                msj = e.description;
                alert("@err 16: " + e.Description);
            }
        } else {
            bCrumb.append('<li></li>');
        }


        var arrLi = $("#breadCrumb_escm_ul li");
        var intLength = arrLi.length;
        if (arrLi.length > 5) {
            p = arrLi.last();
            for (a = 3; a < intLength; a++) {
                if ((arrLi[a].innerHTML == "" && arrLi[a - 1].innerHTML == "") || arrLi[a].innerHTML == "<DIV style=\"DISPLAY: block\" class=chevronOverlay></DIV>") {
                    var pp = arrLi[a].parentNode;
                    pp.removeChild(arrLi[a]);
                    a = arrLi.length + 1;
                }
            }
        }



        jQuery.fn.jBreadCrumb.defaults.minimumCompressionElements = 10;
        bCrumb.append('<li>' + value + '</li>');
        /*jQuery("#breadCrumb_escm").jBreadCrumb({ easing: 'linear' });*/
        jQuery("#breadCrumb_escm").jBreadCrumb();
        jQuery.fn.jBreadCrumb.defaults.minimumCompressionElements = 10;
    } else {
        alert("bCrumb es nulo: " + bCrumb);
    }
}

function Busqueda() {
    var busq = $('input[id$="TxtBusq"]')[0].value;
    if (busq !== undefined && busq !== null && busq.length > 0) {
        location = "Busqueda.aspx?busq=" + busq;
    }
}

function TryBusqueda() {
    if (window.event.keyCode == 13) {
        /*Busqueda();
        return true;*/
        window.event.keyCode = 9;
        Busqueda();
    }
}

function formatDate(d) {
    var monthNumber = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
    var dia = d.getDate().toString();
    if (dia.length < 2)
        dia = "0" + dia;
    return dia  + "/" + monthNumber[d.getMonth()] + "/" + d.getFullYear()
}

function formatHoraMinuto(value) {
    if (value.toString().length < 2)
        value = "0" + value.toString();
    return value;
}



function loadmKey() {
    if (mKey == undefined || mKey == null)
        mKey = new Array();

    if (idioma == "es") {
        mKey[0] = "Erasmus";
        mKey[1] = "Ingreso al Centro";
        mKey[2] = "Galería";
        mKey[3] = "Contacto";
        mKey[4] = "Escuela";
        mKey[5] = "Matrícula";
        mKey[6] = "Instalaciones";
        mKey[7] = "Edificio";
        mKey[8] = "Teatro";
        mKey[9] = "Sala de Coros";

        mKey[10] = "Boletín";
        mKey[11] = "Biblioteca";
        mKey[12] = "Enseñanzas";
        mKey[13] = "Canto Teatro Lírico";
        mKey[14] = "Canto Concierto y Oratorio";
        mKey[15] = "Pedagogía del Canto";
        mKey[16] = "Posgrado";
        mKey[17] = "Master";
        mKey[18] = "Doctorado";
        mKey[19] = "Organigrama";

        mKey[20] = "Claustro de Profesores";
        mKey[21] = "Administración";
        mKey[22] = "Secretaría Académica";
        mKey[23] = "Preinscripción";
        mKey[24] = "Calendario Lectivo";
        mKey[25] = "Legislación";
        mKey[26] = "Información General";
        mKey[27] = "Reglamento Régimen Interno";
        mKey[28] = "Noticias";
        mKey[29] = "Eventos";

        mKey[30] = "Enlaces";
        mKey[31] = "Acceso";
        mKey[32] = "LOGSE";
        mKey[33] = "LOE";
        mKey[34] = "Inscríbase en nuestro boletín y reciba nuestros correos de actualización.";
        mKey[35] = "Nombre";
        mKey[36] = "Enviar";
        mKey[37] = "Cancelar";
        mKey[38] = "Búsqueda";
        mKey[39] = "Contacta con nosotros";/*pg contacto, contacto.js*/

        mKey[40] = "Mensaje";
        mKey[41] = "Completa el formulario para solicitar información.";
        mKey[42] = "Ver Todos";
        mKey[43] = "Galería de Imágenes";
        mKey[44] = "No hay eventos para el mes seleccionado.";
        mKey[45] = "Anterior";
        mKey[46] = "Ant.";
        mKey[47] = "de";
        mKey[48] = "Siguiente";
        mKey[49] = "Sig";

        mKey[50] = "Último";
        mKey[51] = "Inicio";
        mKey[52] = "Su mensaje ha sido enviado correctamente.";
        mKey[53] = "Dirección de correo electrónico no válida.";
        mKey[54] = "Tamaño del campo";
        mKey[55] = "debe estar entre";
        mKey[56] = "y";
        mKey[57] = "Correo electrónico";
        mKey[58] = "Todos los campos son obligatorios.";
        mKey[59] = "Ver Galeria de Imagenes";

        mKey[60] = "Eventos de fecha:";
        mKey[61] = "Entrar";
        mKey[62] = "Usuario";
        mKey[63] = "Contraseña";
        mKey[64] = "Ficheros Adjuntos";
        mKey[65] = "Ver en otra ventana";
        mKey[66] = "Más Galerias de Imágenes";
        mKey[67] = "Se ha detectado el siguiente error:";
        mKey[68] = "Mensaje de error:";
        mKey[69] = "La página que ha pedido no existe o ha sido borrada del servidor.";

        mKey[70] = "Volver a la Página inicial";
        mKey[71] = "Ha ocurrido un error y no fue posible detectar la causa.";
        mKey[72] = "Mensaje de error interno:";
        mKey[73] = "Referencias";
        mKey[74] = "Coordinadores de Área";
        mKey[75] = "Órganos Colegiados";
        mKey[76] = "Representantes de Alumnos";
        mKey[77] = "";
        mKey[78] = "";
        mKey[79] = "";

        mKey[80] = "";
        mKey[81] = "";
        mKey[82] = "";
        mKey[83] = "";
        mKey[84] = "";
        mKey[85] = "";
        mKey[86] = "";
        mKey[87] = "";
        mKey[88] = "";
        mKey[89] = "";

        mKey[90] = "";
        mKey[91] = "";
        mKey[92] = "";
        mKey[93] = "";
        mKey[94] = "";
        mKey[95] = "";
        mKey[96] = "";
        mKey[97] = "";
        mKey[98] = "";
        mKey[99] = "";
    } else {
        mKey[0] = "Erasmus";
        mKey[1] = "Join the Center";
        mKey[2] = "Gallery";
        mKey[3] = "Contact";
        mKey[4] = "The School";
        mKey[5] = "Registration";
        mKey[6] = "Facilities";
        mKey[7] = "The Building";
        mKey[8] = "The Theatre";
        mKey[9] = "The Choir Room";

        mKey[10] = "Newsletter";
        mKey[11] = "The Library";
        mKey[12] = "Lessons";
        mKey[13] = "Vocal Performance";
        mKey[14] = "Voice Concert and Oratorio";
        mKey[15] = "Vocal Pedagogy";
        mKey[16] = "Postgraduate Courses";
        mKey[17] = "Master’s Degree";
        mKey[18] = "PhD";
        mKey[19] = "Faculty";

        mKey[20] = "Teaching Staff";
        mKey[21] = "Board of Directors";
        mKey[22] = "Academic Secretary";
        mKey[23] = "Pre-registration";
        mKey[24] = "Academic calendar";
        mKey[25] = "Legislation";
        mKey[26] = "General Information";
        mKey[27] = "School Policies";
        mKey[28] = "News";
        mKey[29] = "Events";

        mKey[30] = "Links";
        mKey[31] = "Login";
        mKey[32] = "LOGSE";
        mKey[33] = "LOE";
        mKey[34] = "Sign up for our newsletter and receive our email updates.";
        mKey[35] = "Name";
        mKey[36] = "Send";
        mKey[37] = "Cancel";
        mKey[38] = "Search";
        mKey[39] = "Contact us";

        mKey[40] = "Message";
        mKey[41] = "Complete the form to request information.";
        mKey[42] = "See All";
        mKey[43] = "Image Gallery";
        mKey[44] = "There are no events for selected month.";
        mKey[45] = "Previous";
        mKey[46] = "Prev";
        mKey[47] = "of";
        mKey[48] = "Next";
        mKey[49] = "Next";

        mKey[50] = "Last";
        mKey[51] = "First";
        mKey[52] = "Your message has been sent successfully.";
        mKey[53] = "E-mail address is invalid.";
        mKey[54] = "Length of";
        mKey[55] = "must be between";
        mKey[56] = "and";
        mKey[57] = "E-mail";
        mKey[58] = "All form fields are required.";
        mKey[59] = "View Image Gallery";

        mKey[60] = "Events date:";
        mKey[61] = "Enter";
        mKey[62] = "User";
        mKey[63] = "Password";
        mKey[64] = "Associated files";
        mKey[65] = "View in a new window";
        mKey[66] = "More Image Galleries";
        mKey[67] = "Has encountered the following error:";
        mKey[68] = "Error Message:";
        mKey[69] = "The page you have requested does not exist at this adress or is no longer available on the server.";

        mKey[70] = "Return to the Default Page";
        mKey[71] = "There was an error and it was not possible to detect the cause.";
        mKey[72] = "Inner Error Message:";
        mKey[73] = "References";
        mKey[74] = "Coordinadores de Área";/*a falta de traducción*/
        mKey[75] = "Órganos Colegiados";/*a falta de traducción*/
        mKey[76] = "Representantes de Alumnos";/*a falta de traducción*/
        mKey[77] = "";
        mKey[78] = "";
        mKey[79] = "";

        mKey[80] = "";
        mKey[81] = "";
        mKey[82] = "";
        mKey[83] = "";
        mKey[84] = "";
        mKey[85] = "";
        mKey[86] = "";
        mKey[87] = "";
        mKey[88] = "";
        mKey[89] = "";

        mKey[90] = "";
        mKey[91] = "";
        mKey[92] = "";
        mKey[93] = "";
        mKey[94] = "";
        mKey[95] = "";
        mKey[96] = "";
        mKey[97] = "";
        mKey[98] = "";
        mKey[99] = "";

    }
} /*Fin loadmKey*/

