function showImg(_id, _img, $file, $width, $height) {
window.open("/file.php?img="+$file,'Tip','menubar=no,location=no,toolbar=no,resizable=no,scrollbars=no,status=no,width='+$width+',height='+$height+'');
}


image_m = new Array("250", "250", "500", "300");
dmn='http://www.avtoshkola.net';


function AddFavorite() {
 window.external.AddFavorite(dmn,'');
}




  _opacity = new Array();
  _layer = new Array();
  var _stepOpacity=5;
  var _stepTimeOut=0.1;
  var _stepInterval=300;
  var _v = new Array();
  var _h = new Array();
  var _t = new Array();
  var _s = new Array();
  var stop_play;



  function hiddenImgList(_stopKey) {
           if (_layer) {
              for (var id in _layer) {
                  if (_stopKey != _layer[id]) hiddenImage(_layer[id]);
              }
           }
  }
  function hiddenImgList2(_stopKey, _stopKey2) {
           if (_layer) {
              for (var id in _layer) {
                  if (_stopKey  != _layer[id] ||_stopKey2 != _layer[id]) hiddenImage(_layer[id]);
              }
           }
  }


  function hiddenPopupList(_stopKey) {
           stop_play = 1;
           if (_layer) {
              for (var id in _layer) {
                  if (_stopKey != _layer[id]) unSetOpacity(_layer[id]);
              }
           }
  }


  function viewImgList() {
           if (_layer) {
              for (var id in _layer) {
                   popupOver(_layer[id]);
              }
           }
  }

  function hiddenImage(key) {
           _opacity[key]=0;
           _this=document.getElementById(key);
           _this.style.filter ="alpha(opacity="+_opacity[key]+");";
           _this.style.opacity  =  _opacity[key]/100;
           _this.style.visibility = "hidden";

  }


  function popupOver(key) {
           _this=document.getElementById(key);
           _this.style.visibility = "visible";
           clearInterval(_t[key]);
           if (_opacity[key] != 100) setOpacity(key);
  }

  function popupOut(key) {
           _this=document.getElementById(key);
           clearTimeout(_v[key]);
           clearTimeout(_h[key]);
           clearInterval(_t[key]);
           _t[key]=setInterval("unSetOpacity(\""+key+"\")", _stepInterval);
  }




  function setOpacity(key) {
           _this=document.getElementById(key);
           clearTimeout(_h[key]);
           if (!_opacity[key]) _opacity[key] = 0;

           if (_opacity[key] < 100) {
              _opacity[key]+=_stepOpacity;
              _this.style.filter ="alpha(opacity="+_opacity[key]+");";
              _this.style.opacity  =  _opacity[key]/100;
              _v[key]=setTimeout("setOpacity(\""+key+"\")", _stepTimeOut);
           } else {
              clearTimeout(_v[key]);
           }
  }

  function unSetOpacity(key) {
           _this=document.getElementById(key);
           clearTimeout(_v[key]);
           if (!_opacity[key]) _opacity[key] = 100;

           if (_opacity[key] > 10) {
              _opacity[key]-=_stepOpacity;
              _this.style.filter ="alpha(opacity="+_opacity[key]+");";
              _this.style.opacity  =  _opacity[key]/100;
              _h[key]=setTimeout("unSetOpacity(\""+key+"\")", _stepTimeOut);
           } else {
              clearTimeout(_t[key]);
              clearTimeout(_h[key]);
              _this.style.visibility = "hidden";
              _this.style.filter="";
           } 
  }




  function displayShow(key) {
           _this=document.getElementById(key);
           _this.style.display = "";
  }

  function displayHidden(key) {
           _this=document.getElementById(key);
           _this.style.display = "none";
  }


  function showOtherPage(_showPage) {
//         _s[key]=setInterval("hidDisplayAndShow(\""+_hidPage+"\",\""+_showPage+"\")", 1000);

           hidDisplayAndShow(_hidPage, _showPage);
           _hidPage=_showPage;
  }




  function hidDisplayAndShow(_hidPageKey, _showPageKey) {

//           alert("спрятать "+_hidPageKey+" "+_opacity[_hidPageKey]+", показать "+_showPageKey+" "+_opacity[_showPageKey]+" ");

//           clearInterval(_s[key]);
             popupOut(_hidPageKey);
             displayHidden(_hidPageKey);
             displayShow(_showPageKey);
             hiddenImage(_showPageKey);
             popupOver(_showPageKey);
  }

 function showOtherYear(_showYear) {
          hidDisplayAndShow(_hidYear, _showYear);
         _hidYear=_showYear;
 }



