//SLIDE SHOW stuff *************************************************************
// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 6000;

// Slideshow Function *************************************************************
function runSlideShow(value){

document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');

if (currentIndx==option1) {
	currentIndx=option2;
}
else
if (currentIndx==option2) {
	currentIndx=option3;
}
else
if (currentIndx==option3) {
	if (option4!="none") 
	{currentIndx=option4;}
	else {currentIndx=option1;}
}
else
if (currentIndx==option4) {
	if (option5!="none") 
	{currentIndx=option5;}
	else {currentIndx=option1;}
}
else
if (currentIndx==option5) {
	currentIndx=option1;
}

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('linkto').href=linkto[currentIndx];
document.getElementById('photo').alt=title[currentIndx];
document.getElementById('playstop').href="Javascript:stopSS()";
document.getElementById('psbutton').src="/homepage/images/pickscontrolstop.gif";
document.getElementById('psbutton').alt="stop";
delay3 = setTimeout('runSlideShow()', SlideShowSpeed);
}


//Variables for SlideShow Timer
var delay3 = 0;


//This tells the page to call this function(s) when loaded *************************************************************
window.onload=function(){
changeALL(currentIndx=option1);
delaySS();
refreshPage();
//skyscraper images
changeSkyscraperImage();
//inhouse images
changeInhouseImage();
}


//This function calls the SlideShow after a delay *************************************************************
function delaySS() {
	delay3 = setTimeout('runSlideShow(currentIndx=option1)', SlideShowSpeed);
}


//Refreshes page every 10 minutes (value in milliseconds) *************************************************************
function refreshPage() {
var refreshTime = setTimeout('history.go(0)', 600000);
}


//This is for pre-loading the images *************************************************************
imagesPreloaded = new Array()
for (var i = 0; i < photo.length ; i++) 
{
	imagesPreloaded[i] = new Image(580,297)
imagesPreloaded[i].src=photo[i]
}


//Function that is called by the clickable links to change all parameters *************************************************************
function changeALL(value){

	document.getElementById('photo').src = "/homepage/images/picksimagebg.jpg";
	changeOpac(100, 'photo');
	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('linkto').href=linkto[value]
document.getElementById('photo').alt=title[value];
}


//Function to stop slide show *************************************************************
function stopSS() {
	if(delay3) {
      clearTimeout(delay3);
      timerID  = 0;
  	document.getElementById('playstop').href="Javascript:runSlideShow()";
	document.getElementById('psbutton').src="/homepage/images/pickscontrolplay.gif";
	document.getElementById('psbutton').alt="play";
}}


// Back Function *************************************************************
function controlBack()
{
	
document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');


if (currentIndx==option1) {
	if (option5!="none") 
	{currentIndx=option5;}
	else 
	if (option4!="none")
	{currentIndx=option4;}
	else {currentIndx=option3;}
}
else
if (currentIndx==option2) {
	currentIndx=option1;
}
else
if (currentIndx==option3) {
	currentIndx=option2;
}
else
if (currentIndx==option4) {
	currentIndx=option3;
}
else
if (currentIndx==option5) {
	currentIndx=option4;
}


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('linkto').href=linkto[currentIndx];
document.getElementById('photo').alt=title[currentIndx];
}


// Next Function *************************************************************
function controlNext()
{

document.getElementById('photo').src = imagesPreloaded[currentIndx].src;
changeOpac(100, 'photo');

if (currentIndx==option1) {
	currentIndx=option2;
}
else
if (currentIndx==option2) {
	currentIndx=option3;
}
else
if (currentIndx==option3) {
	if (option4!="none") 
	{currentIndx=option4;}
	else {currentIndx=option1;}
}
else
if (currentIndx==option4) {
	if (option5!="none") 
	{currentIndx=option5;}
	else {currentIndx=option1;}
}
else
if (currentIndx==option5) {
	currentIndx=option1;
}

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('linkto').href=linkto[currentIndx];
document.getElementById('photo').alt=title[currentIndx];
}


//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 + ")";
} 