// JavaScript Document
if (document.getElementById("null"))
    	document.getElementById("null").className = "selected";

(function($) {
  $.fn.swipe = function(next, prev) {
    return this.each(function() {
      if ($.rotator.num % 2)
        $(this).animate({ width: ($.rotator.width - 10) }, $.rotator.speed * 1000, function() { $.rotator.obj.eq(next).css({ width: $.rotator.width, zIndex: $.rotator.zIndex, display: 'list-item' }); $.rotator.count++; $.rotator.zIndex++; $.rotator.num++; });
      else
        $.rotator.obj.eq(prev).animate({ width: 0 }, $.rotator.speed * 1000, function() { $.rotator.obj.eq(next).css({ width: 0, zIndex: ($.rotator.zIndex + 2) }); $.rotator.count++; $.rotator.zIndex++; $.rotator.num++; });
      if ($.rotator.first === true && $.rotator.num < $.rotator.total) $.rotator.cm_sp_tag($(this).children('a').attr('class'), (($.rotator.num % $.rotator.total) + 1)); else $.rotator.first = false;
    });
  }
})(jQuery);
$.rotator = { num: 1, first: true, count: Math.floor(Math.random() * 100), speed: 2, interval: 7, width: 958, height: 269, zIndex: 10,
  cm_sp_tag: function(p2, p3) { sep = "-_-"; cmCreateManualImpressionTag('home', 'Billboard' + sep + p2 + sep + 'ItemNum' + p3) }, cm_sp_lnk: function(p1, p2, p3) { sep = "-_-"; hRef = p1 + ((p1.lastIndexOf('?') == -1) ? '?' : '&') + 'cm_sp=Billboard' + sep + p2 + sep + 'ItemNum' + p3; cmCreateManualLinkClickTag(hRef, p2); location.href = hRef }
};  // default settings
function rotator(sfor, sin) {
  $.rotator.obj = $(sfor, sin), $.rotator.total = $.rotator.obj.length;
  $.rotator.obj.eq(($.rotator.count - 1) % $.rotator.total).addClass("f");
  $.rotator.obj.eq($.rotator.count % $.rotator.total).addClass("n");
  $.rotator.cm_sp_tag($($.rotator.obj.filter('.f').children('a')).attr('class'), 1);
  if ($.rotator.total > 1) intv = setInterval('rotatorChange()', ($.rotator.interval * 1000));
  //$.rotator.obj.hover(function() { clearInterval(intv) }, function() { intv = setInterval('rotatorChange()', ($.rotator.interval * 1000)) });
  $('a', $.rotator.obj).click(function(e) { e.preventDefault(); $.rotator.cm_sp_lnk(this.href, $(this).attr('class'), ((($.rotator.num - 1) % $.rotator.total) + 1)) });
}
function rotatorChange() {
  $.rotator.obj.eq($.rotator.count % $.rotator.total).swipe(($.rotator.count + 1) % $.rotator.total, ($.rotator.count - 1) % $.rotator.total);
}
$.ticker = { count: -1, speed: 1, interval: 6, height: 30, cm_re: "NewsTicker-_-ItemNum#-_-" }; // default settings
function ticker(sfor, sin) {
  $.ticker.obj = $(sfor, sin), $.ticker.total = $('li', $.ticker.obj).length;
  tickerScroll(); setInterval('tickerScroll()', ($.ticker.interval * 1000));
  $('a', $.ticker.obj).click(function(e) { e.preventDefault(); cmCreateManualImpressionTag('home', null, $.ticker.cm_re.replace('#', $.ticker.count + 1) + this.href.substr(this.href.lastIndexOf('/') + 1)); hRef = this.href + ((this.href.lastIndexOf('?') == -1) ? '?' : '&') + 'cm_re=' + $.ticker.cm_re.replace('#', $.ticker.count + 1) + this.href.substr(this.href.lastIndexOf('/') + 1); cmCreateManualLinkClickTag(hRef); location.href = hRef });
}
function tickerScroll() {
  if ($.ticker.count < $.ticker.total - 1)
    $.ticker.obj.animate({ top: parseInt($.ticker.obj.css('top')) - $.ticker.height }, $.ticker.speed * 1000, function() { $.ticker.count++ });
  else //if ($.ticker.count == $.ticker.total - 1)
    $.ticker.obj.animate({ top: 0 }, $.ticker.speed * 500, function() { $.ticker.count = 0 });
}
$(function() {
  rotator('li', '#marquee');
  ticker('ul', '#news-ticker');
});