//09 GUBERNATORIAL HOMEPAGE HIGHLIGHTS


//Variables for each Array *************************************************************
var photo=new Array()
var imagelink=new Array()

photo[1]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/images/highlight-keanbyrne.jpg"
imagelink[1]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/bonus/"

photo[2]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/images/highlight-otr.jpg"
imagelink[2]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/other/otr/"

photo[3]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/images/highlight-radiodebate.jpg"
imagelink[3]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/debates/radio/"

photo[4]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/images/highlight-voiceofthevoters.jpg"
imagelink[4]="http://www.njn.net/newspublicaffairs/coverage/09governorrace/voiceofthevoters/"






//Current option to start with *************************************************************
currentIndx=1;


//Variables for SlideShow Timer
var delay3 = 0;


//This function calls the SlideShow after a delay *************************************************************
function delaySS() {
	delay3 = setTimeout('runSlideShow()', SlideShowSpeed);
}


//This is for pre-loading the images *************************************************************
imagesPreloaded = new Array()
for (var i = 1; i < photo.length ; i++) 
{
	imagesPreloaded[i] = new Image(295,112)
imagesPreloaded[i].src=photo[i]
}


//This function loads up the first array option *************************************************************
function showOne() {
document.getElementById('photo').src=imagesPreloaded[currentIndx].src
document.getElementById('imagelink').href=imagelink[currentIndx];
}


//This tells the page to call this function when loaded *************************************************************
window.onload=function(){
showOne();
delaySS();
}


//This function is for the automatic slideshow (1000 = 1 second) *************************************************************


//Fade function *************************************************************

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 4000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

function runSlideShow(){

document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');

if (currentIndx<imagesPreloaded.length-1){
currentIndx=currentIndx+1
}
else {
 currentIndx=1
}	

document.getElementById('photos').style.backgroundImage = "url(" + imagesPreloaded[currentIndx].src + ")";
 
    var speed = Math.round(300 / 100); 
    var timer = 0;
	for(var i = 100; i >= 0; i--) { 
        setTimeout("changeOpac(" + i + ",'" + 'photo' + "')",(timer * speed)); 
        timer++; } 

document.getElementById('imagelink').href=imagelink[currentIndx];
delay3 = setTimeout('runSlideShow()', SlideShowSpeed);
}





//change the opacity for different browsers ********************************************************
function changeOpac(opacity, id) { 
	var object = document.getElementById(id).style; 
    object.opacity = (opacity / 101); 
    object.MozOpacity = (opacity / 101); 
    object.KhtmlOpacity = (opacity / 101); 
    object.filter = "alpha(opacity=" + opacity + ")";
} 