// XMLHttpRequest function to initiate request object 
function AJAX() { 
	var o = false; 
	/*@cc_on @*/ 
	/*@if (@_jscript_version >= 5) 
		try { 
			o = new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) { 
			try { 
				o = new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (E) { 
				o = false; 
			} 
		} 
	@end @*/ 
	if (!o && typeof XMLHttpRequest!='undefined') { 
		o = new XMLHttpRequest(); 
	}
	
	return o; 
} 



//////////////////////////////////new the code////////////////////////////////
/* The variable http will hold our new XMLHttpRequest object. */
var http = AJAX(); 

function populateStep2(pointA){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	//document.getElementById('step4').style.display='none';
	http.open('get', '/ecs/cusRateQuote.cfm?pointA=' + pointA);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleStep2; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

function populateStep3(pointB){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	document.getElementById('step3').style.display='inline';
	//document.getElementById('step4').style.display='none';
	http.open('get', '/ecs/cusCalcRate.cfm?pointB=' + pointB);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleStep3; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

//FOR RESERVATION CENTER
function typelocal(local){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', '/ecs/cusTypeLocal.cfm?local=' + local);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = localHandleStep; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

function localHandleStep(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('nextrow').innerHTML = response;
	}else if (http.readyState == 1){
		document.getElementById('nextrow').innerHTML = 'LOADING...';
	//}else{
		//document.getElementById('nextrow').innerHTML = 'ERROR  ' + http.readyState;
	}
}

function typelocaldrop(localDrop){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', '/ecs/cusTypeLocalDrop.cfm?localDrop=' + localDrop);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = localDropHandleStep; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

function localDropHandleStep(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('nextrowdrop').innerHTML = response;
	}else if (http.readyState == 1){
		document.getElementById('nextrowdrop').innerHTML = 'LOADING...';
	//}else{
	//	document.getElementById('nextrowdrop').innerHTML = 'ERROR  ' + http.readyState;
	}
}


function paymentopt(opt){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', '/ecs/cusPaymentOptions.cfm?opt=' + opt);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = paymentoptHandleStep; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

function paymentoptHandleStep(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('payment').innerHTML = response;
	}else if (http.readyState == 1){
		document.getElementById('payment').innerHTML = 'LOADING...';
//	}else{
	//	document.getElementById('payment').innerHTML = 'ERROR  ' + http.readyState;
	}
}
//END RESERVATION CENTER







//for RIGHT SIDE
function populateCities(pointA){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	document.getElementById('step4').style.display='inline';
	//document.getElementById('step4').style.display='none';
	http.open('get', '/ecs/cusRateQuote_right.cfm?pointA=' + pointA);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleStep4; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

function handleStep4(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('step4').innerHTML = response;
	}else if (http.readyState == 1){
		document.getElementById('step4').innerHTML = 'LOADING...';
//	}else{
//		document.getElementById('step4').innerHTML = 'ERROR  ' + http.readyState;
	}
}
//END for RIGHT SIDE

function handleStep2(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('step2').innerHTML = response;
		//alert("here");
		//populateStep3();
		//document.getElementById('step2').style.display='inline';
	}else if (http.readyState == 1){
		document.getElementById('step2').innerHTML = 'LOADING...';
//	}else{
//		document.getElementById('step2').innerHTML = 'ERROR  ' + http.readyState;
	}
}

function handleStep3(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('step3').innerHTML = response;
	}else if (http.readyState == 1){
		document.getElementById('step3').innerHTML = 'LOADING...';
//	}else{
//		document.getElementById('step3').innerHTML = 'ERROR  ' + http.readyState;
	}
}
