isDOM=$;
isMSIE=document.all && document.all.item;
isNetscape4=document.layers;
isOpera=window.opera;
isOpera5=isOpera && isDOM;
isMSIE5=isDOM && isMSIE && (!isOpera);
isMozilla=isNetscape6=isDOM && !isMSIE && !isOpera;
isGecko=(navigator.userAgent.toLowerCase().indexOf('gecko') != -1);
isMSIE6=isMSIE5 && (navigator.userAgent.toLowerCase().indexOf('6.0') != -1);
isMSIE7=isMSIE5 && (navigator.userAgent.toLowerCase().indexOf('7.0') != -1);

NoMail = false;

function $(v) {return(document.getElementById(v));}

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp=false;}}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {xmlhttp = new XMLHttpRequest();}

var xmlhttpC=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try{xmlhttpC=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttpC=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttpC=false;}}
@end @*/
if (!xmlhttpC && typeof XMLHttpRequest!='undefined') {xmlhttpC = new XMLHttpRequest();}

function SetC(name, value, path) {if(name!=null && name!=''){document.cookie=name+'='+escape(value)+';path='+path+';expires=Fri, 31 Dec 2010 23:59:59 GMT;';return true;}else{return false;}}
function GetC(name) {var cstr=document.cookie;var index=cstr.indexOf(name+'=');if (index==-1) {return null;}index=cstr.indexOf('=',index)+1;var endstr=cstr.indexOf(';',index);if (endstr==-1) {endstr=cstr.length;}return unescape(cstr.substring(index,endstr));}
function DelC(name, path) {var today=new Date();var expire=new Date();expire.setTime(today.getTime()-3600000*24*365);document.cookie=name+'='+'value=;expires='+expire.toGMTString()+';path='+path;}
function SwapGroup(ID) {
	var divs = document.getElementsByTagName('DIV');
	var n = divs.length;
	for(i=0; i<n; i++){
		c=divs[i].id;
		if(!isNaN(parseInt(c))){
// Для варианта меню, когда развернута только одна ветка
/*			if(c==ID){
				$(c).style.display='';
			}else{
				$(c).style.display='none';
			}*/
// Для варианта меню, когда могут быть развернуты все ветки
			if(c==ID){
				if (divs[i].style.display=='') {
					divs[i].style.display='none';
				}else{
					divs[i].style.display='';
				}
			}
		}
	}
	ChangeIFrameHeight(2000);
}
function showDate() {
	if(!window.DD) {
		return false;
	}
	window.setTimeout('showDate()', 1000);
	if (!$('idClock')){
		return false;
	};
	var DT = new Date();
	DT.setTime(DT.getTime()+DD);
	var nD, nM, nY, nMin;nD = Number(DT.getDate());
	nM = Number(DT.getMonth()+1);
	nMin = DT.getMinutes();
	nSec = DT.getSeconds();
	var sDT = (nD<10?'0'+nD:nD)+'.'+(nM<10?'0'+nM:nM)+'.'+DT.getFullYear()+'&nbsp;&nbsp;'+DT.getHours()+':'+(nMin<10?'0'+nMin:nMin)+':'+(nSec<10?'0'+nSec:nSec);
	$('idClock').innerHTML = sDT;
}
function OpenWin(URL, Name, Width) {win = window.open(URL, Name, 'directories=0,hotkeys=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,width='+Width+',height=500');if(win){win.focus();}else{alert('Возможно у Вас заблокированы всплывающие окна. Для полноценной работы на сайте необходимо разрешить всплывающие окна.');}return win;}
function OpenWin2(URL, Name, Width, Height) {win = window.open(URL, Name, 'directories=0,hotkeys=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,width='+Width+',height='+Height);if(win){win.focus();}else{alert('Возможно у Вас заблокированы всплывающие окна. Для полноценной работы на сайте необходимо разрешить всплывающие окна.');}return win;}
function showhidesearch() {var e=$('searchbox');if(e){if(e.style.display=="none"){e.style.display="";} else {e.style.display="none";}}}
function showhidesearch2() {var e=$('searchbox2');if(e){if(e.style.display=="none") {e.style.display="";} else {e.style.display="none";}}}
function OpenOptimal(ID) {document.location.href = '/private/work/torg_optimal.php?FilterDetails=on&ID='+ID;}
function OpenDetail(ID) {OpenWin('/private/work/torg_detail.php?ID='+ID, 'Detail'+ID, 650);}
function OpenDetailNimo(ID) {OpenWin('/private/work/torg_detail_nimo.php?ID='+ID, 'Detail'+ID, 650);}
function OpenDetailGPN(ID) {OpenWin('/private/torg3/detail.php?ID='+ID, 'Detail'+ID, 650);}
function OpenDetailAuct(ID) {OpenWin('/private/work/torg_detail.php?Auct='+ID, 'DetailAuct'+ID, 650);}
function OpenAuctSign(ID) {document.location.href = '/private/auction/sign.php?id='+ID;}
function OpenAuctTorgID(ID) {OpenWin('/private/work/torg_auction.php?id='+ID, 'DetailAuct'+ID, 650);}
function OpenAuctTorg(Auct, Train) {OpenWin('/private/work/torg_auction.php?auct='+Auct+'&train='+Train, 'DetailAuct'+Auct, 650);}
function OpenEdit(ID) {document.location.href='/private/work/torg_edit.php?id='+ID;}
function OpenOffers(ID) {document.location.href='/private/work/torg_offers.php?id='+ID;}
function MakeOffer(ID,My) {if (My!='') {document.location.href='/private/work/torg_offer.php?id='+ID+'&my='+My;} else {document.location.href='/private/work/torg_offer.php?id='+ID;}}
function CloseOffer(ID,My) {if (ID!=''&&My!='') {document.location.href='/private/work/torg_close.php?id='+ID+'&my='+My;}}
function OpenSpot(ID) {document.location.href='/private/work/torg_spot.php?id='+ID;}

