﻿//************************************************************************************* 
// File     :   csor_select_pdf.js
// Requires :   mf_domLibrary_0.1.js, prototype.js
// Author   :   Kyle Weems (ksw)
// Origin   :   mindfly.com
// Created  :   June 30, 2008
// Modified :   July 01, 2008
// Purpose  :   Redirects user to a PDF page if they select it in a select menu.
//*************************************************************************************

//window.location = "http://www.mindfly.com/";

// This function looks for every element marked .selectDoc (which should only be select lists of files),
// and adds an event listener to when the lists change value
function observeSelectPdfLists()
{
    // Get a list of all elements marked .selectDoc.
    var selectList = $$('.selectDoc');
    // If there's at least one...
    if(selectList.length > 0)
    {
        // set i variable for use later
        var i;
        // loop through all the elements found
        for(i=0;i<selectList.length;i++)
        {
            // Add an event observer to the list that triggers when it's value changes.
            selectList[i].observe('change', function(event){navigateToFile(this.value);});
        }
    }
} // end of function selectPDF()


// Opens a window to the file listed
function navigateToFile(file)
{
    // If file has a value
    if(file != "")
    {
        // Open a window showing the file
        window.open(file);
    }
} // end of function navigateToFile()

addLoadEvent(observeSelectPdfLists);
