function GetNick(message,type){
 if(type != 'private'){ ShowMenu('menu'); }

 parent.frames["talk"].document.output.message.value = message;
 parent.frames["talk"].document.output.message.focus();
 parent.frames["talk"].document.output.message.select();
}

var win1;
function WinOp(name){
 if(name != "../all_room.cgi"){ ShowMenu('menu'); }

 win1 = window.open('','win1','width=560,height=300,scrollbars=1,resizable=1');
 win1.location = "http://www.free-time.ru/cgi/chat/"+name;
 win1.focus();
}

var win2;
function WinOpReg(name){
 win2 = window.open('','win1','width=560,height=350,scrollbars=1,resizable=1');
 win2.location = "http://www.free-time.ru/cgi/chat/"+name;
 win2.focus();
}

function Submit(){
 ShowMenu('menu');

 parent.frames["talk"].document.output.message.focus();
 parent.frames["talk"].document.output.message.select();
}

function Reload(room){
 ShowMenu('menu');

 parent.frames["list"].document.location.reload(); 
 parent.frames["last_mess"].document.location.reload(); 
}

function SelectRoom(room){
 parent.frames["list"].document.location.href = "http://www.free-time.ru/cgi/chat/write.cgi?type=SelectRoom&room="+room; 
}

function GoRoom(new_room,old_room){
 self.parent.location = "http://www.free-time.ru/cgi/chat/access.cgi?old_room="+old_room+"&room="+new_room;
}

function Exit(){
 setTimeout ("ExitUrl()", 1);
}

function ExitUrl(){
 if (self.parent.frames.length != 0)
  self.parent.location = "http://www.free-time.ru/chat/";
} 

function Private(id, room){
 var win2;
 win2 = window.open('','win2','width=560,height=450,scrollbars=1,resizable=1');
 win2.location = "http://www.free-time.ru/cgi/chat/private/private.cgi?id="+id+"&room="+room;
 win2.focus();
} 

function KillUser(who, room){
 win1 = window.open('','win1','width=560,height=450,scrollbars=1,resizable=1');
 win1.location = "http://www.free-time.ru/cgi/chat/admins/admins.cgi?room="+room+"&who="+who;
 win1.focus();
}

function SelectColor(value,room){
 eval('document.forms[0].color'+room+'.value = "'+value+'"');
}

function NewZaps(room,type){
 if(type == "new"){
  parent.frames["talk"].document.images[3].src = "http://www.free-time.ru/chat/img/"+room+"/sm.gif";
 }
 else{
  parent.frames["talk"].document.images[3].src = "http://www.free-time.ru/chat/img/"+room+"/gm.gif";
 }
}

function ReturnChat(room){
 parent.talk.document.location.href = "http://www.free-time.ru/cgi/chat/write.cgi?room="+room;
 parent.list.document.location.href = "http://www.free-time.ru/cgi/chat/list.cgi?room="+room;
}

function ShowMenu(layerName, type){
 var layerRef="null", styleSwitch="null";

 if (navigator.appName == "Netscape") {
  layerRef="document.layers";
  styleSwitch="";
 }
 else{
  layerRef="document.all";
  styleSwitch=".style";
 }

 if((eval('parent.frames["talk"].'+layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility').charAt(0) == "h") && (type == "onoff")){
  status_layer = "visible";
 }
 else{
  status_layer = "hidden";
 }
 
 eval('parent.frames["talk"].'+layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="'+status_layer+'"');
}

function TypeMess(room){
 if(document.forms[0].type_message.value == "talk"){
  document.forms[0].type_message.value = "do";
  document.images["talkdo"].src = "http://www.free-time.ru/chat/img/"+room+"/do.gif"; 
 }
 else{
  document.forms[0].type_message.value = "talk"; 
  document.images["talkdo"].src = "http://www.free-time.ru/chat/img/"+room+"/talk.gif";
 }
}