function mail(domain, name, text) {
 var dog = String.fromCharCode(64);
 document.write('<a href="mailto:');
 document.write(name + dog + domain);
 if (text==null || text.length==0) {
  document.write('\">');
  document.write(name + dog + domain);
 } else
 document.write('\" title=\"'+text+'\">'+text);
 document.write('<\/a>');
}


function m_image(where,name,expan,width,height,w_width,w_height) { 
 
 if (!width) width=image_m[0]; 
 if (!height) height=image_m[1]; 
 if (!w_width) w_width=image_m[2]; 
 if (!w_height) w_height=image_m[3]; 
 window.open('/modules/images/view.php?where='+where+'&name='+name+'&expan='+expan+'&width='+width+'&height='+height+'','Tip','menubar=no,location=no,toolbar=no,resizable=no,scrollbars=no,status=no,width='+w_width+',height='+w_height+'') 
} 
 
function over(name,expan,way,id) { 
 if (!id) {
  nameImg="img"+name; 
  dop="_bOver";
 }
 else {
  nameImg=''+id+''+name;
  dop="";
 }

 if (way) way=way+"/";
 srcImage="/images/"+way+""+name+""+dop+"."+expan;
 document[nameImg].src = srcImage; 
} 

function out(name,expan,way,id) { 
 if (!id) {
  nameImg="img"+name; 
  dop="_bOut";
 }
 else {
  nameImg=''+id+''+name;
  dop="";
 }

 if (way) way=way+"/";
 srcImage="/images/"+way+""+name+""+dop+"."+expan;
 document[nameImg].src = srcImage; 

} 


document.onclick = click; 





dom = (document.getElementById)? true : false; 
function load(url) { 
         if (!url) return false; 
         if (dom) { 
            if (url.indexOf('?')>=0){ 
               temp.location.href=url + '&selfWindow=1' 
            } 
            else { 
               temp.location.href=url + '?selfWindow=1' 
            } 
            showLoadWindow(); 
            return false; 
         } 
         else{
            return true;
         } 
} 



function click(){ 
         if (navigator.userAgent && navigator.userAgent.indexOf("pera")>=0) {return true;} 
         var href; 
         namers=window.event.srcElement.name; 
         tn=window.event.srcElement.tagName; 
         cls=window.event.srcElement.className; 

         if (tn == 'FONT' || tn == 'B' || tn == 'I' || tn == 'U' || tn == 'IMG' || tn == 'TD' || tn == 'H1' || tn == 'H2'  || tn == 'H3'  || tn == 'H4'  || tn == 'H5') { 
            namers=window.event.srcElement.parentElement.name; 
            tn=window.event.srcElement.parentElement.tagName; 
            href=window.event.srcElement.parentElement.href; 
            cls=window.event.srcElement.parentElement.className; 
         } 
         if (tn == 'A' && cls == 'selfWindow') { 
            if (!href) href=window.event.srcElement.href; 
            if (href) {


               if (href.indexOf(dmn)>=0  && screen.width >= 850) {
                  load(href);
                  return false;
               }
            } 
         } 
         else { 
            return true;
         } 
} 


function showLoadWindow() {
         //parent.scroll(0, 0);
         document.all.selfWindow.style.display = "";
         document.getElementById('contentSelfWindow').innerHTML = document.all.loadWindow.innerHTML;
}


function insertToFrame(){
        document.getElementById('contentSelfWindow').innerHTML = frames.temp.document.getElementById('contentSelfWindow').innerHTML;
}

function closeSelfWindow(){
         document.getElementById('contentSelfWindow').innerHTML = "";
         document.all.selfWindow.style.display = "none";
}




