URL0="../";
URL1="http://chat.vulcan.ru/";
URL=URL0+"wl/nph-mgwcgi";
c29=String.fromCharCode(29);
c30=String.fromCharCode(30);
c31=String.fromCharCode(31);
c176=String.fromCharCode(176);
re1=0; re3=0; re4=0;
myWin=null;
Timer134=null;
Txt1="общей комнаты, привата и списка чатеров";
Opera=(navigator.appName=="Opera")?1:0;
Netscape=(navigator.appName=="Netscape")?"<br>":"";
OldIgnorBehaviour = 0; // Флаг на переключение старого поведения формы игнорирования
changeRoom=0;

if (document.images) { 
	img=new Array(3); 
	img[0]=new Image(); img[0].src=URL1+"0.gif"; 
	img[1]=new Image(); img[1].src=URL1+"1.gif"; 
	img[2]=new Image(); img[2].src=URL1+"2.gif"; 
	imgfoto=new Array(3); 
	imgfoto[0]=new Image(); imgfoto[0].src=URL1+"check0.gif"; 
	imgfoto[1]=new Image(); imgfoto[1].src=URL1+"check1.gif";
	imgfoto[2]=new Image(); imgfoto[2].src=URL1+"check2.gif";
	medal=new Image(); medal.src=URL1+"gif/medal1_L.gif"; 
} 

function init(){
	try {
		return new XMLHttpRequest();	//Mozilla, Safari, ...
	} catch (trymicrosoft) {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	}
}

req1=init(); req2=init(); req3=init(); req4=init(); reqsoob=init();

function ReqAjax(req,method,param,func,sync) {
	try {
		abortAjax(req)
		if (func=="") return 0;
		err=0;
		if (method=="GET") {
			var url=URL+"?"+param; param=null;
		} else {
			var url=URL;
		}
		req.open(method, url, sync);
		if (method=="POST") req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		req.onreadystatechange=function() {
		        if (req.readyState==4) {
			        if (req.status==200) {
					func(req.responseText);
				}
			}
		}
		req.send(param);
	} catch(e) {
		err=1;
		req.abort();
	}
}

function abortAjax(req) {
	try {
		req.abort();
	} catch(e) {
		alert(e.description);
	}
}

function Par(met) {
	var par="MGWAPP=AJAX&Pr="+met+"&rnd="+Math.random()+"&Opera="+Opera;
	try {
		var F5=top.Frame5.document;
		par+="&ver="+F5.getElementById('ver').value+"&keyNic="+F5.getElementById('keyNic').value+"&Pass1="+F5.getElementById('Pass1').value;
	} catch (e) {
		try {
			var F5=opener.top.Frame5.document;
			par+="&ver="+F5.getElementById('ver').value+"&keyNic="+F5.getElementById('keyNic').value+"&Pass1="+F5.getElementById('Pass1').value;
		} catch(e) {
	        	par+="&keyNic="+opener.document.getElementById('keyNic').value+"&Pass1="+opener.document.getElementById('Pass1').value;
		}
	} finally {
        	return par;
	}
}

function ReadFrame1(tip,t) {
	try {
		if (re1==800) {
			RenewFrame(1);
			return;
		}
		var F5=top.Frame5.document;
		var par=Par("ReadFrame")+"&Room="+F5.getElementById('Room').value+"&Page1="+top.Frame1.document.getElementById('Page1').value+"&key1="+F5.getElementById('key1').value+"&changeRoom="+changeRoom;
		ReqAjax(req1,"POST",par,ResultFrame1,"true");
	} catch (e) {
	}
}

function ReadFrame3(tip,t) {
	try {
		var p1=1; var p2=1;
		if (t==0) timeFrame3=0;
		Fr3Var(top.Frame3.document.getElementById('formFrame3'));
		var F5=top.Frame5.document;
		var par=Par("ReadFrame3")+"&NEW=1&SortF3="+F5.getElementById('SortF3').value+"&Room="+F5.getElementById('Room').value+"&ShowStat="+F5.getElementById('ShowStat').value;
		    par+="&timeFrame3="+t;
		ReqAjax(req3,"POST",par,ResultFrame3,"true");
	} catch(e) {
		//
	}
}

function ReadFrame4(tip,t) {
	try {
		if (re4==200) {
			RenewFrame(4);
			return;
		}
	} catch (e) {
		//
	} finally {
		var F5=top.Frame5.document;
        	var par=Par("ReadFrame")+"&Room="+F5.getElementById('Room').value+"&Page1="+top.Frame4.document.getElementById('Page1').value+"&key4="+F5.getElementById('key4').value;
		    par+="&ICQ="+F5.getElementById('ICQ').value;
		ReqAjax(req4,"POST",par,ResultFrame4,"true");
	}
}

