﻿function RetrieveVideos(product)
{   
    //var url = "http://localhost/testsite/videos/VideoFile.xml";
    var url = "/common/javascripts/VideoFile.xml";
    xmldocvd = null;
    xmldocvd = loadXMLDocVD(url);
    xyz=xmldocvd.getElementsByTagName("product");
//This gets the Product Name tag
    for (l=0;l<xyz.length;l++)
    {
    xy=xmldocvd.getElementsByTagName("product")[l].attributes;
        if (xy.getNamedItem("ID").nodeValue == product)  
        {
        
                    var browserName = navigator.userAgent;
                    var isIE = browserName.match(/MSIE/);
                    if (isIE)
                    {
                    ab=xmldocvd.getElementsByTagName("product")[l].childNodes;
                    bc=xmldocvd.getElementsByTagName("product")[l].firstChild;
                    tt = xmldocvd.getElementsByTagName("product");
                  
                        var plist = document.getElementById("Videos");
                        var newnode = document.createElement("li");
                        var nimg = "<img src='/images/VIDEO_ICON.gif' style='border:0;float:right' />";
                        var nLink = "<a id=mylink href=" + bc.firstChild.data + "target='_blank'>" +nimg+ "</a><br /><br /><br />";
                        newnode.innerHTML = nLink;
                        plist.appendChild(newnode);
                    for (i=1;i<ab.length;i++)
                    {
                      if (bc.nodeType==1)
                       {                       
                        k=bc.nextSibling;
                        newnode = document.createElement("li");
                        nimg = "<img src='/images/VIDEO_ICON.gif' style='border:0;float:right' />";
                        nLink = "<a id=mylink href=" + k.firstChild.data +  "target='_blank'>" +nimg+ "</a><br /><br /><br />";
                        newnode.innerHTML = nLink;
                        plist.appendChild(newnode);
                       }
                    bc=bc.nextSibling;
                    }
                   }//isIE 
                   else
                   {
                        tt = xmldocvd.getElementsByTagName("product");
                    
                        var plist = document.getElementById("Videos");
                        var newnode = document.createElement("li");
                        var nimg = "<img src='/images/VIDEO_ICON.gif' style='border:0;float:right' />";
                        var nLink = "<a id=mylink href=" + tt[l].getElementsByTagName("link")[0].firstChild.nodeValue + "target='_blank'>" +nimg+ "</a><br /><br /><br />";
                        newnode.innerHTML = nLink;
                        plist.appendChild(newnode);
                        nl = tt[l].getElementsByTagName("link").length

                    for (i=1;i<=nl;i++)
                    {
                                            
                        k=tt.nextSibling;
                        newnode = document.createElement("li");
                        nimg = "<img src='/images/VIDEO_ICON.gif' style='border:0;float:right' />";
                        nLink = "<a id=mylink href=" + tt[l].getElementsByTagName("link")[i].firstChild.nodeValue +  "target='_blank'>" +nimg+ "</a><br /><br /><br />";
                        newnode.innerHTML = nLink;
                        plist.appendChild(newnode);
                       
                    tt=tt.nextSibling;
                    }
                   
                   
                   
                   }//non-IE
        }
}
}   

function loadXMLDocVD(url)
{
if (window.XMLHttpRequest)
  {
  xhttpvd=new XMLHttpRequest();
  }
else
  {
  xhttpvd=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttpvd.open("GET",url,false);
xhttpvd.send("");
return xhttpvd.responseXML;
} 
