/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}


var http = createRequestObject(); 


function getOgaData(){	
	
	http.open('post',  'oga_p.php');
	
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.onreadystatechange = handleData;
	
	
	//http.open('get', 'internal_request.php?action=get_products&id=' 
	//		+ document.form_category_select.select_category_select.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send('search_1=' + document.form.search_1.value +
		      '&search_2=' + document.form.search_2.value +
		      '&search_3=' + document.form.search_3.value);	
	

}



function getGbnData(){	
	
	http.open('post',  'gbn_p.php');
	
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.onreadystatechange = handleData;
	
	
	//http.open('get', 'internal_request.php?action=get_products&id=' 
	//		+ document.form_category_select.select_category_select.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send('exchange_a=' + document.form.exchange_a.value +'&symbol_a=' + document.form.symbol_a.value +
		      '&exchange_b=' + document.form.exchange_b.value +'&symbol_b=' + document.form.symbol_b.value +
		      '&exchange_c=' + document.form.exchange_c.value +'&symbol_c=' + document.form.symbol_c.value);	
	

}
function getKscData(){	
	
	http.open('post',  'ksc_p.php');
	
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.onreadystatechange = handleData;
	
	
	//http.open('get', 'internal_request.php?action=get_products&id=' 
	//		+ document.form_category_select.select_category_select.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send('search_1=' + document.form.search_1.value +
		      '&search_2=' + document.form.search_2.value +
		      '&search_3=' + document.form.search_3.value);	
	

}

function getTsgData(){	
	
	http.open('post',  'tsg_p.php');
	
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.onreadystatechange = handleData;
	
	
	//http.open('get', 'internal_request.php?action=get_products&id=' 
	//		+ document.form_category_select.select_category_select.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send('exchange=' + document.form.exchange.value +'&symbol=' + document.form.symbol.value +
		      '&growthone=' + document.form.growthone.value +'&growthtwo=' + document.form.growthtwo.value +
		      '&years=' + document.form.years.value +'&discount=' + document.form.discount.value);	
	

}

function sendMail(){	
	
	http.open('post',  'mail.php');
	
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.onreadystatechange = handleData;
	
	
	//http.open('get', 'internal_request.php?action=get_products&id=' 
	//		+ document.form_category_select.select_category_select.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send('name=' + document.form.name.value +'&email=' + document.form.email.value +
		      '&subject=' + document.form.subject.value +'&message=' + document.form.message.value);	
	

}

function getQuote(){	
	


	http.open('POST',  'handlequote.php');
   http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.onreadystatechange = handleData;
	
	
	//http.open('get', 'internal_request.php?action=get_products&id=' 
	//		+ document.form_category_select.select_category_select.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	//http.send('symbol=' + document.form.symbol.value);
	http.send('&symbol=' + document.form.symbol.value); 

	

	

}



/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleData(){
	/* 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;
		
		/* Change the div element */
		document.getElementById('data_cage').innerHTML = response;
	}
}


