// JavaScript Document

//*****************************************************************************************************************************************
// This function checks to make sure that all sections are enabled or disabled correctly
//*****************************************************************************************************************************************
function setFunctionality(){
// check below to make sure that name and date imprint attributes are still available

// check below to make sure that studio imprint attributes are still available

	found_it = getSelectedValue('studioImprint');

	if ( found_it != 'none' && found_it == 'Die'){
		enableSection('studioImprintColor',5);
		disableSection('studioImprintText',3);
	}
	if ( found_it != 'none' && found_it != 'Die'){
		enableSection('studioImprintText',3);
		enableSection('studioImprintColor',5);
	}
	if ( found_it == 'none'){
		disableSection('studioImprintText',3);
		disableSection('studioImprintColor',5);
	}

// check below to make sure that name and date imprint attributes are still available

	found_it = getSelectedValue('nameImprint');

	if ( found_it != 'none' ){
		enableSection('nameImprintText',3);
		enableSection('nameImprintColor',5);
	}
	if ( found_it == 'none' ){
		disableSection('nameImprintText',3);
		disableSection('nameImprintColor',5);
	}


// check below to make sure that cover title attributes are still available

	found_it = getSelectedValue('coverTitle');

	if ( found_it != 'none' ){
		enableSection('titleColor',5);
	}
	if ( found_it == 'none' ){
		disableSection('titleColor',5);
	}

}

