
// JavaScript Document

/*
INIT VARS
*/
var curIndexNum = "button1";
var preloadFlag = false;
var btnAmt = 0;
/*
INIT IMAGE
Initializes image
*/
function newImage( imgSrc ){
 	var imgName = new Image();
 	imgName.src = imgSrc;
 	return imgName;
}

/*
CHANGE IMAGE - ROLLOVER AND ROLLOUT
This function will update the image currently being displayed
for a button.  Works for rollover and rollout.
*/
function change(imgName, imgLocation, cInd){
	// Strip apart the string and get just the first part of the image name.
	var dIndex = imgLocation.lastIndexOf("_");
	var pt1 = imgLocation.substring(0,dIndex-1);
	// Now reset all images back to their NORM state.
	for(var i=0;i<btnAmt;i++){
		if('button'+(i+1) != curIndexNum){
			document['button'+(i+1)].src = pt1+(i+1)+'_NORM.jpg' 
		}
	}

	// Now update the current rolled over image
	if(curIndexNum != cInd){
 		document[imgName].src = imgLocation ;
	}
}





/*
CHANGE IMAGE - ROLLOVER AND ROLLOUT
This function will update the image currently being displayed
for a button.  Works for rollover and rollout.
*/
function changeport(imgName, imgLocation, cInd){
	//alert("hello world");
	// Strip apart the string and get just the first part of the image name.
	/*var dIndex = imgLocation.lastIndexOf("_");
	var pt1 = imgLocation.substring(0,dIndex-1);
	// Now reset all images back to their NORM state.
	for(var i=0;i<btnAmt;i++){
		if('button'+(i+1) != curIndexNum){
			document['button'+(i+1)].src = pt1+(i+1)+'_NORM.jpg' 
		}
	}*/

	// Now update the current rolled over image
	//if(curIndexNum != cInd){
 		document[imgName].src = imgLocation ;
	//}
}

/*
LOAD BIG PICTURE
This function will load in the large project sample image
at the top of the page.
...example of what's being passed in ['picholder','images/crescor_sample_1.jpg','button1']
*/
/*function loadBigPic(imgName, imgLocation, whichDiv){
 	document[imgName].src = imgLocation ;
	selectCur(imgName, imgLocation,whichDiv);
	curIndexNum = whichDiv
}*/

/*
SET SELECTED
This function is called when the page first loads.  It
makes the first portfolio sample selected.  So it updates
the div style.
*/
function setSelected(imgLocation,whichDiv,amt){
	//alert("imgLocation: "+imgLocation+", whichDiv: "+whichDiv);
	// save the amount of samples to create...
	btnAmt = amt;
	//alert("imgLocation: "+imgLocation+", whichDiv: "+whichDiv);
	// Now update the div's style to show the background as selected
	//document.getElementById(whichDiv).className = 'selectedbtn';	
	document[whichDiv].src = imgLocation ;
	//curIndexNum = whichDiv;
	
}

/*
SELECT CURRENT
This function will update the "selected" state around the
current button.  First it will clear any other "selected" buttons 
and then make our current selection.
*/
function selectCur(imgName, imgLocation, whichDiv){
	// Reset all current selections
	/*for(var i=0;i<btnAmt;i++){
		document.getElementById('button'+(i+1)).className = 'notselectedbtn';
	}*/
	// Now update the div's style to show the background as selected
	//document.getElementById(whichDiv).className = 'selectedbtn';	
	curIndexNum = whichDiv;
}

