	var B_POP_COUNTER = new Number(0);
	var BUFF_C = new Number(0);
	var BUFF = new Array();

	function buffCreate(buff_data) {
		BUFF[BUFF_C] = buff_data;
		return BUFF_C++;
	}
	function confirmAction(url, msg) {
		if (confirm(msg)) {
			location.href = url;
		}
	}
	// div popups
	function popupCreate(hidden, w, h) {
		var obj = document.createElement('div');
		if (hidden) obj.style.display = 'none';
		obj.setAttribute("class", "popup");
		obj.setAttribute("id", "popup_"+B_POP_COUNTER);
		obj.innerHTML = _L_LOADING;
		if (w) obj.style.width = w;
		if (h) obj.style.height = h;
		document.body.appendChild(obj);
		return B_POP_COUNTER++;
	}
	function popupGet(id) {
		return document.getElementById("popup_"+id);
	}
	function popupDisplay(id) {
		var obj = popupGet(id);
		obj.style.display = 'block';
	}
	function triggerDisplay(obj) {
		obj = document.getElementById(obj);
		obj.style.display = (obj.style.display == "none") ? "block" : "none";
	}
	function popupLoadHTML(id, doc, postvars) {
		varLoadHTML("document.getElementById('popup_"+id+"').innerHTML", doc, postvars);
	}
	function popupClose(popup) {
		document.body.removeChild(popupGet(popup));
	}
	/*
		AJAX Functions:
		Borrowed from Ajallerix (http://forge.novell.com/modules/xfmod/project/?ajallerix)
		Read file THANKS
	*/
	function initXMLHttpRequest() {
		if (window.XMLHttpRequest) {
			try {
				req = new XMLHttpRequest();
			} catch(e) {
				req = false;
			}
		} else if (window.ActiveXObject) {
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				req = false;
			}
		}
		return req;
	}
	function varLoadHTML(dest, doc, postvars) {
		var req = initXMLHttpRequest();
		if (req) {
			req.open(postvars ? 'POST' : 'GET', doc, true);
			if (postvars) req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.onreadystatechange = function () {
				if (req.readyState == 4) {
					eval(''+dest+'=req.responseText;');
				}
			}
		} else {
			alert("Cannot initialize XMLHttpRequest");
		}
		req.send(postvars);
	}


	function addGroups(form, obj, popup) {
		form = document.getElementById(form);
		groups = new Array();
		j = 0;
		for (i = 0; i < form.elements.length; i++) {
			if (form[i].checked) {
				groups[j] = form[i].value;
				j++;
			}
		}
		var groups = groups.join(',');
		if (groups.length > 255) {
			alert(_E_AUTH_STRING_SIZE);
			return false;
		}
		obj = BUFF[obj];
		obj.value = groups;
		popupClose(popup);
		BUFF[obj] = null;
		return true;
	}
	function groupChooser(obj, m) {
		var o = buffCreate(obj);
		var p = popupCreate(true);
		popupLoadHTML(p, _C_SITE_REL_URL+'runscript.php/groups/wizard?groups='+obj.value+'&object='+o+'&popup='+p+(m ? '&authwizard=1': '')+'&relpath='+_C_SITE_REL_URL);

		// overflow
		var obj = popupGet(p);
		obj.style.position = 'absolute';

		popupDisplay(p);
		BUFF_C++;
	}
	function chooseIcon(img, icon, object, popup) {
		BUFF[icon].src = img.src;
		BUFF[object].value = img.alt;
		popupClose(popup);
	}
	function showPreview(id) {
		var w = document.body.clientWidth;
		var p = popupCreate(true);

		obj = popupGet(p);

		obj.setAttribute("onclick", "popupClose('"+p+"')");
		obj.setAttribute("style", "margin:10px;overflow:auto;left:"+(w/8)+"px;width:"+(6*w/8)+"px;height:90%;");

		popupLoadHTML(p, _C_SITE_REL_URL+'runscript.php/preview', 'data='+escape(document.getElementById(id).value));
		popupDisplay(p);
	}
	function iconChooser(icon, obj, size) {
		if (!size) size = '16';
		var o = buffCreate(obj);
		var i = buffCreate(document.getElementById(icon));
		var p = popupCreate(true);
		popupLoadHTML(p, _C_SITE_REL_URL+'runscript.php/iconlist?size='+size+'&selected='+obj.value+'&object='+o+'&icon='+i+'&popup='+p+'&relpath='+_C_SITE_REL_URL);
		popupDisplay(p);
	}
	// <form onsubmit="return antiBot(this)">
	function antiBot(obj) {
		obj.auth.value = _C_ANTIBOT;
		return true;
	}
	function uploadImage(id) {
		window.open(_C_SITE_REL_URL+'runscript.php/uploadimage?object='+id, '', 'width=320,height=310');
	}
	function useStyleSheet(title) {
		var taglink;
		for (i = 0; (taglink = document.getElementsByTagName("link")[i]); i++) {
			if (taglink.getAttribute("rel") == "alternate stylesheet") {
				taglink.disabled = (taglink.getAttribute("title") == title) ? false : true;
			}
		}
	}