/**
 * The shop url.  Populated by ecommerce.
 */
var ecomUrl = '';
/**
 * The current inner select box ID.
 */
var currInner;
/**
 * The array of parent select box IDs which are direct links and do not have child select boxes.
 */
var menu_exceptions = new Array();
/**
 * Takes a select element, and redirects page based on selected index.
 *
 * @param object elem the select element
 * @param string sess the session url string to append
 */
function loadBrowsePage(elem, sess) {
	/* build the url */
	var dpt = 'c';
	var dci = elem[elem.selectedIndex].value;
	var currdci = elem.id;
	var url = ecomUrl + '?func=14&DPT=' + dpt + '&DCI=' + dci + '&olddci=' + currdci + sess;
	
	/* load the url */
	loadPage(url);
}
/**
 * Takes a select element, hides the current inner select box, and displays its child select box.
 *
 * @param object elem the select element
 * @param string sess the session url string to append, for exceptions
 */
function loadInnerSelect(elem, sess) {
	var innerElemId = elem[elem.selectedIndex].value;
	/* check if the selected element is an exception */
	for (var i = 0; i < menu_exceptions.length; i++) {
		/* if it is an exception, don't display child select */
		if (menu_exceptions[i] == innerElemId) {
			loadBrowsePage(elem, sess);
		}
	}
	/* display the new one, hide the current one */
	getElem(innerElemId).style.display = 'block';
	getElem(currInner).style.display = 'none';
	
	/* set current to be the new one */
	currInner = innerElemId;
}
/**
 * Redirects page to given url.
 *
 * @param string url the url to redirect to
 */
function loadPage(url) {
	window.location = url;
}
/**
 * Retrieves an element with given id.
 *
 * @param string id the id of the element to retrieve
 * @return object the element
 */
function getElem(id) {
	try {
		if (document.all) {
			return document.all(id);
		} else if (document.getElementById(id)) {
			return document.getElementById(id);
		} else {
			return null;
		}
	} catch (e) {}
}