function esc(s) {
	return window.encodeURIComponent ? window.encodeURIComponent(s) : escape(s);
}

function httpRequest() {
	var o = null;
	
	if (window.ActiveXObject) {
		o = new ActiveXObject("Msxml2.XMLHTTP");
		if (!o) {
			o = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else if (window.XMLHttpRequest) {
		o = new XMLHttpRequest;
	}
	return o;
}

function send(url, func, response, params) {
	var e = httpRequest();
	
	e.open((params ? "POST":"GET"), url, true);
	
	if (func) {
		e.onreadystatechange = function() {
			if (e.readyState==4) {
				func(response && e.responseXML ? e.responseXML : e.responseText);
			}
		};
	}
	
	if (params) {
		e.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		e.setRequestHeader("Content-length", params.length);
		e.setRequestHeader("Connection", "close");
	}
	e.send(params);
}

function uniqval(len) {
	var i, chars='3WzE6hTYbUqI42O8PaASJwLZ5XCVyGBNMeHrtRuopKsdfgjklx7cvFnm10iD9', str='';
	
	if (!len) {
		len=30;
	}
	
	for (i=0; i < len; i++) {
		str += chars.substr((Math.floor(Math.random()*(chars.length+1))),1);
	}
	
	return str;
}

function removeElement(e) {
	e.parentNode.removeChild(e);
}

function rand() {
	return Math.random();
}

function getElementsByClass(str) {
	var all = document.getElementsByTagName("*"), items = [];
	
	for (var i=0; i < all.length; i++) {
		if (all[i].className==str) {
			items.push(all[i]);
		}
	}
	return items;
}

function toggle(a, b) {
	a.style.display = (a.style.display=="none" ? (b ? b : "") : "none");
}
