$(function() {
	$( "#socialTab" ).tabs();
	$( "#homeTab" ).tabs();
	//$( "#youtubeTab" ).tabs();
		
	// Homepage slideshow
	$('#homepage-rotator .home-top-block-container').removeClass('hide');

	$('#homepage-rotator').cycle({
		fx:   'scrollHorz',
		easing: 'easeInOutSine',
		speed:  600,
		timeout: 6000,
		pause: 1,
		cleartype: 1,
		cleartypeNoBg: 1,
		pager: '#home-top-num-rotator',
		pagerAnchorBuilder: function(idx, slide) {
			var id = idx + 1;
			return '<li id="slide' + id + '"><a href="#">' + id + '</a></li>';
		}
	});  
  
	$('#home-top-num-rotator a').click(function() {
		$('#homepage-rotator').cycle('pause');
	}); 

	//load twtter feed into twitter tab
	$("#tweets").tweet({
		avatar_size: 32,
		count: 2,
		username: "Raising_Canes",
		template: function(i){return i["text"]},
		loading_text: "loading tweets..."
	});
	
	//load top 3 youtube video uploads
	var vidCount =0;
	$.jTube({
			request: 'user',
			requestValue: 'RaisingCanesOneLove',
			requestOption: 'uploads',
			limit: 3,
			page: 1,
			success: function(videos) {
				$(videos).each(function() {
					html = '<a href="'+this.link+'" title="'+this.title+'" target="_blank"`><img src="'+this.thumbnail+'"  class="youtube_thm vid'+vidCount+'" ></a>';
					$('#yt_videos').append(html);
					vidCount = vidCount+1;
				});
			},
			error: function(error) {
				$('#yt_videos').html(error);
			}
		});
	
	
	//google analytics for non navigation elements
	$('#slide1 a').click(function(){_gaq.push(['_trackEvent', 'carousel', 'tab', '1']);});
	$('#slide2 a').click(function(){_gaq.push(['_trackEvent', 'carousel', 'tab', '2']);});
	$('#slide3 a').click(function(){_gaq.push(['_trackEvent', 'carousel', 'tab', '3']);});
	$('#slide4 a').click(function(){_gaq.push(['_trackEvent', 'carousel', 'tab', '4']);});
	$('#socialFacebook').click(function(){_gaq.push(['_trackEvent', 'tab', 'social', 'facebook']);});
	$('#socialTwitter').click(function(){_gaq.push(['_trackEvent', 'tab', 'social', 'twiiter']);});
	$('#socialYouTube').click(function(){_gaq.push(['_trackEvent', 'tab', 'social', 'youtube']);});
	$('#homeOpenings').click(function(){_gaq.push(['_trackEvent', 'tab', 'content', 'openings']);});
	$('#homeNews').click(function(){_gaq.push(['_trackEvent', 'tab', 'content', 'news']);});
	
});


