﻿/**********************************************
FOR USE ON TICKER CAROUSEL MODULE
- in use with a modified version of the jQuery
  plugin jCarouselLite within jquery-plugins.js
**********************************************/

"use strict";
// global window: true, document: true, jQuery: true, swfobject: true, Intel: true

(function ($) {

	// Ticker pause
	Intel.mod.tickerPause = function () {
		var oTickerPause = $('.mod-ticker-car').find('#play-pause');
		$(oTickerPause).toggle(
			function () {
				$(this).addClass('play paused');
			},
			function () {
				$(this).removeClass('play paused');
			}
		);
	};

	// Initalize carousel for news
	Intel.mod.carNews = function () {
		var oCarousel = $('#latest-news-carousel');
		$(oCarousel).jCarouselLite({
			visible		: 1,
			scroll		: 1,
			vertical	: true,
			circular	: true,
			auto		: 2500,
			speed		: 1000,
			pause		: "#play-pause"
		});
		$('.mod-ticker-car').find('.carousel-item').css('clear', 'none');
	};

	// Initalize carousel for generic
	Intel.mod.carStuff = function () {
		var oCarousel = $('#latest-stuff-carousel');
		$(oCarousel).jCarouselLite({
			visible		: 1,
			scroll		: 1,
			vertical	: true,
			circular	: true,
			auto		: 2500,
			speed		: 1000,
			pause		: "#play-pause"
		});
		$('.mod-ticker-car').find('.carousel-item').css('clear', 'none');
	};

	// Initalize carousel for press release
	Intel.mod.carPress = function () {
		var oCarousel = $('#press-releases-carousel');
		$(oCarousel).jCarouselLite({
			visible		: 1,
			scroll		: 1,
			vertical	: true,
			circular	: true,
			auto		: 4000,
			speed		: 1000,
			pause		: "#play-pause"
		});
		$('.mod-ticker-car').find('.carousel-item').css('clear', 'none');
	};

	/*************************************
	CAROUSEL: TICKER SELECT
	*************************************/
	// Initialize ticker select drop down
	Intel.mod.tickerSelect = function () {
		var oTickerSort = $('.mod-ticker-car .mod-opts'),
		oTickerOpts = $(oTickerSort).find('.opts');

		// Load press release drop down on page load
		$('#current-ticker span.ticker-container').html($('#press-releases-container').html());
		$('#press-releases-carousel').css('text-indent','0');
		$('.opts li.latest-blogs').hide();
		Intel.mod.carPress();
		$(oTickerOpts).hide();
		$(oTickerSort).find('.ticker-sort').bind('click', function (e) {
			$(oTickerOpts).toggle();
		});

		// Load appropriate carousel on ticker select
		$(oTickerSort).find('li').bind('click', function (e) {
			var oTickerTopic = $(this).attr('class');
			switch (oTickerTopic) {
			case 'latest-news':
				$('#current-ticker span.ticker-container').html($('#latest-news-container').html());
				$('#latest-news-carousel').css('text-indent', '0');
				$('.opts li').show();
				$(this).hide();
				Intel.mod.carNews();
				break;
			case 'latest-stuff':
				$('#current-ticker  span.ticker-container').html($('#latest-stuff-container').html());
				$('#latest-stuff-carousel').css('text-indent', '0');
				$('.opts li').show();
				$(this).hide();
				Intel.mod.carStuff();
				break;
			case 'latest-blogs':
				$('#current-ticker  span.ticker-container').html($('#press-releases-container').html());
				$('#press-releases-carousel').css('text-indent', '0');
				$('.opts li').show();
				$(this).hide();
				Intel.mod.carPress();
				break;
			}
			$(oTickerOpts).hide();
			$(oTickerSort).find('.selected span').text($(this).text());
			return false;
		});
	};

}(jQuery));

// Global JS Inits using jQuery
jQuery(document).ready(function () {
	Intel.mod.tickerPause();
	//Intel.mod.carNews();
	//Intel.mod.carStuff();
	Intel.mod.carPress();
	//Intel.mod.tickerSelect();
});
