/**
 * IDEALIAGroup srl
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.idealiagroup.com/magento-ext-license.html
 *
 * @category   IG
 * @package    IG_MageSpecialist
 * @copyright  Copyright (c) 2010-2011 IDEALIAGroup srl (http://www.idealiagroup.com)
 * @license    http://www.idealiagroup.com/magento-ext-license.html
 */

// Tabs on product's page
jQuery(function() {
	var $previousTab;

	var $productEssential = jQuery('.product-collateral');
	var $tabTitles = jQuery('.product-collateral h2');

	var $tabs = jQuery('<div></div>').addClass('product-collateral-tabs');

	$productEssential.before($tabs);

	var c = 0;
	jQuery('div.box-collateral', $productEssential).each(function() {
		var $me = jQuery(this);
		var $tabTitle = jQuery('h2', $me);

		$me.css('display', 'none');

		$tabs.append($tabTitle);

		$tabTitle.click(function() {
			if($previousTab) {
				$previousTab.fadeOut();
				$me.fadeIn();
			} else {
				$me.css('display', 'block');
			}

			$tabTitles.removeClass('active');
			$tabTitle.addClass('active');
			$previousTab = $me;
		});
		// Default first
		if((c++) == 0)
			$tabTitle.click();
	});
	// Sidebar blocks
	/*var $blocks = jQuery('.sidebar .block');
	 for (var i=0; i<$blocks.length; i++)
	 {
	 var $block = jQuery($blocks[i]);
	 $block.addClass(i % 2 ? 'even' : 'odd');
	 }*/
});

// Hide empty p tags
jQuery(function () {
	jQuery('p').each(function () {
		var $me = jQuery(this);
		
		if (!$me.html())
			$me.css('display', 'none');
	});
});

// Call to action
jQuery(function () {
	jQuery('.call-to-action').each(function () {
		var $me = jQuery(this);
		
		$me.html('<span><span>'+$me.html()+'</span></span>');
	});
});

