

function mailLink_click(mailLink) {
// function to create email link when a mail link is clicked (protection from spambots)
	mailLink.href = "mailto:" + mailLink.name + "@" + mailLink.rel;
}

// Set some variables
var newNum = 1; // Current number that functions are on
var oldNum = 1; // Old number that functions were on
var time = 3000; // Number of milliseconds to show each project
var timerID; // Variable to create the time delay function
var paused = 0; // Checks to see if the rotation should be pause
var numLimit; // Set the number of variables.
var newFeaturedNum = 1; // Current number that featured functions are on
var oldFeaturedNum = 1; // Old number that featured functions were on
var featuredLimit;

// Starts, and only starts, the timer process.
function start()
{ timerID = window.setInterval("change('next')", time); }

// Replacement function then updates the counter
function change(dir)
{
    oldNum = newNum;

    if ( dir == 'prev' )
    { newNum--; }
    else
    { newNum++; }

    resetnewNum();

    // Check to see if there is an image to replace.
    if ( document.getElementById('big_image') )
    {
        var imageSearch = document.getElementById('big_image');

        // Check to see if there is a replacement image.
        if ( document.getElementById('rcolumn_text_box1_image_' + newNum) )
        {
            var imageReplace = document.getElementById('rcolumn_text_box1_image_' + newNum);

            // If so, replace it.
            imageSearch.src = imageReplace.innerHTML;
        }
    }
}

// Reset the counter if it equals "numLimit" or set it to numLimit - 1 if going backwards. Otherwise let it pass through.
function resetnewNum()
{
    if ( newNum > numLimit )
    { newNum = 1; }

    if ( newNum == 0 )
    { newNum = numLimit; }
}

function change_featured(dir)
{
    oldFeaturedNum = newFeaturedNum;

    if ( dir == 'prev' )
    { newFeaturedNum--; }
    else
    { newFeaturedNum++; }

    resetFeatuedNum();

    var divOld = document.getElementById('featured_' + oldFeaturedNum);
    var divNew = document.getElementById('featured_' + newFeaturedNum);
    if ( divOld && divNew )
    {
        divOld.style.display = 'none';
        divNew.style.display = 'block';
    }
}

// Reset the counter if it equals "featuredLimit" or set it to featuredLimit - 1 if going backwards. Otherwise let it pass through.
function resetFeatuedNum()
{
    if ( newFeaturedNum > featuredLimit )
    { newFeaturedNum = 1; }

    if ( newFeaturedNum == 0 )
    { newFeaturedNum = featuredLimit; }
}

// Function to skip to the next div.
function next()
{
    change_featured('next');
}

function prev()
{
    change_featured('prev');
}

function pause()
{
    if ( paused === 0 )
    {
        window.clearTimeout(timerID);
        window.clearInterval(timerID);
        paused = 1;
        document.getElementById('pausebutton').innerHTML = 'Play';
    }
    else
    {
        paused = 0;
        document.getElementById('pausebutton').innerHTML = 'Pause';
        change('next');
        start();
    }
}
