function getXMLHTTP() { //fuction to return the xml http object
	var xmlhttp=false;	
	try{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e)	{		
		try{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1){
				xmlhttp=false;
			}
		}
	}		
	return xmlhttp;
}

// -- CHAINS
// ============================
function chain_getModel(modelId,pid,cid,ref) {		
	var strURL="includes/cchain_findModel.php?modelID="+modelId;
	strURL += "&pid=" + pid; 
	strURL += "&cid=" + cid; 
	strURL += "&ref=" + ref; 
	var req = getXMLHTTP();
	
	if ((req)&&(modelId!="na")) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {			
					document.getElementById('modelsdiv').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

// -- BARS
// ============================
function bars_getModel(modelId,pid,cid,ref) {		
	var strURL="includes/cbars_findModel.php?parentCatID="+modelId;
	strURL += "&pid=" + pid; 
	strURL += "&cid=" + cid; 
	strURL += "&ref=" + ref; 
	var req = getXMLHTTP();
	
	if ((req)&&(modelId!="na")) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('modelsdiv').innerHTML=req.responseText;
					initalizetooltip(); //run this function to initialise the page on dynamic generation fo this section so the tooltip can work - JB
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
}
function bars_getGroup(categoryId,pid,cid,ref) {		
	var strURL="includes/cbars_findGroup.php?category_ID="+categoryId;
	strURL += "&pid=" + pid;
	strURL += "&cid=" + cid;
	strURL += "&ref=" + ref;
	var req = getXMLHTTP();
	
	if ((req)&&(categoryId!="na")) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					document.getElementById('groupsdiv').innerHTML=req.responseText;
					initalizetooltip(); //run this function to initialise the page on dynamic generation fo this section so the tooltip can work - JB
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

// -- Bar Chain Combo
// ============================
function barChainCombo_getModel(modelId,pid,cid,ref) {		
	var strURL="includes/barChainCombo_findModel.php?modelID="+modelId;
	strURL += "&pid=" + pid; 
	strURL += "&cid=" + cid; 
	strURL += "&ref=" + ref; 
	var req = getXMLHTTP();
	
	if ((req)&&(modelId!="na")) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {			
					document.getElementById('modelsdiv').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

// -- SPROCKETS
// ============================
function sprocket_getModel(modelId,pid,cid,ref) {		
	var strURL="includes/sprocket_findModel.php?parentCatID="+modelId;
	strURL += "&pid=" + pid; 
	strURL += "&cid=" + cid; 
	strURL += "&ref=" + ref; 
	var req = getXMLHTTP();
	
	if ((req)&&(modelId!="na")) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('modelsdiv').innerHTML=req.responseText;
					initalizetooltip(); //run this function to initialise the page on dynamic generation fo this section so the tooltip can work - JB
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
}
function sprocket_getGroup(categoryId,pid,cid,ref) {		
	var strURL="includes/sprocket_findGroup.php?categoryID="+categoryId;
	strURL += "&pid=" + pid; 
	strURL += "&cid=" + cid; 
	strURL += "&ref=" + ref; 
	var req = getXMLHTTP();
	
	if ((req)&&(categoryId!="na")) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					document.getElementById('groupsdiv').innerHTML=req.responseText;
					initalizetooltip(); //run this function to initialise the page on dynamic generation fo this section so the tooltip can work - JB
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}