
var showing;
var order = Array();
order['first'] = 1;
order['second'] = 2;
order['third'] = 3;

function subm(f,a){
	f.action=a;
	f.submit();
}


function init() {
	
	if(document.getElementById('shopnav')) {
		initShopNavigation();
	}

}

function initShopNavigation() {
	var n = document.getElementById('shopnav');
	var lists = n.getElementsByTagName('ul');
	for(var i=0;i<lists.length;i++) {
		// hide all sub levels to start with
//		if(lists[i].className != 'first')
//			lists[i].style.display = 'none';

		// scan the current lists
		var items = lists[i].getElementsByTagName('li');
		for(var j=0;j<items.length;j++) {
			// even listener
			items[j].childNodes[0].onclick = function() {
				var subs = this.parentNode.getElementsByTagName('ul');
				if(subs.length>0) {
					// does for sub menu
						// toggle display or hide
						if(subs[0].style.display == 'none') {
							if(showing)
								showing.className = '';
							// close everything but parents
							for(k=0;k<lists.length;k++) {
								if(order[lists[k].className]>=order[subs[0].className]) {
									if(lists[k]!=subs[0])
										lists[k].style.display = 'none';
								}
							}
							subs[0].style.display = 'block';
							this.className ='active';
							showing = this;
						}
						else {
							subs[0].style.display = 'none';
							this.className = '';
						}
				}
				if (this.title!='active')
					return false;
			}
		}

	}
}



function checkTerms(){
	if(document.checkOutForm.terms_read.checked == false){
		alert("You need to read the terms and conditions!");
		return false;
	} else { 
		return true; 
	}
}


// window.onload = init;


