var _links = new Array();
var _headers = new Array();
var _apps = new Object();
var _rlinks_ru = new Array();
var _fsizes = new Array();

/* right side menu */
_rlinks_ru[0]=new RLinks('Об Обществе Агни-Йоги','javascript:parent.location.href="ay_ru_info.html";',false,null);
_rlinks_ru[1]=new RLinks('О представленных изданиях','javascript:parent.location.href="ay_ru_books.html"',false,null);
_rlinks_ru[2]=new RLinks('Электронная библиотека','javascript:parent.location.href="ay_ru_downloads.html"',false,null);
_rlinks_ru[3]=new RLinks('Поиск по книгам','javascript:parent.location.href="ay_ru_search.html"',false,null);
_rlinks_ru[4]=new RLinks('Книги на английском','javascript:parent.location.href="http://www.agniyoga.org"',false,null);
_rlinks_ru[5]=new RLinks('Адрес для справок','javascript:parent.location.href="ay_ru_contact.html"',false,null);

/* books menu */
_links[0]  = new BookLink("ay_ru_lomg1.html","Листы Сада Мории. I ", "Листы Сада Мории. I (\"Зов\")","ru_leaves_of_moryas_1924_i.jpg","LMG1");
_links[1]  = new BookLink("ay_ru_lomg2.html","Листы Сада Мории. II ","Листы Сада Мории. II (\"Озарение\")","ru_leaves_of_moryas_1925_i.jpg","LMG2");
_links[2]  = new BookLink("ay_ru_community.html","Община ","Община","ru_community_1926_i.jpg","COMM");
_links[3]  = new BookLink("ay_ru_agniyoga.html","Агни-Йога","Агни-Йога","ru_agni_yoga_1929_i.jpg","AY");
_links[4]  = new BookLink("ay_ru_infinity1.html","Беспредельность. I","Беспредельность. I","ru_infinity_1930_1_i.gif","INF1");
_links[5]  = new BookLink("ay_ru_infinity2.html","Беспредельность. II","Беспредельность. II","ru_infinity_1930_2_i.gif","INF2");
_links[6]  = new BookLink("ay_ru_hierarchy.html","Иерархия","Иерархия","ru_hierarchy_1931_i.jpg","HRCHY");
_links[7]  = new BookLink("ay_ru_heart.html","Сердце","Сердце","ru_heart_1932_i.jpg","HEART");
_links[8]  = new BookLink("ay_ru_fw1.html","Мир Огненный. I","Мир Огненный. I","ru_fiery_world_1933_i.jpg","FW1");
_links[9]  = new BookLink("ay_ru_fw2.html","Мир Огненный. II","Мир Огненный. II","ru_fiery_world_1934_i.jpg","FW2");
_links[10] = new BookLink("ay_ru_fw3.html","Мир Огненный. III","Мир Огненный. III","ru_fiery_world_1935_i.jpg","FW3");
_links[11] = new BookLink("ay_ru_aum.html","Аум","Аум","ru_aum_1936_i.jpg","AUM");
_links[12] = new BookLink("ay_ru_brotherhood.html","Братство","Братство","ru_brotherhood_1937_i.jpg","BROTH");
_links[13] = new BookLink("ay_ru_supermundane1.html","Надземное","Надземное","ru_supermundane_1938_i.jpg","SUPM1");
_links[14] = new BookLink("ay_ru_crossroads.html","Криптограммы Востока","Криптограммы Востока","ru_crossroads_i.gif","CROSS");
_links[15] = new BookLink("ay_ru_lohr1.html","Письма Елены Рерих. I","Письма Елены Рерих. I","ru_lohr1_i.jpg","LOHR1");
_links[16] = new BookLink("ay_ru_lohr2.html","Письма Елены Рерих. II","Письма Елены Рерих. II","ru_lohr2_i.jpg","LOHR2");
_links[17] = new BookLink("ay_ru_fob.html","Основы буддизма","Основы буддизма","ru_fob_i.jpg","FOB");


