<!--
var ie = false;
if(document.uniqueID) ie = true;
//var url = document.URL.substring(0,document.URL.search(/[a-zA-Z0-9_-]*\.php/));

/// Create an XMLHttpRequest object to make an AJAX request.
function AJAXgetHttpRequest()
{
	var http_request = false;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) http_request.overrideMimeType('text/xml');
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	return http_request;
}


/// Send an AJAX request to the server.
/// Parameters:
///  data: contains parameters what sent to the server (data.params)
/// Return value: true = ok, false = sending failed
function AJAXsendRequest(data)
{
	var http_request = AJAXgetHttpRequest('POST');
	if (!http_request) {
		alert('error: no http request');
		return false;
	}

	// send request
	http_request.open('POST', 'http://www.okmt.hu/portal/ajax.php', true);
	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	
	http_request.onreadystatechange = function() { AJAXgetAnswer(http_request, data); };

	var post = '';
	for(var param in data.params)
		post += param+'='+data.params[param]+'&';
	http_request.send(post);

	return true;
}

/// Incoming AJAX answer. Callback.
/// Parameters:
///  http_request: AJAX answer object
///  data: array to store incoming xml
function AJAXgetAnswer(http_request, data)
{
	if(http_request.readyState != 4) return;
	if (http_request.status != 200) {
		alert('error: status '+http_request.status);
		return false;
	}
	if(data.debug) alert(http_request.responseText);
	data.xml = http_request.responseXML;
	
	data.callback.call(null,data);
}

/// Search for a child tag (not recursive!).
/// Parameters:
///   obj: object, DOM object
///   name: string, tag name (without <>)
/// Return value: object, DOM object (or NULL).
function AJAXgetTag(obj, name)
{
	if(!obj || !obj.childNodes || !obj.childNodes.length)
		return null; // check for valid DOM object and for childrens

	obj = obj.firstChild;
	while(obj) {
		if(obj.nodeName == name) return obj;
		obj = obj.nextSibling;
	}
	
	return null;
}

/// Search for the next tag (sibling) with the same name on the same level.
/// Parameters:
///   obj: object, DOM object
/// Return value: object, DOM object (or NULL).
function AJAXgetNextTag(obj)
{
	if(!obj || !obj.nextSibling)
		return null; // check for valid DOM object and sibling
	
	var name = obj.nodeName;
	while(obj = obj.nextSibling) {
		if(obj.nodeType == 1 && obj.nodeName == name)
			return obj;
	}
			
	return null;
}

/// Return a tag text content, eg <sample>THIS WILL BE THE RESULT</sample>.
/// Warning! Just the first text will be the result.
/// Parameters:
///  obj: object, XML tag (DOM object)
/// Return value: string, value of the tag
function AJAXgetTagValue(obj)
{
	if(!obj || !obj.childNodes || !obj.childNodes[0] || !obj.childNodes[0].data) return "";
	return obj.childNodes[0].data;
}
//-->