function ShowComment(Str) {
	try{
	var C=$('Comment');
	if (C) {
		C.innerHTML = Str;
		MoveComment();
	}
	} catch(e) {}
}
function MoveComment(evnt) {
	var C=$('Comment');
	if (C) {
		C.style.position = 'absolute';
		C.style.display = '';
		var cc = getEventPos(evnt);
		C.style.top=cc.y+10;
		var dw = parseInt(document.body.clientWidth);
		if ((dw>0) && (cc.x+10+200>dw)) {
			C.style.left=dw-200;
		} else {
			C.style.left=cc.x+10;
		}
//		ChangeIFrameHeight();
	}
}
function HideComment() {
	var e=$('Comment');
	if(e) {
		e.style.display = 'none';
	}
}

function SelectDate(VarName) {
	var DateVar=$(VarName);
	var x=(document.body.clientWidth-240)/2;
	var y=(document.body.clientHeight-220)/2;
	window.open("/private/site/selectdate.php?varname="+VarName+"&date="+DateVar.value, "SelectDate", 'directories=0,hotkeys=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,width=240,height=220,left='+x+',top='+y);
}
function SelectGoods(VarName,Maximum) {IDs=$( VarName ).value;var x=(document.body.clientWidth-240)/2;var y=(document.body.clientHeight-220)/2;window.open("/private/site/choose_goods.php?Maximum="+Maximum+"&IDs="+IDs, "SelectGoods", 'directories=0,hotkeys=0,location=0,menubar=0,resizable=0,scrollbars=1,status=1,toolbar=0,width=500,height=500,left='+x+',top='+y);}

var CurrentPageID = 0;

function UpdateCheckFrame(PageID) {
	CurrentPageID = PageID;
	window.clearTimeout();
	if (!xmlhttpC) {
		var em = $('CheckFrame');
		if(em){
			em.src='/private/site/check3.php?page='+PageID;
		}
		return true;
	}
	XmlhttpCheck(PageID);
}

var XmlhttpCheckPointer = 0;