_fsizes[0] = new FileSizes( .398,  .300,  .523, .117,  .140, .060); //Зов
_fsizes[1] = new FileSizes( .652,  .537,  .665, .164,  .284, .122); //Озарение
_fsizes[2] = new FileSizes( .641,  .529,  .624, .151,  .261, .107); //Община
_fsizes[3] = new FileSizes(1.079,  .894, 1.014, .245,  .458, .183); // Агни-Йога
_fsizes[4] = new FileSizes(1.018,  .846,  .595, .164,  .345, .116); // Беспредельность 1
_fsizes[5] = new FileSizes( .588,  .488,  .599, .115,  .256, .080); //Беспредельность 2
_fsizes[6] = new FileSizes(1.005,  .753,  .583, .134,  .258, .097); //Иерархия
_fsizes[7] = new FileSizes(1.380, 1.059,  .816, .196,  .377, .147); //Сердце
_fsizes[8] = new FileSizes(.978,   .821,  .980, .234,  .430, .169); //МО1
_fsizes[9] = new FileSizes(1.566, 1.303,  .650, .151,  .288, .111); //МО2
_fsizes[10]= new FileSizes(1.986, 1.660,  .846, .180,  .385, .135); //МО3
_fsizes[11]= new FileSizes(1.345,  .935,  .750, .170,  .316, .123); //АУМ
_fsizes[12]= new FileSizes(1.225,  .894,  .680, .160,  .311, .119); //БРАТСТВО
_fsizes[13]= new FileSizes(5.155, 3.061, 3.187, .716, 1.457, .539); //Надземное 1
_fsizes[14]= new FileSizes( .256,  .216,  .212, .051,  .075, .033); //Crossroads
_fsizes[15]= new FileSizes(2.707, 2.495, 2.426, .608,  .951, .374); //Letters 1
_fsizes[16]= new FileSizes(    1,     0, 2.458, .642,  .949, .624); //Letters 2
_fsizes[17]= new FileSizes( .648,  .488,  .343, .082,  .143, .058); //Основы буддизма


function openPopUpW(){
   var w=250, h=100;
   if (document.all){
   	var xMax = screen.width;
   	var yMax = screen.height; 
   }else if(window.navigator.appName=="Netscape"){
   	var xMax = parent.outerWidth; 
   	var yMax = parent.outerHeight; 
   }else{ 
   	var xMax = 800; 
   	var yMax = 640; 
   }
      
   var xOffset=(xMax - w)/2;
   var yOffset=(yMax - h)/2;
   return window.open("ay_ru_popupw.html","dialog","width=250,height=100,top="+yOffset+",left="+xOffset+",screenX="+yOffset+",screenY="+xOffset);
}

function writeImg(ndx){
	//var s="<TR><TD VALIGN='TOP' ALIGN='RIGHT'><IMG SRC='ay_book_images/"+_links[ndx].img+"' BORDER='0' width='128' height='150'></TD></TR>";
	var s="<TR><TD VALIGN='TOP' ALIGN='RIGHT'><IMG SRC='ay_book_images/"+_links[ndx].img+"' BORDER='0'></TD></TR>";
	document.write(s);
}

function writeLinks(ndx){
	var s="<TABLE WIDTH='100%' BORDER='0' CELLPADDING='0' CELLSPACING='0' ALIGN='CENTER'>";
	for(var i=0; i < _links.length; i++){
		if(i==14 || i==17)  s+="<TR><TD VALIGN='TOP' ALIGN='RIGHT'><IMG SRC='gifs/type_emb4.gif' border='0'></IMG></TD></TR>";
		if(i!=ndx)
			s+="<TR><TD VALIGN='TOP' ALIGN='RIGHT' nowrap><A HREF='javascript:parent.document.location.href=\""+
               		(_fsizes[i].pdf==0?"javascript:;":_links[i].url)+"\"' CLASS='"+(_fsizes[i].pdf==0?"ay_sel_submenu":"sideBookList")+
               		"' onMouseOver='status=\"\"; return true;' onMouseOut=''>"+_links[i].txt+"</A></TD></TR>";
		else
			s+="<TR><TD CLASS='sideBookListSel' VALIGN='TOP' ALIGN='RIGHT' nowrap>"+_links[i].txt+"</TD></TR>";
	}
	s += "</TABLE>";
	document.write(s);
}

//************ FOOTER ***********//
function writeFooter(){
	var footer="";
	footer += '<HR WIDTH="100%" ALIGN="CENTER" NOSHADE SIZE="1" CLASS="ay_hr">';
	footer += '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="3" CELLSPACING="0" BGCOLOR="#666666"><TR>';
	footer += '<TD CLASS="bottom_addrInTable" ALIGN="CENTER"> 319 West 107th Street, New York, NY 10025-2799<BR>';
	footer += 'phone (212) 864-7752 &#149; fax (212) 864-7704 &#149; e-mail: <A HREF="mailto:info@roerich.org" CLASS="bottom_addrInTable">info@agniyoga.org</A>';
	footer += '</TD></TR></TABLE>';
	document.write(footer);
}

function launch(url){ parent.location.href=url; }

function writeFrames(){
	var app_id=getAppId();
	var s="";
	s+="<FRAMESET ROWS='36,*,51' BORDER=0 BORDERCOLOR=white>";
	s+="	<FRAME NAME=f1 SRC='ay_ru_header_ft.html?ndx="+_apps[app_id].ndx+"' BORDER=0 SCROLLING=NO>";
	//s+="	<FRAMESET COLS='195,*' BORDER=0 BORDERCOLOR=white>";
	s+="	<FRAMESET COLS='160,*' BORDER=0 BORDERCOLOR=white>";
	s+="		<FRAME NAME=f2 SRC='ay_ru_books_nav.html?ndx="+_apps[app_id].ndx+"' BORDER=0 SCROLLING=NO>";
	s+="		<FRAME NAME=f3 SRC='"+_apps[app_id].url_ft + getAppId(1)+"' BORDER=0 SCROLLING=AUTO>";
	s+="	</FRAMESET>";
	s+="	<FRAME NAME=f4 SRC='ay_ru_footer.html' BORDER=0 SCROLLING=NO>";
	s+="</FRAMESET>";
	document.write(s);
}