function GoChat() {
	F4=top.Frame4.document;
	if (F4.getElementById('NameNic').value=="" && F4.getElementById('keyNic').value=="") {
		alert("Отсутствуют и NIC и регистрационный номер!");
		F4.getElementById('NameNic').focus();
		return;
	}
	if (F4.getElementById('Pass1').value=="") {
		alert("Отсутствует пароль!");
		F4.getElementById('Pass1').focus();
		return;
	}
	var par=Par("GoChat")+"&IP="+F4.getElementById('IP').value;
	    par+=encodeURI("&GoNameNic="+F4.getElementById('NameNic').value+"&GokeyNicF4="+F4.getElementById('keyNic').value+"&GoPass1="+F4.getElementById('Pass1').value);
	ReqAjax(req4,"POST",par,ResultGoChat,"false");
}

function ResultGoChat(s) {
	var d = s.split(c29);
	if (d[0]>0) {	//ошибка
		alert(d[1]);
		return;
	} else {
		var i=d[2].split(c30);
		if (i[0]>0) {
			var F5=top.Frame5.document;
			//Pus2
       			F5.getElementById('k').value=i[0];
			F5.getElementById('p').value=i[3];
			F5.getElementById('rnd').value=i[11];
			//F5
			F5.getElementById('keyNic').value=i[0];
			F5.getElementById('NameNic').value=i[1];
			F5.getElementById('Pass1').value=i[2]
			F5.getElementById('Rows').value=i[3];
			//Pus
			if (i[4]!='') {
				F5.getElementById('wall').value='on';
				F5.getElementById('WallPaper').value=i[4];
			} else {
				F5.getElementById('wall').value='';
			}
			F5.getElementById('c1').value=i[5];
			F5.getElementById('c4').value=i[6];
			F5.getElementById('c3').value=i[7];
			F5.getElementById('MyStyle').value=i[8];
			F5.getElementById('hh').value=i[9];
			//Ajax
			F5.getElementById('My6').value=i[12];
			F5.getElementById('My7').value=i[13];
			F5.getElementById('My8').value=i[14];
			F5.getElementById('My9').value=i[15];
			F5.getElementById('My10').value=i[16];
			if (i[17]!="") {
				var t=i[17].split(c31);
				F5.getElementById('t1').value=t[0]; F5.getElementById('t12').value=t[1];
				F5.getElementById('t4').value=t[2]; F5.getElementById('t42').value=t[3];
				F5.getElementById('t3').value=t[4]; F5.getElementById('t32').value=t[5];
			} else {
				F5.getElementById('t1').value=8; F5.getElementById('t12').value=60;
				F5.getElementById('t4').value=8; F5.getElementById('t42').value=60;
				F5.getElementById('t3').value=24; F5.getElementById('t32').value=60;
			}
			F5.getElementById('NicColor').value=i[18];
			//
			F5.getElementById('MsgSmile').value=i[20];
			F5.getElementById('ToMe').checked=(i[21]=="on")?true:false;
			if (d[3]==0) {
				if (i[0]>0) {
					var Pus="Приват/Личная комната [ "+i[22]+" ]";
					try {
						var F4=top.Frame4.document;
						F4.getElementById('d1').innerHTML=Pus;
						F4.getElementById('divleft').style.display="";					
						F4.getElementById('divright1').style.display="";
						F4.getElementById('divright2').style.display="";
       						RenewFrame(4);
        				} catch(e) {
						//
					}
				}
			}
			wall();
			window.defaultStatus="Рад с Вами работать, "+i[1];
			focusf5();
 			}
	}
}

function ReadSetting(i,j)	{
	try {
		var par=Par("ReadSetting")+"&GokeyNic="+i+"&GoPass1="+j;
		ReqAjax(req2,"POST",par,ResultGoChat,"true");
	} catch (e) {
		alert(e.description);
	}
}

function SubMes(TipMsg) {
	FrameToText();
	if (checkit()) {
		try {
			var F5=top.Frame5.document;
			var T=F5.getElementById('Text').value;
			var T=T.split("&nbsp;").join(" ");
			var par=Par("azfl")+"&Opera="+Opera+"&TipMsg="+TipMsg+"&Page1=0";
			    par+="&keyNicIn="+F5.getElementById('keyNicIn').value;
			    par+="&Text="+encodeURIComponent(T);
			if (TipMsg==0) {
				par+="&Room="+F5.getElementById('Room').value+"&key1="+F5.getElementById('key1').value;
				req1.abort();
			} else {
				par+="&key4="+F5.getElementById('key4').value;
				req4.abort();
			}
			ReqAjax(reqsoob,"POST",par,ResultSubMes,"true");
			if (err==1) {
				alert("Ошибка при отправке сообщения...");
			} else {
				if (F5.getElementById('ClearText').checked==true) F5.getElementById('Text').value=Netscape;
			}
		} catch(e) {
			alert(e.description);
		} finally {
			if (F5.getElementById('ClearText').checked==true) TextToFrame();
		}
	}
}

