function loading() {
 var arr=["Main", "Banner", "Index"] 
 for (var i=0; i<3; i++ ) { // по всем фреймам кроме Logo...
  var fl=arr[i]
  var co = getCookie(fl)
  if (typeof co != "undefined")
   if (co != String(top.frames[fl].document.location))
    top.frames[fl].document.location=co
 }
}

function wrapper() {
 var logo=top.Logo.document; var lp=logo.Panel; 
 var args=arguments[0]; var ndir=args.length-1; var trg=0
 var lines="<FONT SIZE=\"-1\"><OL COMPACT>"
 if (ndir==1) { // Если есть только один каталог, то просто грузим его фреймы
    top.dirf[args[0]][0]=ndir
    top.dirf[args[0]][1]=args[1]
//    alert(String(top.dirf[args[0]][1]))
//    alert(args[0]+" : "+top.dirf[args[0]][0])
    loadframes(args[0],args[1])
    }else{ //если же их несколько, то перебираем их по порядку
    for ( var dir=1; dir<=ndir; dir++){
    top.dirf[args[0]][0]=ndir
    top.dirf[args[0]][dir]=args[dir]
    lines = lines + "<LI><A HREF=\""+String(args[dir].Dir).replace(/\/$/,"")+"/"+(args[0]=="Main"?args[dir].Index:vector.Banner)+"\" TARGET=\""+(args[0]=="Main"?"Index":"Banner")+"\">"+args[dir].Text+"</A>"
    if(id(args[0],args[dir].Dir)) trg=dir
   }
    lines=lines+"</OL></FONT>"
    
    with(top.Logo.document){
      if(typeof getElementById != "undefined"){
	//alert('DOM')
	getElementById("Panel").innerHTML=lines
      }else if(typeof all != "undefined"){
	//alert('IE4')
	all["Panel"].innerHTML=lines
      }else if(typeof layers != "undefined"){
	//alert('NN4')
	Panel.document.writeln(lines)
	Panel.document.close()
      }
    }
    if (trg==0) loadframes(args[0],args[1])
 }
 setcookie(args[0])
// makedesign(args[0])
}

function id(frame,d){
var tp={Main:"Index",Index:"Banner",Banner:"Banner"}
var dir=top.root+d //квалифицированное имя разрешенного каталога
var file=String(top.frames[tp[frame]].document.location) 
//квалифицированное имя файла в родительском окне 
//alert(frame+"=\n"+dir+"\n"+file,"\n")
return (file.indexOf(dir) == 0)
}

//Загружает фреймы
function loadframes(frame,vector) {
 var d=vector["Dir"]; var address
 vector[frame]=String(top.frames[frame].document.location)
 for (var frm in vector ) 
 if (frm != "Dir" && frm != "Text" ){
  address=canonify(vector[frm], String(top.frames[frame].document.location),String(document.location))
  if (frame=="Index" && frm=="Main" && idd(frame,frm)) 
   continue // Не загружаем Main.html etc. если находимся в каталоге  
  if (frame=="Banner" && frm=="Main" && idd(frame,frm)) 
   continue
  if (String(top.frames[frm].location) != address)  
   top.frames[frm].location = address
 }
}

function idd(frame,frm){
 for (var i=1; i<=top.dirf[frm][0];i++){
  var a=top.dirf[frm][i]
  if (String(canonify(top.root+a["Dir"]+(a[frame]?a[frame]:""))) == String(top.frames[frame].document.location)) return true
 }
return false
}

function setcookie(frame) {
 // Мы устанавливаем cookie действующий 15 минут 
 var today = new Date(); var expire = new Date()
 expire.setTime(today.getTime() + 15*1000*60)
 // Запоминаем текущую страницу в cookie...
 //alert("cookie for "+String(frame) +" set " +String(top.frames[frame].document.location))
 document.cookie = frame + " = " + escape(top.frames[frame].document.location) + "; path= / ; expires=" + expire.toGMTString()
 f = this.frames.name
}

