jQuery(document).ready(initPage);

function initPage() {
	/** web track index btn* */
	jQuery(".track-btn").click(trackBtn);
	var trackPrefix = '/web/click/product/';
	jQuery("#Idea .track-btn2").click(function() {
		var trackSuffix = 'overview_wm'+this.id;
		var target = trackPrefix.concat(trackSuffix);
		trackClick(target);
	});
	var cursorLink = jQuery('#cursorLink').val();
	if (cursorLink != '') {
		jQuery('#' + cursorLink).removeClass('sidebarNav')
				.addClass('sidebarNavCur');
	}
	initPageMenu();
};

var initPageMenu = function() {
	// Preload other button-like images
	var $tabContentWrap = $('#FtagContent');
	var $tabContentList = $tabContentWrap.children('.introSec');
	var $tabWrapper = $('.FeaturesTag').eq(0);
	var $tabList = $tabWrapper.children('li');

	$tabList.click(function() {
		jQuery(this).children("a").addClass('focus').removeClass('unfocus');
		var selectedTab = jQuery(this).find("span");
		selectedTab.addClass('focus').removeClass('unfocus');

		jQuery(this).siblings().each(function() {
			jQuery(this).children("a").removeClass('focus').addClass('unfocus');
			var notSelectedTab = jQuery(this).find("span");
			notSelectedTab.removeClass('focus').addClass('unfocus');
		});

		var sectionId = this.id.replace(/Tab/, "");
		$tabContentList.each(function(i) {
			jQuery(this).hide();
		});
		$tabContentList.filter('#' + sectionId).show();
	});
	// initialize page always first tab be clicked
	$tabList.eq(0).trigger("click");
	
	// swap img file
	jQuery('.swapNewsImg').click(function() {
				var smallNewsImg = jQuery(this).attr('src');
				jQuery('#bigNewsImg').attr('src', smallNewsImg);
			});

	jQuery('.swapPodcastImg').click(function() {
				var smallPodcastImg = jQuery(this).attr('src');
				jQuery('#bigPodcastImg').attr('src', smallPodcastImg);
			});	
};