function XmlhttpCheck(PageID) {
	var URL = "/private/site/check3.php?page="+PageID;
	if (NoMail) {
		URL += "&nomail";
	}
	try {
		xmlhttpC.abort();
		xmlhttpC.open("GET", URL, true);
		xmlhttpC.onreadystatechange=function() {
				if (xmlhttpC.readyState==4) {
					try {
						parseXmlhttpCheck(xmlhttpC.responseText);
					} catch(err) {}
				}
			}
		xmlhttpC.send("");
	} catch (err) {
		xmlhttpC = false;
		UpdateCheckFrame(PageID);
		return false;
	}
	if (XmlhttpCheckPointer>0) {
		window.clearTimeout(XmlhttpCheckPointer);
	}
	XmlhttpCheckPointer = window.setTimeout('XmlhttpCheck('+PageID+')', 20000);
}
function parseXmlhttpCheck(text) {
//	DebugWrite('<pre>'+text+'</pre>');
	if (text == 'No session id') {
		document.location.href = document.location.href;
		return true;
	} else if (text == 'No session data') {
		document.location.href = document.location.href;
		return true;
	} else if (text == 'Reload') {
		document.location.href = document.location.href;
		return true;
	} else if (text == 'Logout') {
		if (document.forms['logout']) {
			document.forms['logout'].submit();
		} else {
			document.location.href = document.location.href;
		}
		return true;
	}
	var strings = new Array();
	var users = new Array();
	var mails = new Array();
	strings = text.split("\n");
	var usersS = strings[0];
	var mailsS = strings[1];
	users = usersS.toString().split(";");
	mails = mailsS.toString().split(";");
	if (users.length==3) {
		try {
			SetCounts(users[0], users[1], users[2]);
		} catch(e) {}
	}
	if (mails.length>0) {
		for (i in mails) {
			var fromid = mails[i];
			if (fromid!='') {
				if (isOpera) {
					win = window.open('/private/site/sendmessage.php?to='+fromid, 'SendMsg'+fromid, 'directories=0,hotkeys=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,width=600,height=500');
					win.focus();
				} else {
					ShowMail(fromid);
				}
			}
		}
	}
}


function GoToPage(URL){
	FastReload(URL,'',0);
};
function FastReload(URL,Title,ID) {
	var el=$('PageReloadFrame');
	if(el){
		ShowInfoBox('<br>Загрузка страницы...<br><br>');
		var PT=$('PageTitleTD');
		if(PT){
			PT.innerHTML = Title;
		}
		el.src='http://'+DomainName+URL;
		UpdateCheckFrame(ID);
	}else{
		document.location.href=URL;
	}
	return false;
}
function PageLoaded() {
	var el=$('PageReloadFrame');
	var PT=$('PageTitleTD');
	if(el && PT){
		if (el.contentWindow.document.location.href.toString().indexOf("/forum/")==-1) {
			if (el.contentWindow.document.title) {
				if(PT){
					PT.innerHTML = el.contentWindow.document.title;
				}
				document.title = el.contentWindow.document.title;
			}
		}
	}
//	ChangeIFrameHeight(1200);
	try{
		if (el.contentWindow.document.location.href.toString().indexOf("#")==-1) {
			top.scroll(0,0);
		}
	}catch(e){}
	HideInfoBox();
}
function ChangeIFrameHeight(n) {
	if (n<800) {
		n = 800;
	}
	try{
		var el=$('PageReloadFrame');
		if(!el){
			el=window.parent.document.getElementById('PageReloadFrame');
		}
		if(!el){
			return false;
		}
		var h = 0;
		if (el.src.toString().indexOf("/private/")!=-1 && el.contentWindow && el.contentWindow.document.body) {
			h = parseInt(el.contentWindow.document.body.scrollHeight)+20;
		}
		if (h<n) {h = n;}
		el.style.height = h;
	}catch(e){}
}
function ShowInfoBox(text) {
	el = $('TextInfoBox');
	if (el) {
		el.innerHTML = text;
		el.style.left = (parseInt(document.body.scrollWidth)-300)/2;
		el.style.top = (parseInt(document.body.offsetHeight)-40)/2;
		el.style.display = '';
	}
}
function HideInfoBox() {
	el = $('TextInfoBox');
	if (el) {
		el.style.display = 'none';
	}
}

function GetChatObj() {
	var ChatObjFrame = $('ChatObjFrame');
	if (!ChatObjFrame) {
		return false;
	}
	var ChatObj = ChatObjFrame.contentWindow.document.getElementById('ChatObj');
	if (!ChatObj) {
		return false;
	}
	return ChatObj;
}

