// JavaScript Document

//*****************************************************************************************************************************************
// This function checks to make sure that all sections are enabled or disabled correctly
//*****************************************************************************************************************************************
function setFunctionality(){

}

//*****************************************************************************************************************************************
// This function is used ro reset all those sections that follow the most recently selected one
//*****************************************************************************************************************************************
function resetValues(val) { //v3.0

	if ( val < 2 ){
			document.all.ColorTD.style.backgroundColor='#E8E5EC';
	}
	if ( val < 1 ){ // Nothing has been selected on 
			document.all.ColorTD.style.backgroundColor='#FFFFFF';
	}

	setFunctionality();

}
//*****************************************************************************************************************************************
// This function checks to make sure that all selections have been made before submitting
//*****************************************************************************************************************************************
function checkComplete(){
	found_it = getSelectedValue('matColor');
	
	var quantity41 = document.auBuilderForm.qty41.value;
	var quantity42 = document.auBuilderForm.qty42.value;
	var totalMats = 0;
	
	for ( i = 71; i < 77; i++ ){		
		qtyElement = parseInt(eval("document.auBuilderForm.qty" + i + ".value"));
		if ( qtyElement != "" && !isNaN(qtyElement) ){
			totalMats += qtyElement;
		}
	}
	for ( i = 101; i < 111; i++ ){		
		qtyElement = parseInt(eval("document.auBuilderForm.qty" + i + ".value"));
		if ( qtyElement != "" && !isNaN(qtyElement) ){
			totalMats += qtyElement;
		}
	}
	for ( i = 11; i < 61; i++ ){		
		qtyElement = parseInt(eval("document.auBuilderForm.qty10" + i + ".value"));
		if ( qtyElement != "" && !isNaN(qtyElement) ){
			totalMats += qtyElement;
		}
	}
	
	if ( (quantity41 != "" || quantity42 != "") && (found_it  != 'II' && found_it != 'M') ){
			alert("Mats #41 and #42 are only available in Ivory(Ivory/Ivory) or Medallion(Black/Black).");
	}
	else if ( found_it == "II" && totalMats > 0){
			alert("Ivory(Ivory/Ivory) is only available for Mats #41 or #42.");
	}	
	else if ( found_it != "notSelected" ){
		 document.auBuilderForm.submit(); 
	}	
	else{
		alert("Please Finish all necessary selections before submitting album to basket.");
	}

}
