//post szerinti servlet hivast eszkozlunk a member servleten.
function postmember(parameter) {
	try {
		var formPost = new FormPost("member?" + parameter);
		return formPost.submit();
	}
	catch (e) {
        // For IE:
		if (e.description != null) {
			alert(e.name + ": " + e.description);

            // All others:
		} else {
			alert(e);
		}
	}
}
function getTopPos(inputObj) {
	var returnValue = inputObj.offsetTop;
	while ((inputObj = inputObj.offsetParent) != null) {
		if (inputObj.tagName != "HTML") {
			returnValue += inputObj.offsetTop;
		}
	}
	return returnValue;
}
function getLeftPos(inputObj) {
	var returnValue = inputObj.offsetLeft;
	while ((inputObj = inputObj.offsetParent) != null) {
		if (inputObj.tagName != "HTML") {
			returnValue += inputObj.offsetLeft;
		}
	}
	return returnValue;
}
function ScrollTo(name) {
	document.getElementById(name).scrollIntoView(false);
}

function csvArray(csv) {
	var i = 0, A = new Array();
	A = csv.split(",");
	return A;
}
      
  //keressuk meg a beirt tagkodot es fokuszaljunk ra
function search() {
	var t = window.parent.document.getElementsByName("tfMembCode")[0];
	var searchedMemb = t.value;
	var s = new String(postmember("search=" + searchedMemb));
	var members = csvArray(s);
	for (var l = 1; l < members.length+1; l++) {
		var mcode = members[members.length - l];
		var node = tree.getNode(mcode);
		node.expand();
		if (node.isFetching) {
			l--;
		}
	}
	ScrollTo(searchedMemb);
	tree.getNode(searchedMemb).sync();
}

// FormPost Object
//
// Constructor
//    FormPost(url) - Creates the object and sets the URL.
//
// Methods:
//   addField(name, value)
//             - Adds a name/value pair to the form data.
//   clear()   - Removes all name/value pairs from the form data.
//   submit()  - Posts the form data to the object's URL and returns
//               the response data received as a text string.

// Constant defining possible Microsoft XML HTTP ProgIDs.
var FORMPOST_MSXML_HTTP_PROGIDS = new Array("MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
function FormPost(url) {
    // Create the appropriate XMLHTTP object for the browser.

    // For Mozilla:
	if (window.XMLHttpRequest != null) {
		this.xmlHttp = new XMLHttpRequest();
        // For IE:
	} else {
		if (window.ActiveXObject != null) {
            // Try each ProgID until one works.
			var success = false;
			for (var i = 0; i < FORMPOST_MSXML_HTTP_PROGIDS.length && !success; i++) {
				try {
					this.xmlHttp = new ActiveXObject(FORMPOST_MSXML_HTTP_PROGIDS[i]);
					success = true;
				}
				catch (e) {
				}
			}

            // If it couldn't be created, throw an exception.
			if (!success) {
				throw "Cannot create an XMLHTTP object.";
			}
		}
	}

    // Set properties.
	this.url = url;
	this.data = "";

    // Set methods.
	this.addField = FormPostAddField;
	this.clear = FormPostClear;
	this.submit = FormPostSubmit;
}

//
// Implementation of the FormPost.addField() method.
//
function FormPostAddField(name, value) {
    // Add the name/value pair to the request data.
	if (this.data.length > 0) {
		this.data += "&";
	}
	this.data += window.escape(name) + "=" + window.escape(value);
}

//
// Implementation of the FormPost.clear() method.
//
function FormPostClear() {
    // Reset the request data.
	this.data = "";
}

//
// Implementation of the FormPost.submit() method.
//
function FormPostSubmit() {
	try {
        // Set up a synchronous POST request, set the data encoding header and send it.
		this.xmlHttp.open("POST", this.url, false);
		this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.xmlHttp.send(this.data);

        // Check the HTTP response status code. If it is not "OK," throw an exception.
		if (this.xmlHttp.status != 200) {
			throw "HTTP request for \"" + this.url + "\" failed with status \"" + this.xmlHttp.status + " " + this.xmlHttp.statusText + "\"";

            // Otherwise, return the response data as a text string.
		} else {
			return this.xmlHttp.responseText;
		}
	}
	catch (e) {
        // An exception occured, pass it on.
		throw e;
	}
}

