// JavaScript Document


<!--

var current_latest = 1;
var rotate_active = true;
var rotateTimeout;
var rotate_timer = 5000;
var latest_links = new Array();

function rotate_latest() {
if(rotate_active) {
clearTimeout(rotateTimeout);
if(current_latest<3) {
new_latest=current_latest+1;
} else {
new_latest=1;
}
can_fade=true;
switch_latest(new_latest);
rotateTimeout=setTimeout('rotate_latest()',rotate_timer);
}
}

latest_image1 = new Image();
latest_image1.src = "http://www.fitbusinessman.com/public/images/rippedtorso274x226.jpg";
latest_links[1] = "http://www.fitbusinessman.com/members/84.cfm";
latest_image2 = new Image();
latest_image2.src = "http://www.fitbusinessman.com/public/images/angerworkouts274x226.jpg";
latest_links[2] = "http://www.fitbusinessman.com/members/83.cfm";
latest_image3 = new Image();
latest_image3.src = "http://www.fitbusinessman.com/public/images/boxnewsletter274x226.jpg";
latest_links[3] = "http://www.fitbusinessman.com/public/91.cfm";


var current_latest_link=latest_links[1];

var imageFader;
var can_fade=true;

function switch_latest(id)
{
    document.getElementById('latest'+id).style.cursor='pointer';
    if(id!=current_latest)
    {
        document.getElementById('latest'+id).className='active_latest';
        document.getElementById('latest'+current_latest).className='inactive_latest';
        document.getElementById('latest_text'+id).style.display='';
        document.getElementById('latest_text'+current_latest).style.display='none';
        
        if(!can_fade)
        {
            clearTimeout(imageFader);
            changeOpac(0,'latest_image_'+current_latest);
            changeOpac(100,'latest_image_'+id);
        }
        else
        {
            fadeImages(current_latest,id);
        }
        
        current_latest=id;
        current_latest_link=latest_links[current_latest];
    }

}

function fadeImages(fromid,toid)
{
    opacity('latest_image_'+fromid, 100, 0, 500);
    opacity('latest_image_'+toid, 0, 100, 500);
}

function getLatestArticle()
{
    self.location=current_latest_link;
}

function opacity(id, opacStart, opacEnd, millisec)
{
    //speed for each frame
    var speed = Math.round(millisec / 200);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd)
    {
        for(i = opacStart; i >= opacEnd; i--)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
    else if(opacStart < opacEnd)
    {
        for(i = opacStart; i <= opacEnd; i++)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id)
{
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
//-->
