﻿//************************************************************************************* 
// File     :   aram_article_photos.js
// Requires :   prototype.js
// Author   :   Kyle Weems (ksw)
// Origin   :   mindfly.com
// Created  :   August 6, 2007
// Modified :   August 6, 2007
// Purpose  :   Assists in formatting the apperance and layout of photos (and citations)
//              in an article.       
//*************************************************************************************

// Formats the photoLeft and photoRight divs used in the article to the width of the
// image inside them (in the process forcing the cite to same width).
function formatPhotoDivsOnLoad()
{

    var divList = document.getElementsByClassName('photoRight')
    {
        if(divList.length)
        {
            for(i=0;i<divList.length;i++)
            {
                var divImg      = divList[i].getElementsBySelector('img');
                var divWidth    = divImg[0].offsetWidth + 6;
                divList[i].style.width = divWidth + 'px';
            }
        }
    }
    
    var divList2 = document.getElementsByClassName('photoLeft')
    {
        if(divList2.length)
        {
            for(i=0;i<divList2.length;i++)
            {
                var divImg2     = divList2[i].getElementsBySelector('img');
                var divWidth2   = divImg2[0].offsetWidth + 6;
                divList2[i].style.width = divWidth2 + 'px';
            }
        }
    }

    var divList3 = document.getElementsByClassName('photoCenter')
    {
        if(divList3.length)
        {
            for(i=0;i<divList3.length;i++)
            {
                var divImg3     = divList3[i].getElementsBySelector('img');
                var divWidth3   = divImg3[0].offsetWidth + 6;
                divList3[i].style.width = divWidth3 + 'px';
            }
        }
    }
    
} // end of function formatPhotoDivsOnLoad()

addLoadEvent(formatPhotoDivsOnLoad);