$(document).ready(function() {
	$.fn.thisWeeksPoll();
	$(".video_thumbs").contactcarousel({ visible: 3 });
	$(".ContactCarousel").contactcarousel();
	$(".ContactCarousel .carousel_wrapper").width('670px');

	if($.cookie('closedTout')){
		$('.carausel_cta_lg').remove();
	}

	// video carousel nav
	$.fn.videoLoad = function() {
		$('.video_thumbs .carousel_wrapper a').ajaxLoadContent({
			component: 'TopicVideos',
			container: 'div.currentVideo',
			callback: function() {
			$('.video_player').each(function() {
			$(this).find('a img').after('<img src="/images/idea_hub/bkg.thumb-overlay-med.png" alt="play video" class="overlay" >');
			$.ifixpng('/images/pixel.gif');
			$('img[src$=.png]').ifixpng();
		});
			}
		});
	};
	
	$.fn.videoLoad();
	
	// alert box close binding
	$('p.close a').click(function(e) {
		e.preventDefault();
		$.cookie('closedTout', 'true');
		$(this).parent().parent().hide();
	});
	
	$('.video_player').each(function() {
	    $(this).find('a img').after('<img src="/images/idea_hub/bkg.thumb-overlay-med.png" alt="play video" class="overlay" >');
	    $.ifixpng('/images/pixel.gif');
	    $('img[src$=.png]').ifixpng();    
	});
	
	if($.browser.msie && $.browser.version < 7) {
		$('.articles .pod_content li, .discussions .pod_content li').hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
	}
	
	$('.IdeaHub .Topic .articles .pod_content li.Featured').each(function(){
		//set the parent LI height so that it's at least the height of the 'featured' image
		//parent LIs have 22px padding total on top and bottom
		var minHeight = 48;
		if ($(this).height() < minHeight) {
			$(this).height(minHeight);
		}
		var parentHeight = $(this).outerHeight();
		// var containerEle = document.createElement('span');
		// $(containerEle).height(parentHeight);
		$(this).append('<span style="height: '+parentHeight+'px">&nbsp;</span>');
	});
	
	// Omniture tracking:
	// Idea Hub > Topics > [topic_name] > spotlight
	var topicname = parseTitle('topic')
	$('#LoggedOutUtility li a').click(function(){
		var btnType = $(this).parent().attr('id'); var action = '';
		switch(btnType){
			case 'UtilityLogin':
				btnType = 'login_left'; action = 'login';
				break;
			case 'UtilityRegister':
				btnType = 'register_left'; action = 'register';
				break;
			case 'UtilityAbout':
				btnType = 'about_left'; action = 'browse';
				break;
			case 'UtilityNoCard':
				btnType = 'apply_left'; action = 'apply_now';
				break;
		}

	});
	
	//utility nav clicks - logged in
	$('#Utility li a').click(function(){
		var btnType = $(this).parent().attr('id');
		switch(btnType){
			case 'UtilityNavProfile':
				btnType = 'profile_left';
				break;
			case 'UtilityNavSettings':
				btnType = 'settings_left';
				break;
			case 'UtilityNavContacts':
				btnType = 'contacts_left';
				break;
			case 'UtilityNavMessages':
				btnType = 'help_left';
				break;
		}
		return true;
	});
	
				
});

