// JavaScript Document
// John Layman
// December 7, 2006
// Handleform that allows for up to two drop down menus and an additional checkbox style
// item.  The names of these form elements should be as follows:
// 		- menu1: the first drop down menu
//		- menu2 (optional): the second drop down menu
//		- optionalAdd (optional): the first checkbox offering a product addon
//		- optionalItem (optional): a hidden element storing the SKU for the first optional addon
//		- optionalAdd2 (optional): see optionalAdd
//		- optionalItem2 (optional): see optionalItem
//		- optionalAdd3 (optional): see optionalAdd
//		- optionalItem3 (optional): see optionalItem
//		- ProdList: a hidden variable that will eventually serve as the list of products the user
//					has selected from this page.
//
//7/16/07 Mod Ron Clabo - Modified the code to use prodListStr rather thatn ProdId and also added
//                        code to alert the user if they haven't selected an item in the drop downs
//                        rather than to have them go to an error page.  Also simplified code.

function handleform( inform ) {
	prodListStr = '';
	
	if(inform.menu1.options[inform.menu1.selectedIndex].value != ''){
			prodListStr += inform.menu1.options[inform.menu1.selectedIndex].value + ':1,';
	}
	
	if( typeof(inform.menu2) != "undefined" ) {
		if(inform.menu2.options[inform.menu2.selectedIndex].value != '') {
			prodListStr += inform.menu2.options[inform.menu2.selectedIndex].value + ':1,';
		} 
	} 
		
	
	if( typeof(inform.optionalAdd) != "undefined" ) {
		if( inform.optionalAdd.checked == 1 ) {
			prodListStr += inform.optionalItem.value + ':1,';
		}
	}
	
	if( typeof(inform.optionalAdd2) != "undefined" ) {
		if( inform.optionalAdd2.checked == 1 ) {
			prodListStr += inform.optionalItem2.value + ':1,';
		}
	}

	if( typeof(inform.optionalAdd3) != "undefined" ) {
		if( inform.optionalAdd3.checked == 1 ) {
			prodListStr += inform.optionalItem3.value + ':1,';
		}
	}
	if ( prodListStr == '' ) { 
		alert ('Please choose a product to purchase.'); 
		return false; 
	}
	
	inform.ProdList.value = prodListStr;
}
