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"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the XMLHttp object
}

var http = createRequestObject(); 

// Function called to get the strains list
function getStrains(strain_id){
	http.open('get', 'internal_request.php?action=get_strains&id=' 
			+ strain_id);
	http.onreadystatechange = handleShit; 
	http.send(null);
}

// Function called to get the strains list for editing
function getStrainsForEdit(strain_id){
	http.open('get', 'internal_request.php?action=get_strains_for_edit&id=' 
			+ strain_id);
	http.onreadystatechange = handleShit; 
	http.send(null);
}

// Function called to display the selected strain for editing
function listStrainsForEdit(strain_id){
	http.open('get', 'internal_request.php?action=list_strains_for_edit&id=' 
			+ strain_id);
	http.onreadystatechange = handleShitUS; 
	http.send(null);
}

// Function called to get the strains list for adding lineage
function getStrainsForLineage(strain_id){
	http.open('get', 'internal_request.php?action=get_strains_for_lineage&id=' 
			+ strain_id);
	http.onreadystatechange = handleShit; 
	http.send(null);
}
// Function called to display the selected strain for editing
function listStrainsForLineage(strain_id,breeder_id){
	http.open('get', 'internal_request.php?action=list_strains_for_lineage&id=' 
			+ strain_id + '&br_id=' + breeder_id);
	http.onreadystatechange = handleShitUS; 
	http.send(null);
}

// Function called to get breeder info
function getBreederInfo(breeder_id){
	http.open('get', 'internal_request.php?action=get_breeder_info&id=' 
			+ breeder_id);
	http.onreadystatechange = handleShitUS; 
	http.send(null);
}

// Function called to get and display lineage
function getLineage(strain_id){
	http.open('get', 'internal_request.php?action=get_lineage&id=' 
			+ strain_id);
	http.onreadystatechange = handleShitUS; 
	http.send(null);
}

// Function called to handle styled breeder or strain lists returned from internal_request.php
function handleShit(){
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
		document.getElementById('result_cage').innerHTML = response;
	}
}

// Function called to handle unstyled data returned from internal_request.php
function handleShitUS(){
	/* Note: can also use following readyStates if needed later
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
	*/
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
		document.getElementById('results').innerHTML = response;
	}
}
