﻿

/*  Section animation */


        function growSectionContent()
        {
            var el = document.getElementById('mainArticle');
            var frame = document.getElementById('articleFrame');
            var content = document.getElementById('sectionContent');
            
            if (el != null && content != null && frame != null)
            {            
                el.style.top = '-228px';              
                el.style.height = '478px';
                
                frame.style.top = '0';
                
                content.style.height = '426px';   
            }
            
        }
        
        function shrinkSectionContent()
        {
            var el = document.getElementById('mainArticle');
            var frame = document.getElementById('articleFrame');            
            var content = document.getElementById('sectionContent');
            
            if (el != null && content != null && frame != null)
            {            
                el.style.height = '';
                el.style.top = '';  
                frame.style.top = '';
                content.style.height = '';              
            }
        }
        
        
        
        
     


    function showActiveSubsectionLink(el)
    {
        var tags = el.parentNode.parentNode.getElementsByTagName("a");

        for (var i = 0; i < tags.length; i++)
        {
            if (tags[i].style.fontWeight == 'bold')
                tags[i].style.fontWeight = 'normal';
        }
        
        setSubsectionLinkActive(el);
        
    }
    
    function setSubsectionLinkActive(el)
    {
        el.style.fontWeight = 'bold';
    }
    
    function setFirstSubsectionLinkActive(elId)
    {
        var el = document.getElementById(elId);
        
        var tags = el.getElementsByTagName("a");
        
        if (0 < tags.length)
            setSubsectionLinkActive(tags[0]);
    }
    
    
    
    function adjustContentSize()
    {   
        adjustContentSizeToAtLeast(250);
    }
    
    function adjustContentSizeToAtLeast(minFrameHeight)
    {   
        var mainArticle = document.getElementById('mainArticle');
        var subArticle = document.getElementById('subArticle');  
              
        var articleContent = document.getElementById('articleContent');
        var sectionContent = document.getElementById('sectionContent');
        
        var extraDetail = document.getElementById('extraDetail');
        var subArticleContent = document.getElementById('subArticleContent');

        if (articleContent == null) return;

        // Main frame resizing
        var backgroundHeight = articleContent.scrollHeight + 90;
        
        if (backgroundHeight < minFrameHeight ) 
        {
            backgroundHeight = minFrameHeight;
        }

        mainArticle.style.height = backgroundHeight + 'px';
        extraDetail.style.height = backgroundHeight + 'px';     
                
        
        var minContentHeight = minFrameHeight - 60;
        
        var articleHeight = articleContent.scrollHeight + 30;
      
        if (articleHeight < minContentHeight) articleHeight = minContentHeight;
      
        // Content frame resizing
        sectionContent.style.height = articleHeight + 'px';
        
        if (subArticleContent && 180 < subArticleContent.scrollHeight)
        {
            subArticle.style.height = subArticleContent.scrollHeight + 20 + 'px';

//                mainArticle.style.height = subArticleContent.scrollHeight + 80 + 'px';
//                extraDetail.style.height = subArticleContent.scrollHeight + 80 + 'px';    
//            
        }
        
    }   
    
