$(document).ready(function(){
    $('.node .content .extended').hide();
    $('.node .content h3 a, .node .content h2 a').click(function(){
	  	var a = $(this).parents('h3, h2').nextAll('.extended');
    	$(a[0]).toggle();
    });
	
	
     function showTabContent(elem, tab_type)
    {

		$('.close').html('Podrobnosti &raquo;');
		$('.close').unbind();
		$('.close').parent().find('img').css('bottom','1px');
		$('.close').css('bottom','1px');
		
		
        $('.close').attr('class','more');
        $('.more').click(function(){
            showTabContent(this, tab_type);
        });
		
		
		//nastavenia buttonu
        $(elem).html('X Zavrieť');
        $(elem).attr('class','close');
        
		$(elem).unbind();
        $(elem).click(function(){
            hideTabContent(elem, tab_type);
        });

		$(elem).parent().find('img').css('bottom','-1px');
		$(elem).css('bottom','-1px');
        
        
        //zobrazeni obsahu
        $('.content-'+tab_type+'-active').hide();
        $('.content-'+tab_type).attr('class','content-'+tab_type);
        $('#'+$(elem).parent().attr('id')+'-cnt').attr('class','content-'+tab_type+' content-'+tab_type+'-active');
        $('.content-'+tab_type+'-active').fadeIn(300); 
        
    }
    
    
    function hideTabContent(elem, tab_type)
    {

		$(elem).html('Podrobnosti &raquo;');
        $(elem).attr('class','more');
        $(elem).unbind();
        $(elem).click(function(){
            showTabContent(elem, tab_type);
        });
		
		$(elem).parent().find('img').css('bottom','1px');
		$(elem).css('bottom','1px');
		
        //skrytie obsahu

        $('#'+$(elem).parent().attr('id')+'-cnt').attr('class','content-'+tab_type);
        $('#'+$(elem).parent().attr('id')+'-cnt').hide();

    }
    
    
    
    //navod tabs
    $('.tab-how .more').click(function(){
        
        showTabContent(this,'how');

    })
	
	 //navod tabs
    $('.tab-work .more').click(function(){
        
        showTabContent(this,'work');

    })
    
	
});

