/*
* Author: Bryan Black 
* Created: 25 September 2008 
* Notes: This is a class that will enable us to select from an aggerate of pictures and random. 
*
*
*
*/
var randomPic = Class.create({
	
	initialize: function(aryPics,imgID,textDivID,settings){
		//set up all our variables 
		this.pics = aryPics; 
		this.settings = settings; 
		this.imgID = imgID; 
		this.numPics = this.pics.length
		this.randomNum = Math.floor((Math.random() * this.numPics)); 
		this.textDivID = textDivID; 
		
	},
	
	setRandomPic: function(){
		//get the image element 
		ranImage = document.getElementById(this.imgID); 
		//Settings go in this order Width then Height 
		if(this.settings.length > 0){
			ranImage.style.width = this.settings[0] + 'px'; 
			ranImage.style.height = this.settings[1] + 'px'; 
		}
		//now we will set the image src to the src of one of the images in our array 
		ranImage.src = this.pics[this.randomNum]; 
		
		//after setting the random pic it will call the random text function this isn't to modular because most of this stuff had to be hard 
		//coded for simplicity and time sakes. 
		this.setText(this.randomNum);
	},
	
	setText: function(num){
		//Ok so this function must correspond to the pictures so If we get the pictures wrong then we get the text wrong so You got to make sure this is
		//Aligned correctly 
		
		switch(num){
			//Depending on the random num we will put the right text in the div :) 
			case 0: 
				textBox = document.getElementById(this.textDivID); 
				textBox.innerHTML = "<span><strong>Cadet David Krenik</strong><br />Hometown:  Bristol, TN<br />Major:  History<br />Interests:  Track and ROTC</span>"; 
				break; 
				
			case 1: 
				textBox = document.getElementById(this.textDivID); 
				textBox.innerHTML = "<span><strong>Cadet Jennifer Steele</strong><br />Hometown:  Collierville, TN<br />Major:  Economics<br />Interests:  Reading and working out</span>";
				break; 
			
			case 2: 
				textBox = document.getElementById(this.textDivID); 
				textBox.innerHTML = "<span><strong>Cadet Jarrod Hall</strong><br />Hometown:  Blountville, TN<br />Major:  Nursing</span>";
				break;
			
			case 3: 
				textBox = document.getElementById(this.textDivID); 
				textBox.innerHTML = "<span><strong>Cadet Andrew Ditmer</strong><br />Hometown:  Jacksboro, TN<br />Major:  Criminal Justice<br />Interests:  Computers and swimming</span>"; 
				break;
			
			case 4: 
				textBox = document.getElementById(this.textDivID); 
				textBox.innerHTML = "<span><strong>Cadet Brett Honeycutt</strong><br />Hometown:  Elizabethton, TN<br />Major:  Psychology<br />Interests:  Deer hunting and having fun</span>"; 
				break;
			
			case 5: 
				textBox = document.getElementById(this.textDivID);
				textBox.innerHTML = "<span><strong>Cadet Calvin Yancey</strong><br />Hometown:  Oxford, NC<br />Major:  Criminal Justice<br />Interests:  Shooting, Xbox 360 Live</span>"; 
				break;
		}//End of Case Statement 
	}
	
	
});

//First off we will need to set up our array of pics to send to our construct of our class 
function loadRandomPic() {
images = new Array( 
	'http://151.141.90.97/images/cadetprofiles/Cadet David Krenik.jpg',
	'http://151.141.90.97/images/cadetprofiles/CO 1SG Cadet 1SG Jennifer Steele.jpg',
	'http://151.141.90.97/images/cadetprofiles/BN S2 Cadet CPT Jarrod Hall.jpg',
	'http://151.141.90.97/images/cadetprofiles/Cadet Andrew Ditmer.jpg',
	'http://151.141.90.97/images/cadetprofiles/Cadet Brett Honeycutt.jpg',
	'http://151.141.90.97/images/cadetprofiles/Cadet Calvin Yancey.jpg'
	
);

settings = new Array (150,175);


ranPic = new randomPic(images,'randCadet','cadetText',settings);
ranPic.setRandomPic(); 
}

Event.observe(window, 'load', loadRandomPic);
