var iD = 99999;

var winX = 0,	winY = 0,	winBound = '',	winLast = '';

var winID = 0,	winDrag = 0,	winPointed = '',	stateKey = 0;


var upV = 0,	upVV = 0,	upVVV = 0;
var downV = 0,	downVV = 0,	downVVV = 0,		iPage = 0;


var aKey = new Array();

var ted = new Array();

var idStack = new Array();
var idScroll = new Array('','',0);


var morph = new Array();
var morphT = new Array();



var aElem = new Array(0,0,0,0);
var aFade = new Array();
var aHide = new Array();


var opaqType = '';

var DnD = new Array();

var mouse = new Array();



var keyCtrl	= 1;
var keyShift	= 2;



document.onkeyup = KeyUp;
document.onkeydown = KeyDown;

document.onmousemove = MoveWin;
document.onmouseup = UndragWin;
document.onmousedown = Bind;

//document.onmousewheel = Scroller;





function setImage(id,src){	var o = document.getElementById(id);
	if(o)	o.src = src;	}

function setCheck(id,v){	var o = document.getElementById(id);
	if(o)	o.checked = v;	}



function Explode(sep,s)	{	var out = Array();	var p = 0, i = 0;

while(p!=-1 && i<s.length)	{
	i = s.indexOf(sep,p);	if(i==-1)		i = s.length;
	out.push( s.substring(p,i) );			p = i+1;	}	return out;	}



function FindBlocks(s,sign,sign2){	var out = Array();	var i = 0, i2 = 0;

while(i<s.length)	{
	i = s.indexOf(sign,i2);		if(i==-1)		return out;
	i2 = s.indexOf(sign2,i);	if(i2==-1)		i2 = s.length;

	out.push( s.substring(i+sign.length,i2) );	}	return out;	}



function ExecScripts(s)	{					var xScript = FindBlocks(s, '<SCRIPT>', '</SCRIPT>');
	for(var i=0; i<xScript.length; i++)			setTimeout(xScript[i], 0);	}



function elemPos(id,obj){		if(obj==undefined)	obj = document.getElementById(id);

if(obj.style.position=='absolute')
	if(obj.offsetLeft!=0 && obj.offsetTop!=0)		return {0:obj.offsetLeft, 1:obj.offsetTop, 2:obj.clientWidth, 3:obj.clientHeight};

	var x = 0,			y = 0,			w = obj.clientWidth,	h = obj.clientHeight;

while(obj)	{
	x += obj.offsetLeft + obj.clientLeft;
	y += obj.offsetTop + obj.clientTop;			obj = obj.offsetParent;	}

	return {0:x, 1:y, 2:w, 3:h};	}



function parseClip(id,obj)	{	if(obj==undefined)	obj = document.getElementById(id);

	if(obj==undefined)		return {0:0, 1:0, 2:0, 3:0};

	if(obj.style.clip=='')		return {0:0, 1:obj.clientWidth, 2:obj.clientHeight, 3:0};

	var a = obj.style.clip.indexOf('(')+1,			b = obj.style.clip.indexOf(')');
	var dim = Explode(' ', obj.style.clip.substring(a,b));

for(var i=0; i<4; i++)	{
	dim[i] = parseInt(dim[i]);	if(isNaN(dim[i]))	dim[i] = 0;	}

	return {0:dim[0], 1:dim[1], 2:dim[2], 3:dim[3]};	}



function getClientWidth()	{
if(document.documentElement)
	return document.documentElement.clientWidth;
if(document.body)
	return document.body.clientWidth;		return 1024;	}

function getClientHeight()	{
if(document.documentElement)
	return document.documentElement.clientHeight;
if(document.body)
	return document.body.clientHeight;		return 768;	}



