var iFrameHeight=0;

	//Change Language Via Buttons
function OnChangeLanguage(value)
{
	var sPath;

	switch (value)
	{
		case "0":
			sPath = "../arm/index.htm";
			break;
		case "1":
			sPath = "../rus/index.htm";
			break;
		case "2":
			sPath = "../eng/index.htm";
			break;		
	}

	parent.frames[1].location.href=sPath;
}	
//Load Index Page And Cheched Page In The Frame-Main
function OnLoadIndex(value)
{
	var sPageCount;
	var sMainPage;
	var sLanguagePage;

	switch(value)
	{
		case "0":
			sLanguagePage="../arm";
			break;
		case "1":
			sLanguagePage="../rus";
			break;
		case "2":
			sLanguagePage="../eng";
			break;
	}

	try
	{
		sPageCount=parent.frames[0].document.frmMain.pager.value;

		if (sPageCount=="")
		{
			sPageCount="0";
			parent.frames[0].document.frmMain.pager.value="0";
			}
	}
	catch(e)
	{
		sPageCount="0";
	}

	switch(sPageCount)
	{
		case "0":
			sMainPage="/work.htm";
			break;
		case "1":
			sMainPage="/weathermap.htm";
			break;
		case "2":
			sMainPage="/history.htm";
			break;
		case "3":
			sMainPage="/structure.htm";
			break;
		case "31":
			sMainPage="/monitoring.htm";
			break;
		case "32":
			sMainPage="/climat.htm";
			break;
		case "33":
			sMainPage="/operative.htm";
			break;
		case "34":
			sMainPage="/hydromonitoring.htm";
			break;
		case "4":
			sMainPage="/links.htm";
			break;
		case "5":
			sMainPage="/main.htm";
			break;
		case "6":
			sMainPage="/contact.htm";
			break;
		case "7":
			sMainPage="/events.htm";
			break;
		}

        var b_size = BodySize();
        var m_pos = getElementPosition('mainpage');

		iFrameHeight = parseInt(b_size.height-150);
		iFrameHeight = b_size.height - m_pos.top;

		document.getElementById("mainpage").style.height = iFrameHeight - 43 + 'px';

		parent.frames[1].frames[2].location.href=sLanguagePage+sMainPage;
}
//Load Page In The Frame-Main (Check It Page Number)
function OnLoadMain()     
{
	parent.parent.frames[0].document.frmMain.pager.value=parent.parent.frames[1].frames[2].document.frmMain.pagenumber.value;
}
//Load Data Page And Scrolling Page In The Frame-Weather
function OnLoadData()
{
	var iLanguageType;
	var sPath;

	try
	{
		iLanguageType=parent.document.frmMain.languagetype.value;	
	}
	catch(e)
	{
	
	}

	switch (iLanguageType)
	{
		case"0"	:
			sPath="arm/weather.htm";
			break;
		case "1":
			sPath="rus/weather.htm";	
			break;
		case"2":
			sPath="eng/weather.htm";	
			break;
	}

	try
	{
	if (parent.frames[0].document.frmMain.alerttype.value=="1")
	{
		parent.parent.frames[1].document.all("alertmsg").style.display='';
	}
		parent.frames[1].frames[1].location=sPath;
	}
	catch(e)
	{
	
	}

}