//*****************************************************************************************************************************************
// This function is used ro reset all those sections that follow the most recently selected one
//*****************************************************************************************************************************************
function resetValues(val) { //v3.0

	if ( val < 8 ){
			document.all.NameImprintColorTD.style.backgroundColor='#E8E5EC';
	}
	if ( val < 7 ){
			document.all.NameImprintTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm2.nameImprintColor[0].checked = true;
			document.all.NameImprintColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 6 ){
			document.all.StudioImprintColorTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm2.nameImprint[0].checked = true;
			document.all.NameImprintTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 5 ){
			document.all.StudioImprintTextTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm2.studioImprintColor[0].checked = true;
			document.all.StudioImprintColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 4 ){
			document.all.StudioImprintTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm2.studioImprintText[0].checked = true;
			document.all.StudioImprintTextTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 3 ){
			document.all.TitleColorTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm2.studioImprint[0].checked = true;
			document.all.StudioImprintTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 2 ){
			document.all.CoverTitleTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm2.titleColor[0].checked = true;
			document.all.TitleColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 1 ){ // Nothing has been selected on 
			document.all.CoverTitleTD.style.backgroundColor='#FFFFFF';
	}

	setFunctionality();

}
function checkCoverTitle(val) { //v3.0
	resetValues(1);
	var change = 1;
	if ( val == "Custom" ){
		document.auBuilderForm2.customTitle1.disabled = false;
		document.auBuilderForm2.customTitle2.disabled = false;
	}
	if ( val != "Custom" ){
		document.auBuilderForm2.customTitle1.value = "";
		document.auBuilderForm2.customTitle2.value = "";
		document.auBuilderForm2.customTitle1.disabled = true;
		document.auBuilderForm2.customTitle2.disabled = true;
	}

	if ( val == "Monogram" ){
		document.auBuilderForm2.monogramText1.disabled = false;
		document.auBuilderForm2.monogramText2.disabled = false;
		document.auBuilderForm2.monogramText3.disabled = false;
	}
	if ( val != "Monogram" ){
		document.auBuilderForm2.monogramText1.value = "";
		document.auBuilderForm2.monogramText2.value = "";
		document.auBuilderForm2.monogramText3.value = "";
		document.auBuilderForm2.monogramText1.disabled = true;
		document.auBuilderForm2.monogramText2.disabled = true;
		document.auBuilderForm2.monogramText3.disabled = true;
	}

	setBackgroundColors(change,val,'CoverTitleTD');
}
//*****************************************************************************************************************************************
// This function is used to check that the Title Color selected is valid
//*****************************************************************************************************************************************
function checkTitleColor(val) { //v3.0
	resetValues(2);
	var found_it;
	var change = 1;
	
	found_it = getSelectedValue('coverTitle');
   
	if (found_it == "notSelected"){
		alert("You must first select a Cover Title.");
		document.auBuilderForm2.titleColor[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'TitleColorTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint selected is valid
//*****************************************************************************************************************************************
function checkStudioImprint(val) { //v3.0
	resetValues(3);
	var change = 1;
		
	found_it = getSelectedValue('titleColor');
   
	if (found_it == "notSelected"){
		alert("You must first select a Cover Color.");
		document.auBuilderForm2.studioImprint[0].checked = true;
		change = 0;
	}

	if ( val == "Cus" ){
		document.auBuilderForm2.customImprint1.disabled = false;
		document.auBuilderForm2.customImprint2.disabled = false;
		document.auBuilderForm2.customImprint3.disabled = false;
	}
	if ( val == "Die" ){
		document.auBuilderForm2.customImprint1.value = "";
		document.auBuilderForm2.customImprint2.value = "";
		document.auBuilderForm2.customImprint3.value = "";
		document.auBuilderForm2.customImprint1.disabled = true;
		document.auBuilderForm2.customImprint2.disabled = true;
		document.auBuilderForm2.customImprint3.disabled = true;
	}
	if ( val == "none" ){
		document.auBuilderForm2.customImprint1.value = "";
		document.auBuilderForm2.customImprint2.value = "";
		document.auBuilderForm2.customImprint3.value = "";
		document.auBuilderForm2.customImprint1.disabled = true;
		document.auBuilderForm2.customImprint2.disabled = true;
		document.auBuilderForm2.customImprint3.disabled = true;
	}
	setBackgroundColors(change,val,'StudioImprintTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkStudioImprintText(val) { //v3.0
	resetValues(4);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('studioImprint');

	if (found_it == "notSelected"){
		alert("You must first select a Studio Imprint.");
		document.auBuilderForm2.studioImprintText[0].checked = true;
		change = 0;
	}
	
	customImprint1 = document.auBuilderForm2.customImprint1.value;
	customImprint2 = document.auBuilderForm2.customImprint2.value;
	customImprint3 = document.auBuilderForm2.customImprint3.value;
	
	if (found_it == "Cus" && customImprint1 == "" && customImprint2 == "" && customImprint3 == ""){
		alert("Please fill in the Custom Studio Imprint above before selecting a text.");
		document.auBuilderForm2.studioImprintText[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'StudioImprintTextTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Color selected is valid
//*****************************************************************************************************************************************
function checkStudioImprintColor(val) { //v3.0
	resetValues(5);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('studioImprintText');

	if (found_it == "notSelected"){
		alert("You must first select a Studio Imprint Text.");
		document.auBuilderForm2.studioImprintColor[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'StudioImprintColorTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint selected is valid
//*****************************************************************************************************************************************
function checkNameImprint(val) { //v3.0
	resetValues(6);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('studioImprintColor');

	if (found_it == "notSelected"){
		alert("You must first select a Studio Imprint Color.");
		document.auBuilderForm2.nameImprint[0].checked = true;
		change = 0;
	}
	if ( val == "Cus" ){
		document.auBuilderForm2.nameDate1.disabled = false;
		document.auBuilderForm2.nameDate2.disabled = false;
		document.auBuilderForm2.nameDate3.disabled = false;
	}
	if ( val == "none" ){
		document.auBuilderForm2.nameDate1.value = "";
		document.auBuilderForm2.nameDate2.value = "";
		document.auBuilderForm2.nameDate3.value = "";
		document.auBuilderForm2.nameDate1.disabled = true;
		document.auBuilderForm2.nameDate2.disabled = true;
		document.auBuilderForm2.nameDate3.disabled = true;
	}
	
	setBackgroundColors(change,val,'NameImprintTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkNameImprintText(val) { //v3.0
	resetValues(7);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('nameImprint');

	nameDate1 = document.auBuilderForm2.nameDate1.value;
	nameDate2 = document.auBuilderForm2.nameDate2.value;
	nameDate3 = document.auBuilderForm2.nameDate3.value;

	if (found_it == "notSelected"){
		alert("You must first select a Name & Date Imprint.");
		document.auBuilderForm2.nameImprintText[0].checked = true;
		change = 0;
	}
	if (found_it == "Cus" && (nameDate1 == "" && nameDate2 == "" && nameDate3 == "")){
		alert("Please Fill out at least one line for your Name and Date Imprint before selecting a text.");
		document.auBuilderForm2.nameImprintText[0].checked = true;
		change = 0;
	}
	setBackgroundColors(change,val,'NameImprintTextTD');
}


//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint Color selected is valid
//*****************************************************************************************************************************************
function checkNameImprintColor(val) { //v3.0
	resetValues(8);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('nameImprintText');

	if (found_it == "notSelected"){
		alert("You must first select a Name & Date Imprint Text.");
		document.auBuilderForm2.nameImprintColor[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'NameImprintColorTD');
}

//*****************************************************************************************************************************************
// This function checks to make sure that all selections have been made before submitting
//*****************************************************************************************************************************************
function checkComplete2(){
	found_it = getSelectedValue('nameImprintColor');
	
	if ( found_it != "notSelected" ){
		document.auBuilderForm2.submit();
	}
	else{
		alert("Please Finish all necessary selections before submitting album to basket.");
	}

}

//*****************************************************************************************************************************************
// The functions below are for the simple Albums Page
//*****************************************************************************************************************************************
function checkComplete3(){
	found_it = getSelectedValue2('nameImprintColor');
	
	if ( found_it != "notSelected" ){
		document.auBuilderForm.submit();
	}
	else{
		alert("Please Finish all necessary selections before submitting album to basket.");
	}

}

function checkCoverColorSimple(val) { //v3.0
	var found_it;
	var change = 1;
	

	found_it = getSelectedValue2('coverTitle');
	
	if (found_it == "notSelected"){
	document.all.CoverTitleTD.style.backgroundColor='#FFFFFF';
	}

	if ( document.all ){
		document.all.TitleColorTD.style.backgroundColor='#FFFFFF';
	}
		document.auBuilderForm.titleColor[0].checked = true;
	
	if ( document.all ){
		setBackgroundColors(change,val,'CoverTitleTD');
	}
		
	if ( val != 'none' ){
		for( i = 0; i < 5; i++ ){	
			value = 'document.auBuilderForm.titleColor[' + i + '].disabled = false';
			eval(value);
		}
	}
	if ( val == 'none' ){
		value = 'document.auBuilderForm.titleColor[5].checked = true';
		eval(value);
		for( i = 0; i < 5; i++){
			value = 'document.auBuilderForm.titleColor[' + i + '].disabled = true';
			eval(value);
		}
	}

}
function checkTitleColorSimple(val) { //v3.0
	var found_it;
	var change = 1;
	
	found_it = getSelectedValue2('coverTitle');
   
	if (found_it == "notSelected"){
		alert("You must first select a Cover Title.");
		document.auBuilderForm.titleColor[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'TitleColorTD');
}
function checkStudioImprintSimple(val) { //v3.0
	var found_it;
	var change = 1;

	found_it = getSelectedValue2('titleColor');
   
	if (found_it == "notSelected"){
		alert("You must first select a Title Color.");
		document.auBuilderForm.studioImprint[0].checked = true;
		change = 0;
	}
	if ( val == "Cus" ){
		document.auBuilderForm.customImprint1.disabled = false;
		document.auBuilderForm.customImprint2.disabled = false;
		document.auBuilderForm.customImprint3.disabled = false;
		enableSection2('studioImprintText',3);
		enableSection2('studioImprintColor',5);
	}
	if ( val == "Die" ){
		document.auBuilderForm.customImprint1.value = "";
		document.auBuilderForm.customImprint2.value = "";
		document.auBuilderForm.customImprint3.value = "";
		document.auBuilderForm.customImprint1.disabled = true;
		document.auBuilderForm.customImprint2.disabled = true;
		document.auBuilderForm.customImprint3.disabled = true;
		enableSection2('studioImprintColor',5);
		disableSection2('studioImprintText',3);
	}
	if ( val == "none" ){
		document.auBuilderForm.customImprint1.value = "";
		document.auBuilderForm.customImprint2.value = "";
		document.auBuilderForm.customImprint3.value = "";
		document.auBuilderForm.customImprint1.disabled = true;
		document.auBuilderForm.customImprint2.disabled = true;
		document.auBuilderForm.customImprint3.disabled = true;
		disableSection2('studioImprintText',3);
		disableSection2('studioImprintColor',5);
	}
		
	setBackgroundColors(change,val,'StudioImprintTD2');
}
//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkStudioImprintTextSimple(val) { //v3.0
	var found_it;
	var change = 1;

	found_it = getSelectedValue2('studioImprint');

	if (found_it == "notSelected"){
		alert("You must first select a Studio Imprint.");
		document.auBuilderForm.studioImprintText[0].checked = true;
		change = 0;
	}
	
	customImprint1 = document.auBuilderForm.customImprint1.value;
	customImprint2 = document.auBuilderForm.customImprint2.value;
	customImprint3 = document.auBuilderForm.customImprint3.value;
	
	if (found_it == "Cus" && customImprint1 == "" && customImprint2 == "" && customImprint3 == ""){
		alert("Please fill in the Custom Studio Imprint above before selecting a text.");
		document.auBuilderForm.studioImprintText[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'StudioImprintTextTD2');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Color selected is valid
//*****************************************************************************************************************************************
function checkStudioImprintColorSimple(val) { //v3.0
	var found_it;
	var change = 1;

	found_it = getSelectedValue2('studioImprintText');

	if (found_it == "notSelected"){
		alert("You must first select a Studio Imprint Text.");
		document.auBuilderForm.studioImprintColor[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'StudioImprintColorTD2');
}

//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint selected is valid
//*****************************************************************************************************************************************
function checkNameImprintSimple(val) { //v3.0
	var found_it;
	var change = 1;

	found_it = getSelectedValue2('studioImprintColor');

	if (found_it == "notSelected"){
		alert("You must first select a Studio Imprint Color.");
		document.auBuilderForm.nameImprint[0].checked = true;
		change = 0;
	}
	if ( val == "Cus" ){
		document.auBuilderForm.nameDate1.disabled = false;
		document.auBuilderForm.nameDate2.disabled = false;
		document.auBuilderForm.nameDate3.disabled = false;
		enableSection2('nameImprintText',3);
		enableSection2('nameImprintColor',5);
	}
	if ( val == "none" ){
		document.auBuilderForm.nameDate1.value = "";
		document.auBuilderForm.nameDate2.value = "";
		document.auBuilderForm.nameDate3.value = "";
		document.auBuilderForm.nameDate1.disabled = true;
		document.auBuilderForm.nameDate2.disabled = true;
		document.auBuilderForm.nameDate3.disabled = true;
		disableSection2('nameImprintText',3);
		disableSection2('nameImprintColor',5);
	}

	setBackgroundColors(change,val,'NameImprintTD2');
}

//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkNameImprintTextSimple(val) { //v3.0
	var found_it;
	var change = 1;

	found_it = getSelectedValue2('nameImprint');

	nameDate1 = document.auBuilderForm.nameDate1.value;
	nameDate2 = document.auBuilderForm.nameDate2.value;
	nameDate3 = document.auBuilderForm.nameDate3.value;

	if (found_it == "notSelected"){
		alert("You must first select a Name & Date Imprint.");
		document.auBuilderForm.nameImprintText[0].checked = true;
		change = 0;
	}
	if (found_it == "Cus" && (nameDate1 == "" && nameDate2 == "" && nameDate3 == "")){
		alert("Please Fill out at least one line for your Name and Date Imprint before selecting a text.");
		document.auBuilderForm.nameImprintText[0].checked = true;
		change = 0;
	}
	setBackgroundColors(change,val,'NameImprintTextTD2');
}


//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint Color selected is valid
//*****************************************************************************************************************************************
function checkNameImprintColorSimple(val) { //v3.0
	var found_it;
	var change = 1;

	found_it = getSelectedValue2('nameImprintText');

	if (found_it == "notSelected"){
		alert("You must first select a Name & Date Imprint Text.");
		document.auBuilderForm.nameImprintColor[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'NameImprintColorTD2');
}