function fetchWheel()	{		wheelType = (/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";	}



function fetchOpacity()	{		if(opaqType!='')	return;

if (typeof document.body.style.opacity == 'string')	{					// CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
	opaqType = 'opacity';		return;	}
else if (typeof document.body.style.MozOpacity == 'string')	{				// Mozilla 1.6 и младше, Firefox 0.8 
	opaqType = 'MozOpacity';	return;	}
else if (typeof document.body.style.KhtmlOpacity == 'string')	{				// Konqueror 3.1, Safari 1.1
	opaqType = 'KhtmlOpacity';	return;	}
else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5)	{	// Internet Exploder 5.5+
	opaqType = 'filter';		return;	}

	opaqType = false;		return;	}





function morphThread(t)	{		var x = (miliTime()-morphT[t].a+0.001) / (morphT[t].b-morphT[t].a);

	if(x>=1)	x = 1;		var p = morph[morphT[t].id],		k = x;

	if(morphT[t].dyn)		k = Math.sin(x * Math.PI * 0.5);	var now = new Array(0,0,0,0);



	var ops = morphT[t].ops;	var c = ops.length;

for(var i=0; i<c; i++)			switch(ops[i])	{
case 'a':	now[0] = k * (p.a2-p.a) + p.a;
		setOpacity(morphT[t].id,now[0]);

		if(x==1 && p.a2<=0)	morphT[t].elem.style.visibility = 'hidden';

		break;

case 'c':	if(p.c2[0]<0)		now[0] = 'auto';	else	now[0] = Math.round(k * (p.c2[0]-p.c[0]) + p.c[0])+'px';
		if(p.c2[1]<0)		now[1] = 'auto';	else	now[1] = Math.round(k * (p.c2[1]-p.c[1]) + p.c[1])+'px';
		if(p.c2[2]<0)		now[2] = 'auto';	else	now[2] = Math.round(k * (p.c2[2]-p.c[2]) + p.c[2])+'px';
		if(p.c2[3]<0)		now[3] = 'auto';	else	now[3] = Math.round(k * (p.c2[3]-p.c[3]) + p.c[3])+'px';
//document.title = 'rect('+ now[0] +','+ now[1] +','+ now[2] +','+ now[3] +')';
		morphT[t].elem.style.clip = 'rect('+ now[0] +','+ now[1] +','+ now[2] +','+ now[3] +')';	break;

case 'w':	now[0] = Math.round(k * (p.w2-p.w) + p.w);
		morphT[t].elem.style.width = now[0]+'px';		break;
case 'h':	now[0] = Math.round(k * (p.h2-p.h) + p.h);
		morphT[t].elem.style.height = now[0]+'px';		break;

case 'x':	now[0] = Math.round(k * (p.x2-p.x) + p.x);
		morphT[t].elem.style.left = now[0]+'px';		break;
case 'y':	now[0] = Math.round(k * (p.y2-p.y) + p.y);
		morphT[t].elem.style.top = now[0]+'px';			break;	}

if(x>=1){	clearInterval(morphT[t].timer);				morphT[t].done = 1;	}	}



function morphGetThread()	{	var c = morphT.length;

for(var i=0; i<c; i++)	{		if(morphT[i].done==1)		return i;

}	morphT.push( new Array() );	morphT[i].done = 0;		return i;	}



function morphReset(id,op,v,v2,v3,v4){	if(morph[id].reset.indexOf(op)!=-1)	return;		morph[id].reset += op;

	var o = document.getElementById(id);		if(o==undefined)	alert(id);

	var q = elemPos(id);
//	document.title = q[0] + ' : ' + q[1] + ' : ' + q[2] + ' : ' + q[3];

switch(op)	{
case 'a':	morph[id].a = getOpacity(id);		morph[id].a2 = v;

	if(curStyle(o,'visibility')=='hidden')		setOpacity(id,0);
	if(v>=0)					o.style.visibility = 'visible';		return;

case 'c':	morph[id].c = parseClip(id);		if(morph[id].c2==undefined)		morph[id].c2 = new Array();

		morph[id].c2[0] = v;			morph[id].c2[1] = v2;
		morph[id].c2[2] = v3;			morph[id].c2[3] = v4;	return;

case 'w':	morph[id].w = o.clientWidth;		morph[id].w2 = v;	return;
case 'h':	morph[id].h = o.clientHeight;		morph[id].h2 = v;	return;

case 'x':	morph[id].x = o.offsetLeft;		morph[id].x2 = v;	return;
case 'y':	morph[id].y = o.offsetTop;		morph[id].y2 = v;	return;
case 'z':	morph[id].z = o.style.zIndex;		morph[id].z2 = v;	return;

}	}



function morphCheckOp(id,op)	{	var c = morphT.length;
for(var i=0; i<c; i++)
	if(morphT[i].id==id)		if(morphT[i].done!=1)		if(morphT[i].ops.indexOf(op)!=-1)	return i;

	return -1;	}



function morphUpdate(id,op,time,v,v2,v3,v4)	{	var t = morphCheckOp(id,op);

	morphReset(id,op,v,v2,v3,v4);

	if(t==-1)			return op;

	morphT[t].a = miliTime();	morphT[t].b = morphT[t].a + time;

	morphT[t].time = time;		return '';	}



function morphRun(id,query,time,dyn,dt)	{		var com = Explode(',', query);

	if(id=='thread')		return;		if(time==undefined)		time = 500;

	if(dyn==undefined)		dyn = 0;	if(dt==undefined)		dt = 25;

	if(morph[id]==undefined)	morph[id] = new Array();


	var c = com.length,	d = 0,	ops = '';	morph[id].reset = '';

for(var i=0; i<c; i++)	{

switch(com[i])	{

case 'a':	case 'x':	case 'y':
case 'z':	case 'w':	case 'h':
		if((i+1)>c)		return;
		ops += morphUpdate(id,com[i],time, com[i+1]);					i++;		break;

case 'c':	case 'p':
		if((i+4)>c)		return;
		ops += morphUpdate(id,com[i],time, com[i+1],com[i+2],com[i+3],com[i+4]);	i += 4;		break;

default:	return;		}	}

//document.title += ops+'|';
	if(ops=='')			return;


	var t = morphGetThread();	morphT[t].done = 0;

	morphT[t].a = miliTime();	morphT[t].b = morphT[t].a + time;		morphT[t].time = time;

	morphT[t].id = id;		morphT[t].ops = ops;				morphT[t].elem = document.getElementById(id);

	morphT[t].dyn = dyn;		var s = 'morphThread('+t+')';			morphT[t].timer = setInterval(s,dt);	}





function IsCtrl()	{	return stateKey & keyCtrl;	}
function IsShift()	{	return stateKey & keyShift;	}

function FetchTime()	{	return new Date().getTime();	}

function toURL(url)	{	window.location.replace(url);	}





function DragAction(link, ref,id,ref2,id2)	{

	if(ref==ref2)		if(id==id2)	return 0;

switch(ref+ref2)	{
case 'ff':	case 'ffO':	case 'fOf':	case 'fOfO':
case 'pp':	case 'ppO':	case 'pOp':	case 'pOpO':
case 'ii':
case 'if':
	cpRequest(link+ref+','+id+','+ref2+','+id2);		return 1;	}

	return -1;	}



function DragSelect(ref,id, ref2,id2)	{

if(IsShift())	{
	var a = ref;	ref = ref2;	ref2 = a;
	a = id;		id = id2;	id2 = a;	}

if(DnD.select!=undefined)	if(FetchTime()<DnD.select)
	return false;		DnD.select = FetchTime() + 100;

if(ref!=undefined && ref!='')	{
	DnD.id = id;		DnD.ref = ref;	}	else	DnD.ref = '';
if(ref2!=undefined && ref2!='')	{
	DnD.id2 = id2;		DnD.ref2 = ref2;}	else	DnD.ref2 = '';

	DnD.x = mouse.x;	DnD.y = mouse.y;

	return false;	}



function DragBind(link, ref,id,ref2,id2)	{

if(IsShift())	{
	var a = ref;	ref = ref2;	ref2 = a;
	a = id;		id = id2;	id2 = a;	}

if(DnD.bind!=undefined)		if(FetchTime()<DnD.bind)
	return false;		DnD.bind = FetchTime() + 100;

	var Range = Math.abs(DnD.x-mouse.x)+Math.abs(DnD.y-mouse.y);
	if(Range<5)		return true;


	var x = DragAction(link, DnD.ref,DnD.id, ref,id);
	if(x<=0)		x = DragAction(link, DnD.ref,DnD.id, ref2,id2);


	DnD.id = 0;		DnD.ref = '';
	DnD.id2 = 0;		DnD.ref2 = '';

	DnD.x = mouse.x;	DnD.y = mouse.y;	return false;	}





function delayHide(id)	{
	if(aHide[id]!=undefined)	clearTimeout(aHide[id]);
	var s = "document.getElementById('"+ id +"').style.visibility='hidden'";
	aHide[id] = setTimeout(s,100);	}

function cancelHide(id)	{
	if(aHide[id]!=undefined)	clearTimeout(aHide[id]);
	var o = document.getElementById(id);
if(o)	o.style.visibility = 'visible';	}

function clearHide(id)	{
	if(aHide[id]!=undefined)	clearTimeout(aHide[id]);	}





	var inAccCheck = 0;

function AccCheck()	{		inAccCheck = 1;

	var x = document.getElementsByName('acc[]');

for(var i=0; i<x.length; i++)	{
	setTimeout(x[i].onchange,1);	}

	setTimeout('inAccCheck = 0',50);	}



function AccCheck2(el,req)	{

	if(req=='')			return;

	var parent = document.getElementById(req);
	var child = document.getElementById(el);

if(parent==undefined)	{
	child.checked = 0;		return;	}

if(child.checked)
	if(parent.checked==0)	{

if(inAccCheck)
	child.checked = 0;	else	parent.checked = 1;

	setTimeout(parent.onchange,1);	}	}





function SetGroup(name,v,vv,vvv){	var x = document.getElementsByName(name);

if(vvv==undefined)
	for(var i=0; i<x.length; i++)	x[i][v] = vv;
else	for(var i=0; i<x.length; i++)	x[i][v][vv] = vvv;	}



function CustomHV(name,v,input,vv)	{

	SetGroup(name,'style','backgroundColor','#ffffff');
	v.style.backgroundColor = '#bfbfbf';

	var x = document.getElementsByName(input);
	x[0].value = vv;	}





function FixPosition(o)	{

if ((o.offsetLeft+o.clientWidth)>(document.documentElement.clientWidth-50))
	o.style.left = document.body.clientWidth - o.clientWidth - 50 + 'px';	else

if (o.offsetLeft<50)
	o.style.left = 50 + 'px';

if ((o.offsetTop+o.clientHeight)>(document.documentElement.clientHeight+document.documentElement.scrollTop-50))	{
if (o.clientHeight>(document.documentElement.clientHeight-50))
	o.style.top = document.documentElement.scrollTop + 50 + 'px';
else	o.style.top = document.documentElement.scrollTop + document.documentElement.clientHeight - o.clientHeight - 50 + 'px';	}	else
	
if (o.offsetTop<(document.documentElement.scrollTop+50))
	o.style.top = document.documentElement.scrollTop + 50 + 'px';	}



function PatchPosition(o)	{
if(mouse.x<o.offsetLeft || mouse.x>(o.offsetLeft+o.clientWidth))	o.style.left = mouse.x-20 + 'px';
if(mouse.y<o.offsetTop || mouse.y>(o.offsetTop+o.clientHeight))		o.style.top = mouse.y-20 + 'px';	}



function InPosition(o)	{
if(mouse.x<o.offsetLeft || mouse.x>(o.offsetLeft+o.clientWidth) || mouse.y<o.offsetTop || mouse.y>(o.offsetTop+o.clientHeight))
	return false;	return true;	}





function UpdateXY(elem,aEvent)	{		var e = aEvent ? aEvent : window.event;

	aElem[0] = e.offsetX;			aElem[1] = e.offsetY;
	aElem[2] = elem.clientWidth;		aElem[3] = elem.clientHeight;

	return false;	}





function Bind(aEvent)	{	var e = aEvent ? aEvent : window.event;

	setOpacity(winPointed, 0.5);

if(winPointed!='')	{			winBound = winPointed;			var win = document.getElementById(winBound);
	winX = win.offsetLeft - mouse.x;	winY = win.offsetTop - mouse.y;		return false;	}

if(winLast!='')	{	if(mouse.x>(document.documentElement.clientWidth-5))		return;

	var win = document.getElementById(winLast);

if(mouse.x<win.offsetLeft || mouse.x>(win.offsetLeft+win.clientWidth) || mouse.y<win.offsetTop || mouse.y>(win.offsetTop+win.clientHeight))
	ClearWin(winLast);	}

	return true;	}



function MoveWin(aEvent){	var e = aEvent ? aEvent : window.event;

//	winPointed = '';

	mouse.x = e.clientX+document.documentElement.scrollLeft;
	mouse.y = e.clientY+document.documentElement.scrollTop;

	if(winBound=='')	return true;

	var win = document.getElementById(winBound);

	win.style.left = (mouse.x + winX) + 'px';
	win.style.top = (mouse.y + winY) + 'px';

	return false;
}



function BindWin(win,e)	{
	winBound = win;		winLast = win;

	var win = document.getElementById(win+'_win');

	winX = win.offsetLeft - mouse.x;
	winY = win.offsetTop - mouse.y;		return false;	}




function FailDrag()	{
	return false;	}



function ClickWin(e)	{

	if(winLast=='')		return true;


	var win = document.getElementById(winLast);

if(mouse.x<win.offsetLeft || mouse.x>(win.offsetLeft+win.clientWidth) || mouse.y<win.offsetTop || mouse.y>(win.offsetTop+win.clientHeight))
	ClearWin(winLast);

	return true;
}



function UndragWin()	{

	setOpacity(winBound, 1);

	winBound = '';

	return true;	}



function Console(aEvent){	var e = aEvent ? aEvent : window.event;

	var xConsole = document.getElementById('console_input');		if(e.keyCode==96)	return false;

if(e.keyCode==13)	{
	wrapRequest('console','tildeh','?com='+xConsole.value);			xConsole.value = '';	}	}



function KeyDown(aEvent){	var e = aEvent ? aEvent : window.event;		downVVV = downVV;	downVV = downV;		downV = e.keyCode;

	if(e.keyCode==16)	stateKey |= keyShift;
	if(e.keyCode==17)	stateKey |= keyCtrl;

if(e.keyCode==27)	{	var xCP = document.getElementById('cp');	if(xCP)	{
if(xCP.style.visibility=='visible')
	xCP.style.visibility = 'hidden';	else	xCP.style.visibility = 'visible';	}	}


	var val = true;		if(downV==17 || downVV==17 || downVVV==17)	val = false;


if(downVVV==17 && downVV==49 && downV==50)	{
	winRequest('win','?core=login',19);	}

if(e.keyCode==27)	{	if(winLast=='')		return true;

	ClearWin(winLast);

//	fadeOut(winLast,0.5);
	}
//	document.getElementById(winLast).style.visibility = 'hidden';
//	document.getElementById(winLast+'_x').innerHTML = '';	}

	return val;	}



function KeyUp(aEvent)	{	var e = aEvent ? aEvent : window.event;		upVVV = upVV;		upVV = upV;		upV = e.keyCode;

	if(upV==192)	{	var oConsoleI = document.getElementById('console_input'),		oConsole = document.getElementById('console');
	if(oConsole)	{
		if(oConsole.style.visibility=='hidden')	{
			oConsole.style.visibility = '';	oConsoleI.focus();	}	else		oConsole.style.visibility = 'hidden';	}	}

	if(e.keyCode==16)	stateKey &= ~keyShift;
	if(e.keyCode==17)	stateKey &= ~keyCtrl;

	return true;	}





function ProcGroup(id,from,to,op,val)	{

for(var i=from; i<=to; i++)	{

	var name = id + '_' + i,	oSrc = document.getElementById(name);

if(oSrc)	switch(op)	{
case 'hide':	oSrc.style.display = 'none';		break;
case 'show':	oSrc.style.display = 'inline';		break;
case 'check':	oSrc.checked = 1;			break;
case 'uncheck':	oSrc.checked = 0;			break;
case 'docheck':	oSrc.checked = val;			break;

case 'smartcheck':
if(val)	{	if(i==from)		oSrc.checked = val;	}
else		oSrc.checked = val;	break;	}

}	}



function xProcGroup(id,from,to,one,op,val)	{

switch(op)	{
case 'show':
	ProcGroup(id,from,to,'hide',val);
	ProcGroup(id,one,one,'show',val);		break;	}	}





function CheckParent(id,set)	{	var a = 0, b = 0, s, oSrc;

for(var i=0; i<9; i++)	{
	a = set.indexOf('.', a)+1;	if(a==0)	break;
	b = set.indexOf(',', a);	if(b==-1)	break;

	s = set.substring(a,b);
	var name = id + '_' + s;	oSrc = document.getElementById(name);
	if(oSrc)			oSrc.checked = 1;	}	}



function togglemenu(oUlId)	{
	var oUl=document.getElementById(oUlId);
	oUl.style.display=((oUl.style.display=="none") ? 'block' : 'none');	}

function vismenu(oUlId)	{
	var oUl=document.getElementById(oUlId);
	oUl.style.display='block';	}

function hidmenu(oUlId)	{
	var oUl=document.getElementById(oUlId);
	oUl.style.display='none';	}


function runMenu(id)	{
	s = "vismenu('" + id + "')";
	setTimeout(s,500);	}


function open_window(link,w,h)	{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
	newWin = window.open(link,'order',win);	}



function miscop(src,dst)	{

	iD++;

	var oSrc = document.getElementById(src);
	var oDst = document.getElementById(dst);

	var xAct = 'var oSrc = document.getElementById(\'form_' + iD + '\');	oSrc.innerHTML = \'\';';

	oDst.innerHTML += '<span id="form_' + iD + '">' + oSrc.innerHTML + '<center class="link" align="right"><b style="cursor:pointer" onclick="' + xAct + '">Удалить</b></center></span>';	}



function doop(dst,check)	{
	var o = document.getElementById(dst);
if(check.checked==true)
	o.style.display = 'block';
else	o.style.display = 'none';	}





function asyncPage(s)	{			var xs = '', xPos=0, lPos = 0;

while(xPos=s.indexOf('href="?',xPos+6))	{	if(xPos==-1)	break;

	xs += s.substring(lPos,xPos+6);		lPos = s.indexOf('"', xPos+6);
	var link = 'javascript:LoadPage(\'' + s.substring(xPos+6,lPos) + '\')';

	xs += link;	}			xs += s.substring(lPos,s.length);	return xs;	}



function uPage()	{
	var oTodo = document.getElementById('todos');
	oTodo.innerHTML = asyncPage(oTodo.innerHTML);	}



function FetchReq()	{			var req;

if (window.XMLHttpRequest) {			req = new XMLHttpRequest();
	if (req.overrideMimeType)		req.overrideMimeType('text/xml');
} else if (window.ActiveXObject){
	try {   req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try {	req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) {}	}	}

if (!req) {	alert('Giving up :( Cannot create an XMLHTTP instance');	return req;	}

	return req;	}




function LoadPage(url)	{
	req = FetchReq();	if (!req)	return;
	req.onreadystatechange = function() { asyncHandler(req,'todos'); };
	req.open('GET', url+'&async', true);	req.send(null);
	document.getElementById('wait').style.visibility = 'visible';	}



function asyncHandler(req,id)	{
if (req.readyState == 4)			if (req.status == 200)	{
	var p = document.getElementById(id);	p.innerHTML = asyncPage(req.responseText);
	document.getElementById('cp').style.display = 'none';
	document.getElementById('wait').style.visibility = 'hidden';	}
else	alert('There was a problem with the request.');	}





function patchString(s,a,b)	{		var xs = '', xPos=0, lPos = 0;

while(xPos=s.indexOf('href="?',xPos+6))	{	if(xPos==-1)	break;

	xs += s.substring(lPos,xPos+6);		lPos = s.indexOf('"', xPos+6);
if(s[xPos+7]=='&')
	xs += s.substring(xPos+6,lPos);
else	xs += a + s.substring(xPos+6,lPos) + b;	}

	xs += s.substring(lPos,s.length);	return xs;	}



function apatchID(req,id, a,b)	{

if (req.readyState == 4)	if (req.status == 200) {

	p = document.getElementById(id);
	var s = patchString(req.responseText, a,b);

//	alert(s);

	p.innerHTML = s;	}

else	alert('There was a problem with the request.');	}



function makeRequest(id,url,a,b){		var req = false;
	req = new FetchReq();			if (!req)	return;
	req.onreadystatechange = function() {	apatchID(req,id,a,b); }
	req.open('GET', url, true);		req.send(null);	}



function oneRequest(url)	{		var req = false;
	req = new FetchReq();			if (!req)	return;
	req.open('GET', url, true);		req.send(null);	}



function getCaps()	{
//	var s = '?java=1;sw=' + screen.width + ';sh=' + screen.height;
//	return s;
	return '';
}



function callURL(url)	{			var req = false;
	req = new FetchReq();			if (!req)	return;
	req.open('GET', url, true);		req.send(null);	}



function partRequest(id,url,bits,a,b)	{

if(a==undefined)
	a = 'javascript:partRequest(\''+id+'\',\'';
if(b==undefined)
	var b = '\','+bits+')';			var req = false;

	req = new FetchReq();			if (!req)	return;
	req.onreadystatechange = function() {	apatchID(req,id,a,b);	}
	req.open('GET', url+'&async='+bits, true);		req.send(null);	}





function plexRequest(url,id,val,val2) {
	makeRequest(url+'&val='+val+'&val2='+val2,id);	}





function winJoint(req,id, a,b)	{

if (req.readyState == 4)	if (req.status == 200) {

	var win = document.getElementById(id);
	var content = document.getElementById(id+'_x');

	var isEmpty = content.innerHTML=='';

	content.innerHTML = patchString(req.responseText, a,b);

	win.style.visibility = 'visible';


if(isEmpty)	{
	win.style.left = (mouse.x-win.clientWidth/2) + 'px';
	win.style.top = (mouse.y-50) + 'px';
	FixPosition(win);	}


//if(vis!='visible')		FixPosition(win);
if(!InPosition(win))	{
	PatchPosition(win);	FixPosition(win);	}

	winLast = id;

}

else	alert('There was a problem with the request.');	}



function winRequest(id,url,bits)	{	var a = 'javascript:winRequest(\''+id+'\',\'';

	if(bits==undefined)			bits = 19;

	var b = '\','+bits+')';			var req = false;

	req = new FetchReq();			if (!req)	return;
	req.onreadystatechange = function() {	winJoint(req,id,a,b);	}
	req.open('GET', url+'&async='+bits, true);		req.send(null);	}







function wrapFunc(id,id2,time)	{//		alert(id + ' x ' + id2);

	var elemA = document.getElementById(id);
	var elemB = document.getElementById(id2);

//	elemA.innerHTML = elemB.innerHTML;
	elemB.outerText = '';

}



function animateX(o,x)	{

	var oElem = document.getElementById(o),			xElem = document.getElementById(x);

//	oElem.innerHTML = xElem.innerHTML;

//	oElem.innerHTML = '123';

//	alert(xElem.innerHTML);

	xElem.outerText = '';

//	document.title = xElem.style.visibility +' x '+ xElem.style.opacity;

//	setOpacity(o, 1);

//	oElem.style.height = '';

//	oElem.style.height = '';

}



function wrapJoint(req, id,to,inter, a,b)	{

if (req.readyState == 4)	if (req.status == 200)	{
//	alert(req.responseText);
	var xid = Explode(',', id);		var xto = Explode(',', to);

	var s = patchString(req.responseText, a,b);
	var i = 0, ii,ii2, i2;	var xID = '', oID = '', content = '';


for(var x=0; x<xid.length; x++)	{		var xSign = '<wrap id="'+ xid[x];

	i = s.indexOf(xSign,i);			if(i==-1)	continue;
	oID = xto[x];				xID = oID+'_x';

	i = s.indexOf('>',i);			if(i==-1)	continue;	i++;
	i2 = s.indexOf('</wrap>',i);
if(i2==-1)	{				if(s.indexOf('atal error')!=-1 || s.indexOf('arse error')!=-1)
	alert(req.responseText);		break;	}

	content = s.substr(i, i2-i);		ExecScripts(content);


	var xInter = (inter >> x) & 1;


if(xInter==0)	{

	var oElem = document.getElementById(oID);		oElem.innerHTML = content;

}	else	{

	var xy = elemPos(oID);

	var oElem = document.getElementById(oID),		xElem = document.getElementById(xID);

if(xElem==null)	{				xElem = document.createElement("DIV");

	xElem.id = xID;				xElem.style.position = 'absolute';

	xElem.style.zindex = 100;		document.body.appendChild(xElem);	}



	xElem.style.left = xy[0]+'px';		xElem.style.top = xy[1]+'px';

	xElem.style.width = xy[2]+'px';		setOpacity(xID, 0);



	var h1 = oElem.clientHeight;		xElem.innerHTML = oElem.innerHTML;

	oElem.innerHTML = content;		oElem.style.height = '';

	var h2 = oElem.clientHeight;		oElem.style.height = h1+'px';


	setOpacity(oID, 0);

if(h2<h1)	{

	morphRun(oID, 'h,'+h2, 400, 1,1);	morphRun(oID, 'a,1', 1000, 1,1);	}

else{	var xxx = 'morphRun(\''+ oID +'\', \'a,1\', 800, 1,1)';

	setTimeout(xxx, 200);			morphRun(oID, 'h,'+h2, 300, 1,1);	}



	xxx = 'animateX(\''+ oID +'\',\''+ xID +'\')';

	setTimeout(xxx, 1000);

}



}



}

else	alert('There was a problem with the request.');	}



function wrapRequest(id,to,url,inter,a,b){	if(to=='')	to = id;	//	alert(url);

	var xList = Explode(',', to);		var xCount = 0;
for(var i=0; i<xList.length; i++)	{	var xID = document.getElementById(xList[i]);
	if(xID)	{				xCount++;
	if(xID.innerHTML=='')	{		xID.innerHTML = '<div style="position:absolute"><img alt="" src=".pic/wait.gif" /></div>';	}	}	}

	if(xCount==0)				return;


if(inter==undefined)
	inter = 0;
if(a==undefined)
	a = 'javascript:wrapRequest(\''+ id +'\',\''+ to +'\',\'';
if(b==undefined)
	b = '\','+ inter +')';					var req = false;

	req = new FetchReq();			if (!req)	return;
	req.onreadystatechange = function() {			wrapJoint(req,id,to,inter,a,b);	}
	req.open('GET', url+'&async=32&wrap='+id+'&wrapto='+to, true);		req.send(null);	}



	var cpPanel = 'cp_x';

function cpSelect(panel)	{		if(cpPanel==panel)		return;

	var a = document.getElementById(cpPanel);
	var b = document.getElementById(panel);

	a.style.borderColor = '#bfbfbf';
	b.style.borderColor = '#007fff';

	cpPanel = panel;

}

function cpRequest(url,wrap)	{
	if(wrap==undefined)	wrap = 'cpx';			wrapRequest(wrap,cpPanel, url);
	var xCP = document.getElementById('cp');
	xCP.style.visibility = 'visible';			xCP.style.top = document.documentElement.scrollTop + 'px';	}





function wrapiRequest(id,to,url,inter,a,b, time)	{
	var s = 'wrapRequest(\''+id+'\', \''+id+'\', \''+url+'\', '+inter+', \''+a+'\', \''+b+'\')';
	setInterval(s, time);	}





function ClearWin(win)	{	if(win=='')	return;

	document.getElementById(win).style.visibility = 'hidden';

	if(winLast==win)	winLast = '';	}



function eveDoLink(link,text) {
	var xLink = "<a target=\"_blank\" href=\"" + link + "\">" + text + "</a>";	return xLink;	}



function eveInsertText(id,text) {
	document.getElementById("content").innerHTML = form.caretPos;	}



function eveUpdateText() {
	head = document.getElementById("header").value;
	content = document.getElementById("content").value;

sign = "\r\n";

for(var i=0; i<=99; i++)	{
	head = head.replace(sign, '<br>');
	content = content.replace(sign, '<br>');	}

	document.getElementById("v_header").innerHTML = head;
	document.getElementById("v_content").innerHTML = content;	}



function insertAtCursor(myField, myValue) {   
	var myField = document.getElementById(myField);
//  Для MSIE   
if (document.selection)	{
	myField.focus();   
	sel = document.selection.createRange();   
	sel.text = myValue;	}   

// Для нормальных браузеров   
else if (myField.selectionStart || myField.selectionStart == '0')	{
	var startPos = myField.selectionStart;   
	var endPos = myField.selectionEnd;   
	myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);	}   

// Для остальных
else	myField.value += myValue;	}  





