function getcurrentvideos() {
  var rnd = (new Date()).getTime();
  var url = '/bollywood/current-videos.html?rnd='+rnd;
  $("#beingwatched").load(url,function() {
    if(window.addVideoThumbs) {
      addVideoThumbs('.beingwatched .videoitem');
    }
    vid_timer_count = 100;
    last_vid_update = (new Date()).getTime();
  });
}

function updatevidtimer() {
  if(vid_timer_count >= 0) {
    var ob = document.getElementById('vidtimer');
    if(ob) {
      ob.style.width = vid_timer_count+'%';
    }
    vid_timer_count--;
  }
  if(vid_timer_count == 0) {
    getcurrentvideos();
  }
}

function stopvidtimer() {
  if(vid_timer) {
    clearInterval(vid_timer);
  }
}

function startvidtimer() {
  stopvidtimer();
  vid_timer = setInterval('updatevidtimer()',400);
}

function checkvidupdated() {
  if(vid_timer_count == -1) {
    var now = (new Date).getTime();
    if((now - last_vid_update) > (60*1000)) {
      getcurrentvideos();
    }
  }
}

var vid_timer_count = 100;
var vid_timer = null;
var last_vid_update = (new Date()).getTime();
startvidtimer();
setInterval('checkvidupdated()',10000);

