﻿// Set slideShowSpeed (milliseconds)
var speed = 5000;
var homePicsTotal = 41;
var j=0;

runStatus = new Object();
runStatus.firstRun = "yes";


//preload the images
var preLoad = new Array()
for (i = 0; i < (homePicsTotal -1); i++){
   preLoad[i] = new Image();
   preLoad[i].src = "images/pic_home_" + i + ".jpg";
}


//fade out our first image, intervaled function
function slideShow(homePicsTotal) {
	
	if (runStatus.firstRun == "yes") {
		runStatus.firstRun = "no";
		j++;
	}
		
	thisNode = document.getElementById("picBig");
	thisNode.src = "images/pic_home_" + j + ".jpg";
   
	j++;
   
   	if (j == (homePicsTotal+1)) {
		j=0;
	}
	
	
}

var meInterval = setInterval('slideShow(homePicsTotal)', speed);
	

function stopSlideshow() {
	delete runStatus;
	delete meInterval;
}	
	
	
function randomHomeImage () {

	//Change this variable when more homepage images are added
	//Start the first one with 0, not 1 and count 0 in your totals
	var homePicsTotal = 42;
	
	var ranNum= Math.floor(Math.random()*homePicsTotal);
	
	thisNode = document.getElementById("picBig");
	//thisNode.src = "images/pic_home_" + ranNum  + ".jpg";
	
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	
	//alert(b_version);
	
	//if ((browser=="Microsoft Internet Explorer") && (b_version==6)){
	
	if(typeof document.body.style.maxHeight == "undefined"){
		
		//alert("IE 6");
	
		//adjust our layout for STUPID IE!!!!!!!!
		news = document.getElementById("contentNews");
	
		offset = news.offsetHeight;
	
		//alert("test " + offset);
		
		raves = document.getElementById("contentRaves");
		raves.style.marginTop = -(offset);
		
		featured = document.getElementById("featuredPhotos");
		featured.style.marginTop = -(offset);
	
	}
		
}

function randomImageSet () {

	//Change this variable when more homepage images are added
	//Start the first one with 0, not 1 and count 0 in your totals
	var homePicsTotal = 3;

	var ranNum= Math.floor(Math.random()*homePicsTotal);
	
	//array for top image
	var topLeftArray = new Array();
	topLeftArray[0] = "images/contact_food_topLeft.jpg";
	topLeftArray[1] = "images/contact_event_topLeft.jpg";
	topLeftArray[2] = "images/contact_music_topLeft.jpg";
	
	//array for bottom left image
	var bottomLeftArray = new Array();
	bottomLeftArray[0] = "images/contact_food_botLeft.jpg";
	bottomLeftArray[1] = "images/contact_event_botLeft.jpg";
	bottomLeftArray[2] = "images/contact_music_botLeft.jpg";
	
	//array for bottom right image
	var bottomRightArray = new Array();
	bottomRightArray[0] = "images/contact_food_botRight.jpg";
	bottomRightArray[1] = "images/contact_event_botRight.jpg";
	bottomRightArray[2] = "images/contact_music_botRight.jpg";
	
	var topLeftImage = document.getElementById("picSmallContainer");
	var bottomLeftImage = document.getElementById("picBigContainer");
	var bottomRightImage = document.getElementById("picBigContainerTwo");
	
	topLeftImage.style.background = "url(" + topLeftArray[ranNum]  + ") no-repeat top left";
	bottomLeftImage.style.background = "url(" + bottomLeftArray[ranNum]  + ") no-repeat top left";
	bottomRightImage.style.background = "url(" + bottomRightArray[ranNum]  + ") no-repeat top left";

}
