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
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/

var http = createRequestObject(); 


/* Function to get the text */
function getText(pageID,thisText){
	/* Create the request. The first argument to the open function is the method (POST/GET), and the second argument is the url... */
	if (pageID == "home" || pageID == "enviro") {
		http.open('get', 'includes/php/intro_text.inc.php?action=getText&id=' + thisText + '&pageID=' + pageID);
	} else {
		http.open('get', '../includes/php/intro_text.inc.php?action=getText&id=' + thisText + '&pageID=' + pageID);	
	}
	http.onreadystatechange = handleText; 
	http.send(null);
}

function handleText(){
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('intro_text').innerHTML = response;
	}
}


/* Function to get the image */
function getImg(pageID,thisImg){
	http.open('get', '../includes/php/packaging_img.inc.php?action=getImg&id=' + thisImg + '&pageID=' + pageID);
	http.onreadystatechange = handleImg; 
	http.send(null);
}

function handleImg(){
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('mid_container_right').innerHTML = response;
	}
}


/* Function to get the gallery image */
function getGalleryImg(pageID,thisImg,divID,textDivID){
	var opts = { method: 'get' }
	new Ajax.Updater(divID,'../includes/php/gallery_img.inc.php?action=getGalleryImg&id=' + thisImg + '&pageID=' + pageID, opts);
	new Ajax.Updater(textDivID,'../includes/php/gallery_txt.inc.php?action=getGalleryTxt&id=' + thisImg + '&pageID=' + pageID, opts);
}

/* Function to opena popup window */
function openWindow(thisImg) {
	window.open('../preview.php?img=' + thisImg,'preview','top=20,left=20,width=400,height=400,scrollbars=no,menubar=no,toolbar=no');	
}