function find(tip) {
	var F5=top.Frame5.document;	
	if (tip==0) {
		F5.getElementById('Flag').value="1";
		F5.getElementById('FT').value="";
	}
	var par=Par("find")+"&Opera="+Opera+"&FT="+F5.getElementById('FT').value+"&filtr1="+F5.getElementById('filtr1').value;
	 par+="&DAY="+F5.getElementById('DAY').value+"&Flag="+F5.getElementById('Flag').value;
	 par+="&D="+F5.getElementById('D').value+"&M="+F5.getElementById('M').value;
	 par+="&FindIP="+F5.getElementById('FindIP').value;
	ReqAjax(req2,"POST",par,InnerFrame1d2,"true");
}

function I(i) {
	OldIgnorBehaviour = 0;
	var par=Par("Ignor") + "&keyNicIn=" + i;
	ReqAjax(req2,"POST",par,InnerFrame1d2,"true");
}

function SF1(i) {
	var par=Par("WriteInfo") + "&keyNicIn=" + i;
	ReqAjax(req2,"POST",par,InnerFrame1d2,"true");
}

function Setting(pr) {
	var par=Par(pr);
	ReqAjax(req2,"POST",par,InnerFrame1d2,"true");
}

function friend(opt) {
	var par=Par("friend")+"&azfl="+opt;
	if (opt>0) {
		var F1=top.Frame1.document;
        	if (opt==1) {
			var o1=(F1.getElementById('o1').checked)?"on":"";
			var o2=(F1.getElementById('o2').checked)?"on":"";
			alert("Настройки списка друзей записаны!");
		} else {
			var o1=(F1.getElementById('oR1').checked)?"on":"";
			var o2=(F1.getElementById('oR2').checked)?"on":"";
			var o3=(F1.getElementById('oR3').checked)?"on":"";
			var topMsg=F1.getElementById('topMsg').value;
			par+="&o3="+o3+"&topMsg="+topMsg;
			alert("Настройки личного зала записаны!");
		}
		par+="&o1="+o1+"&o2="+o2;
	}
	ReqAjax(req2,"POST",par,InnerFrame1d2,"true");
}

function AddDelFriend(keyNicIn,check) {
	var par=Par("AddDelFriend")+"&keyNicIn="+keyNicIn+"&check="+check;
	ReqAjax(req2,"POST",par,OK,"true");
}

function AddDelMyRoom(keyNicIn,check) {
	var par=Par("AddDelMyRoom")+"&keyNicIn="+keyNicIn+"&check="+check;
	ReqAjax(req2,"POST",par,OK,"true");
}

function NoRoom(keyNicIn,check) {
	var par=Par("NoRoom")+"&keyNicIn="+keyNicIn+"&check="+check;
	ReqAjax(req2,"POST",par,OK,"true");
}

function DelHome2() {
	if (confirm('Удалить у ников ТЕКУЩИЙ признак наличия сообщений в вашем привате и "подсвечивать" только новые ники в вашем привате?')) {
		var par=Par("DelHome2");
		ReqAjax(req2,"POST",par,OK,"true");
		ReadFrame3(1,0);
	}
}

function DelPrivat() {
	var t=top.Frame4.document.getElementById('DelPrivat').title+"?";
	if (confirm(t)) {
		var par=Par("DelPrivat")+"&Pade1="+Page1+"&ICQ="+top.Frame5.document.getElementById('ICQ').value;
		ReqAjax(req2,"POST",par,OK,"true");
		RenewFrame(4);
	}
}

function DelPrivatAll () {
	var t=top.Frame4.document.getElementById('DelPrivatAll').title+"?";
	if (confirm(t)) {
		var par=Par("DelPrivatAll")+"&ICQ="+top.Frame5.document.getElementById('ICQ').value;
		ReqAjax(req2,"POST",par,OK,"true");
		RenewFrame(4);
	}
}

function DelPrivat2All () {
	var t=top.Frame4.document.getElementById('DelPrivat2All').title+"?";
	if (confirm(t)) {
		var par=Par("DelPrivat2All")+"&ICQ="+top.Frame5.document.getElementById('ICQ').value;
		ReqAjax(req2,"POST",par,OK,"true");
		RenewFrame(4);
	}
}

function RePrivatAll()	{
	var t=top.Frame4.document.getElementById('RePrivatAll').title+"?";
	if (confirm(t)) {
		var par=Par("RePrivatAll")+"&ICQ="+top.Frame5.document.getElementById('ICQ').value;
		ReqAjax(req2,"POST",par,OK,"true");
		RenewFrame(4);
	}
}

