

	/**
	 * Copy a yacht item from the "all yachts" list to the "selected yachts" list, 
	 * then disable the item in the "all yachts" list
	 */
	function addListItem(event) {
	
		/* Get yacht lists tags */
		var pool = document.getElementById("FranchisePool");
		var selection = document.getElementById("FranchiseSelection");
		
		/* Loop over "all yachts" list */
		for (var i=0; i < pool.options.length; ++i) {

			/* If item is selected */
			if (pool.options[i].selected == true) {

				/* Check to see if the item already exists in the "selected yachts" list */
				var index = isSelectOption(selection, 
				                           pool.options[i].text, 
										   pool.options[i].value);
										   
				/* If the item is not already in the "selected yachts" list, then add it */		   
				if (index === false) {

					if (selection != null && selection.options != null) {
					
						/* Copy item to "selected yachts" list */
						selection.options[selection.options.length] = 
						new Option(pool.options[i].text, pool.options[i].value, false, false);
						
					}
								
								
					/* Disable and deselect the item in the "all yachts" list */
					pool.options[i].disabled = true;
					pool.options[i].selected = false;
				}
			}
		}
	}
	
	
	
	/**
	 * Remove a yacht item from the "selection" list,
	 * then re-enable theitem in the "pool" list 
	 */
	function removeListItem(event) {
	
		/* Get yacht lists tags */
		var pool = document.getElementById("FranchisePool");
		var selection = document.getElementById("FranchiseSelection");		
		
		/* Loop over "selected yachts" list */
		for (var i=0; i < selection.options.length; ++i) {
		
			/* If item is selected */
			if (selection.options[i].selected == true) {

				/* Check to see if the item exists in the "all yachts" list */
				var index = isSelectOption(pool, 
				                           selection.options[i].text, 
										   selection.options[i].value);
										   
				/* If the item exists in the "all yachts" list, then re-enable it */
				if (index !== false) { 
					pool.options[index].disabled = false; 
				}
				
				/* Remove selected item from the "selected yachts" list */
				selection.remove(i);
				
				/* we just modified the "selected yachts" list which throws off the 
				 * indexes so we need to restart the loop again from the beginning */
				i = -1;
			}
		}
		
	}
	
	
	
 	/**
	 * Search a <select> tag for an <option> tag with the specified text and value
	 * if found, return the <option> tag's index
	 * else return boolean false
	 */
	function isSelectOption(selectObj, text, value) {
	
		if (selectObj != null && selectObj.options != null) {
		
			for (var i=0; i < selectObj.options.length; ++i){
			
				if (selectObj.options[i].text == text && 
				    selectObj.options[i].value == value) {
					return i;
				}
			}
			
			return false;
		}
	}


	
	