function OnViewAlert()
{
	if (parent.frames[0].document.frmMain.alerttype.value=="0")
	{
			parent.parent.frames[1].document.all("alertmsg").style.display='';
	}
}
//Change Page In The Frame-Main Via MenuBar On The Index Page
function OpenPage(value)
{
	var sURL;

	switch(value)
	{
		case "0":
			sURL = "work.htm";
			break;
		case "1":
			sURL = "weathermap.htm";
			break;
		case "2":
			sURL = "history.htm";
			break;
		case "3":
			sURL = "structure.htm";
			break;
		case "4":
			sURL = "links.htm";
			break;
		case "5":
			sURL = "main.htm";
			break;
		case "6":
			sURL = "contact.htm";
			break;
		case "7":
			sURL = "events.htm";
			break;
	}
	
	window.frames[2].location.href=sURL;
}
function BackToPage()
{
	parent.frames[2].location.href="work.htm";
}
function OnOver(value)
{
	try
	{
	var oImage=parent.parent.frames[1].document.frames[2].document.frmMain;
	var oDocAll=parent.parent.frames[1].document.frames[2].document.all;
	var oData=parent.parent.frames[1].document.frames[0].document.frmMain;
	var sLangType=parent.parent.frames[1].document.frames[2].document.frmMain.langtype.value;
	var sImgUrl;
	var sImgWidth;
	var sImgHeight;
	var sYear;

	oDocAll.layer0.style.display="none";

	switch(value)
	{
		//YEREVAN
		case "1":
			oDocAll.marzname1.innerText=oImage.countyname1.value;
			oDocAll.nightdata1.innerText=oData.nighttemp1.value;
			oImage.imgPhenom1_1.src=oData.precipimage1_1.value;
			oDocAll.daydata1.innerText=oData.daytemp1.value;
			oImage.imgPhenom1_2.src=oData.precipimage1_2.value;
			oDocAll.eveningdata1.innerText=oData.evening1.value;
			oImage.imgPhenom1_3.src=oData.precipimage1_3.value;

			oDocAll.humidity1.innerText=oData.humiditydata1.value;

			sImgUrl="../images/yerevan.jpg";
			sImgWidth="170";
			sImgHeight="172";

			break;
			
		//SHIRAK
		case "2":
			oDocAll.marzname2.innerText=oImage.countyname2.value;
			oDocAll.nightdata2.innerText=oData.nighttemp2.value;
			oDocAll.daydata2.innerText=oData.daytemp2.value;
			oImage.imgPhenom2.src=oData.precipimage2.value;
			
			sImgUrl="../images/shirak.jpg";
			sImgWidth="177";
			sImgHeight="240";

			break;
			
		//KOTAYK
		case "3":
			oDocAll.marzname2.innerText=oImage.countyname3.value;
			oDocAll.nightdata2.innerText=oData.nighttemp3.value;
			oDocAll.daydata2.innerText=oData.daytemp3.value;
			oImage.imgPhenom2.src=oData.precipimage3.value;
			
			sImgUrl="../images/kotaik.jpg";
			sImgWidth="189";
			sImgHeight="240";

			break;
			
		//GEGHARKUNIK
		case "4":
			oDocAll.marzname2.innerText=oImage.countyname4.value;
			oDocAll.nightdata2.innerText=oData.nighttemp4.value;
			oDocAll.daydata2.innerText=oData.daytemp4.value;
			oImage.imgPhenom2.src=oData.precipimage4.value;
			
			sImgUrl="../images/geharkunik.jpg";
			sImgWidth="254";
			sImgHeight="240";

			break;
			
		//LORI
		case "5":
			oDocAll.marzname2.innerText=oImage.countyname5.value;
			oDocAll.nightdata2.innerText=oData.nighttemp5.value;
			oDocAll.daydata2.innerText=oData.daytemp5.value;
			oImage.imgPhenom2.src=oData.precipimage5.value;
			
			sImgUrl="../images/lori.jpg";
			sImgWidth="320";
			sImgHeight="240";

			break;
			
		//TAVUSH
		case "6":
			oDocAll.marzname2.innerText=oImage.countyname6.value;
			oDocAll.nightdata2.innerText=oData.nighttemp6.value;
			oDocAll.daydata2.innerText=oData.daytemp6.value;
			oImage.imgPhenom2.src=oData.precipimage6.value;
			
			sImgUrl="../images/taush.jpg";
			sImgWidth="244";
			sImgHeight="240";

			break;
			
		//ARAGATSOTN
		case "7":
			oDocAll.marzname3.innerText=oImage.countyname7.value;
			oDocAll.nightdata3_1.innerText=oData.nighttemp7_1.value;
			oDocAll.daydata3_1.innerText=oData.daytemp7_1.value;
			oImage.imgPhenom3_1.src=oData.precipimage7_1.value;

			oDocAll.nightdata3_2.innerText=oData.nighttemp7_2.value;
			oDocAll.daydata3_2.innerText=oData.daytemp7_2.value;
			oImage.imgPhenom3_2.src=oData.precipimage7_2.value;

			sImgUrl="../images/aragatsotn.jpg";
			sImgWidth="133";
			sImgHeight="120";

			break;
			
		//ARARAT
		case "8":
			oDocAll.marzname2.innerText=oImage.countyname8.value;
			oDocAll.nightdata2.innerText=oData.nighttemp8.value;
			oDocAll.daydata2.innerText=oData.daytemp8.value;
			oImage.imgPhenom2.src=oData.precipimage8.value;
			
			sImgUrl="../images/ararat.jpg";
			sImgWidth="320";
			sImgHeight="239";

			break;
			
		//ARMAVIR
		case "9":
			oDocAll.marzname2.innerText=oImage.countyname9.value;
			oDocAll.nightdata2.innerText=oData.nighttemp9.value;
			oDocAll.daydata2.innerText=oData.daytemp9.value;
			oImage.imgPhenom2.src=oData.precipimage9.value;
			
			sImgUrl="../images/armavir.jpg";
			sImgWidth="320";
			sImgHeight="157";
			
			break;
			
		//VAYOTS-DZOR
		case "10":
			oDocAll.marzname3.innerText=oImage.countyname10.value;
			oDocAll.nightdata3_1.innerText=oData.nighttemp10_1.value;
			oDocAll.daydata3_1.innerText=oData.daytemp10_1.value;
			oImage.imgPhenom3_1.src=oData.precipimage10_1.value;

			oDocAll.nightdata3_2.innerText=oData.nighttemp10_2.value;
			oDocAll.daydata3_2.innerText=oData.daytemp10_2.value;
			oImage.imgPhenom3_2.src=oData.precipimage10_2.value;

			sImgUrl="../images/vayots_dzor.jpg";
			sImgWidth="133";
			sImgHeight="120";

			break;
			
		//SYUNIK
		case "11":
			oDocAll.marzname3.innerText=oImage.countyname11.value;
			oDocAll.nightdata3_1.innerText=oData.nighttemp11_1.value;
			oDocAll.daydata3_1.innerText=oData.daytemp11_1.value;
			oImage.imgPhenom3_1.src=oData.precipimage11_1.value;

			oDocAll.nightdata3_2.innerText=oData.nighttemp11_2.value;
			oDocAll.daydata3_2.innerText=oData.daytemp11_2.value;
			oImage.imgPhenom3_2.src=oData.precipimage11_2.value;

			sImgUrl="../images/syunik.jpg";
			sImgWidth="87";
			sImgHeight="120";

			break;
			
		//ARTSAKH
		case "12":
			oDocAll.marzname2.innerText=oImage.countyname12.value;
			oDocAll.nightdata2.innerText=oData.nighttemp12.value;
			oDocAll.daydata2.innerText=oData.daytemp12.value;
			oImage.imgPhenom2.src=oData.precipimage12.value;
			
			sImgUrl="../images/artsakh.jpg";
			sImgWidth="191";
			sImgHeight="240";
			
			break;
		//SEVAN
		case "13":
			switch (sLangType)
			{
				case "0":
					sYear=" ";
					sYear+=oData.singlletter1.value;
					sYear+=".";
					break;
				case "1":
					sYear=" ";
					sYear+=oData.singlletter.value;
					sYear+=".";
					break;
				case "2":
					sYear=" y.";
					break;
			}
			oDocAll.marzname4.innerText=oImage.countyname13.value;
			oDocAll.nightdata4.innerText=oData.nighttemp13.value;
			oDocAll.daydata4.innerText=oData.daytemp13.value;
			oImage.imgPhenom4.src=oData.precipimage13.value;
			oDocAll.datayear1.innerText=oData.datayear13_1.value+sYear;
			oDocAll.datayear2.innerText=oData.datayear13_2.value+sYear;
			oDocAll.datayear3.innerText=oData.datayear13_11.value;
			oDocAll.datayear4.innerText=oData.datayear13_21.value;
			
			sImgUrl="../images/sevan.jpg";
			sImgWidth="87";
			sImgHeight="120";
			
			break;
	}
	
	//YEREVAN [LAYER1]
	if (value=="1")
	{
		oImage.imgMarz1.src=sImgUrl;
		oImage.imgMarz1.width=sImgWidth;
		oImage.imgMarz1.height=sImgHeight;
		oDocAll.layer1.style.display="";
	}

	//SHIRAK, KOTAYK, GEGHARKUNIK, LORI, TAVUSH, ARARAT, ARMAVIR, ARTSAKH [LAYER2]
	if (value=="2" || value=="3" || value=="4" || value=="5" || value=="6" || value=="8"  || value=="9"  || value=="12")
	{
		oImage.imgMarz2.src=sImgUrl;
		oImage.imgMarz2.width=sImgWidth;
		oImage.imgMarz2.height=sImgHeight;
		oDocAll.layer2.style.display="";
	}
	
	//ARAGATSOTN, VAYOTS-DZOR, SYUNIK [LAYER3]
	if (value=="7" || value=="10" || value=="11")
	{
		oImage.imgMarz3.src=sImgUrl;
		oImage.imgMarz3.width=sImgWidth;
		oImage.imgMarz3.height=sImgHeight;
		oDocAll.layer3.style.display="";
	}
	
	//SEVAN [LAYER4]
	if (value=="13")
	{
		oImage.imgMarz4.src=sImgUrl;
		oImage.imgMarz4.width=sImgWidth;
		oImage.imgMarz4.height=sImgHeight;
		oDocAll.layer4.style.display="";
	}
	}
	catch(e)
	{}

}
function OnOut()
{
	try
	{
	var oImage=top.frames[1].document.frames[2].document.frmMain;
	var oDocAll=top.frames[1].document.frames[2].document.all;
	var oData=top.frames[1].document.frames[0].document.frmMain;
	
	oDocAll.layer1.style.display="none";
	oDocAll.layer2.style.display="none";
	oDocAll.layer3.style.display="none";
	oDocAll.layer4.style.display="none";
	oDocAll.layer0.style.display="";

	oImage.imgMarz1.src="../images/blank.gif";
	oImage.imgMarz1.width="";
	oImage.imgMarz1.height="";

	oImage.imgMarz2.src="../images/blank.gif";
	oImage.imgMarz2.width="";
	oImage.imgMarz2.height="";

	oImage.imgMarz3.src="../images/blank.gif";
	oImage.imgMarz3.width="";
	oImage.imgMarz3.height="";
	
	oImage.imgMarz4.src="../images/blank.gif";
	oImage.imgMarz4.width="";
	oImage.imgMarz4.height="";
	}
	catch(e)
	{}

}
function OnOpenWork(value, value1)
{
	var sDocumentUrl;

	parent.parent.frames[0].document.frmMain.listing.value= "0";

	switch(value)
	{
		case "1":
			sDocumentUrl="monitoring.htm";
			break;
		case "2":
			sDocumentUrl="climat.htm";
			break;
		case "3":
			sDocumentUrl="operative.htm";
			break;			
		case "4":
			sDocumentUrl="hydromonitoring.htm";
			break;			
	}

	parent.frames[2].location.href=sDocumentUrl;

}