function UnLoadFrame5() {
	var par=Par("UnLoad");
	ReqAjax(req2,"POST",par,NO,"false");
	req1.abort(); req3.abort(); req4.abort(); reqsoob.abort();
}

function F2(i,j,k) {
	try {
		OpenWinAjax(j+"&keyNicIn="+i+"&flag="+k+"&Room="+top.Frame5.document.getElementById('Room').value,j);
	} catch (e) {
		OpenWinAjax(j+"&keyNicIn="+i+"&flag="+k,j);
	}
}

function NoSubmit() {return(false);}

function saveNN() {
	var NN=(top.Frame4.document.getElementById('Cookie0').checked)?"":top.Frame4.document.getElementById('NameNic').value;
	NN = escape(NN);
	var KN=(top.Frame4.document.getElementById('Cookie0').checked)?"":top.Frame4.document.getElementById('keyNic').value;
	KN = escape(KN);
	var P1=(top.Frame4.document.getElementById('Cookie2').checked)?top.Frame4.document.getElementById('Pass1').value:"";
	P1 = escape(P1);
	setCookie("NameNic",NN);
	setCookie("keyNic",KN);
	setCookie("Pass1",P1);
}

function setCookie(name,value) {
	var expiresDate = new Date();
	expiresDate.setTime(expiresDate.getTime() + (30*24*60*60*1000));	//хранение 30 дней
	var expires=expiresDate.toGMTString();
	var newCookie=name + "=" + value + "; path=/; expires=" + expires;
	top.Frame4.document.cookie=newCookie + ";";
}

function getCookie(name) {
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) return "";
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function StartTimer134() {Timer134=setInterval("WorkTimer134()",1000);}

function StopTimer134() {clearInterval(Timer134);}

function WorkTimer134() {
	try {
		WorkTimerFrame(1,top.Frame1.document.getElementById('TimerFr'),"top.Frame5.document.getElementById('"+top.Frame5.document.getElementById('tipt1').value+"').value");
		WorkTimerFrame(3,top.Frame3.document.getElementById('TimerFr'),"top.Frame5.document.getElementById('"+top.Frame5.document.getElementById('tipt3').value+"').value");
		if (top.Frame5.document.getElementById('keyNic').value>0) WorkTimerFrame(4,top.Frame4.document.getElementById('TimerFr'),"top.Frame5.document.getElementById('"+top.Frame5.document.getElementById('tipt4').value+"').value");
	} catch(e) {
	}
}

function WorkTimerFrame(tip,Fr,F5At) {
	try {
		if (Fr.value!="Stop") {
			if (Fr.value==" "+c176) {
				Fr.value=" "+eval(F5At);
				return;
			}
			var pus2=Fr.value-1;
			if (pus2<0) {
				eval("ReadFrame"+tip+"(1,0)");
				eval("re"+tip+"+=1");
				Fr.value=" "+c176;
			} else {
				Fr.value=" "+pus2;
			}
		}
	} catch (e) {
	}
}

function Timers() {
	var RTimer=top.Frame5.document.getElementById('RTimer');
	var Timer1=top.Frame1.document.getElementById('TimerFr');
	var Timer3=top.Frame3.document.getElementById('TimerFr');
	var Timer4=top.Frame4.document.getElementById('TimerFr');
	var keyNic=top.Frame5.document.getElementById('keyNic').value;
	if (RTimer.value=="STOP") {
		openPopup("Запущены БЫСТРЫЕ таймеры<br>"+Txt1,2000,112);
		RTimer.value="FAST";
		RTimer.title="Запущены быстрые таймеры. Запустить медленные таймеры "+Txt1+"?";
		StartStopTimerFrame(Timer1,"t1","t12",1);
		StartStopTimerFrame(Timer3,"t3","t32",3);
		if (keyNic>0) StartStopTimerFrame(Timer4,"t4","t42",4);
	} else {
		if (RTimer.value=="FAST") {
			openPopup("Запущены МЕДЛЕННЫЕ таймеры<br>"+Txt1,2000,112);
			RTimer.value="SLOW";
			RTimer.title="Запущены медленные таймеры. Остановить таймеры "+Txt1+"?";
			StartStopTimerFrame(Timer1,"t12","t10",1);
			StartStopTimerFrame(Timer3,"t32","t30",3);
			if (keyNic>0) StartStopTimerFrame(Timer4,"t42","t40",4);
		} else {
			openPopup("ОСТАНОВЛЕНЫ таймеры<br>"+Txt1,2000,112);
			RTimer.value="STOP";
			RTimer.title="Все таймеры остановлены. Запустить быстрые таймеры "+Txt1+"?";
			StartStopTimerFrame(Timer1,"t10","t1",1);
			StartStopTimerFrame(Timer3,"t30","t3",3);
			if (keyNic>0) StartStopTimerFrame(Timer4,"t40","t4",4);
		}
	}
}

