var OldSelect = "";
var CurSelect = "";
var ClTxtMaterialOver = 0x5a4c16;
var ClBkgMaterialOver = 0xfff8d4;
var ClTxtMaterialPassiv = 0x0b3d67;
var ClBkgMaterialPassiv = 0xebe8dc;
var ClTxtMaterialActiv = 0x6c767e;
var ClBkgMaterialActiv = 0xffffff;

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function getafter(id)
{
  var gr0 = window.location.href;
  if(gr0.indexOf("?",0) == -1) {
     OldSelect = document.all['material'+id].children[0];
   }
  else {
     var gr1 = gr0.substr(gr0.indexOf("?",0)+1, gr0.length);
     var NameId = gr1.substr(0, gr1.length-5);
     OldSelect = document.all[NameId];
   } 

  OldSelect.style.color = ClTxtMaterialActiv;
  OldSelect.style.backgroundColor = ClBkgMaterialActiv;
  OldSelect.onclick = MEmpty;
  OldSelect.onmouseover = MEmpty;
  OldSelect.onmouseout = MEmpty;
  OldSelect.style.cursor = "default";

}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function SetFrame()
{
 CurSelect = event.srcElement;

 var html_name = CurSelect.id + ".html"   
 
 CurSelect.onclick = MEmpty;
 CurSelect.onmouseover = MEmpty;
 CurSelect.onmouseout = MEmpty;
 CurSelect.style.cursor = "default";
 CurSelect.style.textDecoration = "none";

 if(OldSelect != "") {
    OldSelect.style.cursor = "hand";
    if(OldSelect.id.indexOf("arj", 0) == -1) {
       OldSelect.onclick = SetFrame;
       OldSelect.onmouseover = MOver;
       OldSelect.onmouseout = MOut;
       OldSelect.style.color = ClTxtMaterialPassiv;
       OldSelect.style.backgroundColor = ClBkgMaterialPassiv;
	 }
  }  
 if(html_name.indexOf("arj", 0) == -1) {
    CurSelect.style.color = ClTxtMaterialActiv;
    CurSelect.style.backgroundColor = ClBkgMaterialActiv;
  }
 OldSelect = CurSelect;
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function MOver()
{
event.srcElement.style.cursor = "hand";
event.srcElement.style.color = ClTxtMaterialOver;
event.srcElement.style.backgroundColor = ClBkgMaterialOver;
event.srcElement.style.textDecoration = "underline";
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function MOut()
{
event.srcElement.style.color = ClTxtMaterialPassiv;
event.srcElement.style.backgroundColor = ClBkgMaterialPassiv;
event.srcElement.style.textDecoration = "none";
}

//------------------------------------------------------------------
//------------------------------------------------------------------
function MEmpty()
{
}


//--------------------------------------------------------------------------
//   
//--------------------------------------------------------------------------
function up_level()
{
  window.parent.MaterialZone.innerHTML = document.body.innerHTML;	 

  HeightAlign(window.parent.LeftPattern, window.parent.MaterialZone, 80);
}

//--------------------------------------------------------------------------
//           Выравнивание левой стороны
//--------------------------------------------------------------------------
function HeightAlign(object1, object2, length)
{
  if(object1==null)  return;

  if((object2.clientHeight - length) > 10)
      object1.style.height = object2.clientHeight - length;
   else  
      object1.style.height = 10;
}


//------------------------------------------------------------------
//------------------------------------------------------------------
//-------------------------------------------------------------
//    For change language
//-------------------------------------------------------------
function LangClick()
{
  var OldLocation = window.location.href;
  var TargetLang = event.srcElement.id

  if((OldLocation.indexOf("find.cgi?", 0) != -1) ||
      (OldLocation.indexOf("tmplnk_", 0) != -1)) {
     var strEnd; 
     switch(TargetLang) {
       case "az":
	      strEnd = "_a.html";
	      break;
       case "en":
	      strEnd = "_e.html";
	      break;
       case "ru":
	      strEnd = "_r.html";
	      break;
      }
     window.location.href = "../index" + strEnd;
	 return;
   }

  var posVopros = OldLocation.indexOf("?", 0); 
  if(posVopros != -1) 
     OldLocation = OldLocation.substr(0, posVopros);

  var Find = OldLocation.substr(OldLocation.length-7, OldLocation.length);
  var Replace;
  switch(TargetLang) {
    case "az":
	   Replace = "_a.html";
	   break;
    case "en":
	   Replace = "_e.html";
	   break;
    case "ru":
	   Replace = "_r.html";
	   break;
   }
  var NewLocation = OldLocation.replace(Find, Replace);
  window.location.href = NewLocation;
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
function LangOver()
{
event.srcElement.style.cursor = "hand";
event.srcElement.style.color = 0x0e71aa;
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function LangOut()
{
event.srcElement.style.color = 0x000000;
}

//------------------------------------------------------------------
//                       INDEX
//------------------------------------------------------------------
//------------------------------------------------------------------
//
//------------------------------------------------------------------
function OpenNews(folder, num, lang)
{
  var strM = "s_news/" + folder +"/news" + num + "_" + lang + ".html";
  var wnd2 = open(strM,"","toolbar=no,scrollbars=yes,resizable=yes,  width=620,height=460,status=yes,location=no");
  wnd2.top.moveTo((screen.width-620)/2, (screen.height-460)/2-30);
}


//------------------------------------------------------------------
//------------------------------------------------------------------
//------------------------------------------------------------------
//------------------------------------------------------------------
//         Archive of the section
//------------------------------------------------------------------
function strModify(url_old)
{
 var url_new = "";

 while(true) {
    url_new = url_old.replace("../", "_zzz_");
	if(url_new == url_old) break;
	url_old = url_new;
  }	

 while(true) {
    url_new = url_old.replace("/", "_zz_");
	if(url_new == url_old) break;
	url_old = url_new;
  }	
   
 return url_new;
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function strRestore(url_old)
{
 var url_new = "";

 while(true) {
    url_new = url_old.replace("_zzz_", "../");
	if(url_new == url_old) break;
	url_old = url_new;
  }	

 while(true) {
    url_new = url_old.replace("_zz_", "/");
	if(url_new == url_old) break;
	url_old = url_new;
  }	
   
 return url_new;
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function MakeWindow(url, width, height)
{
 var str1 = "toolbar=no, scrollbars=yes, resizable=yes, status=yes, location=no, ";
 var str2 = "width=" + width + ", height=" + height;
 var str = str1 + str2;

 url = strModify(url);
 var wnd = open("arj_opener.html",url, str);

 wnd.top.moveTo((screen.width-width)/2, (screen.height-height)/2);
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function LoadArjMaterial()
{
  var str7 = strRestore(this.name) + ".html";
  hideframe.navigate(str7);
}

//------------------------------------------------------------------
//               Photo Album
//------------------------------------------------------------------
function fopenWindow(PURL,PWidth,PHeight)
{
	var str1 = "toolbar=no, scrollbars=auto, resizable=no, status=yes, location=no, ";
	var str2 = "width="+PWidth+", height="+PHeight;
	var str = str1 + str2;
	var wnd = open(PURL,"",str);
	wnd.Width = PWidth;
	wnd.Hidth = PHeight;
    wnd.top.moveTo((screen.width-wnd.Width)/2, (screen.height-wnd.Hidth)/2-25);
}

 
//------------------------------------------------------------------
//
//------------------------------------------------------------------
function OpenWnd(url, wndWidth, wndHeight)
{
 var str = "toolbar=no, scrollbars=yes, resizable=no, status=yes," +
           " location=no, width=" + wndWidth + ", height=" + wndHeight +
		   " , left=" + ((screen.width-wndWidth)/2+15) + 
		   ", top=" + ((screen.height-wndHeight)/2-45);

 var wnd = open(url, "", str);
}


//------------------------------------------------------------------
//
//------------------------------------------------------------------
function SetStat()
{
 if(this.Type==0) {
    this.location.href = "#Text";
  }
 else if(this.Type==1) {
    this.location.href = "#Video";
    MediaPlayer1.autostart = true;
  }	
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function OpenDistrict(url, wndWidth, wndHeight, iType)
{
 var str = "toolbar=no, scrollbars=yes, resizable=no, status=yes," +
           " location=no, width=" + wndWidth + ", height=" + wndHeight +
		   " , left=" + ((screen.width-wndWidth)/2+15) + 
		   ", top=" + ((screen.height-wndHeight)/2-45);

 var wnd = open(url, "", str);
 wnd.Type = iType;
}

/*
//------------------------------------------------------------------
//
//------------------------------------------------------------------
function MOver2()
{
event.srcElement.style.cursor = "hand";
event.srcElement.style.color = 0x7d9ece;
event.srcElement.style.textDecoration = "underline";
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
function MOut2()
{
event.srcElement.style.color = 0x093279;
event.srcElement.style.textDecoration = "none";
}

 

//------------------------------------------------------------------
//                       INDEX
//------------------------------------------------------------------
//------------------------------------------------------------------
//
//------------------------------------------------------------------
function OpenNews(num, lang)
{
  var strM = "s_news/news" + num + "_" + lang + ".html";
  var wnd2 = open(strM,"","toolbar=no,scrollbars=yes,resizable=yes,  width=620,height=460,status=yes,location=no");
  wnd2.top.moveTo((screen.width-620)/2, (screen.height-460)/2);
}
*/
