//Script to prepare the page for jquery tabs

////////////////////////////////////////////////
//Create menu after the image gallery
///////////////////////////////////////////////

//use jQuery via $j
var $j = jQuery.noConflict();



$j(document).ready(function(){

	//read number of comments for tabmenu
	var commentsCount = $j('.tx-comments-count').text();
	//console.log(commentsCount);

	$j('.tx-comments-count').addClass("hideme");

	//prep the tab menu to be injected below
	var tabMenu = "<ul>";
	if ( $j('#showDetails').length ) {
	    tabMenu += "<li><a href=\"#showDetails\"><span>Description</span></a></li>";
	}
	if ( $j('#showspecs').length) {
	    tabMenu += "<li><a href=\"#showspecs\"><span>Composantes</span></a></li>";
	}
	if ( $j('#comments-plugin').length ) {
	    tabMenu += "<li><a href=\"#comments-plugin\"><span>"+commentsCount+"</span></a></li>";
	}
        tabMenu += " </ul>";

	//insert the tabmenu after the gallery
	$j(tabMenu).insertAfter('#externalthumbs');
	//copy across the comments section into the news single view div
	$j('#comments-plugin').insertBefore('.news-single-backlink');
	//and off we go to include the tabs with effects
	$j("div.news-single-item > ul").tabs({ fx: { height: 'toggle', opacity: 'toggle' } });


	//apply rounded corner to comments elements
	$j('div.tx-comments-comment-content').corner();
    });