function StartStopTimerFrame(Ftimer,tipt1,tipt2,tip) {
	try {
		var tipt0=eval("top.Frame5.document.getElementById(\'tipt"+tip+"\')"); tipt0.value=tipt1;
		var interval=eval("top.Frame5.document.getElementById(\'"+tipt1+"\').value");
		var interval2=eval("top.Frame5.document.getElementById(\'"+tipt2+"\').value");
		if (interval==0) {
			Ftimer.value="Stop";
			Ftimer.title="Таймер остановлен. Запуcтить быстрый таймер?";
			eval("req"+tip+".abort()");
		} else {
			Ftimer.value=" "+interval;
			if (interval2==0) {
				Ftimer.title="Запущен медленный таймер "+interval+" сек. Остановить таймер?";
			} else {
				Ftimer.title="Запущен таймер "+interval+" сек. Запустить медленный таймер "+interval2+" сек.?";
			}
		}
	} catch(e) {
	}
}

function LocalTimerFrame(tip,FrameTimer) {
	var tipt0=eval("top.Frame5.document.getElementById(\'tipt"+tip+"\').value");
	if (tipt0=="t"+tip) {
		var tipt1="t"+tip+"2"; var tipt2="t"+tip+"0";
	} else {
		if (tipt0=="t"+tip+"2") {
			var tipt1="t"+tip+"0"; var tipt2="t"+tip;
		} else {
			var tipt1="t"+tip; var tipt2="t"+tip+"2";
		}
	}
	StartStopTimerFrame(FrameTimer,tipt1,tipt2,tip);
}

function ValuePage(tip,plusminus) {
	var Frame=eval("top.Frame"+tip+".document");
	eval("top.Frame5.document.getElementById('key"+tip+"').value=1");
	var Page=Frame.getElementById('Page1').value-0; Page+=plusminus;
	if (Page<0) Page=0;
	if (Page>9999) Page=9999;
	Frame.getElementById('Page1').value=Page;
	if (Page==0) {
		eval("RenewFrame("+tip+")");
		StartStopTimerFrame(Frame.getElementById('TimerFr'),"t"+tip,"t"+tip+"2",tip);
	} else {
		StartStopTimerFrame(Frame.getElementById('TimerFr'),"t"+tip+"0","t"+tip,tip);
		eval("InnerFrame"+tip+"d2('')");
		eval("ReadFrame"+tip+"("+tip+",0)");
	}
}

function Fr3Var(form) {
	try {
		var F5=top.Frame5.document;
		try {
			F5.getElementById('SortF3').value=form.SortF3[form.SortF3.selectedIndex].value;
		} catch(e) {
			for (var i=0; i<form.SortF3.length; i++) {
				if (form.SortF3[i].checked) {
					F5.getElementById('SortF3').value=form.SortF3[i].value;
					break;
				}
			}
		}
		F5.getElementById('Room').value=form.Room[form.Room.selectedIndex].value;
	} catch(e) {
	}
}

function ResultFrame3(s) {
	try {
		var d=s.split(c29);
		if (timeFrame3!=d[4]) {
			timeFrame3=d[4];		
			var Fr3=top.Frame3.document;
			Fr3.getElementById('d1').innerHTML=d[1];
		        Fr3.getElementById('d2').innerHTML="<table><tr><td id=f11>"+ParserFrame3(d[2])+"</table>";
			Fr3.getElementById('d3').innerHTML=d[3];
		}
	} catch(e) {
	}
}

function ParserFrame3(dat) {
        var pus="";
	var keyNic=top.Frame5.document.getElementById('keyNic').value;
	var dd=dat.split(c31);
        for (var ii=0; ii<dd.length; ii++) pus+=W(dd[ii],keyNic);
	return pus;
}

