/*
	JS Extending Library
	AJAX Library
	build 200816061228
*/
var ajaxReq, callThisFunc;
var funcDone = false;
var channelFree = true;
var Number = {
	rand: function(min, max) {
		return Math.floor(Math.random() * ((max + 1) - min)) + min;
	}
};
function inner_vote_result(str,id){
	eval(str);
	$(id).innerHTML='<table><tr><td>Всего голосов: <b>'+count+'</b>, общий балл: <b>'+value+'</b></td></tr></table>';
}
function nWindow(src,w,h,l,t,scroll,center){
	w = (w?w:100);
	h = (h?h:100);
	if(center){
		l=((screen.width-w)/2); 
		t=((screen.height-h)/2);
	}else{
		l = (l?l:0);
		t = (t?t:0);
	}
	scroll = (scroll?scroll:0);
	window.open(src,'',config='width='+w+',scrollbars='+scroll+',height='+h+', left='+(l?l:((screen.width-350)/2))+', top='+(t?t:((screen.height-300)/2))+', toolbar=0');
}
function $(id){
return document.getElementById(id);
}
function loading(id){
	$(id).innerHTML='<img src="/files_files/ajax_loading.gif">';
}
function time() {
	return new Date().getTime();
}

function isset(v) {
	return (typeof(v) == 'undefined' ? false : true);
}

function IDgen() {
	return time().toString() + Number.rand(10000, 99999).toString();
}
function vote(){
	inner_vote_result(ajaxReq.responseText,'voting');
}
function ajax(url, callFunc, post,load) {
	if(load)loading(load);
	if (! isset(callFunc)) var callFunc = '';
	if (! isset(post)) var post = '';
	if (callFunc != '') {
		if (! channelFree) {
			setTimeout('ajax("'+ url +'", "'+ callFunc +'", "'+ post +'")', 250);
			return;
		}
	}
	channelFree = false;
	funcDone = false;
	callThisFunc = callFunc;
	if (url.indexOf('?') == -1) url += '?'; else url += '&';
	url += IDgen();
	if (window.XMLHttpRequest) {
		ajaxReq = new XMLHttpRequest();
		ajaxReq.onreadystatechange = processReqChange;
		if (post == '') {
			ajaxReq.open("GET", url, callFunc != '');
			ajaxReq.send(null);
		} else {
			ajaxReq.open("POST", url, true);
			ajaxReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded, charset=utf-8');
			ajaxReq.send(post);
		}
	} else if (window.ActiveXObject) {
		ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
		if (ajaxReq) {
			ajaxReq.onreadystatechange = processReqChange;
			if (post == '') {
				ajaxReq.open("GET", url, callFunc != '');
				ajaxReq.send();
			} else {
				ajaxReq.open("POST", url, true);
				ajaxReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded, charset=utf-8');
				ajaxReq.send(post);
			}
		}
	}
}

function processReqChange() {
	if (ajaxReq.readyState == 4) {
		if (ajaxReq.status == 200) {
			if (! funcDone) {
				funcDone = true;
				if (callThisFunc != '') eval(callThisFunc);
			}
		} else if (jsExtLibData.debug) {
			if (ajaxReq.status < 200  ||  ajaxReq.status > 600) {
				alert('Server returned unknown error code.');
			} else {
				var res = getHttpCodeText(ajaxReq.status);
				if (res == '') alert('Server returned error code '+ ajaxReq.status + '.');
				else alert('Server returned error code '+ ajaxReq.status + '. ' + getHttpCodeText(ajaxReq.status) + '.');
			}
		}
		channelFree = true;
	}
}

function getHttpCodeText(code) {
	switch (code) {
		case 200: return 'O.K.';
		case 201: return 'Created';
		case 202: return 'Accepted';
		case 203: return 'Non-Authoritative Information';
		case 204: return 'No Content';
		case 205: return 'Reset Content';
		case 206: return 'Partial Content';
		case 207: return 'Multi-Status';
		case 300: return 'Multiple Choices';
		case 301: return 'Moved Permanently';
		case 302: return 'Found';
		case 303: return 'See Other';
		case 304: return 'Not Modified';
		case 305: return 'Use Proxy';
		case 306: return 'Switch Proxy';
		case 307: return 'Temporary Redirect';
		case 400: return 'Bad Request';
		case 401: return 'Unauthorized';
		case 402: return 'Payment Required';
		case 403: return 'Forbidden';
		case 404: return 'Not Found';
		case 405: return 'Method Not Allowed';
		case 406: return 'Not Acceptable';
		case 407: return 'Proxy Authentication Required';
		case 408: return 'Request Timeout';
		case 409: return 'Conflict';
		case 410: return 'Gone';
		case 411: return 'Length Required';
		case 412: return 'Precondition Failed';
		case 413: return 'Request Entity Too Large';
		case 414: return 'Request-URI Too Long';
		case 415: return 'Unsupported Media Type';
		case 416: return 'Requested Range Not Satisfiable';
		case 417: return 'Expectation Failed';
		case 421: return 'There are too many connections from your internet address';
		case 422: return 'Unprocessable Entity';
		case 423: return 'Locked';
		case 424: return 'Failed Dependency';
		case 425: return 'Unordered Collection';
		case 426: return 'Upgrade Required';
		case 449: return 'Retry With';
		case 500: return 'Internal Server Error';
		case 501: return 'Not Implemented';
		case 502: return 'Bad Gateway';
		case 503: return 'Service Unavailable';
		case 504: return 'Gateway Timeout';
		case 505: return 'HTTP Version Not Supported';
		case 506: return 'Variant Also Negotiates';
		case 507: return 'Insufficient Storage';
		case 509: return 'Bandwidth Limit Exceeded';
		case 510: return 'Not Extended';
	}
	return '';
}