﻿//************************************************************************************* 
// File     :   mf_wcog_resourceicons.js
// Version  :   1.0
// Requires :   mf_domLibrary_0.1.js, prototype.js
// Author   :   Kyle Weems (ksw)
// Origin   :   mindfly.com
// Created  :   April 18, 2008
// Modified :   April 18, 2008
// Purpose  :   Adds a class to the list items in the ulResources list that have anchors
//              inside them with href attribute that point to pdf files.
//*************************************************************************************


// Version History (only for changes of at least 0.0.1 in version number)
// ===============
// Version 1.0   (04/18/2008) - Basic functionality completed (see purpose section in file's top comments).


//=============================================================================================
// function()
//=============================================================================================
// Description of function.
function markPDFListItems()
{
    // if ulResources exists...
    if($$('.ulResources').length)
    {
        // ...Then collect a list of all the list items within it.
        var listItems = $$('.ulResources')[0].select('li')
        // For each item in the list...
        for(i=0;i<listItems.length;i++)
        {    
            // ... Check if there is an anchor within it...
            if(listItems[i].select('a').length)
            {
                // ...Then check the anchor's href attribute for ".pdf". If it has that...
                if(listItems[i].select('a')[0].href.include('.pdf'))
                {
                   // ... Then add a class to the list item.
                   listItems[i].addClassName('liPDF');
                }
                else 
                {
                    listItems[i].addClassName('liNotPDF');
                }
            } 
        }
    }
} // end of markPDFListItems()


addLoadEvent(markPDFListItems);