function W(w,keyNic) {
	var i=w.split(c30);
	if (i.length==1) return ("<hr>" + w);
	var s1=""; var s2="";
	var Pus="";
	if (i[9]==1) var Pus="<nobr><span style='width:100%; background:#C4FDF3; border:solid aqua; border-width:1px 1px 1px 0;'> ";

	Pus+="<a href='javascript:I("+i[0]+")' title=";
	if (i[1]=="m1") {
		Pus+="'\"Почетный чатер\"'><img src="+medal.src+"></a>"
	} else {
		if (i[1]=="a1") {Pus+="'Игнорировать'";
			Pus+=" id=a10>x</a>";
		} else {
			if (i[1]=="a2") {Pus+="'Ник \""+i[5]+"\" игнорирован вами лично'";s1="<s>";s2="</s>";}
			else {
				Pus+="'Ник \""+i[5]+"\" игнорирован Admin`ом'";s1="<s>";s2="</s>";
			}
			Pus+=" id="+i[1]+">__</a>"
		}
	}
	Pus+="<a href='javascript:SF1("+i[0]+")'>";
	if (i[4]!=0) Pus+="<img src="+imgfoto[i[3]].src+" title='Личная инфа с фото'>";
	else Pus+="<img src="+img[i[3]].src+" title='Личная инфа'>";
	Pus+="</a><a href='javascript:F2("+i[0]+",\"filtr\",0)' id=a10 title='Все разговоры ника в комнатах'>&#164;</a>";
	try {
	    	if (keyNic>0 && i[10]<3) {
			Pus+="<a href='javascript:ICQ("+i[0]+",\""+i[5]+"\")' title='В привате только \""+i[5]+"\"'";
			Pus+=" id=a10>*";
			Pus+="</a>";
		}
	} catch(e) {
	}

        if (i[2]!="a4") {
		Pus+="<a href='javascript:SF1("+i[0]+")' title="+i[11]+"><img src="+URL0+"smiles/"+i[2]+".gif></a>";
	}

	Pus+=" <a oncontextmenu='myMenu(\"top.Frame3.document\","+i[0]+",\""+i[12]+"\",\""+i[6]+"\",2,this,"+i[4]+"); return false;' href='javascript:SF5("+i[0]+",\""+i[5]+"\",\""+i[6]+"\");'>"+s1+i[12]+s2+"</a>";

	if (top.Frame5.document.getElementById('NicPlace').checked || i[0]==3 || i[7].indexOf("[ ")>0) Pus+=i[7];

	if (i[9]==1) Pus+="</span></nobr>";
	Pus+="<br>"
	return Pus
}

function RenewFrame(tip) {
	try {
		eval("InnerFrame"+tip+"d2('')");
		eval("top.Frame5.document.getElementById('key"+tip+"').value=1");
		eval("top.Frame"+tip+".document.getElementById('Page1').value=0");
		eval("ReadFrame"+tip+"(1,0)");
	} catch(e) {
	}
}

function InnerFrame1d2(s) {
	re1=0;
	top.Frame1.document.getElementById('d2').innerHTML=s;
}

function ResultFrame1(s) {
	try {
		var F5=top.Frame5.document;
		var d=s.split(c29);
		if (d[0]!="alert") {
			top.Frame1.document.getElementById('d1').innerHTML=d[1];
			if (d[2]!="" && F5.getElementById('key1').value<d[3]) {
				ParserFrame1(d[2]);
				F5.getElementById('key1').value=d[3];
			}
		} else {
			eval(d[2]);
		}
	} catch(e) {
	}
}

function ParserFrame1(dat) {
	var F5=top.Frame5.document;
	var h1=(F5.getElementById('hh').value/2);
	var MyStyle1=F5.getElementById('MyStyle').value;
	var dd = dat.split(c31);
	FireFox=(Opera==1)?"":"-moz-user-select: none; ";
	noCopy=(F5.getElementById('Room').value==10)?"ondragstart='return false;' onselectstart='return false;' oncontextmenu='return false;' onmousedown='return false;'":"";
	for (var ii=0; ii<dd.length-1; ii++) {
		var Pus0=P(dd[ii],1);
		if (Pus0!="") {
			var Pus="<table "+noCopy+" cellspacing="+h1+" cellpadding=0 style='"+FireFox+MyStyle1+"'>"+Pus0+"</td></tr></table>";
			try {
				var newChild=top.Frame1.document.createElement("DIV");
				newChild.innerHTML=Pus;
				top.Frame1.document.getElementById('d2').insertBefore(newChild,top.Frame1.document.getElementById('d2').firstChild);
			} catch(e) {
			}
		}
	}
}

