var $paths = new Array(4);
/* $id =>  $path */
$paths['photo1'] = 'images/homepage/home_wide_1_low.jpg';
$paths['photo2'] = 'images/homepage/home_wide_2_low.jpg';
$paths['photo3'] = 'images/homepage/home_wide_3_low.jpg';
$paths['photo4'] = 'images/homepage/home_wide_4_low.jpg';

var $buttons = new Array(4);
/* $btton_id =>  $photo_id */
$buttons['photo1']=['button1'];
$buttons['photo2']=['button2'];
$buttons['photo3']=['button3'];
$buttons['photo4']=['button4'];

var $captions = new Array(4);
/* $id =>  $caption */
$captions['photo1'] = "Meredith was HumRRO's first president";
$captions['photo2'] = 'HumRRO fill contracts for ....';
$captions['photo3'] = 'HumRRO has staff all over the country.';
$captions['photo4'] = "HumRRO's headquarters is located in Alexandria Va.";


var $stopRotation= 0;
function Show(id, stop){
    $stopRotation = stop
    for (var i=0; i<$paths.length; i++)
    {
      var check = 'photo'+String(i+1);  
//      alert(' check \''+check + '\' - id \''+id+'\''); 
      
      if(document.getElementById(check)) {
        document.getElementById(check).style.display = 'none';
        document.getElementById($buttons[check]).className = '';
      }
            
      if (check==id){
          
        if(document.getElementById(check)) {
            changeOpac(0, check );
            document.getElementById(check).style.display = '';
            opacity(check, 0, 100 , 1000);
        }
        if(document.getElementById($buttons[check])) {
            document.getElementById($buttons[check]).className = 'activeButton';
        }
      }        
    }
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	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 + ")";
}

var rotateId=1;
function rotate(){
    if($stopRotation)
    return;
    
    Show('photo'+rotateId, 0);
    rotateId = rotateId+1;
    if(rotateId>$paths.length)
        rotateId =1;
    $to = setTimeout('rotate();', 7000);    //3000);

}