(function($){
	
	$.fn.nameItems = function( options ){
	
		var conf = { htmlEl : 'ul > li' }
		if ( options ) $.extend( conf, options );
		
		var el = this;
		var getID = el.attr('id');
		var idCount = 0;
		var htmlEl = conf.htmlEl;
		
		el.find('> ' + htmlEl).each(function() {
			idCount++
			$(this).addClass(getID + '_item_' + idCount);
		});
		
		return this;
	};
})( jQuery );

jQuery(document).ready(function($){
    // Remove unwanted empty paragraphs
    $('p:empty').remove();
	
	// Remove unwatend <br /> inside link
	$('a > br:first-child').remove();
	
	// Define textoverlay element
	$('#hero > div:nth-child(2)').addClass('textoverlay');
	
	// Add "first" and "last" classes to appropriate elements
	$('.navigation li:first-child').addClass('first');
	$('.navigation li:last-child').addClass('last');
	
	// Add unique classes to all children elements
	$('#header').nameItems({ htmlEl : 'div' });
	$('#hero').nameItems({ htmlEl : 'div' })
	$('#feature').nameItems({ htmlEl : 'div' })
	$('#teaserTop').nameItems({ htmlEl : 'div' });
	$('#sidebar_1').nameItems();
	$('#sidebar_2').nameItems();
	$('#teaserBottom').nameItems({ htmlEl : 'div' });
	$('#footerTop').nameItems({ htmlEl : 'div' });
	$('#footerBottom').nameItems({ htmlEl : 'div' });
	
	// Equalize height of products
	var maxHeight = 0;
	$('.productBlock').each(function() {
		if ( $(this).height() > maxHeight ) { 
			maxHeight = $(this).height();
		}
	});
	$('.productBlock').height(maxHeight);
});
