// JavaScript Document

//Initial variables 
var m_top = 25;				// Top of menu
var am_h = new Array();		// Array of Heights of each submenumenu // May be calculated by length of strings of Menu items
var asm_w = new Array();	// Array of maximum Widthes of each submenu
							// calculated with function getLargestElement(arr)
var am_left = new Array();	// Array of Left Coordinates of each menu item
var height_koef = 14.6;		// Koefficient to calculate submenu height.
var m_bottom = 200;			// Bottom of menu after clipping
var z_ind = 1;				// z- index of DHTML element
var m_color = '#FEF2D8';
var max_length = 20;		// maximum nonscrollable quatity of submenu items
var max_height = max_length*14.7;		// maximum nonscrollable height of submenu
// scrolling variables
var step = 3; 				// +x, srolling UP, -x, scrolling down
var t_ms = 50;				// milliseconds for SeTimeOut() function
var stmt;  					// Variable for SetTimeOut() function
// var scrolled = false;
//
var x_coord, y_coord;
var LM_1, LM_2, LM_3, LM_4	// Menu items
var L_exp									// layer for experiments
var SM_1, SM_2, SM_3, SM_4	// submenus
var SM_shadow1, SM_shadow2, SM_shadow3, SM_shadow4  // Floats to behind of each submenu
var SM_Arrow_Up, SM_Arrow_Down
var aSM = new Array()
//-----------------------------------

//Array of Menu items
var aMenu = new Array();	
aMenu[0] = "A HISTORICAL INTRODUCTION";
aMenu[1] = "DISTRICTS";
aMenu[2] = "MEMOIRS";
aMenu[3] = "INDEXES";

//Arrays of SubMenu items
var aSMitems_1 = new Array();			//ܳ˳
aSMitems_1[0] = "A few words";
aSMitems_1[1] = "The Region in Its Geographical Setting";
aSMitems_1[2] = "A Historical Chronology";
aSMitems_1[3] = "The Great Resettlement of the 18th Century";
aSMitems_1[4] = "Gandzak as the Seat of Aghvank Catholicoses";
aSMitems_1[5] = "Gandzak Vicarate";
aSMitems_1[6] = "Population";
aSMitems_1[7] = "The Local Trade";
aSMitems_1[8] = "The Historical Monuments of the Region";
var aHrefItems_1 = new Array();
aHrefItems_1[0] = "1_0.htm";
aHrefItems_1[1] = "1_1.htm";
aHrefItems_1[2] = "1_2.htm";
aHrefItems_1[3] = "1_3.htm";
aHrefItems_1[4] = "1_4.htm";
aHrefItems_1[5] = "1_5.htm";
aHrefItems_1[6] = "1_6.htm";
aHrefItems_1[7] = "1_7.htm";
aHrefItems_1[8] = "1_8.htm";

var aSMitems_2 = new Array();			//ٳϳ ݳ
aSMitems_2[0] = "Gandzak(Gyanja)";
aSMitems_2[1] = "Dashkesan";
aSMitems_2[2] = "Getabek";
aSMitems_2[3] = "Ghazakh";
aSMitems_2[4] = "Kasum-Ismayilov";
aSMitems_2[5] = "Khanlar";
aSMitems_2[6] = "Shamkhor";
aSMitems_2[7] = "Touz";
aSMitems_2[8] = "Artzvashen ";
var aHrefItems_2 = new Array();
aHrefItems_2[0] = "2_0.htm";
aHrefItems_2[1] = "2_1.htm";
aHrefItems_2[2] = "2_2.htm";
aHrefItems_2[3] = "2_3.htm";
aHrefItems_2[4] = "2_4.htm";
aHrefItems_2[5] = "2_5.htm";
aHrefItems_2[6] = "2_6.htm";
aHrefItems_2[7] = "2_7.htm";
aHrefItems_2[8] = "2_8.htm";
var aSMitems_3 = new Array();			//ݳ
aSMitems_3[0] = "A new year in the Gorge of Shamkor";
aSMitems_3[1] = "Acquaintance with Shahen Meghrian";
aSMitems_3[2] = "I can never Forget You, Honourable Mother and Son from Buzlukh!";
aSMitems_3[3] = "Honourable Grand-Dad Badam from Brajur";
aSMitems_3[4] = "The Savages of Rustam Aliyev";
aSMitems_3[5] = "Strangely Enough, I was Encouraged by a Person who had Destroyed a Church";
aSMitems_3[6] = "An Argument over our Dwelling in Ghotyul";
aSMitems_3[7] = "A Slide Show in the Open Air in Banants";
aSMitems_3[8] = "Imprisoned in Kosh for  the Endeavours to Defend Banants";
aSMitems_3[9] = "Munificent on the Verge of Grave";
var aHrefItems_3 = new Array();
aHrefItems_3[0] = "3_0.htm";
aHrefItems_3[1] = "3_1.htm";
aHrefItems_3[2] = "3_2.htm";
aHrefItems_3[3] = "3_3.htm";
aHrefItems_3[4] = "3_4.htm";
aHrefItems_3[5] = "3_5.htm";
aHrefItems_3[6] = "3_6.htm";
aHrefItems_3[7] = "3_7.htm";
aHrefItems_3[8] = "3_8.htm";
aHrefItems_3[9] = "3_9.htm";

