
	// --- delivery_item_class ---
	
	function delivery_item_class(parent, container) {
		this.parent = parent;
		this.container = container;
		this.div = null;
		this.radio = null;
		this.next = null;
		
		this.construct();
	}
	
	delivery_item_class.prototype.construct = function() {
		var f, current, stack = new Array();
		stack[stack.length] = this.container;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			switch (current.tagName.toUpperCase()) {
				case "DIV" :
					if (current.className == "delivery_block") this.div = current;
					break;
					
				case "INPUT" :
					if (current.type = "radio") this.radio = current;
					break;
			}
			
			if (current.childNodes.length > 0) {
				for (f = 0; f < current.childNodes.length; f++)
					if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
			}
		}
		
		if (this.div != null && this.radio != null) {
			var self = this;
			var loop = this.container;
			
			while (this.next == null && loop != null) {
				if (loop.nodeType == 1 && loop.tagName.toUpperCase() == "DIV" && loop.className == "payment_block") this.next = loop;
				else loop = loop.nextSibling;
			}
			
			this.radio.onclick = function() {
				self.parent.select(self);
			}
			
			this.next.style.display = "none";
		}
	}
	
	delivery_item_class.prototype.swap_to = function(ref) {
		ref.appendChild(this.div);
		this.container.style.display = "none";
	}
	
	delivery_item_class.prototype.select = function() {
		this.next.style.display = "block";
	}
	
	delivery_item_class.prototype.unselect = function() {
		this.next.style.display = "none";
	}

	// --- delivery_content_class ---

	function delivery_content_class(container) {
		this.container = container;
		this.items = new Array();
		
		this.before = null;
		this.first_heading = null;
		this.div = null;
		this.i_top = null;
		this.i_bottom = null;
		
		this.construct();
	}
	
	delivery_content_class.prototype.construct = function() {
		var cr, ref, pos = 0, start = true;
		
		while (pos < this.container.childNodes.length) {
			cr = this.container.childNodes[pos];
			if (cr.nodeType == 1 && cr.tagName.toUpperCase() == "DIV") {
				if (cr.className == "input_table") {
					ref = new delivery_item_class(this, cr);
					this.items[this.items.length] = ref;
				
				} else if (cr.className == "input_heading") {
					if (start) {
						this.first_heading = cr;
						start = false;
					} else cr.style.display = "none";
				}
			}
		
			pos++;
		}
		
		this.div = document.createElement("DIV");
		this.div.className = "input_table";
		
		this.i_top = document.createElement("SPAN");
		this.i_top.className = "i_top";
		
		this.i_bottom = document.createElement("SPAN")
		this.i_bottom.className = "i_bottom";
		
		this.div.appendChild(this.i_top);
		this.div.appendChild(this.i_bottom);
		
		this.container.insertBefore(this.div, this.first_heading.nextSibling);
		
		var f;
		for (f = 0; f < this.items.length; f++)
			this.items[f].swap_to(this.div);
			
		var founded = null;
		f = 0;
		
		while (founded == null && f < this.items.length)
			if (this.items[f].radio.checked) founded = this.items[f];
			else f++;
			
		if (founded != null) this.select(founded);
	}
	
	delivery_content_class.prototype.select = function(item_ref) {
		if (this.before != null) this.before.unselect();
		item_ref.select();
		this.before = item_ref;
	}
