// Case object
function dondcase(i){
	this.open = 0;
	this.value = '';
	this.number = i;
}






// Create all X number of cases
function createCases(){
	// Create 26 case objects
	for(i=1; i<= number_of_cases; i++){
		objName = 'case' + i;
		this[objName] = new dondcase(i);
	}
}




// Open the case
function openCase(objCase){
	// If this is the very first choice, then it's the case they want to keep
	if( pickone == 0 ){
		pickone = objCase;

		message.innerHTML = 'This will be your case to hold or to sell: Case # ' + pickone.number;
	}
	// Every other case after the first gets opened.
	else {

		turncount++; // taking a turn

		objCase.open = 1; // Mark as opened
		document.getElementById('value' + objCase.value.key).className = 'valueUsed';

		// Display overlay for 1.5 seconds unless its' an offer then the suspense goes all the way up to 2 seconds!
		overlay.className = 'caseAmount';
		overlay.style.display = '';
		overlay.innerHTML = '<p>$' + addCommas(objCase.value.val) + '</p>';

		if( turncount == turn[round] ){
			setTimeout("completeTurn();", 2000);
		}
		else {
			setTimeout("overlay.innerHTML = ''; overlay.style.display = 'none';", 1000);
		}
	}
}





function caseHTML(){
	for( i=1; i <= number_of_cases; i++){
		newcaseDiv = document.createElement('div');
		casesDiv.appendChild(newcaseDiv);
		newcaseDiv.className = 'case';
		newcaseDiv.innerHTML = '<p>' + i + '</p>';
		newcaseDiv.id = 'case' + i;
	}
}