


function submitForm(form_name) {
	document.forms[form_name].submit();
}

//----------------------------------------------------------------------------------------------------

function updateFormValue(the_form, the_element, the_value) {
	//alert(document.forms[the_form][the_element].value);
	document.forms[the_form][the_element].value = the_value;
}


//==================================================
// BEGIN FORM VALIDATION FUNCTIONS
//==================================================
function validateForm_ContactUs(the_form) {
	var is_valid = true;	// we assume it is a valid form
	// custom code can be added to this fucntion if form specific actions are required
	
	// call the standard form validation function
	is_valid = validateForm(the_form);
	
	return is_valid;
}



//==================================================
// END FORM VALIDATION FUNCTIONS
//==================================================



//==================================================
// BEGIN HOME PAGE FUNCTIONS
//==================================================

function initHomePage() {
	// if the browser supports the js feature
	if (document.getElementById) {
		// if there is an element in the page with id 'homePageImg'
		if (img_node = document.getElementById('homePageImg')) {
			// if the node is an img
			if (img_node.nodeName == 'IMG') {
				// there is more than one image to display
				if (home_page_num_images > 1) {
					//alert(home_page_delay);	
					//swapImg(img_node, home_page_images[1]);
					// start the animation
					home_page_interval = setInterval("homePageAnimation()", home_page_delay);
				}
			}
		}
	}
}

//----------------------------------------------------------------------------------------------------

function homePageAnimation() {
	//alert('homePageAnimation');
	//clearInterval(home_page_interval);
	if (home_page_index >= home_page_num_images) {
		home_page_index = 0;
	}
	//alert(home_page_index);	
	swapImg(img_node, home_page_images[home_page_index]);
	home_page_index++;
}

//----------------------------------------------------------------------------------------------------

function swapImg(img_node, new_file) {
	img_node.src = new_file;
	//alert(img_node.src);
}

//==================================================
// END HOME PAGE FUNCTIONS
//==================================================




//==================================================
// START PRICE CALC FUNCTIONS
//==================================================

function validateForm_PriceCalc(the_form) {
	var is_valid = true;	// we assume it is a valid form
	// custom code can be added to this fucntion if form specific actions are required
	
	// call the standard form validation function
	is_valid = validateForm(the_form);
	
	//alert(' the select is ' + hasValue_Select(the_form.elements['prodID']) );
	
	return is_valid;
}

//----------------------------------------------------------------------------------------------------

// this function displays/hides the number of color select inputs for the logo locations
function toggleColors(checkbox) {
	//alert(checkbox.checked);
	var dd_node;
	
	// get the dd node that contains the color selection form element
	var dt_node = checkbox.parentNode;
	//alert(dt_node.nodeName);
	var dl_node = dt_node.parentNode;
	//alert( dl_node.nodeName);
	var dl_children = dl_node.childNodes;
	var num_dl_children = dl_children.length;
	//alert('num_dl_children = ' + num_dl_children);
	for (var x=0; x<num_dl_children; x++) {
		if (dl_children[x].nodeName == 'DD') {
			//alert(dl_children[x].nodeName);
			//dl_children[x].style.display = 'block';
			//alert(dl_children[x].style.display);
			dd_node = dl_children[x];
		}
	}
	
	// if we found the element
	if (dd_node) {
		// see if the checkbox is checked
		if (checkbox.checked) {
			dd_node.style.display = 'block';
		} else {
			dd_node.style.display = 'none';
		}
	}
}

//----------------------------------------------------------------------------------------------------

function updateLogoLocationSelections(element) {
	var prod_index = -1;	// this will hold the index of the selected product
	var loc_id_str = 'logoLocation';	// the beginning of the name of each dt node
	var loc_node;		// a var to hold the node
	
	// get the product id for the model selected
	var prod_id = element.options[element.selectedIndex].value;
	
	var num_prods = prods.length;	// the prods array is created in the pricing_calc file
	// loop each product
	for (var x=0; x<num_prods; x++) {
		// if the selected product matches this prod id
		if (prods[x]['prodID'] == prod_id) {
			prod_index = x;	// set the cat array index
			// break out of loop
			x = num_prods;
		}
	}
	
	
	
	// loop through all the locations
	for (x=0; x<location_ids.length; x++) {
		
		var num_prod_locs = prods[prod_index]['locs'].length;
		var show_loc = false;
		// loop through all the locations for the selected category
		for (z=0; z<num_prod_locs; z++) {
			// if the location is part of the cat
			if (location_ids[x] == prods[prod_index]['locs'][z]) {
				show_loc = true;
			}
		}
		
		// get the node of the location
		loc_node = document.getElementById( (loc_id_str + location_ids[x]) );
		
		if (show_loc == true) {
			toggleNodeDisplay(loc_node, true);
		} else {
			// uncheck the loc
			setLocationDefaults(loc_node);
			// hide the dl
			toggleNodeDisplay(loc_node, false);
		}
	}
			
	

}

//----------------------------------------------------------------------------------------------------


function setLocationDefaults(loc_node) {
	var child_nodes = loc_node.childNodes;
	for (var x=0; x<child_nodes.length; x++) {
		switch (child_nodes[x].nodeName) {
			case 'DT':
				//alert(child_nodes[x].nodeName);
				var dt_node = child_nodes[x];
				var dt_kids = dt_node.childNodes;
				for (var z=0; z<dt_kids.length; z++) {
					if (dt_kids[z].nodeName == 'INPUT') {
						//alert(dt_kids[z].nodeName);		
						//alert(dt_kids[z].checked);		
						dt_kids[z].checked = false;
					}
				}
				break;
			case 'DD':
				var dd_node = child_nodes[x];
				var dd_kids = dd_node.childNodes;
				for (var z=0; z<dd_kids.length; z++) {
					if (dd_kids[z].nodeName == 'SELECT') {
						//alert(dt_kids[z].nodeName);		
						//alert(dt_kids[z].checked);		
						dd_kids[z].selectedIndex = 0;
					}
				}
				
				dd_node.style.display = 'none';
				break;
		}
	}
}

//----------------------------------------------------------------------------------------------------

function toggleNodeDisplay(loc_node, state) {
	if (state) {
		loc_node.style.display = 'block';
	} else {
		loc_node.style.display = 'none';
	}
}


//==================================================
// END PRICE CALC FUNCTIONS
//==================================================