debug = 0;

// Firefox selectNodes, selectSingleNode compatibility
if(document.implementation.hasFeature("XPath","3.0"))
{	//selectNodes
	//prototyping the XMLDocuemtn
	XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
	{	if(!xNode)
		{	xNode = this;
		}
		var oNSResolver = this.createNSResolver(this.documentElement);
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver,
				XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
		var aResult = [];
		for(var i=0; i<aItems.snapshotLength; i++)
		{	aResult[i] = aItems.snapshotItem(i);
		}
		return aResult;
	}
	//prototyping the Element
	Element.prototype.selectNodes = function(cXPathString)
	{	if(this.ownerDocument.selectNodes)
		{	return this.ownerDocument.selectNodes(cXPathString,this);
		}
		else
		{	throw "For XML Elements Only";
		}
	}

	//selectSingleNode
	//prototyping the XMLDocument
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
	{	if(!xNode)
		{	xNode = this;
		}
		var xItems = this.selectNodes(cXPathString, xNode);
		if(xItems.length > 0)
		{	return xItems[0];
		}
		else
		{	return null;
		}
	}
	//prototyping the Element
	Element.prototype.selectSingleNode = function(cXPathString)
	{	if(this.ownerDocument.selectSingleNode)
		{	return this.ownerDocument.selectSingleNode(cXPathString, this);
		}
		else
		{	throw "For XML Elements Only";
		}
	}
}

function showhidden(id,showorhide)
{	var objid = document.getElementById(id);
	objid.style.visibility = showorhide;
}

function ajax_request(url,params,fieldobj,type)
{	//branch for native XMLHttpRequest object
	if(window.XMLHttpRequest)
	{	try
		{	req = new XMLHttpRequest();
		}
		catch(e)
		{	req = false;
		}
	}
	//branch for IE/Windows ActiveX version
	else if(window.ActiveXObject)
	{	try
		{	req = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch(e)
		{	req = false;
		}
	}
	if(req)
	{	req.onreadystatechange = function()
			{	if(req.readyState == 4)
				{	if(req.status == 200)
					{	if(type == "shopcart")
						{	complete_shopcart(req,fieldobj);
						}
						else if(type == "parts")
						{	complete_parts(req,fieldobj);
						}
						else if(type == "resources")
						{	complete_resources(req,fieldobj);
						}
					}
					else
					{	alert("Error creating XMLHTTPrequest " + req.readyState);
					}
				}
			}

		req.open("POST", url, true);
		req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		if(debug)
		{	window.open(url+params+'&debug=1','debugwin','');
		}
		req.send(params);
	}
}
