
	/* *
	 *
	 *		@function			Advertising Javascript
	 *
	 *		@website			MyWyoming.org
	 *		@owner				TCT West, Inc.
	 *
	 *		@author				Alan Ferguson
	 *		@company			Vision West, Inc.
	 *		@date					July 15, 2010
	 *
	 *		@description	asdsf.
	 *
	 * */

	/* *
	 * On DOM Ready
	 * */
	
	var timer_link = new Array;
	
	$(document).ready(function() {
	
	});

	/* *
	 * Load Banner Ad
	 *
	 *		First grab the banner advertisement
	 *		to immediately load and then set a timer
	 *		to load banner ads every 30 seconds.
	 *
	 * */

	function BannerAd(type, video_id, stream_id, channel_id, owner_ids)
	{
		
		GrabBannerAd(type, video_id, stream_id, channel_id, owner_ids);
		
		BannerAdTimer(type, video_id, stream_id, channel_id, owner_ids, 30000);
		
	}

	/* *
	 * Start Advertising
	 *
	 *	Begin the process of selecting and
	 *	displaying advertisements.
	 *
	 *	Depending if the timer is true or false,
	 *	the advertisements are processed once, or
	 *	cycled by using a timer.
	 *
	 * */
	
	function BannerAdTimer(type, video_id, stream_id, channel_id, owner_ids, interval)
	{
		
		timer_link[type] = setInterval("GrabBannerAd(" + type + ", " + video_id + ", " + stream_id + ", " + channel_id + ", '" + owner_ids + "');", interval);

	}
	
	/* *
	 * Clear Banner Ad Timer
	 * */
	
	function ClearBannerAdTimer(type)
	{
		
		clearInterval(timer_link[type]);
		
	}
	
	/* *
	 * Load Advertisement
	 * */
	
	function GrabBannerAd(type, video_id, stream_id, channel_id, owner_ids)
	{
		
		$.ajax({
			url: "/grab-banner-ad",
			type: "POST",
			data: {"type":type, "video_id":video_id, "stream_id":stream_id, "channel_id":channel_id, "owner_ids":owner_ids},
			dataType: "text",
			success: function(data) {
				PopulateBannerAd(type, data);
				if (data.length < 1) ClearBannerAdTimer(type);
			},
			error: function(obj, error) {
			}
		});
		
	}
	
	/* *
	 * Populate Banner Ad
	 * */
	
	function PopulateBannerAd(type, data)
	{
		
		if (data.length > 0)
		{
			$("#banner-ad-" + type).html(data);
			$("#banner-ad-" + type + ".hidden").removeClass("hidden");
		}
		
	}