var CommLeft = GetC('CommLeft');
var CommTop = GetC('CommTop');
if (CommLeft=='' || CommLeft<=0 || CommLeft>500) {CommLeft=156;}
if (CommTop=='' || CommTop<=0 || CommTop>500) {CommTop=0;}

function ShowComm() {
	var CommTab = $('CommTab');
	var ChatObj = $('ChatObjFrame');
	if (CommTab && ChatObj) {
		CommTab.style.left = CommLeft;
		CommTab.style.top = CommTop;
		CommTab.style.visibility = 'visible';
		ChatObj.style.display = '';
		ChatObj.style.visibility = 'visible';
		window.top.focus();
	}
}

function HideComm() {
	var CommTab = $('CommTab');
	var ChatObj = $('ChatObjFrame');
	if (CommTab && ChatObj) {
		CommLeft = parseInt(CommTab.style.left);
		CommTop = parseInt(CommTab.style.top);
		SetC('CommLeft', CommLeft, '/');
		SetC('CommTop', CommTop, '/');
		CommTab.style.left = -2000;
	}
}

function ShowChat() {
	ShowComm();
}

function ChatPre() {
	HideComm();
}

function CallUser(UserID, Win) {
	if (UserName=='') {
		return false;
	}
	if (!Win) {
		try {
			if (fow) {
				Win = fow;
			} else {
				return false;
			}
		} catch(e) {
			return false;
		}
	}
	var CO = Win.GetChatObj();
	if (!CO) {
		alert('Не найден коммуникатор.');
		return false;
	}
	var UserName = '';
	var UserFIO = '';
	xmlhttp.abort();
	xmlhttp.open("GET", "/private/site/userinfo.php?id="+UserID, false);
	xmlhttp.send("");
	if (xmlhttp.readyState==4 && xmlhttp.status==200) {
		var Strings = xmlhttp.responseText.toString().split("	", 2);
		if (Strings.length != 2) {
			alert('Возникла ошибка при получении информации о пользователе.');
		} else {
			UserName = Strings[0];
			UserFIO = Strings[1];
			var res = CO.FormingListCall(UserID, UserName, UserFIO);
			Win.focus();
			Win.ShowComm();
		}
	} else {
		alert('Невозможно получить информацию о пользователе.');
	}
}

function jsFunc() {
	ShowComm();
}

var isDrag = false;
X0point = 0;
Y0point = 0;

function CDD(evnt) {
	isDrag = true;
	var e, elem, mx;
	e = getEventPos(evnt);
	if (isMSIE5) {
		e.x=e.x-10;
	}
	elem = $('CommTab');
	if (elem) {
		X0point = e.x - parseInt(elem.style.left);
		Y0point = e.y - parseInt(elem.style.top);
//		elem.style.filter="Alpha(Opacity=90)";
	}
	var el2 = $('ChatObjFrame');
	if (el2) {
		el2.style.visibility = 'hidden';
	}
	document.body.onmousemove = CDM;
	document.body.onmouseup = CDU;
}

function CDM(evnt) {
	if(!isDrag) return true;
	var e, elem, mx;
	e = getEventPos(evnt);
	if (isMSIE5) {
		e.x=e.x-10;
	}
	elem = $('CommTab');
	if (elem) {
		var w = elem.width;
		var h = elem.height;
		var ww = document.body.scrollWidth;
		var wh = document.body.scrollHeight;
		if (e.x-10<X0point) {
			e.x=X0point;
		}
		if (e.y-10<Y0point) {
			e.y=Y0point;
		}
		if (e.x+10>ww-w+X0point) {
			e.x=ww-w+X0point;
		}
		if (e.y+10>wh-h+Y0point) {
			e.y=wh-h+Y0point;
		}
		elem.style.left = e.x-X0point;
		elem.style.top = e.y-Y0point;
	}
	return false;
}

function CDU(evnt) {
	if (!isDrag) {
		return false;
	}
	isDrag = false;
	var el = $('CommTab');
	if (el) {
		CommLeft = el.style.left;
		CommTop = el.style.top;
		SetC('CommLeft', CommLeft, '/');
		SetC('CommTop', CommTop, '/');
//		el.style.filter="";
	}
	var el2 = $('ChatObjFrame');
	if (el2) {
		el2.style.visibility = 'visible';
	}
}

