/*
	Talisma Javascript Code
	Author: Eric Russell, 2008.06.03
	
	This code is for creating the dropdown selections on the "Contact Us" form.
	When a user makes a selection from the first dropdown, we need to either
	redraw the secondary dropdown with the required contents from the various arrays
	below, else we need to write out a blank, disabled dropdown.
*/

// Dropdown arrays
var ordersDetails        = new Array ("Order Inquiry", "Shipping Inquiry", "Furniture Orders", "Returns", "Store Purchases", "Other");
var cancelDetails        = new Array ();
var assistanceDetails    = new Array ();
var productsDetails      = new Array ();
var registryDetails      = new Array ("Manage Registry", "Existing Order Inquiry", "Gift-Giver Inquiry", "Store Registries", "Other");
var siteFeedbackDetails  = new Array ();
var storeFeedbackDetails = new Array ();
var genFeedbackDetails   = new Array ();
var unsubDetails         = new Array ();
var otherDetails         = new Array ();
var swatchesDetails      = new Array ();


// Variables for the possible combinations of dropdown blocks
var defaultContentContainerOpen  = '<p><label>&nbsp;</label>';
var defaultContentDropStart      = '<select name="select2" id="sel2" class="dropDown"';
var defaultContentDropStartSel   = '><option value="req" selected="selected">Please Select</option>';
var defaultContentDropClose      = '</select>';
var defaultContentDropNone       = ' disabled></select>';
var defaultContentContainerClose = '</p>';
//var blankSecondDropdown          = defaultContentContainerOpen + defaultContentDropStart + defaultContentDropNone + defaultContentContainerClose;
var blankSecondDropdown          = "";
var selValForSecDropDownEditMode ="";

function createDetailList (selection) {
	// If the user has made a selection, we run through this loop
	// to generate the code for the second dropdown box.
	if (selection != '') {
		var contentToInsertStart = defaultContentContainerOpen + defaultContentDropStart + defaultContentDropStartSel;
		var contentToInsertClose = defaultContentDropClose + defaultContentContainerClose;
		var selectionArray = eval (selection + 'Details');
		var selectionLength = selectionArray.length;
		var selectionDetails = "";
		
		// Test to see if the user's selection has details for the second dropdown
		if (selectionLength > 0) {
			// The user's selection has details for the second dropdown, so create the list and write the output
			for (i = 0; i < selectionLength; i++) {
				if(selectionArray[i] == selValForSecDropDownEditMode){
					selectionDetails = selectionDetails +
				                   '<option value="' + selectionArray[i] + '" selected>' + selectionArray[i] + '</option>';
				}else{
				selectionDetails = selectionDetails +
				                   '<option value="' + selectionArray[i] + '">' + selectionArray[i] + '</option>';
				}
			}
			
			document.getElementById ('detailContent').innerHTML = contentToInsertStart + selectionDetails + contentToInsertClose;
			document.getElementById ('detailContent').className = "";
		}
		
		else {
			// The user's selection does not have details for the second dropdown, so write the blank dropdown code
			document.getElementById ('detailContent').innerHTML = blankSecondDropdown;
			document.getElementById ('detailContent').className = "nodetails";
		}
		
	}
	
	// If the user resets the first dropdown to the default,
	// we clear the second dropdown and disable it again.
	else {
		document.getElementById ('detailContent').innerHTML = blankSecondDropdown;
		document.getElementById ('detailContent').className = "nodetails";
	}
}
