function initOrderType(orderType) {
	if (orderType == '') {
		show("deliverypaymentmethod");
		show("DELIVERY");	
		hide("collectionpaymentmethod");
		hide("COLLECTION");		
	}
	if (orderType == 'COLLECTION') {
		show("collectionpaymentmethod");
		show("COLLECTION");		
		hide("deliverypaymentmethod");
		hide("DELIVERY");
	}
	if (orderType == 'DELIVERY') {
		show("deliverypaymentmethod");
		show("DELIVERY");	
		hide("collectionpaymentmethod");
		hide("COLLECTION");	
	}	
}

function changeOrderType(orderType) {
	if (orderType == 'COLLECTION') {
		show("collectionpaymentmethod");
		show("COLLECTION");		
		hide("deliverypaymentmethod");
		hide("DELIVERY");
	}
	if (orderType == 'DELIVERY') {
		show("deliverypaymentmethod");
		show("DELIVERY");		
		hide("collectionpaymentmethod");
		hide("COLLECTION");
	}
	clearSelectOrderType();
}

function clearSelectOrderType() {
	document.getElementById('collectionpaymentmethod').options[0].selected = true;
	document.getElementById('deliverypaymentmethod').options[0].selected = true;
	document.getElementById('COLLECTION').options[0].selected = true;	
	document.getElementById('DELIVERY').options[0].selected = true;
}

function hide(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function show(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function MM_jumpMenu(target, selObj, restore) {
    eval(target+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex = 0;
}

function nestedDiv(attributeGroupId, attributeId) {
	$.ajax({
		type: "POST",
		url: "/ajaxattribute",
		data: ({attributeId : attributeId}),
		success: function(responseText){$('#nested_'+attributeGroupId).html(responseText);},
		dataType: "html"
	});	
}

function populateNestedDiv() {
	var values = {};
	$.each($('#submenuform').serializeArray(), function(i, field) {
	    values[field.name] = field.value;
	    if (isNumber(field.name)) {
	    	
	    }
	});	
}

function isNumber(n) {
	 return !isNaN(parseFloat(n)) && isFinite(n);
}	