function getPos(el){
	var lxx, lyy;
	for (lxx=0,lyy=0;el!=null;) {
		lxx += el.offsetLeft;
		lyy += el.offsetTop;
		if (el.scrollTop != 0) {
//			lyy -= el.scrollTop;
		}
		el=el.offsetParent;
	}
	return {x:lxx, y:lyy};
}

function getEventPos(evnt){
	var ex, ey;
	if (!evnt) {
		evnt = window.event;
	}
	try {
		if (!window.parent || window.parent==window) {
			return getEventPos2(evnt);
		}
	} catch(e) {
		return getEventPos2(evnt);
	}
	if (evnt) {
		var pos = getPos(evnt.srcElement);
		if (pos.x>evnt.offsetX) {
			ex=evnt.offsetX+pos.x;
		} else {
			ex=evnt.offsetX;
		}
		if (pos.y>evnt.offsetY) {
			ey=evnt.offsetY+pos.y;
		} else {
			ey=evnt.offsetY;
		}
	}
	return {x:ex,y:ey};
}
function getEventPos2(evnt){
	var pos = getPos(evnt.srcElement);
	return {x:pos.x,y:pos.y};
}

function SetCounts(C1, C2, C3) {
	if (!window.parent) {return false;}
	if (window.parent.document.getElementById('AUsersOnline')) {
		window.parent.document.getElementById('AUsersOnline').innerHTML='Авторизованных: '+C1;
		if (C2!='' && C2>0) {
			window.parent.document.getElementById('AUsersHere').innerHTML='Всего на сайте: '+C2;
		}
		window.parent.document.getElementById('AUsersAdm').innerHTML='Администрация: '+C3;
	}
}
function EditPoll(id){GoToPage('/private/polls/admin.php?id='+id);}
function DelPoll(id){if(confirm('Вы действительно хотите удалить опрос и все результаты опроса?')){GoToPage('/private/polls/admin.php?act=del&id='+id);}}

function SelectTNVED(VarName) {
	if ($(VarName)) {
		ID=$(VarName).value;
		OpenWin("/private/instruments/fea/tnved.php?ID="+ID, "TNVED", 600);
	}
}

function OpenHelp() {
	OpenWin('/private/site/help.php?PageID='+CurrentPageID, 'Help', 700);
}

var MailXMLs = new Array();
function ShowMail(AuthorID) {
	try{
		var n = parseInt(AuthorID);
		if(isNaN(n) || n==0) {
			return false;
		}
	} catch(e) {
		return false;
	}
	n = MailXMLs.length;
	MailXMLs[n]=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try{MailXMLs[n]=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{MailXMLs[n]=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){MailXMLs[n]=false;}}
	@end @*/
	if (!MailXMLs[n] && typeof XMLHttpRequest!='undefined') {MailXMLs[n] = new XMLHttpRequest();}
	var URL = "http://"+DomainName+"/private/mail/lastmessage.php?ID="+AuthorID+"&r="+Math.random();
	MailXMLs[n].open("GET", URL, true);
	MailXMLs[n].onreadystatechange=function(evnt) {
			if (MailXMLs[n].readyState==4) {
				if (MailXMLs[n].status==200) {
					parseMailXmlCheck(n, MailXMLs[n].responseText, AuthorID);
				}
			}
		}
	MailXMLs[n].send("");
}

function parseMailXmlCheck(n, text, AuthorID) {
	var arr = text.toString().split("\n", 5);
	if (arr.length<5) {
		return false;
	}
	
	if (arr[1]=='') {
		return false;
	}
	
	if (arr[4]=='') {
		return false;
	}
	
	var MessageText = '<img src="/images/dd/mail.gif" width="37" height="35" alt="" border="0" align="left">';
	MessageText += 'Дата: '+arr[3];
	MessageText += '<br>';
	MessageText += 'Автор: ';
	var Img = '/images/status/online.gif';
	if (arr[3]==-1) {
		Img = '/images/status/blocked.gif';
	} else if (arr[3]==0) {
		Img = '/images/status/offline.gif';
	} else if (arr[3]==2) {
		Img = '/images/status/away.gif';
	}
	MessageText += '<nobr>';
	MessageText += '<img src="'+Img+'" width="10" height="10" border="0">';
	MessageText += '&nbsp;<a href="#" onclick="OpenWin(\'/profile/'+arr[0]+'\', \'Profile'+arr[0]+'\', 600); event.returnValue=false;return false;">'+arr[1]+'</a></nobr>';
	MessageText += '<br>';
	MessageText += '<br>';
	var TT = arr[4];
	MessageText += TT.toString().replace(/<a/ig, '<a style="font-size:11px;"');
	
	try {
		var msgwin = window.replywindows[AuthorID];
		if (msgwin) {
			msgwin.AddMsgInHistory(1, TT);
		} else {
			ShowDD(300, MessageText, arr[0], n);
		}
	} catch(e) {
		ShowDD(300, MessageText, arr[0], n);
	}
}