function P(w,m) {
	var i = w.split(c30);
	var F5 = top.Frame5.document;
	var keyNic=F5.getElementById('keyNic').value;
	var TM="";	
	if (i[9]==0) if (keyNic>0 && i[5]==keyNic && F5.getElementById('ToMe').checked==true) TM=1;
	var Pus="";
	var dt = i[0].split(" ");
	if (F5.getElementById('dt').checked!=true) i[0]=dt[1];
	var Pus="<tr>"
	if (i[1]==3 && i[4]!=2) {
		if (F5.getElementById('MsgAdmin').checked||i[4]==1) {
	        	Pus+="<tr><td id=td3><a href='javascript:DT(\""+i[0]+"\")'><nobr>"+i[0]+"</nobr></a><td id=td3>&nbsp;";
			if (i[4]==1) Pus+="<b>";
			Pus+= i[11];
			if (i[4]==1) Pus+="</b>";
		} else {
			Pus="";
		}
	} else {		
		if (F5.getElementById('N').checked==false) {
			i[11]=i[11].split("<IMG src=http://chat.vulcan.ru/smiles/").join("<s class=smile>[smile=");
			i[11]=i[11].split(".gif>").join(".gif]</s> ");
		}
		Pus+="<tr><td><a href='javascript:DT(\""+i[0]+"\")' style='text-decoration:none;'><nobr>"+i[0]+"</nobr></a>";
		if (TM==1) {
			Pus+="<td style='width:100%; background:#c4fdf3; border:1 solid aqua;'>";
		} else {
			Pus+="<td>";
		}
			if (i[8]==1) Pus+="<span style='cursor:pointer;font:bold 10px verdana;' title='В момент отправки сообщения получателя не было в чате'>&nbsp;&radic;&nbsp;</span> ";
			if (F5.getElementById('My6').value=="on") {
				Pus+="<a href='javascript:I("+i[1]+");' title='Игнорировать' id=a10i>x</a>";
			}
			if (F5.getElementById('My7').value=="on") {
		       		Pus+="<a href='javascript:SF1("+i[1]+")' title='Личная инфа' id=a10i>i</a>";
			}
	       		if (F5.getElementById('My8').value=="on") {
				Pus+="<a href='javascript:F2("+i[1]+",\"filtr\",0)' title='Все разговоры ника в комнатах' id=a10>&#164;</a>";
				if (keyNic>0) {
					Pus+="<a href='javascript:ICQ("+i[1]+",\""+i[2]+"\")' title='В привате только \""+i[6]+"\"'";
					Pus+=" id=a10>*</a>";
				}
			}
                      	if (F5.getElementById('My10').value!="") {
				i[14]=""; i[15]="";
				i[3]="black"; i[7]="black"; i[10]="#3f3f2f";
			}
			var i14=(i[14]!="")?i[14]:i[2]
			Pus+=" <a oncontextmenu='myMenu(\"top.Frame"+m+".document\","+i[1]+",\""+i14+"\",0,0,this,1); return false;' href='javascript:SF5("+i[1]+",\""+i[2]+"\",\""+i[3]+"\")'>"+i[14]+"</a>";
			if (i[5]!="") {
				var i15=(i[15]!="")?i[15]:i[6]
				Pus+=" &#187; <a oncontextmenu='myMenu(\"top.Frame"+m+".document\","+i[5]+",\""+i15+"\",0,0,this,1); return false;' href='javascript:SF5("+i[5]+",\""+i[6]+"\",\""+i[7]+"\")'>"+i[15]+"</a>";	
			}
			Pus+=" : <font color="+i[10]+">" + i[11];
			if (F5.getElementById('keySoob').value==1) {Pus+="</font><span id=td11> &#8213; "+i[13] + "</span>";}
	}
	return Pus
}

function InnerFrame4d2(s) {
	re4=0;
	top.Frame4.document.getElementById('d2').innerHTML=s;
}

function ResultFrame4(s) {
	try {
		var F5=top.Frame5.document;
		var d=s.split(c29);
		if (d[2]!="" && F5.getElementById('key4').value<d[3]) {
			ParserFrame4(d[2]);
			F5.getElementById('key4').value=d[3];
		}
	} catch(e) {
	}
}

function ParserFrame4(dat) {
	var F5=top.Frame5.document;
	var h1=(F5.getElementById('hh').value/2);
	var MyStyle1=F5.getElementById('MyStyle').value;
	var dd=dat.split(c31);
	for (var ii=0; ii<dd.length-1; ii++) {
		var Pus="<table cellspacing="+h1+" cellpadding=0 style='"+MyStyle1+"'>"+P(dd[ii],4)+"</td></tr></table>";
		try {
			var newChild=top.Frame4.document.createElement("DIV");
			newChild.innerHTML=Pus;
			top.Frame4.document.getElementById('d2').insertBefore(newChild,top.Frame4.document.getElementById('d2').firstChild);
		} catch(e) {
		}
	}
}

function OpenWinAjax(met,win) {
	top.Frame5.document.getElementById('Pr').value=met;
	WinAjax=open(URL0+"Ajax-Win.shtml",win,"width="+(screen.width-120)+",height="+(screen.height-120)+",top=0,left=0,scrollbars,toolbar,resizable,location,status");
	WinAjax.focus();
}

