// Swaps out an image based on the values of pull-down menues
// Defaults to Black ink on Gold Foil, Style AP1
function swapStyleFoilColorImage() {
	var sealStyle = (document.maverick.style.value) ? document.maverick.style.value : 'TYP1';

	switch (sealStyle) {
		case '1854':
		sealStyle = 'TYP1';
		break;
		case '1855':
		sealStyle = 'TYP2';
		break;
		case '1856':
		sealStyle = 'TYP3';
		break;
		case '1857':
		sealStyle = 'TYP4';		
		break;
		case '1858':
		sealStyle = 'TYP5';
		break;
		case '1859':
		sealStyle = 'TYP6';
		break;
		case '1860':
		sealStyle = 'TYP7';		
	}
	
	swapImage = document.getElementById('swap_image');
	swapImage.src = "/images/thank_you_seals/" + sealStyle + ".jpg";
}

// Swaps out an image based on the values of pull-down menues
// Defaults to Black ink on Gold Foil, Style AP1
function mouseOverSwapStyleFoilColorImage(sealStyle) {
	
	switch (sealStyle) {
		case '1854':
		sealStyle = 'TYP1';
		break;
		case '1855':
		sealStyle = 'TYP2';
		break;
		case '1856':
		sealStyle = 'TYP3';
		break;
		case '1857':
		sealStyle = 'TYP4';		
		break;
		case '1858':
		sealStyle = 'TYP5';
		break;
		case '1859':
		sealStyle = 'TYP6';
		break;
		case '1860':
		sealStyle = 'TYP7';			
	}
	
	
	swapImage = document.getElementById('swap_image');
	swapImage.src = "/images/thank_you_seals/" + sealStyle + ".jpg";
}
		
// Some seal style do not have the option of
//	the addtional text. Hide the input when not applicable

function displayInputField(sealType) {

	var wording = document.getElementById("wording");
	
	wording.disabled = false;
	wording.style.backgroundColor = "";

	//	Type 1
	if (sealType == '1854') {}	

	//	Type 2
	else if (sealType == '1855') {
		wording.value = '';
		wording.disabled = true;
		wording.style.backgroundColor = "#C1C8D2";		
	}

	//	Type 3
	else if (sealType == '1856') {		
		wording.value = '';
		wording.disabled = true;
		wording.style.backgroundColor = "#C1C8D2";	
	}	
	
	//	Type 4
	else if (sealType == '1857') {}	

	//	Type 5
	else if (sealType == '1858') {}
	
	//	Type 6
	else if (sealType == '1859') {
		wording.value = '';
		wording.disabled = true;
		wording.style.backgroundColor = "#C1C8D2";
	}	
	
	//	Type 7
	else if (sealType == '1860') {}		
}		
	
// This is for when the user clicks on a seal style, the menu will reflect that clicked choice
// It also runs the function to show or hide the optional wording field. 
function setStyleMenu(sealType) {
	document.maverick.style.value = sealType;
	displayInputField(sealType);
}		

// Checking the required form fields for values
function checkFormFields(form) {		
	// Make sure the error string is empty
	var i = 0;
	var error_string = '';
		
	// Get the style info for the required fields and set them to no border
	var quantityStyle = document.getElementById("quantity_box").style;
	var companyStyle = document.getElementById("company_box").style;
	var companyValue = document.getElementById("company_name");
	var quantityValue = document.getElementById("quantity");
		
	// reset the border styles of fields that were corrected
	quantityStyle.border = "solid white 1px";
	companyStyle.border = "solid white 1px";
	companyValue.className = '';
	quantityValue.className = '';
		
	// Make sure that the quantity is a number
	if (document.maverick.quantity.value == '') {
		i++;
		error_string += i + ") Please select a Quantity\n";
		quantityStyle.border = "solid red 1px";
		quantityValue.className = "notice_o";
	}	
	
	if (document.maverick.company_name.value == '') {
		i++;
		error_string += i + ") Please enter a Company Name.\n";
		companyStyle.border = "solid red 1px";	
		companyValue.className = "notice_o";
	}	

	// If there were any errors, make an alert box and prevent submission
	if (error_string != "") {
		var fieldCount;
		if (i == 1) { fieldCount = "field"; }
		else { fieldCount = i + " fields"; }
		alert(error_string + "\nThe error/missing required " + fieldCount + " will be outlined in red"); 
		return false;
	}
}