/****************************************
*
Bosch Lightbox JS: Divisions OCS/CMS/ASA
Kittelberger media | 2010-12 dsp
*

e1: product compare: fadein/fadeout products
*****************************************/

$(document).ready (function () {
	
	// START e1
		function removeCol (whichCol, whichTable) {
			prodCount = parseInt ($('.lightbox.prodCompare table.pdTable.' +whichTable+' tr:first').find('th').length);
			if (prodCount > 2)  {
				$('.lightbox.prodCompare table.pdTable.' +whichTable+' .'+whichCol).remove();
				$('.lightbox.prodCompare table.pdTable.' +whichTable+' tr th').removeClass ('odd');
				$('.lightbox.prodCompare table.pdTable.' +whichTable+' tr td').removeClass ('odd');	
				$('.lightbox.prodCompare table.pdTable.' +whichTable+' tr').find('th:odd').addClass ('odd');
				$('.lightbox.prodCompare table.pdTable.' +whichTable+' tr').find('td:odd').addClass ('odd');
			};				
		};
		
		$('.fadeOut').bind ('click', function () {
			elmClass = $(this).closest('th').attr('class');
			tableClass = $(this).closest('table').attr('class');
			all_elmClass = elmClass.split(' ');
			all_tableClass = tableClass.split(' ');
			
			for (i = 0; i < all_elmClass.length; i++) {
				if(all_elmClass[i].indexOf('col_') != -1) {
					spec_elmClass = all_elmClass[i];
				};
			};
			for (i = 0; i < all_tableClass.length; i++) {
				if(all_tableClass[i].indexOf('tbl_') != -1) {
					spec_tableClass = all_tableClass[i];
				};
			};
			
			removeCol (spec_elmClass, spec_tableClass);
			
			
		});
	// END e1
	
	// START e2 
		$('a.toggleHead').bind ('click', function () {
			$(this).toggleClass('down');
			$(this).next('table.pdTable').toggleClass('hide');
		});

});