function curStyle(el, cssprop){
if (el.currentStyle) //IE
	return el.currentStyle[cssprop]
else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox
	return document.defaultView.getComputedStyle(el, "")[cssprop];
else	//try and get inline style
	return el.style[cssprop];	}





function getOpacity(id)	{		var elem = document.getElementById(id);

	if(opaqType=='')		fetchOpacity();

	if(curStyle(elem,'visibility')=='hidden')	return 0;

if (opaqType=="filter")	{		var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
	if (oAlpha)			return oAlpha.opacity / 100;		return 1;	}

if(elem.style[opaqType]=='' && elem.style[opaqType]!='0')
	return 1;			return parseFloat(elem.style[opaqType]);	}



function setOpacity(sElemId, nOpacity)	{		if(opaqType=='')	fetchOpacity();

	var elem = document.getElementById(sElemId);
	if (!elem || !opaqType)				return;

	if(curStyle(elem,'visibility')=='hidden' && nOpacity!=0)		elem.style.visibility = 'visible';
  
if (opaqType=="filter")	{				nOpacity *= 100;
	var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
	if (oAlpha) oAlpha.opacity = nOpacity;
	else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";  }

else	elem.style[opaqType] = nOpacity;	}





function findFade(id)	{		var time = FetchTime();
for(var i=0; i<aFade.length; i+=2)	if(aFade[i]==id)	{
	if(time>(aFade[i+1]+2000)){	aFade.splice(i,2);	break;	}	else	return i;	}
	return -1;	}

function remFade(id)	{		var i = findFade(id);
	if(i!=-1)			aFade.splice(i,2);	}

function addFade(id)	{		if(findFade(id)!=-1)				return 0;
	aFade.push(id);			aFade.push(FetchTime());			return 1;	}


function strFade()	{		var s = aFade.length + ' : ';
for(var i=0; i<aFade.length; i++)	s += aFade[i] + ' | ';				return s;	}



function miliTime()	{		var xTime = FetchTime();			return xTime;	}



function procFade(id, a,b, from,to){	var x = (miliTime()-a) / (b-a);

if(x>=1)	{			setOpacity(id,to);		remFade(id);
if(to==0)	{			var xID = document.getElementById(id);
	if(xID)				xID.style.visibility = 'hidden';	}	return;	}

//	var k = x * Math.PI * 0.5;
//	var now = from + Math.sin(k) * (to-from);

	var now = from + x * (to-from);

	setOpacity(id,now);

	var s = 'procFade(\''+id+'\','+a+','+b+','+from+','+to+')';

	setTimeout(s,10);	}



function runFade(id,time, to)	{	if(addFade(id)==0)	return;

	var elem = document.getElementById(id);

	if(curStyle(elem,'visibility')=='hidden')		setOpacity(id,0);
if(to>=0)
	elem.style.visibility = 'visible';
	

	var from = getOpacity(id);

	var a = miliTime();	var b = a + time;

	if(from==to)		return;

	var s = 'procFade(\''+id+'\','+a+','+b+','+from+','+to+')';

	setTimeout(s,10);	}

function fadeIn(id, time)	{	runFade(id,time,1);	}
function fadeOut(id, time)	{	runFade(id,time,0);	}




function SlideRoutine(list,delay,period,index)	{

	var xList = Explode(',', list);

	var xIndex = index+1;

	if(xIndex>=xList.length)	xIndex = 0;

//	document.title += index;


//alert(period);
//	alert(xList[index] + ' x ' + xList[xIndex]);
	fadeOut(xList[index], period);
	fadeIn(xList[xIndex], period);


	var s = 'SlideRoutine(\''+list+'\','+delay+','+period+','+xIndex+')';
	setTimeout(s, delay);
}


function SlideShow(list,delay,period)	{

	var s = 'SlideRoutine(\''+list+'\','+delay+','+period+',0)';

	setTimeout(s, delay);	}





function FollowFolder(to,enter,prop)	{

	if(prop==undefined)		prop = enter;

if(IsShift())
	cpRequest('?route=folder_edit;;;'+prop);
else	cpRequest('?route=folder_nav;;;'+enter);

	return false;	}



function FollowMod(type)	{

if(IsShift())
	cpRequest('?pages='+type+'_cp&cp=cfg');
else	cpRequest('?pages='+type+'_cp');

//	alert('123');
	return false;
}



function FollowMod2(type)	{

	cpRequest('?route='+ type +'cp_lobby;'+ cpPanel +';;');

	return false;
}







function eveAddLink()	{
	var xEl = document.getElementById('content');		xEl.focus();

	var xLink = "<a target=\"_blank\" href=\"" + document.getElementById("link").value + "\">" + document.getElementById("link_t").value + "</a>";
	insertAtCursor('content', xLink);
	document.getElementById('v_content').innerHTML = document.getElementById('content').value;	}





function catClick(id,view)	{			var name = 'cat_'+id;

	var o = document.getElementById(name);
	var oo = document.getElementById(name+'_x');

if(o.innerHTML!='')	{
	oneRequest('?op=cf='+ id +','+view);		o.innerHTML = '';	o.style.height='';	}
else{	wrapRequest('mod',name, '?mod_0=of='+ id +';vf='+ id +','+ view);	}	}





function FrameContent(id)	{			var x = document.getElementById(id);

if (x.contentDocument)
	var d = x.contentDocument;	else
if (x.contentWindow)
	var d = x.contentWindow.document;
else	var d = window.frames[id].document;		return d.body.innerHTML;	}




function asyncPatchString(s)	{	var a = 'javascript:wrapRequest(\'cpx\',\''+ cpPanel + '\',\'';
	ExecScripts(s);
	var b = '\')';			return patchString(s, a,b);	}



function LinkFrame(frame,win,out){	var x = document.getElementById(out);
if(x)	{				var z = asyncPatchString(FrameContent(frame));
	if(z!='')			x.innerHTML = z;	}	}



function validateUser()	{		xForm = window.document.form;			var oPW = document.getElementById('opw');
	if(oPW)
	if(oPW.value=="")	{	window.alert("Вы не указали пароль");		oPW.focus();		return false; }

	return true;	}





function tedInit(o,out)	{
	ted.object = o;		ted.out = document.getElementById(out);	}


function tedOut()	{
	if(ted.object!=undefined && ted.out!=undefined)
		ted.out.innerHTML = ted.object.value;	}


function tedSelect(myField)	{//	document.title += '1';		return;

if (document.selection)	{
	return;	}

// Для нормальных браузеров   
else if (myField.selectionStart || myField.selectionStart == '0')	{
	ted.a = myField.selectionStart;
	ted.b = myField.selectionEnd;	}

	return;	}



function tedUpdate()	{	if(ted.out==undefined)	return;

	var x = ted.object.value;

for(var i=0; i<=99; i++)	x = x.replace("\r\n", '<br />');

	ted.out.innerHTML = x;

	var la = ted.out;	}



function tedPatch(a,b)	{	var area = ted.object;

	var A = '<'+a;		if(b!=undefined)	A += ' '+ b;
	A += '>';		var B = '</'+a+'>';

if (document.selection)	{
	ted.object.focus();	sel = document.selection.createRange();		sel.text = A + sel.text + B;	}

else	area.value = area.value.substring(0, ted.a) + A + area.value.substring(ted.a, ted.b) + B + area.value.substring(ted.b, area.value.length);

//else	alert('something else');	//	ted.object.value += A + sel.text + B;


	tedUpdate();	}





function capsRequest(redraw)	{

	fetchWheel();		fetchOpacity();

	var caps = "?caps&body="+getClientWidth()+'x'+getClientHeight()+"&screen="+screen.width+'x'+screen.height+"&depth="+(((navigator.appName.substring(0,3)=="Mic"))?screen.colorDepth:screen.pixelDepth);

	caps += '&alpha='+opaqType+'&wheel='+wheelType;

	req = new FetchReq();				if(req)	{
	req.open('GET', caps, true);			req.send(null);	
if(redraw)
	setTimeout('window.location.replace(document.URL)', 500);	}	}



/*
var tickXY;
var tickW = 685; // width of ticker in pixel
var tickFirst = true;
var l2, l3, l;



function tickinit() {

	tickXY = elemPos('ticktext');

	l2 = tickXY[0] + tickW;
	l3 = tickXY[0] - l2;
	l = l2;

	setInterval('tick()', 50);	}



function tick()	{		var tick = document.getElementById('ticktext');

	l = l - 2;		if (l < l3) l = l2;
	cl = tickXY[0] - l;	cr = l2 - l;


	tick.style.left = l + 'px';
	tick.style.top = tickXY[1] + 'px';
	tick.style.clip = 'rect(auto '+cr+'px auto '+cl+'px)';
	if (tickFirst)		tick.style.visibility = 'visible';


	tickFirst = false;	}




//	setTimeout('tickinit()', 3000);
*/





function FixFolderPosition(group,first)	{	//	first = 1;

	var xBeacon = document.getElementById(group),		xFile = document.getElementsByName(group+'_file');

	var xPos = elemPos('', xBeacon), x = 0, y = -1,		cCol = Math.floor((xPos[2]/142));

	var cRow = Math.floor(xFile.length / (cCol-1)) + 1;	if(cCol>xFile.length)		cRow = 1;


	var s = '<table class="cms_text" cellpadding="4" cellspacing="4">',	i = 0;

if(first)	{
	s += '<tr>'+ xFile[0].value +'</tr>';		i = 1;	}

for(var r=0; r<cRow; r++){	s += '<tr>';

for(var c=0; c<cCol; c++){	if(i>=xFile.length)	break;
	s += xFile[i].value;	i++;		}	if(cRow==1)	s += '<td></td>';	s += '</tr>';	}


	s += '</table>';


	xBeacon.innerHTML = s;


/*

for(var i=0; i<xFile.length; i++)	{	x = i % r;	if(x==0)	s += '<table><tr>';

	xFile[i].style.left = (xPos[0]+x*w) + 'px';		xFile[i].style.top = (xPos[1]+y*h) + 'px';

	xFile[i].style.visibility = 'visible';	}

*/


/*
for(var i=0; i<xFile.length; i++)	{	x = i % r;	if(x==0)	y++;

	xFile[i].style.left = (xPos[0]+x*w) + 'px';		xFile[i].style.top = (xPos[1]+y*h) + 'px';

	xFile[i].style.visibility = 'visible';	}
*/

}





function VerticalScroll(d)	{

	var view = elemPos(idScroll[0]),		clip = elemPos(idScroll[1]);

	if(clip[3]<view[3])		return;		var y = clip[1] + d;

	var minY = view[3] - clip[3],			maxY = 0;

if(morph[idScroll[1]])
	y = parseInt(morph[idScroll[1]].y2) + d/10;

	if(y<minY)	y = minY;	if(y>maxY)	y = maxY;

	morphRun(idScroll[1], 'y,'+ y +',c,'+ (-y) +',-1,'+ (view[3]-y) +',-1', 250,1);

	morphRun(idScroll[1], 'y,'+ y, 500,1);

}





function wrapRoutine(from,to,bits,x)	{

	if(bits==undefined)				bits = 0;

	var a = document.getElementById(from);		var b = document.getElementById(to);

	if(a==undefined || b==undefined)		return;

if(bits&1)	{

	sa = 'javascript:wrapRequest(\''+ x +'\',\''+ to +'\',\'';	sb = '\',0)';

	b.innerHTML = patchString(a.innerHTML, sa,sb);

}

else	b.innerHTML = a.innerHTML;			a.outerText = '';	}



function placeRoutine(from,to,bits,x)	{

	setTimeout('wrapRoutine(\''+from+'\',\''+to+'\','+bits+',\''+x+'\')',0);	}





function runAlpha0(id)	{	morphRun(id,'a,0',500,1);	}
function runAlpha1(id)	{	morphRun(id,'a,1',500,1);	}



function rollnroll(id)	{				var a = document.getElementById(id);

	var aXY = elemPos('',a),			bXY = elemPos(id+'_back');

	a.style.width = bXY[2]+'px';

if(bXY[3])	{
	morphRun(id, 'c,-1,-1,0,-1',500,1);		morphRun(id+'_back', 'h,0',500,1);	}
else	{
	morphRun(id, 'c,-1,-1,'+aXY[3]+',-1',500,1);	morphRun(id+'_back', 'h,'+aXY[3],500,1);	}	}



function linkInputs(from,to)	{

	var a = Explode(',', from),			b = Explode(',', to);

	var aC = a.length,				bC = b.length;

for(var i=0; i<aC; i++)	{

	var xA = document.getElementById(a[i]), 	xB = document.getElementById(b[i]);

	if(xA==undefined || xB==undefined)		continue;

//	alert(xA.value+' x '+xB.value);

	xB.value = xA.value;

}	}



function tuner(name)	{
	var a = document.getElementsByName(name),	query = '?route=view_cfg;;;';
if(a.length)
	query += a[0].value;				winRequest('win', query);	}



function selectScroll(id,clip,type)	{
	idScroll[0] = id;	idScroll[1] = clip;	idScroll[2] = type;	}

function clearScroll()	{
	idScroll[0] = '';	idScroll[1] = '';	idScroll[2] = 0;	}



function SystemWheel(e)	{	var evt = window.event || e;

	var delta = evt.detail ? evt.detail*(-120) : evt.wheelDelta;

	if(idScroll[0]=='')	return true;

	VerticalScroll(delta);

if (evt.preventDefault)
	evt.preventDefault();	else	return false;	}



fetchWheel();

if (document.attachEvent)
	document.attachEvent("on"+wheelType, SystemWheel)
if (document.addEventListener)
	document.addEventListener(wheelType, SystemWheel, false);

