$(document).ready(function() {

		infoBlocks = new Array();
		
		infoBlocksCounter = -1;
		

		elementCounter = -1;
		
		$('#container .ce_text').children().each(function(i) {
			
			
			var domEl = $(this).get(0);
			
			if (domEl.tagName == 'H1'){
				
				if (infoBlocksCounter > -1){
					infoBlocks[infoBlocksCounter] = tempBlock;
				}
				
				infoBlocksCounter++;
				
				elementCounter = -1;
				tempBlock = new Array();
				
				

			}else{
				if (infoBlocksCounter > -1){
					
					elementCounter++;
					tempBlock[elementCounter] = $(this);
					
					$(this).hide(0);
					
				}
			}
	
		});
		
		
		if (infoBlocksCounter > -1){
			infoBlocks[infoBlocksCounter] = tempBlock;
		}
		
		//showTab(0);
		
		$(document).find('h1').each(function(i) {
			
			if ($(this).hasClass('open')){
				showTab(i);
			}
			
			$(this).click(function() {
				
				showTab(i);
				
			});
			
		});
	
	
});


function showTab(i){
	
	$(document).find('h1').each(function(hi) {
		
		if (i == hi){
			$(this).addClass('active');
		}else{
			$(this).removeClass('active');
		}
		
	});
	
	for (j = 0; j < infoBlocks.length; j++){
		
		tempBlock = infoBlocks[j];
		
		if (i == j){
			for (y = 0; y < tempBlock.length; y++){
				tempBlock[y].slideDown(500);
			}
		}else{
			for (y = 0; y < tempBlock.length; y++){
				tempBlock[y].slideUp(500);
			}
		}
		
	}
	
}
