
function getParentByClassName(element, className)
{
    var parent = element;

    if (className)
    {
        while (parent && parent.className != className)
        {
            parent = parent.parentNode;
        }
    }

    return parent;
}

function getFirstChildByClassRegex(element, tagName, classRegex, stopClassRegex)
{
    var match;
    var child = element.firstChild;

    while (child != null && (!child.className || !child.className.match(stopClassRegex)))
    {
        if (child.tagName && child.tagName == tagName && child.className && child.className.match(classRegex))
        {
            match = child;
            break;
        }
        else
        {
            match = getFirstChildByClassRegex(child, tagName, classRegex, stopClassRegex);

            if (match)
            {
                break;
            }
        }

        child = child.nextSibling;
    }

    return match;
}

function getChildrenByClassRegex(root, classRegexes, tagName, matches)
{
    matches = (matches ? matches : new Array());

    if (root)
    {
        var child = root.firstChild;

        while (child)
        {
            if (!tagName || child.tagName == tagName)
            {
                for (index in classRegexes)
                {
                    if (child.className && child.className.match(classRegexes[index]))
                    {
                        matches[matches.length] = child;
                    }
                }
            }

            getChildrenByClassRegex(child, classRegexes, tagName, matches);
            child = child.nextSibling;
        }
    }

    return matches;
}

function addEventToElement(target, eventType, func, useCapture)
{
    var result = false;

    if (target.addEventListener)
    {
        target.addEventListener(eventType, func, useCapture);
        result = true;
    }
    else if (target.attachEvent)
    {
        result = target.attachEvent("on" + eventType, func);
    }
    else
    {
        alert("Handler could not be attached");
    }

    return result;
}

function addEventToElements(targets, eventType, func, useCapture)
{
    var result = true;

    for (var i = 0; i < targets.length; i++)
    {
        result &= addEventToElement(targets[i], eventType, func, useCapture);
    }

    return result;
}

function removeEventFromElement(target, eventType, func, useCapture)
{
    var result = false;

    if (target.removeEventListener)
    {
        target.removeEventListener(eventType, func, useCapture);
        result = true;
    }
    else if (target.detachEvent)
    {
        result = target.detachEvent("on" + eventType, func);
    }
    else
    {
        window.alert("Handler could not be removed");
    }

    return result;
}

function removeEventFromElements(targets, eventType, func, useCapture)
{
    var result = true;

    for (var i = 0; i < targets.length; i++)
    {
        result &= removeEventFromElement(targets[i], eventType, func, useCapture);
    }

    return result;
}

function getEvent(event)
{
    var evt = event;

    if (!evt)
    {
        evt = window.event;
    }

    return evt;
}

function getEventSource(event)
{
    var source;

    if (event && event.srcElement)
    {
        source = event.srcElement;
    }
    else if (event && event.currentTarget)
    {
        source = event.currentTarget;
    }
    else
    {
        window.alert("Event source not found!");
    }

    return source;
}

function getClickableImageEventSource(source)
{
    // If IE, the original source will be the image being clicked instead of the parent element that generated the event
    if (source && source.src)
    {
        source = source.parentNode;
    }

    return source;
}

/**
 * @deprecated
 */
var console = (beaPortalConsole ? beaPortalConsole : new Console());

/**
 * @deprecated
 */
function Console()
{
    this.canvas = null;
    this.println = consolePrintln;
    this.show = consoleShow;
}

/**
 * @deprecated
 */
function consolePrintln(object)
{
    if (!this.canvas)
    {
        this.canvas = window.open("about:blank", "Console", "toolbar = no, width = 640, height = 480, directories = no, status = no, scrollbars = yes, resize = no, menubar = no");
    }

    this.canvas.document.write(object);
    this.canvas.document.write("<br/>");
}

/**
 * @deprecated
 */
function consoleShow(object)
{
    this.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

    for (property in object)
    {
        this.println(property + " = " + eval("object." + property));
    }

    this.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
}

function limpiaTxtBusqueda() {
  //if ((document.getElementById("textoBusqueda").value == "Introduzca palabra o frase") ||
    // (document.getElementById("textoBusqueda").value == "Introduce word or phrase") ||
    // (document.getElementById("textoBusqueda").value == "Introduisez un mot ou une phrase") ||
     //(document.getElementById("textoBusqueda").value != ""))
         document.getElementById("textoBusqueda").value = "";
}

function limpiaTxtBusquedaRv() {
  //if ((document.getElementById("textoBusqueda").value == "Introduzca palabra o frase") ||
    // (document.getElementById("textoBusqueda").value == "Introduce word or phrase") ||
    // (document.getElementById("textoBusqueda").value == "Introduisez un mot ou une phrase") ||
     //(document.getElementById("textoBusqueda").value != ""))
         document.getElementById("textoBusquedaRv").value = "";
}

function limpiaAutorBusqueda() {
  //if ((document.getElementById("autorBusqueda").value == "Introduzca autor") ||
   //  (document.getElementById("autorBusqueda").value == "Introduce author") ||
   //  (document.getElementById("autorBusqueda").value == "Introduisez l'auteur") ||
    // (document.getElementById("autorBusqueda").value != ""))
         document.getElementById("autorBusqueda").value = "";
}


function limpiaBuscador() {
  if ((document.getElementById("keywordSearch").value == "Introduzca palabra o frase") ||
     (document.getElementById("keywordSearch").value == "Introduce word or phrase") ||
     (document.getElementById("keywordSearch").value == "Introduisez un mot ou une phrase"))
         document.getElementById("keywordSearch").value = "";
}

function lpdata(){
	  //document.forms[0].elements[2].value = "";
	  var key=window.event.keyCode;//codigo de tecla. 
	  	if ((key < 13 || key > 13) && (key < 32 || key > 32) && (key < 44 || key > 44) && (key < 45 || key > 45) && (key < 46 || key > 46) && (key < 48 || key > 57) && (key <= 64 || key > 90) && (key < 97 || key > 122) && (key < 209 || key > 209) && (key < 225 || key > 225) && (key < 233 || key > 233) && (key < 237 || key > 237) && (key < 241 || key > 241) && (key < 243 || key > 243) && (key < 250 || key > 250)){//si no es numero  
         	 window.event.keyCode=0;//anula la entrada de texto. 
	}
} 
	 