function findVar(form) {
	var F5=top.Frame5.document;
	F5.getElementById('FT').value=form.FT.value;
	F5.getElementById('FindIP').value=form.FindIP.value;
	if (form.filtr1.checked) {
		F5.getElementById('filtr1').value="on";
	} else {
		F5.getElementById('filtr1').value=0;
	}
	F5.getElementById('DAY').value=form.DAY[form.DAY.selectedIndex].text;
	for (var i=0; i<form.Flag.length; i++) {
		if (form.Flag[i].checked) {
			F5.getElementById('Flag').value=form.Flag[i].value;
			break;
		}
	}
	F5.getElementById('D').value=form.D[form.D.selectedIndex].text;
	F5.getElementById('M').value=form.M[form.M.selectedIndex].text;
}


function OK(s) {alert(s);}

function NO(s) {}

function RefAll3() {
	InnerFrame1d2("");
	RenewFrame(1);
	ReadFrame3(1,0);
	if (top.Frame5.document.getElementById('keyNic').value>0) RenewFrame(4);
}

function ResultSubMes(s) {
	if (s.split(c29,1)==1) {
		ReadFrame1(1,0);
	} else {
		ReadFrame4(1,0);
	}
}

function ICQ (i,j) {
	top.Frame5.document.getElementById('ICQ').value=i;
	var F4=top.Frame4.document;
	var icq=F4.getElementById('icq');
	RenewFrame(4);
	if (i>0) {
		openPopup('Приват в "режиме ICQ"! Будут показаны ТОЛЬКО ваши разговоры с ником "'+j+'"',2000,160);
		var t="Убрать режим ICQ с ником "+j;
		icq.innerHTML="<a href='javascript:ICQ(0,0);' title=\""+t+"\"><img src=tet2.gif title=\""+t+"\"> "+j+"</a>"
		F4.getElementById('DelPrivat').title="Удалить сообщения ДАННОГО ЛИСТА привата из Вашего общения с ником '"+j+"'";
		F4.getElementById('DelPrivatAll').title="Удалить ВСЕ сообщения привата из Вашего общения с ником '"+j+"'";
		F4.getElementById('DelPrivat2All').title="Удалить БЕЗВОЗВРАТНО ВСЕ сообщения привата из Вашего общения с ником '"+j+"'";
		F4.getElementById('RePrivatAll').title="Восстановить ВСЕ ранее удаленные сообщения привата из Вашего общения с ником '"+j+"'";
	} else {
		openPopup("Приват переведен в обычное состояние...",2000,112);
		icq.innerHTML="&nbsp;";
		F4.getElementById('DelPrivat').title="Удалить сообщения ДАННОГО ЛИСТА привата";
		F4.getElementById('DelPrivatAll').title="Удалить ВСЕ сообщения привата";
		F4.getElementById('DelPrivat2All').title="Удалить БЕЗВОЗВРАТНО ВСЕ сообщения привата";
		F4.getElementById('RePrivatAll').title="Восстановить ВСЕ ранее удаленные сообщения привата";
	}
}

function CloseM(cm)  {
	try {
		clearTimeout(CloseTimer);
	} catch(e) {
	} finally {
		PUS=eval(cm+".getElementById('contextmenu')");
        	CloseTimer=setTimeout("PUS.style.display='none';",2000);
	}
}

function myMenu(M,i,j,k,l,element,foto) {
	CloseM(M);
	Menu=eval(M);
	var theElement=element;
	var x=(l>0)?l:element.offsetLeft+40;
	var y=element.offsetHeight;
	while (theElement!=null) {
		y+=theElement.offsetTop;
		theElement=theElement.offsetParent;
	}
	var contextmenu=Menu.getElementById('contextmenu');
	contextmenu.style.display="";
	contextmenu.style.left=x;
	contextmenu.style.top=y;
	Menu.getElementById('menu1').href="javascript:OpenWinAjax('ReadInfo&keyNicIn="+i+"','Info')";
	Menu.getElementById('menu1').innerHTML="<img src="+URL0+"user.gif> Инфо: <b>"+j+"</b>";
	if (foto!=0) {
		Menu.getElementById('menu2').href="javascript:OpenWinAjax('ViewGallery&keyNicIn="+i+"','Gallery')";
		Menu.getElementById('menu2').innerHTML="<img src="+URL0+"picture.gif height=15px> Просмотреть фотоальбом";
	} else {
		Menu.getElementById('menu2').href="javascript:alert('Нет здесь фотоальбома... Нет!')";
		Menu.getElementById('menu2').innerHTML="<img src="+URL0+"picture.gif height=15px> Фотоальбома нет...";
	}
	Menu.getElementById('menu3').href="javascript:I("+i+")";
	Menu.getElementById('menu4').href="javascript:F2("+i+",'filtr',0)";
	if (top.Frame5.document.getElementById('keyNic').value>0) {
		Menu.getElementById('menu5').href="javascript:ICQ("+i+",\""+j+"\")";
	} else {
		Menu.getElementById('menu5').href="javascript:alert('Вам надо войти в чат!')";
	}
}

function LoveSmile() {}