function OnLoadWorkPage(pagenum, hiddencount, worktype)
{
	var ihiddenobj;
	var ihiddenimg;
	var pagename;
//	var oPage=parent.frames[1].frames[2].document;
//alert("pagenum "+pagenum)
//alert("hiddencount "+hiddencount)
//alert("worktype "+worktype)

	parent.parent.frames[0].document.frmMain.pager.value=document.frmMain.pagenumber.value;
	
	for (i=1; i<=hiddencount; i++)
	{
		if (pagenum==i)
		{
			ihiddenobj = eval("document.frmMain.ballstate" + i);
			ihiddenobj.value="1";
			ihiddenimg = eval("document.frmMain.ball" + i);
			ihiddenimg.src = "../images/ball_green.gif";
		}
		else
		{
			ihiddenobj = eval("document.frmMain.ballstate" + i);
			ihiddenobj.value="0";
			ihiddenimg = eval("document.frmMain.ball" + i);
			ihiddenimg.src = "../images/ball_blue.gif";
		}
	}

	parent.frames[2].frames[0].location.href= worktype + pagenum + ".htm";
	
}

function OnChangeWork(pagenum, hiddencount, worktype)
{	
	var imgnum;
	var ihiddenobj;
	var pagename;
	var oPage=parent.frames[2];

	for (i=1; i<=hiddencount;i++)
	{
		imgnum = eval("oPage.document.frmMain.ball" + i);
		imgnum.src="../images/ball_blue.gif";
		
		if (pagenum==i)
		{
			ihiddenobj = eval("oPage.document.frmMain.ballstate" + pagenum);

			if (ihiddenobj.value=="1")
			{
				imgnum = eval("oPage.document.frmMain.ball" + pagenum);
				imgnum.src="../images/ball_green.gif";
			}
			else
			{
				imgnum = eval("oPage.document.frmMain.ball" + pagenum);
				imgnum.src="../images/ball_green.gif";
				ihiddenobj.value="1";

				oPage.frames[0].location= worktype + pagenum + ".htm";
			}
		}
		else
		{
			ihiddenobj = eval("oPage.document.frmMain.ballstate" + i);
			ihiddenobj.value="0";
		}
	}
}
function OnCheckPage()
{
	parent.parent.parent.frames[0].document.frmMain.listing.value = document.frmMain.workpagenumber.value;
}
function OnHistory(value)
{
		parent.parent.frames[1].frames[2].frames[0].location.href="historybody.htm#"+value;
}
function OnLink(value)
{
		parent.parent.frames[1].frames[2].frames[0].location.href="../linksbody.htm#"+value;
}

function MM_swapImgRestore() 
{ 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{
	var d=document; 

	if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0)
		{ 
			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
		}
	}
}

function MM_findObj(n, d)
{
	var p,i,x;  if(!d) d=document;

	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) 
		x=d.all[n]; 
		for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		 x=MM_findObj(n,d.layers[i].document);
		if(!x && document.getElementById) 
			x=document.getElementById(n); 
			return x;
}

function MM_swapImage() 
{
  var i,j=0,x,a=MM_swapImage.arguments; 
  
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
   {
		document.MM_sr[j++]=x; 
		if(!x.oSrc) 
			x.oSrc=x.src; 
			x.src=a[i+2];
	}
}

function BodySize() 
{
  var iWidth = 0, iHeight = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    iWidth = window.innerWidth;
    iHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    iWidth = document.documentElement.clientWidth;
    iHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    iWidth = document.body.clientWidth;
    iHeight = document.body.clientHeight;
  }

  return {"width": iWidth, "height": iHeight};
}
function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}