function MarkReaded(ID, n) {
	MailXMLs[n].open("GET", "http://"+DomainName+"/private/mail/markreaded.php?ID="+ID+"&r="+Math.random(), true);
	MailXMLs[n].onreadystatechange=function(evnt) {
			if (MailXMLs[n].readyState==4) {
				if (MailXMLs[n].status==200) {
					MailXMLs[n]=null;
				}
			}
		}
	MailXMLs[n].send("");
}

var DDs = 0;
function ShowDD(w,text,AuthorID, n) {
	DDs++;
	var el;
	el = document.createElement('DIV');
	el.id = 'dd'+DDs;
	document.body.appendChild(el);
	el.style.fontSize = '11px';
	el.style.padding = '0px';
	el.style.backgroundColor = WindowBackgroundColor;
	el.style.border = '2px solid #006400';
	el.style.borderRight = '0px';
	el.style.position = 'absolute';
	el.style.width = '200px';
//	el.style.height = '100px';
//	el.style.filter = 'alpha(opacity=0, style=0)';
	el.style.overflow = 'hidden';
	el.style.display = 'none';
	
	var iHTML = '<table width="'+w+'" height="100%" cellpadding="0" cellspacing="0" border="0">';
	iHTML += '<tr>';
	iHTML += '<td valign="top" style="padding:3px;"><div style="font-size:11px;overflow-x:auto;width:'+(w-36)+'px;height:100px;">';
	iHTML += text;
	iHTML += '</div></td>';
	iHTML += '<td rowspan="2" background="/images/dd/close_bg.gif" width="30" align="right" valign="top">';
//	iHTML += '<img src="/images/dd/close2.gif" width="30" height="46" alt="Закрыть" border="0" style="cursor:pointer;" onclick="CloseDD(\''+el.id+'\');">';
	iHTML += '<img src="/images/communicator/close.gif" width="21" height="21" alt="Закрыть" border="0" style="margin:5px;cursor:pointer;" onclick="CloseDD(\''+el.id+'\');">';
	iHTML += '</td>';
	iHTML += '</tr>';
	if (AuthorID!=99999) {
		iHTML += '<tr>';
		iHTML += '<td height="20" style="padding:3px;">';
		iHTML += '<input type="button" class="register" value="Ответить" style="width:120px;font-size:10px;font-weight:bold;color:#006400;" onclick="OpenWin2(\'/private/site/reply.php?to='+AuthorID+'\', \'Reply'+AuthorID+'\', 550, 550);CloseDD(\''+el.id+'\');">';
		iHTML += '&nbsp;&nbsp;&nbsp;';
		iHTML += '<input type="button" class="register" value="История общения" style="width:120px;font-size:10px;font-weight:bold;" onclick="OpenWin(\'/private/site/sendmessage.php?to='+AuthorID+'\', \'SendMsg'+AuthorID+'\', 600);CloseDD(\''+el.id+'\');">';
		iHTML += '</td>';
		iHTML += '</tr>';
	}
	iHTML += '</table>';
	el.innerHTML = iHTML;
	
	el.style.width = 2;
	
	el.style.top = 100;
	el.style.left = parseInt(document.body.offsetWidth)-parseInt(el.style.width)-21;
	
	el.style.display = '';
	
	MoveDD(20,w,el.id);
	window.focus();
	
	MarkReaded(AuthorID, n);
}

