// JavaScript Document

//*****************************************************************************************************************************************
// This function checks to make sure that all sections are enabled or disabled correctly
//*****************************************************************************************************************************************
function setFunctionality(){
// check below to make sure that cover title attributes are still available
	

	found_itCC = getSelectedValue('coverColor');

	found_it = getSelectedValue('coverMaterial');
	found_itCM = getSelectedValue('coverMaterial');	
	found_it10000 = getSelectedValue('coverMaterial');
	
	if(found_it == "L" || found_it == "Br" || found_it == "Cs"){
		disableSection('coverColor', 53);
	}
		
	if(document.auBuilderForm.nameImprint[2].checked == true){
	
		disableSection('nameImprintText', 3);
		disableSection('nameImprintColor', 5);
	
	}else{
	
		enableSection('nameImprintText', 3);
		enableSection('nameImprintColor', 5)
	
	}
	
	// Restricting MB and MG if cs1 * cs2 < mini-small || >= XX-Large(16X20)... 
	var endResult = document.auBuilderForm.cs1.value * document.auBuilderForm.cs2.value;
	
	if(endResult < 80 || endResult >= 256){
	
		document.auBuilderForm.coverMaterial[14].disabled = true;
		document.auBuilderForm.coverMaterial[15].disabled = true;
	
	}else{
	
		document.auBuilderForm.coverMaterial[14].disabled = false;
		document.auBuilderForm.coverMaterial[15].disabled = false;
	
	}
	
	if(found_it10000 != 'AP' && found_it10000 != 'AC'){
		
		disableSection('acrylic', 5);
	
	}
	
	if(found_it10000 == 'AP' || found_it10000 == 'AC'){
	
		enableSection('acrylic', 5);
		
		if(endResult < 48 || endResult >= 256){
	
			document.auBuilderForm.acrylic[2].disabled = true;
			document.auBuilderForm.acrylic[3].disabled = true;
			document.auBuilderForm.acrylic[4].disabled = true;
	
		}else{
	
			document.auBuilderForm.acrylic[2].disabled = false;
			document.auBuilderForm.acrylic[3].disabled = false;
			document.auBuilderForm.acrylic[4].disabled = false;
	
		}
	
	}
	
	if(found_it == 'Pc'){
	
		disableSection('coverTitle', 37);
		disableSection('titleColor', 5);
		disableSection('nameImprint', 2);
		document.auBuilderForm.nameDate1.disabled = true;
		document.auBuilderForm.nameDate2.disabled = true;
		document.auBuilderForm.nameDate3.disabled = true;
		document.auBuilderForm.nameDate1.value = "";
		document.auBuilderForm.nameDate2.value = "";
		document.auBuilderForm.nameDate3.value = "";
		document.auBuilderForm.cameo[11].checked = true;
		disableSection('nameImprintText', 3);
		disableSection('nameImprintColor', 5);
	
	}	
	
	if(found_it == 'Mp' || found_it == 'Mi' || found_it == 'MPe'){
	
		enableSection('coverColor', 53);
	
	}
	
	if(found_it == 'MB' || found_it == 'MG' || found_it == 'Mp' || found_it == 'MPe' || found_it == 'AP' || found_it == 'AC'){
	
		enableSection('coverColor', 53);
		disableSection('cameo', 11);
		disableSection('coverTitle', 37);
		disableSection('titleColor', 5);
		disableSection('nameImprint', 2);
		document.auBuilderForm.nameDate1.disabled = true;
		document.auBuilderForm.nameDate2.disabled = true;
		document.auBuilderForm.nameDate3.disabled = true;
		document.auBuilderForm.nameDate1.value = "";
		document.auBuilderForm.nameDate2.value = "";
		document.auBuilderForm.nameDate3.value = "";
		disableSection('nameImprintText', 3);
		disableSection('nameImprintColor', 5);
	
	}
	
	if(found_it == 'Mi'){
	
		enableSection('coverColor', 53);
		disableSection('cameo', 11);
		disableSection('coverTitle', 37);
		disableSection('titleColor', 5);
		disableSection('nameImprint', 1);
		document.auBuilderForm.nameImprint[2].disabled = true;
		document.auBuilderForm.nameDate1.disabled = false;
		document.auBuilderForm.nameDate1.value = "";
		document.auBuilderForm.nameDate2.disabled = true;
		document.auBuilderForm.nameDate3.disabled = true;
		disableSection('nameImprintText', 1);
		document.auBuilderForm.nameImprintText[1].checked = true;
		disableSection('nameImprintColor', 3);
		document.auBuilderForm.nameImprintColor[3].checked = true;
	
	}

	if (found_it != 'MPec' && found_it != 'MB' && found_it != 'MG' && found_it != 'Mp' && found_it != 'MPe' && found_it != 'AP' && found_it != 'AC' && found_it != 'Mi' && found_it != 'Pc'){
		if(found_it != "L" && found_it != "Br" && found_it != "Cs"){
			
			enableSection('coverColor',53);
			
		}else{
		
			if(found_it == "L"){
		
				document.auBuilderForm.coverColor[72].checked = true;
				
			}
			
			if(found_it == "Br"){
			
				document.auBuilderForm.coverColor[51].checked = true;
			
			}
			
			if(found_it == "Cs"){
			
				document.auBuilderForm.coverColor[52].checked = true;
			
			}
			if(found_it == "PW"){
			
				document.auBuilderForm.coverColor[72].checked = true;
			
			}
		
		}
		enableSection('cameo',11);
		enableSection('coverTitle', 37);
		enableSection('titleColor',5);
		enableSection('nameImprint',2);
	
		if(found_it != "L" && found_it != "Br" && found_it != "Cs"){
		
			enableSection('nameImprintText', 3);
			enableSection('nameImprintColor',5);
			
		}
			
	}
	if (found_it == 'Pw'){
		disableSection('coverColor',75);
	}
		
	if (found_it == 'Pw'){
		disableSection('cameo',11);
		document.auBuilderForm.coverStyle[1].checked = true;
		disableSection('coverTitle', 37);
		disableSection('titleColor',5);
		disableSection('nameImprint',2);
		disableSection('nameImprintText',3);
		disableSection('nameImprintColor',5);
	}
	
	if(found_it == 'MB' || found_it == 'MG' || found_it == 'Mp' || found_it == 'MPe' || found_it == 'AP' || found_it == 'AC' || found_it == 'Mi' || found_it == 'L' || found_it == 'Pc'){
		
		var getCoverColor = getSelectedValue("coverColor");		
		if(getCoverColor == 'leather'){
			
			document.auBuilderForm.leatherColor.disabled = false;
		
		}else{
		
			document.auBuilderForm.leatherColor.disabled = true;
			document.auBuilderForm.leatherColor.value = "";
		
		}
		
	}
		
		
	found_it = getSelectedValue('coverColor');

	if ( found_it == 'oPorcelain' || found_it == 'oBirch' || found_it == 'oIvory' || found_it == 'oCharcoal' || found_it == 'oMeadow' || found_it == 'oMahogany' || found_it == 'oOnyx' || found_it == 'oRoyalBlue' || found_it == 'pIvory' || found_it == 'pBlack' || found_it == 'pPeanut' || found_it == 'pWine'){
	
			disableSection('coverTitle',37);
			//document.auBuilderForm.coverTitle[4].checked = true;
			disableSection('titleColor',5);
			disableSection('nameImprint',2);
			disableSection('nameImprintText',3);
			disableSection('nameImprintColor',5);
		
			document.auBuilderForm.customTitle1.disabled = true;
			document.auBuilderForm.customTitle2.disabled = true;
			document.auBuilderForm.monogramText1.disabled = true;
			document.auBuilderForm.monogramText2.disabled = true;
			document.auBuilderForm.monogramText3.disabled = true;
			
			document.auBuilderForm.nameDate1.disabled = true;
			document.auBuilderForm.nameDate2.disabled = true;
			document.auBuilderForm.nameDate3.disabled = true;
			document.auBuilderForm.nameDate1.value = "";
			document.auBuilderForm.nameDate2.value = "";
			document.auBuilderForm.nameDate3.value = "";

		
	}
	else{
			
		found_it = getSelectedValue('coverMaterial');	
			
		if(found_it != 'MB' && found_it != 'MG' && found_it != 'Mp' && found_it != 'MPe' && found_it != 'AP' && found_it != 'AC' && found_it != 'Mi' && found_it != 'Pc' && found_it != 'Pw'){
		
			enableSection('coverTitle',36);
			enableSection('titleColor',5);
			enableSection('nameImprint',2);
			document.auBuilderForm.nameDate1.disabled = false;
			document.auBuilderForm.nameDate2.disabled = false;
			document.auBuilderForm.nameDate3.disabled = false;
		
			document.auBuilderForm.customTitle1.disabled = false;
			document.auBuilderForm.customTitle2.disabled = false;
			document.auBuilderForm.monogramText1.disabled = false;
			document.auBuilderForm.monogramText2.disabled = false;
			document.auBuilderForm.monogramText3.disabled = false;
	
			if(found_it != "L" && found_it != "Br" && found_it != "Cs"){
		
				enableSection('nameImprintText', 3);
				enableSection('nameImprintColor',5);
			
			}
			
		}
		
		if(found_it != 'MB' && found_it != 'MG' && found_it != 'Mp' && found_it != 'MPe' && found_it != 'AP' && found_it != 'AC'){
		
			// Do Nothing...
		
		}else{
			
			disableSection('cameo', 11);
			disableSection('coverTitle', 37);
			disableSection('titleColor', 5);
			disableSection('nameImprint', 2);
			disableSection('nameImprintText', 3);
			disableSection('nameImprintColor', 5);
		
		}
		
		if(found_it != 'Mi'){
		
			// Do Nothing...
		
		}else{
		
			disableSection('titleColor',5);
			disableSection('cameo', 11);
			disableSection('coverTitle', 37);
			disableSection('nameImprint', 1);
			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);
	}

// check below to make sure that studio imprint attributes are still available

	found_it = getSelectedValue('studioImprint');

	if ( found_it != 'none' ){
		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');
	found_it2 = getSelectedValue('coverMaterial');

	if ( found_it != 'none' ){
	
		if(found_it2 == 'Mi'){
		
			disableSection('nameImprintText', 1);
			disableSection('nameImprintColor', 3);
		
		}else{
		
			// Do Nothing...
		
		}
		
	}
	if ( found_it == 'none' ){
		disableSection('nameImprintText',3);
		disableSection('nameImprintColor',5);
	}
	
	if ( found_itCM == 'L' || found_itCC == 'leather' ){
		document.auBuilderForm.titleColor[4].disabled = true;
		document.auBuilderForm.nameImprintColor[4].disabled = true;
	}
	
}

function checkReference () {

	msg = "Please add the Client Reference Name to the Kingston email order confirmations that go out to our customers.  Please put the Client Reference Name information between the Special Instructions and the Albums header."

	if ( document.auBuilderForm.clientReference.value == "") {
		alert(msg);
		return 0;
	} else {
		return 1;
	}

}

function showSample(imageFile,prodDesc){
	window.open('sampleImage.php?imageFile='+imageFile+'&prodDesc='+prodDesc, 'enlarge', 'width=550,height=480,left=1,top=0,status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
}

//*****************************************************************************************************************************************
// This function is used ro reset all those sections that follow the most recently selected one
//*****************************************************************************************************************************************
function resetValues(val) { //v3.0

	if ( val < 24 ){
			document.all.NameImprintColorTD.style.backgroundColor='#E8E5EC';
	}
	if ( val < 23 ){
	
			document.all.NameImprintTextTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.nameImprintColor[0].checked = true;
			document.all.NameImprintColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 22 ){
			document.all.NameImprintTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.nameImprintText[0].checked = true;
			document.all.NameImprintTextTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 21 ){
			document.all.StudioImprintColorTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.nameImprint[0].checked = true;
			document.all.NameImprintTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 20 ){
			document.all.StudioImprintTextTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.studioImprintColor[0].checked = true;
			document.all.StudioImprintColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 19 ){
			document.all.StudioImprintTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.studioImprintText[0].checked = true;
			document.all.StudioImprintTextTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 18 ){
			document.all.TitleColorTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.studioImprint[0].checked = true;
			document.all.StudioImprintTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 17 ){
			document.all.CoverTitleTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.titleColor[0].checked = true;
			document.all.TitleColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 16 ){
			document.all.LaminationTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.coverTitle[0].checked = true;
			document.all.CoverTitleTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 15 ){
			document.all.lpOrderTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.lamination[0].checked = true;
			document.all.LaminationTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 14 ){
			document.all.AUDesignTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.lpOrder[0].checked = true;
			document.all.lpOrderTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 13 ){
			document.all.BlankLastTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.auDesign[0].checked = true;
			document.all.AUDesignTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 12 ){
			document.all.BlankFirstTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.blankLast[0].checked = true;
			document.all.BlankLastTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 11 ){
			document.all.StartingPageTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.blankFirst[0].checked = true;
			document.all.BlankFirstTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 10 ){
			document.all.ContactSheetTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.startingPage[0].checked = true;
			document.all.StartingPageTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 9 ){
			document.all.CoverStyleTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.contactSheet[0].checked = true;
			document.all.ContactSheetTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 8 ){
			document.all.CameoTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.coverStyle[0].checked = true;
			document.all.CoverStyleTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 7 ){
			document.all.silkColorTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.cameo[0].checked = true;
			document.all.CameoTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 6 ){
			document.all.CoverColorTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.silkColor[0].checked = true;
			document.all.silkColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 5 ){
			document.all.AcrylicTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.coverColor[0].checked = true;
			document.all.CoverColorTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 4 ){
	
		document.all.CoverMaterialTD.style.backgroundColor='#E8E5EC';
		document.auBuilderForm.acrylic[0].checked = true;		
		document.all.AcrylicTD.style.backgroundColor='#FFFFFF';
			
	}
	if ( val < 3 ){
			document.all.ReturnTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.coverMaterial[0].checked = true;
			document.all.CoverMaterialTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 2 ){
			document.all.SizeTD.style.backgroundColor='#E8E5EC';
			document.auBuilderForm.return2[0].checked = true;
			document.all.ReturnTD.style.backgroundColor='#FFFFFF';
	}
	if ( val < 1 ){ // Nothing has been selected on 
			document.all.SizeTD.style.backgroundColor='#FFFFFF';
	}

	setFunctionality();

}

//*****************************************************************************************************************************************
// This function is used to check that the Cover Color selected is valid
//*****************************************************************************************************************************************
function checkReturn(val) { //v3.0

	if ( checkReference() == 0 ) { return; }

	resetValues(2);

	//var reg = /[^0-9]/;
	var reg = /([0-9]*\.[0-9]+|[0-9]+)/;

var found_it;
	var change = 1;
   
	capacity = document.auBuilderForm.capacity.value;
	photosize1 = document.auBuilderForm.cs1.value;
	photosize2 = document.auBuilderForm.cs2.value;

	if ( !( capacity.match(reg) && photosize1.match(reg) && photosize2.match(reg) ) ){
		alert("Photo Size and Number of Images must be numeric only.");
		document.auBuilderForm.return2[0].checked = true;
		change = 0;
	}
	
	if (capacity == "" || photosize1 == "" || photosize2 == ""){
		alert("Photo Size and Number of Images must be entered before moving on.");
		document.auBuilderForm.return2[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'ReturnTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Cover Color selected is valid
//*****************************************************************************************************************************************
function checkCoverMaterial(val) { //v3.0

	var found_it;
	var change = 1;
	resetValues(3);
   
    found_it = getSelectedValue('return2');
	
	if (found_it == "notSelected"){
		alert("You must first select a Return Shipment Choice.");
		document.auBuilderForm.coverMaterial[0].checked = true;
		change = 0;
	}
	
	if(val == 'TT'){ alert("The Cover Color choice you make below is for the front of your album. Enter your choice for the back and spine of the album in the special remarks section."); }
	if(val == 'TTF'){ alert("The Cover Color choice you make below is for the Panel Strip on the front of the album.  Enter your color choice for the rest of the album in the special remarks section."); }
	
	setBackgroundColors(change,val,'CoverMaterialTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the UnknownSection selected is valid
//*****************************************************************************************************************************************

function checkAcrylic(val) { //v3.0

	var found_it;
	var change = 1;
	resetValues(4);
   
    found_it = getSelectedValue('coverMaterial');
	
	if (found_it == "notSelected"){
		alert("You must first select a Cover Material.");
		document.auBuilderForm.acrylic[0].checked = true;
		change = 0;
		
	}
	
	setBackgroundColors(change,val,'AcrylicTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Cover Color selected is valid
//*****************************************************************************************************************************************

function checkCoverColor(val) { //v3.0
	resetValues(5);
	var found_it;
	var found_it2;
	var change = 1;
		
	found_it = getSelectedValue('acrylic');
	found_it2 = getSelectedValue('coverMaterial');
		
	if (found_it == "notSelected"){
		alert("You must first select a type of Acrylic.");
		document.auBuilderForm.coverColor[0].checked = true;
		change = 0;
	}
	
	if ((val == "hBlack") || (val == "hBrown") || (val == "hWine") || (val == "wNaturalOak") || (val == "wDesertPine") || (val == "wRusticOak")) { 
		document.auBuilderForm.coverTitle[37].checked = true; 
		document.auBuilderForm.titleColor[5].checked = true; 
		document.auBuilderForm.nameImprintText[3].checked = true; 
		document.auBuilderForm.nameImprintColor[5].checked = true; 
	}
	
	if ((found_it2 == "La" || found_it2 == "Lk"|| found_it2 == "L") && ( val == 'TP101' ||  val == 'TP111' ||  val == 'TP104' ||  val == 'TP105' ||  val == 'TP110' || val == 'TPCustom') ){
		alert("You cannot select a tapestry design with a Leatherette or Leather Cover Material.");
		document.auBuilderForm.coverColor[0].checked = true;
		change = 0;
	}
	if (found_it2 == "Tp"  && !( val == 'TP101' ||  val == 'TP111' ||  val == 'TP104' ||  val == 'TP105' ||  val == 'TP110' || val == 'TPCustom') ){
		alert("You must select a Tapestry cover option.");
		document.auBuilderForm.coverColor[0].checked = true;
		change = 0;
	}
	
	if ( (val == 'wNaturalOak') || (val == 'wDesertPine') || (val == 'wRusticOak') ) {
		document.auBuilderForm.coverTitle[37].checked
		document.auBuilderForm.titleColor[5].checked
		document.auBuilderForm.nameImprint[2].checked		
		document.auBuilderForm.nameImprintText[3].checked
		document.auBuilderForm.nameImprintColor[5].checked
	}

	setBackgroundColors(change,val,'CoverColorTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Silk Color selected is valid
//*****************************************************************************************************************************************
function checksilkColor(val) { //v3.0

	var found_it;
	var change = 1;
	resetValues(6);
   
    found_it = getSelectedValue('return2');
	
	if (found_it == "notSelected"){
		alert("You must first select a Silk Color Choice.");
		document.auBuilderForm.silkColor[0].checked = true;
		change = 0;
	}
	setBackgroundColors(change,val,'silkColorTD');
}


//*****************************************************************************************************************************************
// This function is used to check that the Cover Cameo selected is valid
//*****************************************************************************************************************************************
function checkCameo(val) { //v3.0
	resetValues(7);
	var found_it;
	var found_it2;
	var change = 1;

	found_it = document.auBuilderForm.leatherColor.value;
	found_it2 = getSelectedValue('coverColor');
	found_it3 = getSelectedValue('coverMaterial');
	
	if ( found_it2 == "notSelected" ){
		alert("You must select a Cover Color.");
		document.auBuilderForm.cameo[11].checked = true;
		change = 0;
	}	
	if ( found_it == "" && found_it3 == "L" ){
		alert("You must Enter a Leather Color.");
		document.auBuilderForm.cameo[0].checked = true;
		change = 0;
	}		
	if ( val == "other" ){
		document.auBuilderForm.coverCameoOther.disabled = false;
	}
	if ( val != "other" ){
		document.auBuilderForm.coverCameoOther.value = "";
		document.auBuilderForm.coverCameoOther.disabled = true;
	}
	
	setBackgroundColors(change,val,'CameoTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Cover Cameo selected is valid
//*****************************************************************************************************************************************
function checkCoverStyle(val) { //v3.0
	resetValues(8);
	var found_it;
	var found_it2;
	var found_it3;
	var change = 1;

	found_it = getSelectedValue('cameo');
	found_it2 = getSelectedValue('coverColor');
	found_it3 = getSelectedValue('acrylic');

	if (found_it == "notSelected"){
		alert("You must first select a Cameo.");
		document.auBuilderForm.coverStyle[0].checked = true;
		change = 0;
	}
	
	if(found_it2 == 'notSelected'){
	
		alert("You must first select a Cover Color.");
		document.auBuilderForm.coverStyle[0].checked = true;
		change = 0;
	
	}
	
	if(found_it3 == 'notSelected'){
	
		alert("You must first select a type of Acrylic.");
		document.auBuilderForm.coverStyle[0].checked = true;
		change = 0;
	
	}
	
	if (found_it == "other"){
		if ( document.auBulderForm.coverCameoOther.value == "" ){
			alert("You must first enter information in the 'other' box for Cameo Color.");
			document.auBuilderForm.coverStyle[0].checked = true;
			change = 0;
		}
	}
	
	setBackgroundColors(change,val,'CoverStyleTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Cover Title selected is valid
//*****************************************************************************************************************************************
function checkContactSheet(val) { //v3.0
	resetValues(9);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('coverStyle');
   
   	if (found_it == "notSelected"){
		alert("You must first select a Cover Style.");
		document.auBuilderForm.contactSheet[0].checked = true;
		change = 0;
	}
		
	if (val == 'N'){
			alert("Albums Unlimited is responsible for order of pictures only if contact sheet is submitted.");
	}
	
	setBackgroundColors(change,val,'ContactSheetTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Title Color selected is valid
//*****************************************************************************************************************************************
function checkStartingPage(val) { //v3.0
	resetValues(10);
	var found_it;
	var change = 1;
	
	found_it = getSelectedValue('contactSheet');
   
	if (found_it == "notSelected"){
		alert("You must first select a Contact Sheet Option.");
		document.auBuilderForm.startingPage[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'StartingPageTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint selected is valid
//*****************************************************************************************************************************************
function checkBlankFirst(val) { //v3.0
	resetValues(11);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('startingPage');
   
	if (found_it == "notSelected"){
		alert("You must first select a Starting Page.");
		document.auBuilderForm.blankFirst[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'BlankFirstTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkBlankLast(val) { //v3.0
	resetValues(12);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('blankFirst');

	if (found_it == "notSelected"){
		alert("You must first select a First Page Option.");
		document.auBuilderForm.blankLast[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'BlankLastTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkAUDesign(val) { //v3.0
	resetValues(13);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('blankLast');

	if (found_it == "notSelected"){
		alert("You must first select a Last Page Option.");
		document.auBuilderForm.auDesign[0].checked = true;
		change = 0;
	}
	
	setBackgroundColors(change,val,'AUDesignTD');
}
//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkLPOrder(val) { //v3.0
	resetValues(14);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('auDesign');

	if (found_it == "notSelected"){
		alert("You must first choose if Albums Unlimited will design your album for you or not.");
		document.auBuilderForm.lpOrder[0].checked = true;
		change = 0;
	}
	
	if (val == 'N') {
		document.auBuilderForm.lpPaperType[3].checked = true;
	}
	
	setBackgroundColors(change,val,'lpOrderTD');
}

function checkLPInfo (val) {

	if (document.auBuilderForm.lpPaperType[3].checked) { return; }
	
	if (!document.auBuilderForm.lpOrder[1].checked) {
		alert('Please first select "Yes" from Lab Prints Ordered.');
		document.auBuilderForm.lpPaperType[3].checked = true;
	}
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkLamination(val) { //v3.0
	resetValues(15);
	var found_it;
	var change = 1;
	
	found_it = getSelectedValue('lpOrder');
	
	
			
	if (found_it == "notSelected"){
		
		alert("You must first choose if you would like Lab Prints Ordered from Albums Unlimited.");
		document.auBuilderForm.lamination[0].checked = true;
		change = 0;
		
	}
		
	setBackgroundColors(change,val,'LaminationTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Studio Imprint Color selected is valid
//*****************************************************************************************************************************************
function checkCoverTitle(val) { //v3.0
	resetValues(16);
	var found_it;
	var found_it2;
	var change = 1;
	
	found_it = getSelectedValue('blankLast');
	found_it2 = getSelectedValue('coverMaterial');

	if (found_it == "notSelected"){
		
		alert("You must first select a Last Page Option.");
			
		change = 0;
		
	}
	
	if(val == "Custom"){
	
		document.auBuilderForm.customTitle1.disabled = false;
		document.auBuilderForm.customTitle2.disabled = false;
	
	}else{
	
		document.auBuilderForm.customTitle1.value = "";
		document.auBuilderForm.customTitle2.value = "";
		document.auBuilderForm.customTitle1.disabled = true;
		document.auBuilderForm.customTitle2.disabled = true;
	
	}	
	
	if ( val == "Monogram" ){
		document.auBuilderForm.monogramText1.disabled = false;
		document.auBuilderForm.monogramText2.disabled = false;
		document.auBuilderForm.monogramText3.disabled = false;
	}
	if ( val != "Monogram" ){
		document.auBuilderForm.monogramText1.value = "";
		document.auBuilderForm.monogramText2.value = "";
		document.auBuilderForm.monogramText3.value = "";
		document.auBuilderForm.monogramText1.disabled = true;
		document.auBuilderForm.monogramText2.disabled = true;
		document.auBuilderForm.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(17);
	var found_it;
	var change = 1;
	
	found_it = getSelectedValue('coverTitle');
   
	if (found_it == "notSelected"){
		alert("You must first select a Cover Title.");
		document.auBuilderForm.titleColor[5].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(18);
	var found_it;
	var found_it2;
	var change = 1;

	found_it = getSelectedValue('titleColor');
    found_it2 = getSelectedValue('lamination');
   
	if (found_it == "notSelected"){
		alert("You must first select a Title Color.");
		document.auBuilderForm.studioImprint[0].checked = true;
		change = 0;
	}else if(found_it2 == 'notSelected'){
	
		alert("You must first select a Lamination Service.");
		document.auBuilderForm.studioImprint[0].checked = true;
		change = 0;
	
	}
	
	if (val == 'Die') {	
		document.auBuilderForm.studioImprintText[0].disabled = true;
		document.auBuilderForm.studioImprintText[1].disabled = true;
		document.auBuilderForm.studioImprintText[2].disabled = true;
		document.auBuilderForm.studioImprintText[3].disabled = false;
		document.auBuilderForm.studioImprintText[3].checked = 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(19);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('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;
	
	if (found_it == "Cus" && customImprint1 == "" && customImprint2 == ""){
		alert("Please fill in the Custom Studio Imprint above before selecting a text.");
		document.auBuilderForm.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(20);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('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,'StudioImprintColorTD');
	
}

//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint selected is valid
//*****************************************************************************************************************************************
function checkNameImprint(val) { //v3.0
	resetValues(21);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('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;
	}
	
	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;
	}

	setBackgroundColors(change,val,'NameImprintTD');
}

//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint Text selected is valid
//*****************************************************************************************************************************************
function checkNameImprintText(val) { //v3.0
	resetValues(22);
	var found_it;
	var change = 1;

	found_it = getSelectedValue('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,'NameImprintTextTD');
}


//*****************************************************************************************************************************************
// This function is used to check that the Name Imprint Color selected is valid
//*****************************************************************************************************************************************
function checkNameImprintColor(val) { //v3.0
	resetValues(23);
	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.auBuilderForm.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 checkComplete(){
	found_it = getSelectedValue('nameImprintColor');
	
	if( document.auBuilderForm.giftBox55.value != "" || document.auBuilderForm.giftBox88.value != "" || document.auBuilderForm.giftBox1010.value != "" || document.auBuilderForm.giftBox1114.value != "" || document.auBuilderForm.giftBox1212.value != "" || document.auBuilderForm.giftBox1218.value != ""){
		document.auBuilderForm.submit();
	} else if ( document.auBuilderForm.coverMaterialSwatches.value != "" ){
		document.auBuilderForm.submit();
	} else if ( document.auBuilderForm.kingUpgradeCovSampleBox1.value != "" || document.auBuilderForm.kingUpgradeCovSampleBox2.value != ""){
		document.auBuilderForm.submit();		
	} else if ( found_it != "notSelected" ){
		document.auBuilderForm.submit();
	} else{
		alert("Please Finish all necessary selections before submitting album to basket.");
	}

}
