var rssDoc;
var objInterval;
var FeedType = "";

function InitActiveXObject(){
SetUpdateTimer();    
      rssDoc = new ActiveXObject("Microsoft.XMLDOM");
      rssDoc.async = false;
     
}

function SetUpdateTimer(){
// var IntervalSetting = System.Gadget.Settings.read("cboRefreshInterval");
//if (objInterval != null) window.clearInterval(objInterval);
 if (objInterval == null) objInterval = window.setInterval("UpdateVideos()", 30000); 
           
}


function GetVideos(max, feed){
 
 var iMax = max;
 
// var rssDoc = new ActiveXObject("Microsoft.XMLDOM");
// rssDoc.async = false;
 rssDoc.load(feed);
 
 var headNode = rssDoc.selectNodes("/feed");
 var itemNodes = rssDoc.selectNodes("/feed/entry");
 
 if(itemNodes.length<iMax){
  iMax = itemNodes.length;
 }
 
 var feedBody = ""; 
 var strVideoID;
 var strVideoTitle;
 var intVideoIDStartIndex;
 var strImagesrc;
 
 
 for(i=0;i<iMax;i++){
//Extract videoID and title
    strVideoID = itemNodes.item(i).getElementsByTagName("id").item(0).text;
    strVideoTitle = itemNodes.item(i).getElementsByTagName("title").item(0).text;
    intVideoIDStartIndex = strVideoID.lastIndexOf('/')+1; 
    strVideoID = strVideoID.substring(intVideoIDStartIndex);

    //Build Image src
    strImagesrc = "http://img.youtube.com/vi/" + strVideoID + "/1.jpg";
     
    //feedBody = feedBody + "<p><a href='" + strVideoID + "'>" + strVideoID + "</a></p>"
      feedBody = feedBody + "<p><img id='" + strVideoID + "' src='" + strImagesrc + "' alt='" + strVideoTitle + "' onClick='showFlyout(id)' height='80px' width='90px' position='absolute' style='cursor: hand'/> </p>";

 }
 
 //feedBody = feedBody + "<br /><label for='FeedType' style='font-weight: normal; font-size: 10px; left: 12px; width: 78px; top: 33px; height: 14px; color: white'>" + FeedType + "</label>"
 
 myFeeds.innerHTML  = feedBody;
 document.getElementById("indicator").style.display = "none";
 
 //document.getElementById("myFeeds").innerHTML  = feedBody
 //myChannel.innerText = headNode.item(0).getElementsByTagName("id").item(0).text
}