﻿/*
    add the getElementById function
    to browsers which don't support it
*/
if(!document.getElementById){
  if(document.all)
  document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined")
    return document.all[arguments[0]]
    else
    return null
  }
  else if(document.layers)
  document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined")
    return document[arguments[0]]
    else
    return null
  }
}

doris.cE = function(e) { return document.createElement(e); }
doris.gE = function(e) { return document.getElementById(e); }

doris.loadFile = function(url) {
    var xmlhttp = window.XMLHttpRequest? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
    var response;
    
    if (xmlhttp) {
        xmlhttp.open('GET', url, false);
        xmlhttp.setRequestHeader('Connection', 'close');
        xmlhttp.send(null);
        response = xmlhttp.responseText;
    }
    
    return response;
}

doris.processVideoData1 = function() {
    var d = doris;
    d.videos = eval(d.videosJson).value.items;
    
    var container = d.gE('videoContainer'); 
    for (var iterator = 0; iterator < d.videos.length; iterator++) {
        var video = d.videos[iterator];
        if (video.VideoID) {
            var span = d.cE('span');
        
            span.className = 'video';
            span.innerHTML += '<div class="videoTitle">' + video.Title + '</div>';
            span.innerHTML += '<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/' + video.VideoID + '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/' + video.VideoID + '&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="500" height="400"></embed></object>';
            if (video.Description) { span.innerHTML += '<div class="videoDescription">' + video.Description + '<br/><br/></div>'; }
        
            container.appendChild(span);
        }
    }
}

doris.processVideoData = function() {
    var d = doris;
    d.videos = eval(d.videosJson).value.items;
    
    var list = d.gE('videoList');
    for (var iterator = 0; iterator < d.videos.length; iterator++) {
        var video = d.videos[iterator];
        if (video.VideoID) {
            var span = d.cE('span');
            
            span.className = 'videoLink';
            span.innerHTML += '<a href="#" onclick="doris.displayVideo(' + iterator + '); return false;">' + video.Title + '</a><br />';
            list.appendChild(span);
        }
    }
    d.displayVideo(0);
}

doris.displayVideo = function(index) {
    var d = doris;
    var video = d.videos[index];
    
    if (video.VideoID) {
        var container = d.gE('videoContainer');
        var span = d.cE('span');

        span.className = 'video';
        span.innerHTML += '<div class="videoTitle">' + video.Title + '</div>';
        span.innerHTML += '<object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/' + video.VideoID + '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/' + video.VideoID + '&hl=en&fs=1&autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" width="500" height="400"></embed></object>';
        span.innerHTML += '<div class="videoDescription">' + video.Description + '<br/><br/></div>';
        
        container.innerHTML = '';
        container.appendChild(span);
    }
}
