function debuglog(msg) {
  if (window.debug !== true) {
    return false;
  } else if (typeof console == 'undefined') {
    alert(msg);
  } else {
    console.log(msg);
  }
}

$(document).ready(function () {
  /* ---------------------------------------------------------------------------
  * Correct width of image/ad containers */
	$('#pixblock').width($('#toppix').width() + 6);

  /* ---------------------------------------------------------------------------
  * Set up more toggle action for "more" link onclick events */
  $(".morebbballlink").click($(".morebbball").toggle);
	$(".moregbballlink").click($(".moregbball").toggle);
	$(".morefootballlink").click($(".morefootball").toggle);
	$(".moreoslink").click($(".moreos").toggle);
	$(".moresoccerlink").click($(".moresoccerlink").toggle);

  /* ---------------------------------------------------------------------------
  * Adjust colors and font size based on cookie values, if present */
  var getcook = getCookie('BackgroundColor'),
      getfsize = getCookie('FontSize');

  if (getcook == 'black') {
	  $('.articleleftcol').css({
      'background-color':'#0f0f0f',
      'color':'#ccc'
      });
	  $('.articleleftcol').css({
      'background-image':'url(images/designelements/articlebg_black.jpg)',
      'color':'#ccc'
      });

    $('#toblacktext').toggle();
	  $('#towhitetext').toggle();
  }

  if (getfsize == '18'){
		$('.articleleftcol').css({
      'font-size':'18px'
      });
	}

  /* ---------------------------------------------------------------------------
  * Set up related article toggle action for "reclick" onclick events */
  $('.related .relclick').click(function () {
    $(".morearticles").toggle();
	  $(".close").toggle();
  });

  /* ---------------------------------------------------------------------------
  * Set up tab fading */
  if ($.fn.tabs) {
    $('#scoreBox ul, #sportScoreBox ul, #popular-stories ul').tabs({
      'fxFade':true,
      'fxSpeed':'fast'
    });
  }

  /* ---------------------------------------------------------------------------
  * Interval-driven conditional show/hide for line scores where:
  * - from midnight to noon, yesterday's scores show
  * - from noon to midnight, today's scores show
  * Interval allows for change out while page is viewed, so that users who are
  * looking at the page during the rollover from AM-PM or vice-versa will have
  * the line score content swapped appropriately. */
	
/* shelton commented out - this shouldn't be necessary with new scoreboard tag	
  function updateLineScoreDisplay() {
    if ($('#scoreBox').length != 1) {
      clearInterval(window.lineScoreCheck);
      return;
    }

    var months = [
          'Jan', 'Feb', 'March', 'April', 'May', 'June',
          'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'
          ],
        dt = new Date(),
        dt_str = months[dt.getMonth()] + '. ' + dt.getDate();

    debuglog(dt + ' :: ' + dt_str);

    $('#scoreBox .ui-tabs-panel').each(function () {
      var sport = $(this),
          scores = sport.find('.lineScoreDay').hide(),
          scheds = sport.find('.scheduleDay').hide(),
          first_score = $(scores.get(0)),
          next_sched = $(scheds.get(0));

      debuglog(sport.attr('id') + '\n'
        + 'scores:' + scores.length + ', scheds:' + scheds.length + '\n'
        + 'score: ' + first_score + ', sched:' + next_sched);

      if (scores.length) {
        // scores found
        if (dt.getHours() < 12) {
          // before noon
          debuglog('showing most up-to-date scores');
          // show most up-to-date scores, today or yesterday
          first_score.show();
        } else if (first_score.find('.lineScoreDate').text() == dt_str) {
          // today
          debuglog('showing today\'s scores');
          // show today's scores
          first_score.show()
        } else {
          // afternoon and old scores only
          debuglog('showing next upcoming schedule');
          // show next upcoming day of scheduled games (today, tomorrow, etc)
          next_sched.show();
        }
      } else if (scheds.length) {
        // no scores found
        debuglog('showing next upcoming schedule');
        // show next upcoming day of scheduled games (today, tomorrow, etc)
        next_sched.show();
      }
    });

    debuglog('===================================================');
  }

  // clean up pre-existing intervals so update isn't run too often
  clearInterval(window.lineScoreCheck);
  // set a new interval to run an update check every 5 seconds
  window.lineScoreCheck = setInterval(updateLineScoreDisplay, 5000);
  // do an initial check
  updateLineScoreDisplay();
--- end shelton commenting out */


  /* ---------------------------------------------------------------------------
  * Set up font sizing control actions for "up" and "down" onclick events */
  $('.up').click(function () {
    $('.articleleftcol').css({
      'font-size':'18px'
      });

    setCookie('FontSize', '18', exp);
  });

  $('.down').click(function () {
    $('.articleleftcol').css({
      'font-size':null
      });

    setCookie('FontSize', '14', exp);
  });

  /* ---------------------------------------------------------------------------
  * Set up color toggle action for "to*text" onclick events */
  $('#toblacktext').click(function () {
		$('#toblacktext').toggle();
 		$('#towhitetext').toggle();

    $('.articleleftcol').css({
      'background-color':'#fff',
      'color':'#000'
      });
	  $('.articleleftcol').css({
      'background-image':'url(images/designelements/articlebg_white.jpg)',
      'color':'#000'
      });

	  setCookie('BackgroundColor', 'white', exp);
  });

	$('#towhitetext').click(function () {
		$('#toblacktext').toggle();
 		$('#towhitetext').toggle();

    $('.articleleftcol').css({
      'background-color':'#0f0f0f',
      'color':'#ccc'
      });
	  $('.articleleftcol').css({
      'background-image':'url(images/designelements/articlebg_black.jpg)',
      'color':'#ccc'
      });

	  setCookie('BackgroundColor', 'black', exp);
  });

  /* ---------------------------------------------------------------------------
  * Force objects to have transparent wmode, and div parent to be positioned
  * relative; this corrects the menu displaying behind flash ads */
  $('param[name=wmode]').attr('value', 'transparent');
  $('embed').attr('wmode', 'transparent');
  $('object,embed').parent('div').each(function() {
    var obj = $(this);
    switch (obj.css('position')) {
      case 'relative':
      case 'absolute':
        obj.css({
          'z-index':1
          });
        break;
      default:
        obj.css({
          'position':'relative',
          'z-index':1
          });
        break;
    }
  });

  //$('#loadingscoreboard').css({"display":"none"});
  //$('#container-4').css({"display":"block"});
  //$('#container-5 ul').css({"display":"block"});
  //$('#container-6 ul').css({"display":"block"});
});