var aSMitems_4 = new Array();			// زβ ޲Ҳܺ
aSMitems_4[0] = "Bibliography";
aSMitems_4[1] = "Personal names";
aSMitems_4[2] = "Toponyms";
var aHrefItems_4 = new Array();
aHrefItems_4[0] = "4_0.htm";
aHrefItems_4[1] = "4_1.htm";
aHrefItems_4[2] = "4_2.htm";

asm_w[0] = getLargestElement(aSMitems_1)*7.8;
asm_w[1] = getLargestElement(aSMitems_2)*7.8;
asm_w[2] = getLargestElement(aSMitems_3)*7.8;
asm_w[3] = getLargestElement(aSMitems_4)*7.8;

am_h[0] = setheight(aSMitems_1, height_koef, max_length)
am_h[1] = setheight(aSMitems_2, height_koef, max_length)
am_h[2] = setheight(aSMitems_3, height_koef, max_length)
am_h[3] = setheight(aSMitems_4, height_koef, max_length)

			//   ID,  left, top,  width,   height, color, vis,   z-index, other
var sss = css('SM_1', 25, 50, asm_w[0], am_h[0], m_color, 'hidden', 50, 'FONT-FAMILY: Arial AM; FONT-SIZE: 12px; padding:2px;')
sss += css('SM_2', 108, 50, asm_w[1], am_h[1], m_color, 'hidden', 51, 'FONT-FAMILY: Arial AM; FONT-SIZE: 12px; padding:2px;')
sss += css('SM_3', 259, 50, asm_w[2], am_h[2], m_color, 'hidden', 52, 'FONT-FAMILY: Arial AM; FONT-SIZE: 12px; padding:2px;')
sss += css('SM_4', 372, 50, asm_w[3], am_h[3], m_color, 'hidden', 53, 'FONT-FAMILY: Arial AM; FONT-SIZE: 12px; padding:2px;')
writeCSS(sss, false);
// End testing CSS

	function init_m(){
		if (is.ns4)
		document.captureEvents(Event.MOUSEDOWN)
		
		document.onmousedown = mouseDown
		document.onmousemove=showcoord
		LM_1 = new DynLayer('M_1')
		LM_2 = new DynLayer('M_2')
		LM_3 = new DynLayer('M_3')
		LM_4 = new DynLayer('M_4')
		//******************************
		SM_1 = new DynLayer('SM_1')
		SM_2 = new DynLayer('SM_2')
		SM_3 = new DynLayer('SM_3')
		SM_4 = new DynLayer('SM_4')
		//******************************
		SM_shadow1 = new DynLayer('SM_shadow1');
		SM_shadow2 = new DynLayer('SM_shadow2');
		SM_shadow3 = new DynLayer('SM_shadow3');
		SM_shadow4 = new DynLayer('SM_shadow4');
		SM_1.write(fillSubMenu(aSMitems_1, aHrefItems_1, aInitSb[0]))
		SM_2.write(fillSubMenu(aSMitems_2, aHrefItems_2, aInitSb[1]))
		SM_3.write(fillSubMenu(aSMitems_3, aHrefItems_3, aInitSb[2]))
		SM_4.write(fillSubMenu(aSMitems_4, aHrefItems_4, aInitSb[3]))

		//******************************
		SM_Arrow_Up = new DynLayer('SM_Arrow_Up')
		SM_Arrow_Down = new DynLayer('SM_Arrow_Down')
		aSM[0] = SM_1;
		aSM[1] = SM_2;
		aSM[2] = SM_3;
		aSM[3] = SM_4;
	}	
	//*************************************************************
	function showcoord(eee){
		//var evvv = is.ns ? eee : event
		if(is.ns){
			x_coord=eee.clientX
			y_coord=eee.clientY
		}
		else {
			x_coord=event.x
			y_coord=event.y
		}
		show_hide_submenu(LM_1, SM_1, SM_shadow1, x_coord, y_coord)
		show_hide_submenu(LM_2, SM_2, SM_shadow2, x_coord, y_coord)
		show_hide_submenu(LM_3, SM_3, SM_shadow3, x_coord, y_coord)
		show_hide_submenu(LM_4, SM_4, SM_shadow4, x_coord, y_coord)
		//for Book 6 only
		if(document.getElementById("selsettle")){
		if(getVisibleLayerNum()==1 || getVisibleLayerNum()==2 || getVisibleLayerNum()==3 || getVisibleLayerNum()==0){
			document.getElementById("selsettle").style.visibility="hidden";
			}
		else{
			document.getElementById("selsettle").style.visibility="visible";
			}
		}
	}
