

/*
jQuery(function(){
	$('.akkordeonContent').hide();
	
	$('.akkordeonTitle').css({'cursor':'pointer'});
	
	$('.akkordeonTitle').click(function( e ){
		
		var element = $(this);
		var next_element = $(this).next('.akkordeonContent');
		
		if( !element.hasClass('active') ){
			
			element.addClass('active');
			
			$('.akkordeonTitle').not(element).removeClass('active');
			$('.akkordeonContent').not(next_element).slideUp( 500 );
			next_element.slideToggle( 500, function(){
				element.removeClass('active');
			});
			element.toggleClass('active');
			
		}
		
		e.preventDefault();
	});


});
*/


jQuery(function(){
	
		$('.akkordeonTitle').css({'cursor':'pointer'});
		$('.akkordeonContent').hide();
		$('.akkordeonTitle').click( function(e) {
			var trig = $(this);
			if ( !trig.hasClass('active') ) {
				trig.addClass('active');
				trig.next('.akkordeonContent').slideToggle('slow');
			} else {
				trig.next('.akkordeonContent').slideToggle('slow');
				trig.removeClass('active');
			};
			e.preventDefault();
		});

		$('.product .downloads').click(function(){
			var array = String( $(this).attr('id') ).split('_');
			var id = array.pop();
			
			var width = 670;
			
			$.ajax({
				type : "POST",
				async: false,
				url : "/mahout_cms/plugins/catalog/ajax_blocks.php",
				data : "mode=renderProduktDownloads&product_id=" + id,
				success : function( msg ){
					makeLightBox( msg, width );
					
				}
			});
		});
		
		
		function makeLightBox( msg, width )
		{
			if( $('#lightbox_bg').length > 0 ){
				$('#lightbox_bg').remove();
				$('#lightbox').remove();
			}
			
			$.ajax({
				type : "POST",
				async: false,
				url : "/mahout_cms/plugins/catalog/ajax_blocks.php",
				data : "mode=renderLightbox",
				success : function( lightbox ){
					
					$('body').prepend( lightbox );
					
					$('#lightbox_bg').css( 'opacity', 0.5 );
					$('#lightbox').fadeIn("slow");			
					$('#lightbox_content').html( msg );
					
					var half_width = width / 2;
					var half_height = $('#lightbox').height() / 2;
					
					$('#lightbox').css({
						'width': width,
						'left': '50%',
						'top': '40%',
						'margin-left': '-' + half_width + 'px',
						'margin-top': '-' + half_height + 'px'
					});					
				}
			});
		}
});
