function add_to_estimate(productcode,partnum,store,claim,claim_search_number){

var r=confirm("Add part "+partnum+" to list?" );
if (r==true)
{

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser isn't supported by HeavyTruckParts.Net");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById(productcode+'_'+partnum);
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	var queryString = "?pc=" + productcode 
			+"&partnum=" + partnum 
			+"&store="+store
            +"&claim="+claim
            +"&claim_search_number="+claim_search_number;
	ajaxRequest.open("GET", "./myestimate/estimate_add_part.php" + queryString, true);
	ajaxRequest.send(null); 
}

}

// getAjaxObject()
// Charlie Scherer, 2/1/2007
// Description:
// 	Tries to create an AJAX object.
// returns:
//	an AJAX object or null for failure.
function getAjaxObject()
{
	var ajaxRequest;
	try
	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				// Something went wrong
				ajaxRequest = null;
			}
		}
	}
	return ajaxRequest;
}

// replaceInnerHTMLOnReady(ajaxRequest, elementId)
// Charlie Scherer, 2/1/2007
// Arguments:
//	ajaxRequest - an active ajaxRequest
//	elementId   - the id of an element with an innerHTML property
// Description:
//	Sets the innerHTML property of the indicated element with the
//	server response to the ajax when the readyState becomes 4.
// Returns:
//	void
function replaceInnerHTMLOnReady(ajaxRequest, elementId)
{
	if(ajaxRequest.readyState == 4)
	{
		var element = document.getElementById(elementId);
		element.innerHTML = ajaxRequest.responseText;
	}
}

// buildQueryString(form)
// Charlie Scherer, 2/1/2007
// Arguments:
//	form - a form
// Description:
//	Builds a string for appending to a URL or putting in a URI encoded post
//	request out of a form.
// Returns:
//	A string suitable for passing the form's info an a URL
function buildQueryString(form)
{
	var queryString = "";
	for(var i = 0; i < form.length; ++i)
	{
	    if(i != 0)
		{
			queryString += "&";
		}
		queryString += encodeURI(form[i].name);
		queryString += "="
		queryString += encodeURI(form[i].value);
	}
	return queryString;
}
function sendPostRequest(ajax, url, query)
{
	ajax.open("POST", url);
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajax.setRequestHeader("Content-length", query.length);
	ajax.setRequestHeader("Connection", "close");
	return ajax.send(query);
}
function showPopup(popupName)
{
	var popupDiv = document.getElementById(popupName);

	popupDiv.style.visibility = 'visible';
	popupDiv.style.zIndex = '1';

}
function hidePopup(popupName)
{
	var popupDiv = document.getElementById(popupName);
	popupDiv.style.visibility = 'hidden';
	popupDiv.style.zIndex = '-1';
}
function setWaitingCursor(b_wait)
{
	var ary_links = document.getElementsByTagName("a");
	var str_cursor;

	if(b_wait)
	{
		str_cursor = "wait";
		document.body.style.cursor = "wait";
	}
	else
	{
		str_cursor = "pointer";
		document.body.style.cursor = "default";
	}

	for(var i = 0; i < ary_links.length; ++i)
	{
		if(ary_links[i].className == "psuedolink")
		{
			ary_links[i].style.cursor = str_cursor;
		}
	}
}
function setSelectByValue(str_select, str_value)
{
	var select = document.getElementById(str_select);
	for(var i = 0; i < select.options.length; ++i)
	{
		if(select.options[i].value == str_value)
		{
			select.selectedIndex = i;
		}
	}
}