function getAppId(number){
	var qs=document.location.search;
     pos1 = qs.indexOf("app_id=")+7;
     pos2 = qs.indexOf("_",pos1);
     pos2 = (pos2 == -1?qs.length:pos2+(number==null?0:1));
	var app_id=(number==null?qs.substring(pos1,pos2):"#"+qs.substring(pos2));
	return app_id;
}

function writeRLinks(ndx,childNdx,arrList){
	var htmls = "<TABLE WIDTH='120px' BORDER='0' ALIGN='LEFT' CELLPADDING='0' CELLSPACING='5'>";
	htmls += "\n\t<TR><TD ROWSPAN='3'>&nbsp;</TD><TD CLASS='common_text' VALIGN='TOP'>";
	htmls += "\n<DIV ALIGN='LEFT'><A HREF='javascript:parent.location.href=\"ay_ru_index.html\"'>";
	htmls += "\n<IMG SRC='gifs/maitreya_small.gif' WIDTH='80' HEIGHT='86' ALIGN='MIDDLE' BORDER='0'></A></DIV>";
	htmls += "\n</TD></TR><TR><TD><BR></TD></TR><TR><TD CLASS='common_text' ALIGN=LEFT VALIGN='TOP' NOWRAP>";

//	var arrList = new Array();
	if(arrList == null) arrList = _rlinks_ru;
	for(var i=0; i<arrList.length; i++){
		if(i==ndx){
			var prnt = arrList[i];
			if(prnt.children && prnt.children.length>0){
				if(childNdx!=null) htmls += "\n<A CLASS='ay' onMouseOver='return true;' HREF='"+prnt.url+"'>"+arrList[i].txt+"</A><BR>";
				else			   htmls += "\n<SPAN CLASS='ay_sel'>"+arrList[i].txt+"</SPAN><BR>";
				for(var j=0; j<prnt.children.length; j++){
					var child = prnt.children[j];
					if(childNdx!=null && childNdx==j){
						htmls += "\n<SPAN CLASS='ay_sel_submenu'>&nbsp;&nbsp;&nbsp;&nbsp;"+child.txt+"</SPAN><BR>";
					}else{
						htmls+="\n<A CLASS='ay_submenu' HREF='"+child.url+"' onMouseOver='return true;'>&nbsp;&nbsp;&nbsp;&nbsp;"+child.txt+"</A><BR>";
					}
				}
			}else{
				htmls += "\n<SPAN CLASS='ay_sel'>"+arrList[i].txt+"</SPAN><BR>";
			}
		}
		else
		{
			htmls+="\n<A HREF='"+arrList[i].url+"' CLASS='ay' onMouseOver='return true;'>"+arrList[i].txt+"</A><BR>";
		}
	}
	htmls += "\n</TD></TR></TABLE>";
	document.write(htmls);
}
//---------------------------------------------------------------------------------------
function App(ndx, url_ft)       { this.ndx = ndx; this.url_ft = url_ft; }
function Header(text)           { this.text = text; }
function BookLink(url,txt,txt_home,img,app){ 
	this.url=url;
	this.txt=txt;
	this.txt_home=txt_home;
	this.img=img;
	this.app=app;
}
function FileSizes(pdf, zpdf, doc, zdoc, txt, ztxt){
     this.pdf  = pdf ;
     this.doc  = doc ;
     this.txt  = txt ;
     this.zpdf = zpdf;
     this.zdoc = zdoc;
     this.ztxt = ztxt;
}
//function BookLink(url, txt, img){ this.url = url; this.txt = txt; this.img = img; }
//****** MAIN NAVIGATION *******//
function RLinks(txt,url,hasChildren,parentId){
	this.txt = txt;
	this.url = url;
	this.hasChildren = hasChildren;
	this.parentId = parentId;
	this.children = new Array();
}

for(i=0; i < _links.length; i++){
     _headers[i] =new Header("<A HREF='javascript:launch(\"ay_ru_index.html\");' CLASS='top_nav'>Общество Агни-Йоги</A> | <A HREF='javascript:launch(\""+_links[i].url+"\");' CLASS='top_nav'>"+_links[i].txt+"</A> | <FONT COLOR='FAE54A'> Полный текст</FONT> | <A HREF='javascript:launch(\"ay_ru_downloads.html\");' CLASS=\"top_nav\"> Электронная библиотека</A>");
     _apps[_links[i].app] = new App(i, _links[i].url.substring(0,_links[i].url.indexOf(".html"))+"_ft.html");
}
