//accordion function
$.fn.accordion = function(param) {
  if ( param === undefined ) {
      param = $(".tab-content > div:has(dl.accordion)"); // DEFAULT: all divs after .tab-content that contains DL tag
  }
  $(".accordion dd").hide(); //Hide all content
  var features = $(param);
  features.css("cursor","pointer");
  features.find(".more").show();
  features.find(".close").hide();
  features.hover(
    function(){
      $(this).find(".more").addClass("hover");
      $(this).find(".close").addClass("hover");
    },
    function(){
      $(this).find(".more").removeClass("hover");
      $(this).find(".close").removeClass("hover");
    }
  );
  features.click(function(){
    $(this).find("dd").slideToggle("fast");
    $(this).find(".close").toggle();
    $(this).find(".more").toggle();
  });
}

//When page loads...
$(document).ready(function() {
	$(".tab-content").hide(); //Hide all content
	$(".second-navigation ul li:first").addClass("active").show(); //Activate first tab
	$(".tab-content:first").show(); //Show first tab content

	//On Click Event
	$(".second-navigation ul li").click(function(ev) {
		ev.preventDefault();
		$(".second-navigation ul li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		$("#middle-column").removeClass('bg-none');
		$("#middle-column").removeClass('no-right-padding');		
		$("#middle-column").width(550);
		$("#right-column").show();
		$("#block-bottom").show();
		$(".tab-content").not(activeTab).hide(); //Hide all other tab content
	});

	//Hide right column
	$(".second-navigation ul li.wide-selection").click(function() {	
	  $("#middle-column").width(720);
		$("#middle-column").addClass('bg-none');
		$("#right-column").hide();
		$("#block-bottom").hide();
	});

	//Add class to remove padding from middle content to display the comparison table correctly across all browsers
	$(".second-navigation ul li.comparison-table").click(function() {	
	  $("#middle-column").addClass('no-right-padding')
	});

	//Feedburner
	$('.feedburnerFeedBlock li').eq(-1).addClass('last');
	$('.feedburnerFeedBlock li').each(function(){
		// variables
		var fbHeadline = $(this).find('.headline');
		var fbContent = $(this).find('div');
		var fbDate = $(this).find('.date');

		// move date
		$(fbDate).html('<span class="dateN">' + $(fbDate).text() + '</span>');
		$(this).find('.dateN').appendTo(fbHeadline);
		$(fbDate).remove();

		// create 'Read more'
		$(fbHeadline).find('a').clone().appendTo($(this)).text('Read More').removeClass().addClass('readMore arrow-01').wrap('<p class="tright pbn" />');
	}); 
	
	//call accordion with default value - product pages
	$().accordion(); 
});