function canonify(address, base, key) {
 if ((typeof address)== "object") { // Если условное выражение...
  if ((address.IF).test(key)) address = address.THEN
  else address = address.ELSE
 }
//  if (address == 0) return base
  address = String(address)
   if (/^\w{3,4}:.*/.test(address) == false) {// Краткая форма...
    var s = base.replace(/\/[^\/]*$/,"/") +address // удалить /xx.html
    for (var i=0;i<3;i++) s = s.replace(/\/\.\//,"/") // удалить /./
    for (var i=0;i<3;i++) s = s.replace(/\/[^\/]*\/\.\.\//,"/") // удалить /../xx/
    return s		
   }else{
    for (var i=0;i<3;i++) address = address.replace(/\/\.\//,"/") // удалить /./
    for (var i=0;i<3;i++) address = address.replace(/\/[^\/]*\/\.\.\//,"/") // удалить /../xx/
   } return address
}

function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { 
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
	    	end = document.cookie.indexOf(";", offset)
	    	if (end == -1)
			end = document.cookie.length
	    	return unescape(document.cookie.substring(offset,end))
		}
	}
}

function bonw(){
top.style=-top.style
top.frames["Main"].location.reload()
}

function colorset(){
 if (top.style<0)
  top.frames["Main"].document.writeln("<STYLE>BODY {background-color:#EEEEEE; background-image:url(none); color:black}\n A {color:#990000}\n P {color:#000000; textIndent:2em}\n B {color:#000000}\n TD {color:#000000}\n TH {color:#000000}\n FONT {color:#000000}\n DIV {color:#000000}</STYLE>")
 else
  top.frames["Main"].document.writeln("<STYLE>P {textIndent:2em}</STYLE>")
}

function restore(){
 delete top.o
 top.frames["Index"].document.location=top.root+"MainIndex.html"
 top.frames["Banner"].document.location=top.root+"ShortNews.html"
 top.frames["Main"].document.location=top.root+"News.html"
}

function topbar(){
 var colo = (top.style>0) ? "Черное на белом" : "Белое на черном"
 top.frames["Main"].document.writeln('<TABLE BORDER="1" ALIGN="center" VALIGN="middle" WIDTH="95%"><TR><TH><A HREF="javascript:top.prevh()"><FONT SIZE="-1" COLOR="#FFFFFF">Вернуться назад</FONT></A></TH><TH><A HREF="'+top.root+'/ShortNews.html" TARGET="Banner"><FONT SIZE="-1" COLOR="#FFFFFF">Лента новостей</FONT></A></TH><TH><A HREF="javascript:top.restore()"><FONT SIZE="-1" COLOR="#FFFFFF">В начало</FONT></A></TH><TH><A HREF="http://rwp2.forum24.ru/"><FONT SIZE="-1" COLOR="#FFFFFF">Комментировать</FONT></A></TH><TH><A HREF="javascript:top.bonw()"><FONT SIZE="-1" COLOR="#FFFFFF">'+ colo +'</FONT></A></TH></TR></TABLE>')
}

function historic(){
  if(top.his[0] != String(top.Main.document.location) )
   if(typeof document.all=="undefined")
    top.his.unshift(String(top.Main.document.location))
   else{//В IE<5.5 не реализованы функции shift&unshift
    for(var i=top.his.length-1; i>=0; i--)
     top.his[i+1]= top.his[i]
    top.his[0]=String(top.Main.document.location)
   }
}

function prevh(){
 if(top.his.length > 1){
  if(typeof document.all=="undefined"){
   top.his.shift(); top.Main.document.location=top.his.shift()
  }else{
   var t=top.his[1] 
   for(var i=0; i<top.his.length-1; i++)
    top.his[i]= top.his[i+2]
   delete top.his[top.his.length-1]
   delete top.his[top.his.length-1]
   top.Main.document.location=t   
  }
 }
}


