function $(id) {
    return document.getElementById(id);
}

function parseRecords(xml, nid) {
    it = xml.getElementsByTagName(nid);
		result = "";
    for (i = 0; i < it.length; i++) {
    	if ( $(it[i].firstChild.nodeValue)!=undefined )
    		$(it[i].firstChild.nodeValue ).checked=true;
    }
    return result;
}

function show_flyelement(idel) {
	$(idel).style.visibility="visible";
	$(idel).style.width="100px";
	$(idel).style.height="50px";
}

function hide_flyelement(idel) {
	$(idel).style.visibility="hidden";
	$(idel).style.width="0px";
	$(idel).style.height="0px";
}

function getcurrentselection(rtable, mid, nid, id, item) {
    advAJAX.get({
        url : "ajax_sselect.php?rtable="+rtable+"&mid="+mid+"&nid="+nid+"&id="+id+"&item="+item,
        onInitialization : function() {
        	show_flyelement('ajaxwaitmodule');
        },
        onComplete: function () {
        	hide_flyelement('ajaxwaitmodule');
        },
        onError : function() {
        	alert('Wystąpił błąd!');
        },
        onSuccess : function(obj) {
        	if (itemid == '') 
            parseRecords(obj.responseXML, nid);
        }
    });
}

function setselection(rtable, mid, nid, id, item) {
	getcurrentselection(rtable, mid, nid, id, item);

}

function initSelection(rtable,mid,nid,id) {
	getcurrentselection(rtable,mid,nid,id,'');
	
}

