var today = new Date();
var dif = 7-today.getDay(); 

if (dif < 7)
{
	var nextSun = new Date(today.getFullYear(), today.getMonth(), today.getDate()+dif, 9, 00, 0, 0);
}
else
{
	if(today.getHours() >= 9 && today.getHours() < 13)
	{
		var nextSun = new Date(today.getFullYear(), today.getMonth(), today.getDate()-1, 0,0, 0, 0);
	}
	else if(today.getHours() < 9)
	{
		var nextSun = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 9, 00, 0, 0);
	}
    else
    {
        var nextSun = new Date(today.getFullYear(), today.getMonth(), today.getDate()+dif, 9, 00, 0, 0);
    }
}

$(document).ready(function() {
  if($('#countdown-container').is(':visible')) {
    $('#defaultCountdown').countdown({
		  alwaysExpire: true,
		  onExpiry: goHeaderLive,
		  timezone: -6,
		  until: nextSun    
	  });
  }
});

function goHeaderLive() {
  $('#countdown-container').fadeOut();
  $('#watch').fadeOut();
  $('#isLive').fadeIn();
}
