/*
	Copyright 1995-2007 BalticDEV (http://balticdev.com/)
	GPL: You can freely copy, modify and redistribute this file


	Usage:
	-------------------------------------------------------------
	function updateCallback(xmlHttp, parm) {
		var txt = xmlHttp.responseText;
		var xml = xmlHttp.responseXML;
		var elm = document.getElementById( parm );
		if( !elm )
			return;
		elm.innerHTML = txt;
	}

	...

	AjaxRequestData( updateCallback, "price", true, url, post_vars );
	-------------------------------------------------------------

	Whatever output returns generated page gets set as inner html of element "price"
*/

function NewAjaxObject()
{
	var xmlHttp;
	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) {
				alert("Your browser does not support AJAX!");
				return null;
			}
		}
	}
	return xmlHttp;
}

function AjaxRequestData( func, parm, async, req_get, req_post )
{
	var xmlHttp = NewAjaxObject();
	if( !xmlHttp ) {
	    return false;
	}
/*	var browser_name = Navigator?Navigator.name:"";

	if (browser_name.indexOf("Netscape")<0) {
	    alert( "NS" );
		xmlHttp.onreadystatechange = function() {
		    if( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
			     func( xmlHttp, parm );
		    }
		};
	}
*/
	if( !req_post )
	{
		xmlHttp.open("GET", req_get, false ); // async = false
		xmlHttp.send(null);
	} else {
		xmlHttp.open("POST", req_get, false ); // async = false
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", req_post.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(req_post);
	}
//	if (browser_name.indexOf("Netscape")>=0) {
	     func( xmlHttp, parm );
//	}
	return true;
}

