var open_menu = new Array(); 
for (var i=0; i<10; i++) {open_menu[i]=0}
var scrol=0;

// открывание картинки в новом окне
function window_Open(adress){
windop=window.open("","mywin",config='height=300,width=300'); //,"width=1200,height=800"
windop.document.open();
windop.document.write("<html><head><title>Big Image</title>");
windop.document.write("</head><body bgcolor=#f0f8f0>");
windop.document.write("<center><font face=Arial,Verdana size=3 color=#000080><b></b></font></center>");
windop.document.write('</br><p align="center"><img border="0" src="'+adress+'"></p></br>');
//windop.document.write("<center><form><input type='button' value='Закрыть' onClick='window.close()'></form></center>")
windop.document.write("</body></html>");
windop.document.close();
}

img1=new Image(); // это обязательное условие работы функции которая ниже

function imgopen(imgf,tit){
img1.src=imgf;
img1.onload=new Function('if(img1.width!=0) eval(iopen);');

rand_id='image'+(Math.round(Math.random()*1000));

outf="<html><head>"
 +"<"+"title>"+tit+"<"+"/title>"
 +"<style>body{margin:0px}</style>"
 +"</head>"
 +"<body leftmargin=0 topmargin=0>"
 +"<img src=\""+imgf+"\">"
 +"</body></html>" ;

iopen="iwin=self.open('"+imgf+"', '"+rand_id+"', 'width='+(img1.width)+',height='+(img1.height)+',top=50,left=50, resizable=yes');"
 +"iwin.document.write('"+outf+"');"
 +"iwin.focus();";

// теперь нужно подождать загрузки изображения
// для этого используется обработчик события загрузки картинки onLoad описанный ранее

/*if(img1.width!=0) eval(iopen);
  else alert("Не удалось определить размеры картинки!");*/
}


function bigban(id1,id2){

document.getElementById(id2).src=id1;
}

// функция при нажатии кнопки на исходной странице
function newPage(lin)
{ 
//scrol=document.body.scrollTop;

// не для старого ие 
/*
scrol=document.body.scrollTop;								
SetCookie ("scrolll_date", scrol);*/

var lkj=lin;
var bse=location.href.substring(0,location.href.lastIndexOf("/")+1);// получил ляляляbse+
//alert(bse);
if (bse=="file:///C:/Documents%20and%20Settings/d.musikov/Рабочий%20стол/munk3/static%20pages/")
{bse="file:///C:/Documents%20and%20Settings/d.musikov/Рабочий%20стол/munk3/"}
if (bse=="file:///C:/Documents%20and%20Settings/ди/Мои%20документы/Мои%20веб-узлы/munk3/static%20pages/")
{bse="file:///C:/Documents%20and%20Settings/ди/Мои%20документы/Мои%20веб-узлы/munk3/"}
if (bse=="http://www.kuntsevo.org/static%20pages/" || bse=="http://www.kuntsevo.org/")
{//alert(bse); 
bse="http://www.kuntsevo.org/"} // то есть - образаем ссылку до домена, 
// чтобы потом добавить адрес, например static%20pages/ustav.htm?=
document.location=bse+lkj;
}

////////////////////////// функция раскрытия одного меню
function OpenMenu(i){ 
		if (open_menu[i]!=1){	SecondFormPlus="SecondForm"+i;
								document.getElementById(SecondFormPlus).style.display="inline"; 
								open_menu[i]=1; 
								}
		else{
			SecondFormPlus="SecondForm"+i;
			document.getElementById(SecondFormPlus).style.display="none"   
			open_menu[i]=0;
			} 
}

////////////////////////// функция установки кука при открытии меню
function SetCookieMenu(i){ 
		menu_name="menu"+i; 
		if (GetCookie(menu_name)!=1){SecondFormPlus="SecondForm"+i;
								document.getElementById(SecondFormPlus).style.display="inline"; 
								SetCookie (menu_name, 1);
								}
		else{
			SecondFormPlus="SecondForm"+i;
			document.getElementById(SecondFormPlus).style.display="none"   
			SetCookie (menu_name, 0);
			} 
}

function init2(){
/* не для ие
und=GetCookie("scrolll_date"); 

if (und!=1){document.body.scrollTop=GetCookie("scrolll_date"); }
tt=GetCookie("scrolll_date");
SetCookie ("scrolll_date", 1); // еденица просто маркер
*/

for (var i=0; i<10; i++)  {
     SecondFormPlus="SecondForm"+i; 
     menu_name="menu"+i;
     if(GetCookie(menu_name)==1){document.getElementById(SecondFormPlus).style.display="inline"}
     }

}

function getCookieVal (offset) {
         var endstr = document.cookie.indexOf (";", offset);      if (endstr == -1) {
            endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); }
function FixCookieDate (date) { var base = new Date(0);
         var skew = base.getTime(); // dawn of (Unix) time - should be 0
         if (skew > 0) {  // Except on the Mac - ahead of its time
            date.setTime (date.getTime() - skew); } }
function GetCookie (name) {
         var arg = name + "="; var alen = arg.length; var clen = document.cookie.length;
         var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) {
               return getCookieVal (j); } i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) { break;} }return null; }
// Function to create or update a cookie.
function SetCookie (name,value,expires,path,domain,secure) {document.cookie = name + "=" + escape (value) +
            ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");}
// Function to delete a cookie. (Sets expiration date to start of epoch)
      function DeleteCookie (name,path,domain) {if (GetCookie(name)) { document.cookie = name + "=" +
               ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") +
               "; expires=Thu, 01-Jan-70 00:00:01 GMT"; }}
               
// Examples
      var expdate = new Date (); FixCookieDate (expdate); // Исправляет ошибки для Mac
      expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000)); // 24 от текущего времени
      

/////////////////////////////////// установка плавной прозрачности
function setElementOpacity(sElemId, nOpacity)
{
  var opacityProp = getOpacityProperty();
  var elem = document.getElementById(sElemId);

  if (!elem || !opacityProp) return; // Если не существует элемент с указанным id или браузер не поддерживает ни один из известных функции способов управления прозрачностью
  
  if (opacityProp=="filter")  // Internet Exploder 5.5+
  {
    nOpacity *= 100;
	
    // Если уже установлена прозрачность, то меняем её через коллекцию filters, иначе добавляем прозрачность через style.filter
    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; // Для того чтобы не затереть другие фильтры используем "+="
  }
  else // Другие браузеры
    elem.style[opacityProp] = nOpacity;
}

function getOpacityProperty()
{
  if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
    return 'opacity';
  else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 и младше, Firefox 0.8 
    return 'MozOpacity';
  else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
    return 'KhtmlOpacity';
  else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
    return 'filter';

  return false; //нет прозрачности
}

