// UPenn Home Page: Final JS Functions

// init vars
bgStart = 1;
bgEnd = 8;

// setup onload events
window.onload = function() {
	randImage = RandRange( bgStart, bgEnd );
	setInterface(randImage);
}

function RandRange( intFrom, intTo, intSeed ){
	// Make sure that we have integers.
	intFrom = Math.floor( intFrom );
	intTo = Math.floor( intTo );
	 
	// Return the random number.
	return(
		Math.floor(
			intFrom + 
			(
				(intTo - intFrom + 1) * 
				 
				// Seed the random number if a value was passed.
				Math.random( 
					(intSeed != null) ? intSeed : 0 
					)
			))
		);
}

function setInterface(num) {
	currentBg = parseInt(num);
	if(currentBg <= bgStart) {
		previousBg = bgEnd;
	} else {
		previousBg = currentBg - 1;
	}
	if(currentBg >= bgEnd) {
		nextBg = bgStart;
	} else {
		nextBg = currentBg + 1;
	}
    //set bg
	//document.getElementById("mainContent").style.backgroundImage = "url(/images/"+currentBg+".jpg)";
	document.getElementById("middle_container").style.backgroundImage = "url(images/random/"+currentBg+".jpg)";
	
	//set interface elements
	//document.getElementById("previous").href = "javascript:setInterface("+previousBg+");";
	//document.getElementById("next").href = "javascript:setInterface("+nextBg+");";
	//document.getElementById("aboutImgLink").href = "about/photos.php#img_"+currentBg;
}
