var highlightcolor = "blue";

function completeOne() {
	document.getElementById('onecont').className='step';
    document.getElementById('fourcont').className='step';
    document.getElementById('finishcont').className='step';
	document.getElementById('two').innerHTML = document.getElementById('waiter').innerHTML;
	document.getElementById('three').innerHTML = '';
	url = "two.php?vol=" + this.document.formone.volume.value;
	simpleXMLHttpRequest(url, loadTwo, null2);
	document.formone.submitbutton.disabled = true;
	document.getElementById('twocont').className='step highlighted';
}

function completeTwo() {
    document.getElementById('onecont').className='step';
    document.getElementById('fourcont').className='step';
    document.getElementById('finishcont').className='step';
    document.getElementById('twocont').className='step highlighted';
	document.getElementById('three').innerHTML = document.getElementById('waiter').innerHTML;
	url = "three.php?vol=" + this.document.formone.volume.value + "&book=" + this.document.formone.book.value;
	simpleXMLHttpRequest(url, loadThree, null2);
	document.formone.submitbutton.disabled = false;
}

function completeThree() {
	document.getElementById('twocont').className='step';
	document.getElementById('four').innerHTML = document.getElementById('waiter').innerHTML;
	url = foursrc +"?vol=" + this.document.formone.volume.value + "&book=" + this.document.formone.book.value + "&ch=" + this.document.formone.ch.value;
	simpleXMLHttpRequest(url, loadFour, null2);
	document.getElementById('fourcont').className='step highlighted';
}

function completeFour() {
	document.getElementById('fourcont').className='step';
	document.getElementById('finishcont').className='step highlighted';
}

function null2(a,b) {
alert('failure '+a+' '+b);
}

function loadTwo(xml, text) {
	document.getElementById('two').innerHTML = text;
}

function loadThree(xml, text) {
        document.getElementById('three').innerHTML = text;
}

function loadFour(xml, text) {
	document.getElementById('four').innerHTML = text;
	calculateRate();
}

function calculateRate() {
    url = fourrate +"?vol=" + document.formone.volume.value + "&book=" + document.formone.book.value + "&ch=" + document.formone.ch.value;
    if (document.formone.month && document.formone.day && document.formone.year) {
	    url += "&year=" + document.formone.year.value;
	    url += "&month=" + document.formone.month.value;
	    url += "&day=" + document.formone.day.value;
		simpleXMLHttpRequest(url, loadFourRate, null2);
	} else if (document.formone.days) {
	   url += "&days=" + document.formone.days.value;
       simpleXMLHttpRequest(url, loadFourRate, null2);
	}
}

function loadFourRate(xml, text) {
        document.getElementById('fourrate').innerHTML = text;
}
