function loadXML(archivo){

	var xmlDoc;
	// code for IE
	if (window.ActiveXObject)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation.createDocument)
	{
		xmlDoc=document.implementation.createDocument("","",null);
	}
	else
	{
		alert('Su browser no es compatible con VFTV. Por favor utilice IE6+ o FF1+');
	}
	var strnode, msgsobj, video_seleccionado;
	xmlDoc.async = false;
	xmlDoc.load(archivo); //Leemos el XML
	return xmlDoc;

}

function getFirstElement(node,elementName) {
    
    child =  node.firstChild;
    while (  child != null ) {
        if (child.nodeType == 1) {
            if ( child.nodeName == elementName) {
                return child;
            }
        }    
        child = child.nextSibling;    
    }
    return null;    
}


function getLastElement(node,elementName) {
    
    child =  node.lastChild;
    while (  child != null ) {
        if (child.nodeType == 1) {
            if ( child.nodeName == elementName) {
                return child;
            }
        }    
        child = child.previousSibling;    
    }
    return null;    
}



function getNthElement(node, elementName, n) {
        
    foundCount = 0;
    child =  node.firstChild;    
    while (child != null)  {
        if (child.nodeType == 1) {
            if (child.nodeName == elementName) {
                foundCount = foundCount + 1;
                if (foundCount == n) {        
                    return child;        
                }
            }
        }
        child = child.nextSibling
    }
    
    return null;    
}

function getElementText(node) {
        
    if (node == null) {
        return("");
    }
    
    child =  node.firstChild;
    foundCDATA = false;
    foundPlainText = false;
    
    while (child != null) {    
        if (child.nodeType == 4) {            // CDATA node
            result = child.nodeValue;
            foundCDATA = true;
        }
        else {
            if (child.nodeType == 3) {        // Text node
                result = child.nodeValue;
                foundPlainText = true;
            }
        }
        if (foundCDATA == true) {
            return result
        }    
        child = child.nextSibling    
    }
    if (foundPlainText == false) {
        return("")
    }

    return result;
}
