Event.observe(window, 'load', init, false);

var myWidth = 0;
var myHeight = 0;
var firstVID;

var rand_no = Math.random();
rand_no = rand_no * 100;
rand_no = Math.ceil(rand_no);

if( rand_no % 2 ) { 
  firstVID = 'EBM854BTGL0';
}
else {
  firstVID = 'PTehTbT7aho';
}

function init(){
    var rss = $("rssBox");
    getBrowserSize();
    rssHeight = myHeight*0.99;
    if( rssHeight < 500 ) {
        rssHeight = 500;
    }
    rss.style.height = rssHeight + 'px';
    showVideo(firstVID);
}

function showVideo(vid) {
//     var vwin = $("vidBox");
//     vwin.innerHTML = '<embed src="http://www.youtube.com/v/' + vid + '&autoplay=true" type="application/x-shockwave-flash" width="425" height="350"></embed></div>';
     var url = "/showVideo.php";
     var pars = 'vid=' + vid; 
     var target = 'vidBox';
     var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});
     var newbox = $("newbox");
     var box = $("box");
     newbox.innerHTML = box.innerHTML;
//alert(pars);
}

function fetchVideo(lid, pid) {
     var lnode = $(lid);

     var url = "/fetchPhraseContent.php";
     var pars = 'link_id=' + lid + '&phrase_id=' + pid; 
     var target = lid;
//alert(pars);
     var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});
}

function getBrowserSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
}

