	$(document).ready(function()
	{
		for (i = 0; i <= arrProductPlaceHolderID_Expand.length - 1; i++)
			AssignExpandEvent(arrProductPlaceHolderID_Expand[i], true, arrProductPlaceHolderID_Expand, arrProductPlaceHolderID_Hide, arrProductPlaceHolderID_Corappse )
		
		for (i = 0; i <= arrProductPlaceHolderID_Corappse.length - 1; i++)
			AssignExpandEvent(arrProductPlaceHolderID_Corappse[i], false, arrProductPlaceHolderID_Expand, arrProductPlaceHolderID_Hide, arrProductPlaceHolderID_Corappse )

		for (i = 0; i <= arrVideoPlaceHolderID_Expand.length - 1; i++)
			AssignExpandEvent(arrVideoPlaceHolderID_Expand[i], true, arrVideoPlaceHolderID_Expand, arrVideoPlaceHolderID_Hide, arrVideoPlaceHolderID_Corappse )
		
		for (i = 0; i <= arrVideoPlaceHolderID_Corappse.length - 1; i++)
			AssignExpandEvent(arrVideoPlaceHolderID_Corappse[i], false, arrVideoPlaceHolderID_Expand, arrVideoPlaceHolderID_Hide, arrVideoPlaceHolderID_Corappse )

		for (i = 0; i <= arrMagazinePlaceHolderID_Expand.length - 1; i++)
			AssignExpandEvent(arrMagazinePlaceHolderID_Expand[i], true, arrMagazinePlaceHolderID_Expand, arrMagazinePlaceHolderID_Hide, arrMagazinePlaceHolderID_Corappse )
		
		for (i = 0; i <= arrMagazinePlaceHolderID_Corappse.length - 1; i++)
			AssignExpandEvent(arrMagazinePlaceHolderID_Corappse[i], false, arrMagazinePlaceHolderID_Expand, arrMagazinePlaceHolderID_Hide, arrMagazinePlaceHolderID_Corappse )

		// Hide all tab divs
		//product
		$('#two').hide();
		$('#three').hide();
		$('#four').hide();
		$('#five').hide();
		$('#six').hide();
		
		$('#twoVideo').hide();
		$('#threeVideo').hide();
		$('#fourVideo').hide();
		$('#fiveVideo').hide();

		$('#twoMagazine').hide();
		$('#threeMagazine').hide();
		$('#fourMagazine').hide();
		$('#fiveMagazine').hide();
		$('#sixMagazine').hide();
		
		$('#productGuideTab li a').click(function()
		{
		    $('#one').hide(); $('#two').hide(); $('#three').hide(); $('#four').hide(); $('#five').hide(); $('#six').hide();
			$('#product_list ul li').removeClass('active');
			$(this).parent().addClass('active');
			var currentTab = $(this).attr('href');
			$(currentTab).show();
			return false;
		});
		
		$('#videoGuideTab li a').click(function()
		{ 
			$('#oneVideo').hide();
			$('#twoVideo').hide();
			$('#threeVideo').hide();
			$('#fourVideo').hide();
			$('#fiveVideo').hide();
			
			$('#entertain_list ul li').removeClass('active');
			$(this).parent().addClass('active');
			var currentTab = $(this).attr('href');
			$(currentTab).show();
			return false;
		});
		
		$('#magazineGuideTab li a').click(function()
		{
		    $('#oneMagazine').hide();
		    $('#twoMagazine').hide();
		    $('#threeMagazine').hide();
		    $('#fourMagazine').hide();
		    $('#fiveMagazine').hide();
		    $('#sixMagazine').hide();
		
			$('#magazine_list ul li').removeClass('active');
			$(this).parent().addClass('active');
			var currentTab = $(this).attr('href');
			$(currentTab).show();
			return false;
		});
	});

	function AssignExpandEvent(divID, bExpand, arrExpandList, arrHideList, arrCorappseList )
	{
		$(divID).click(function()
		{
			ExpandProduct(bExpand, arrExpandList, arrHideList, arrCorappseList); 
			return false;
		});
	}

	function ExpandProduct(bExpand, expandList, hideList, corappseList)
	{
		if (bExpand)
		{
			for (i = 0; i <= expandList.length - 1; i++)
				$(expandList[i]).hide();
				
			for (i = 0; i <= hideList.length - 1; i++)
				$(hideList[i]).show();
				
			for (i = 0; i <= corappseList.length - 1; i++)
				$(corappseList[i]).show();
		}
		else
		{
			for (i = 0; i <= expandList.length - 1; i++)
				$(expandList[i]).show();
				
			for (i = 0; i <= hideList.length - 1; i++)
				$(hideList[i]).hide();
				
			for (i = 0; i <= corappseList.length - 1; i++)
				$(corappseList[i]).hide();
		}
	}

	var productTabs = new Array();



	productTabs[0] = ["#tabProductFresh",       "img/v2_tab/btn_ProductFresh.png", "img/v2_tab/btn_ProductFresh_active.png"];
	productTabs[1] = ["#tabProductReviews", "img/v2_tab/btn_recentreviews.png", "img/v2_tab/btn_recentreviews_active.png"];
	productTabs[2] = ["#tabProductReleases",    "img/v2_tab/btn_latestreleases.png", "img/v2_tab/btn_latestreleases_active.png"];
	productTabs[3] = ["#tabProductEco",         "img/v2_tab/btn_ProductEco.png", "img/v2_tab/btn_ProductEco_active.png"];
	productTabs[4] = ["#tabProductPerformance", "img/v2_tab/btn_ProductPerformance.png", "img/v2_tab/btn_ProductPerformance_active.png"];
	productTabs[5] = ["#tabProductMesurfFavs",  "img/v2_tab/btn_mesurfEditorsChoice.png", "img/v2_tab/btn_mesurfEditorsChoice_active.png"];
    
    var videoTabs = new Array();
    videoTabs[0] = ["#tabVideoFresh",       "img/v2_tab/btn_videoFresh.png", "img/v2_tab/btn_videoFresh_active.png"];
    videoTabs[1] = ["#tabVideoSurfClips",   "img/v2_tab/btn_videoSurfClips.png", "img/v2_tab/btn_videoSurfClips_active.png"];
    videoTabs[2] = ["#tabVideoRadClips",    "img/v2_tab/btn_videoRadClips.png", "img/v2_tab/btn_videoRadClips_active.png"];
    videoTabs[3] = ["#tabVideoFilmTrailers","img/v2_tab/btn_videoFilmTrailers.png", "img/v2_tab/btn_videoFilmTrailers_active.png"];
    videoTabs[4] = ["#tabVideoMesurfFavs",  "img/v2_tab/btn_videoEditorsChoice.png", "img/v2_tab/btn_videoEditorsChoice_active.png"];

    var magazineTabs = new Array();
    magazineTabs[0] = ["#tabMagazineFresh",       "img/v2_tab/btn_MagazineFresh.png", "img/v2_tab/btn_MagazineFresh_active.png"];
    magazineTabs[1] = ["#tabMagazineFeatures",    "img/v2_tab/btn_MagazineFeatures.png", "img/v2_tab/btn_MagazineFeatures_active.png"];
    magazineTabs[2] = ["#tabMagazineInterviews",  "img/v2_tab/btn_MagazineInterviews.png", "img/v2_tab/btn_MagazineInterviews_active.png"];
    magazineTabs[3] = ["#tabMagazineShapers",     "img/v2_tab/btn_MagazineShapers.png", "img/v2_tab/btn_MagazineShapers_active.png"];
    magazineTabs[4] = ["#tabMagazineArtists",     "img/v2_tab/btn_MagazineArtists.png", "img/v2_tab/btn_MagazineArtists_active.png"];
    magazineTabs[5] = ["#tabMagazinePhotographers", "img/v2_tab/btn_MagazinePhotographers.png", "img/v2_tab/btn_MagazinePhotographers_active.png"];

    function switchProductTabImage(aTag, arrTabs)
    {
        ResetTabs(arrTabs);
        path = getProductImagePath(aTag, arrTabs);
        jQuery(aTag).children("img").attr("src", path);
    }
    
    function ResetTabs(tabs)
	{
		for (i = 0; i <= tabs.length - 1; i++)
		{
			jQuery(tabs[i][0]).children("img").attr("src", tabs[i][1]);
		}
	}
    
	function getProductImagePath(id, productLists)
	{
		for (i = 0; i <= productLists.length - 1; i++)
		{
			if (productLists[i][0] == id)
			{
				return productLists[i][2];
			}
		}
		return;
	}
	

