// Global AJAX object

function getXmlHttpObject()
{
	var xmlHttp = null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
	  	{
	  		try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
	  		catch (e)
			{
				// Browser does not support AJAX
				return false;
			}
		}
	}
	return xmlHttp;
}



function changePortfolio(a, clientid, catname)
{
  var xmlHttp;
	xmlHttp = null;
	xmlHttp = getXmlHttpObject();

	if(xmlHttp != null)
	{
		xmlHttp.onreadystatechange=function()
		{
			// We are going to write some code here
			if(xmlHttp.readyState==4)
			{
				var xmlDoc=xmlHttp.responseXML.documentElement;
				document.getElementById("portcatname").innerHTML=xmlDoc.getElementsByTagName("portcatname")[0].childNodes[0].nodeValue;
				document.getElementById("portfoliosectionnav").innerHTML=xmlDoc.getElementsByTagName("portfoliosectionnav")[0].childNodes[0].nodeValue;
				document.getElementById("portfolionav").innerHTML=xmlDoc.getElementsByTagName("portfolionav")[0].childNodes[0].nodeValue;
				document.getElementById("clientcontainer").innerHTML=xmlDoc.getElementsByTagName("clientcontainer")[0].childNodes[0].nodeValue;
			}
		}

		var programlink;
		programlink = 'include/clientajax.php';
		programlink += '?id=' + clientid;
		programlink += '&catname=' + catname;

		// Do a GET request, to a URL, and asynchronous is true
		xmlHttp.open("GET",programlink,true);

		xmlHttp.send(null);

		// Disable the anchor, if JavaScript is turned on
		return false;
	} else {
		// If the AJAX object could not be created, then return true to allow the link to work
		return true;
	}

}