function MoveDD(d,w,name) {
	var el = $(name);
	if (!el) {return false;}
	
	if (parseInt(el.style.width)<-d) {
		d = -parseInt(el.style.width);
	}
	el.style.width = parseInt(el.style.width)+d;
	el.style.left = parseInt(document.body.offsetWidth)-parseInt(el.style.width)-21;
	var op = Math.round(parseInt(el.style.width)*100/w);
//	el.style.filter = 'alpha(opacity='+op+', style=0)';
	if (parseInt(el.style.width)==0) {
		el.style.display = 'none';
		document.body.removeChild(el);
		return false;
	}
	if (parseInt(el.style.width)<w) {
		setTimeout("MoveDD("+d+","+w+",'"+name+"')", 10);
	}
}

function CloseDD(name) {
	MoveDD(-20,1000,name);
}


var fow = window;
try {
	while (fow.opener) {fow = fow.opener;}
	while (fow.parent && fow!=fow.parent) {fow = fow.parent;}
} catch(err) {}
if (!fow) {fow = window}

if (isMSIE6 || isMSIE7) {
	showDate();
}


function DebugWrite(text) {
	var el = $('DebugDiv');
	if (!el) {return false;}
	var t = el.innerHTML;
	t = t + text;
	el.innerHTML = t;
}




function TryLogin(Login, Pass) {
	if (Login=='' || Pass=='') {
		alert('Введите логин и пароль.');
		return false;
	}
	if (xmlhttp) {
		xmlhttp.abort();
		var re = /\&/g;
		Pass = Pass.toString().replace(re, '%26');
		re = /=/g;
		Pass = Pass.toString().replace(re, '%3D');
		xmlhttp.open("GET", "/private/auth/login.php?name="+Login+"&pass="+Pass+"&rid="+Math.random(), false);
		xmlhttp.send("");
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
			var txt = xmlhttp.responseText;
			var strings = new Array();
			strings = txt.split("\n");
			var authcode = strings[0];
			if (authcode == '-1') {
				alert('Ваша учетная запись заблокирована. За более подробной информацией обратитесь к администратору.');
				return false;
			} else if (authcode == '-2') {
				alert('Неправильный пароль. Пожалуйста, попробуйте ввести пароль еще раз.');
				return false;
			} else if (authcode == '-3') {
				alert('Указанный логин не существует. Пожалуйста, попробуйте ввести логин и пароль еще раз.');
				return false;
			} else if (authcode == '-4') {
				alert('С Вашего IP-адреса доступ к этой учетной записи запрещен.');
				return false;
			} else if (authcode == '-6') {
				alert('Ваша учетная запись не имеет доступа к данному сайту.');
				return false;
			} else if (authcode == '-6') {
				alert('Ваша учетная запись не имеет доступа к данному сайту.');
				return false;
			} else if (authcode == '-7') {
				alert("В вашем профиле найдены некорректные данные.\nВы можете самостоятельно исправить данные на сайте oilid.ru или обратиться за помощью к администратору.");
				return false;
			} else if (authcode == '-10') {
				return true;
			} else if (authcode == '1') {
				var url = '/';
				var fr = $('PageReloadFrame');
				try {
					var urlstr = fr.contentWindow.document.location.href;
					urlstr = urlstr.toString().substr(DomainName.toString().length+7);
					if (urlstr!='/private/main.php' && urlstr!='/private/main.php#') {
						url = '/?url='+urlstr;
					}
				} catch(e) {}
				document.location.href = url;
				return false;
			} else {
				alert('Ошибка авторизации ('+txt+'). Пожалуйста, повторите попытку чуть позже.');
				return false;
			}
		} else {
			return true;
		}
	} else {
		return true;
	}
}
function TryLogout() {
	if (xmlhttp) {
		xmlhttp.abort();
		xmlhttp.open("GET", "/private/auth/logout.php", false);
		xmlhttp.send("");
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
			var txt = xmlhttp.responseText;
			if (txt == '0') {
				var url = '/';
				var fr = $('PageReloadFrame');
				try {
					var urlstr = fr.contentWindow.document.location.href;
					urlstr = urlstr.toString().substr(DomainName.toString().length+7);
					if (urlstr!='/private/main.php' && urlstr!='/private/main.php#') {
						url = '/?url='+urlstr;
					}
				} catch(e) {}
				document.location.href = url;
				return false;
			} else {
				return true;
			}
		} else {
			return true;
		}
	} else {
		return true;
	}
}
