function sendData(data, page, target, method) {
	if(document.all) {
		var obj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		var obj = new XMLHttpRequest();
	}
	
	var dst_obj = document.getElementById(target);

	if(method == "GET") {
		if(data != "") {
			obj.open(method, page + "?" + data);
		}	
	} else if(method == "POST") {
		if(data != "") {
			obj.open(method, page);
		}
	}
	
	obj.onreadystatechange = function() {
		if (obj.readyState == 4) {
			if(target == "details_window") {
				dst_obj.innerHTML = obj.responseText;
				dst_obj.style.display = "block";
			} else if(target == "block_equip") {
				rslt_array = eval(obj.responseText);
			}
		}
	}

	if(method == "GET") {
		obj.send(null);
	}
	else if(method == "POST") {
		obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		obj.send(data);
	}
}

function close_window(target, dump) {
	document.getElementById(target).style.display = "none";
	if(dump == 1) {
		document.getElementById(target).innerHTML = "";
	}
}

function check(grp_id) {
	document.getElementById(grp_id +"[usr_may_read]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_reply]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_reply_closed]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_edit_own]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_edit_other]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_edit_own_closed]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_edit_other_closed]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_edit_silently]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_edit_title_own]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_change_status]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_create_new_topic]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_delete_topic]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_delete_post_own]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_delete_post_other]").checked = "checked";
	document.getElementById(grp_id +"[usr_may_attach_file]").checked = "checked";
}

function uncheck(grp_id) {
	document.getElementById(grp_id +"[usr_may_read]").checked = "";
	document.getElementById(grp_id +"[usr_may_reply]").checked = "";
	document.getElementById(grp_id +"[usr_may_reply_closed]").checked = "";
	document.getElementById(grp_id +"[usr_may_edit_own]").checked = "";
	document.getElementById(grp_id +"[usr_may_edit_other]").checked = "";
	document.getElementById(grp_id +"[usr_may_edit_own_closed]").checked = "";
	document.getElementById(grp_id +"[usr_may_edit_other_closed]").checked = "";
	document.getElementById(grp_id +"[usr_may_edit_silently]").checked = "";
	document.getElementById(grp_id +"[usr_may_edit_title_own]").checked = "";
	document.getElementById(grp_id +"[usr_may_change_status]").checked = "";
	document.getElementById(grp_id +"[usr_may_create_new_topic]").checked = "";
	document.getElementById(grp_id +"[usr_may_delete_topic]").checked = "";
	document.getElementById(grp_id +"[usr_may_delete_post_own]").checked = "";
	document.getElementById(grp_id +"[usr_may_delete_post_other]").checked = "";
	document.getElementById(grp_id +"[usr_may_attach_file]").checked = "checked";
}

function add_attach() {
	elem = document.getElementById("attachement_list");
	node = document.createElement("li");
	node_label = document.createElement("label");
	node_text_add = document.createTextNode("Attachement name ");
	node_label.appendChild(node_text_add);
	node_input = document.createElement("input");
	node_input.setAttribute("name", "attach_add_name[]");
	node_input.setAttribute("type", "text");
	node_input.setAttribute("style", "background-color: #cecfac; border: 1px solid #760903; width: 75%;");
	node_label.appendChild(node_input);
	node.appendChild(node_label);
	node.appendChild(document.createElement("br"));
	node_label2 = document.createElement("label");
	node_text_file = document.createTextNode("\r\nSelect file to upload ");
	node_label2.appendChild(node_text_file);
	node_file = document.createElement("input");
	node_file.setAttribute("name", "attach_add_file[]");
	node_file.setAttribute("type", "file");
	node_file.setAttribute("style", "background-color: #cecfac; border: 1px solid #760903; width: 75%;");
	node_label2.appendChild(node_file);
	node.appendChild(node_label2);
	elem.appendChild(node);
}

function display_add_cat() {
	elem = document.getElementById("new_cat_input");
	if(elem.style.visibility == "visible") {
		elem.style.visibility = "hidden";
	} else {
		elem.style.visibility = "visible";
	}
}