var xmlhttp;
/*==================================
Function to intialize XMLHttpRequest
===================================*/
function Get_XML_HTTP_Object(){
	 // code for IE7+, Firefox, Chrome, Opera, Safari
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	// code for IE6, IE5
	} else if (window.ActiveXObject) {
		 return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return null;
	}
}
function loadBrand (pgID) {
	
	
	//set xmlhttp
	xmlhttp = Get_XML_HTTP_Object();
	//Show message for older browsers
	if (xmlhttp == null){
		document.getElementById("brandBox").innerHTML = "Your browser does not support XMLHTTP!";
		return;
	}
	//Set response function
	xmlhttp.onreadystatechange = myResponse;
	//Put form fields into variables
	var myVars = "pgID=" + pgID;
	
	//send request
	xmlhttp.open("POST","http://www.northamericanpet.com/wp-content/themes/overeasy/includes/grabBrandData.php",true);
	//send header information
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", myVars.length);
	xmlhttp.setRequestHeader("Connection", "close");
	//send parameters
	xmlhttp.send(myVars);
	
	/*==============================================
	Process server response
	================================================*/
	function myResponse(){
		//if request is complete
		if(xmlhttp.readyState == 4) {
			//set Response
			var Response = xmlhttp.responseText;
			var myArray = Response.split("splithere");
			document.getElementById("brand_content").innerHTML = myArray[0];
			document.getElementById("brand_bg").style.backgroundImage = "url(" + myArray[1] +")";
		} 
	}
};
	

