 timeoutID=null;
 menuOld=0;
 msout = true;

// Determine browser.

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

if ( window.navigator.userAgent.indexOf("Firefox")>=0 ) {
	isMinNS4 = 0;
	isMinIE4 = 1;
	isMinIE5 = 1;
	}


 if(navigator.appName=="Netscape")
         {NS4=true;mouseX="event.pageX";}
 else {NS4=false;mouseX = "document.body.scrollLeft + window.event.clientX";}


function moveLayers(menuName)
{
 if(menuOld!="") popUp(menuOld,false); menuOld=menuName;
}

function popOff(menuNum)
{
   msout = true;
   timeoutID=setTimeout("if (msout) {popUp(menuOld, false,0)}",1000);
}

function popUp(menuNum,on)
{
  if (on) {
    msout = false;
    if(timeoutID) clearTimeout(timeoutID);
    moveLayers(menuNum);
    showLayer('menu'+menuNum)
    mOver(menuNum)
  }
  else {
        hideLayer("menu"+menuNum)
        mOut(menuNum)
  }

}

pageDone=false;

function preload() {
   this.length = preload.arguments.length;
   for (var i = 0; i < this.length; i++) {
      this[i] = new Image();
      this[i].src = preload.arguments[i]; // andr
   }
}

function mOver(position) {
 if (pageDone) {
   img="mc"+position;
    document.images[img].src=cache[position-1].src; // andr
 }
}

function mOut(position) {
 if (pageDone) {
   img="mc"+position;
   document.images[img].src="/_/images/m"+position+".gif"; // andr
 }
}


function smOver(i,position) {
 msout=false;
 if (pageDone) {
   img="smc"+i+position;
    document.images[img].src=cache2[position-1].src; // andr
 }
}

function smOut(i,position) {
 popOff(1)
 if (pageDone) {
   img="smc"+i+position;
   document.images[img].src="/_/images/sm"+position+".gif"; // andr
 }
}

function lizSmOver(i,position) {
 msout=false;
 if (pageDone) {
   img="smc"+i+position;
   document.images[img].src=cache3[position-1].src; // andr
 }
}

function lizSmOut(i,position) {
 popOff(1)
 if (pageDone) {
   img="smc"+i+position;
   document.images[img].src="/_/images/sml"+position+".gif"; // andr
 }
}

var cache = new preload(
      "/_/images/ma1.gif",
      "/_/images/ma2.gif",
      "/_/images/ma3.gif",
      "/_/images/ma4.gif",
      "/_/images/ma5.gif",
      "/_/images/ma6.gif");

var cache2 = new preload(
      "/_/images/sm1h.gif",
      "/_/images/sm2h.gif",
      "/_/images/sm3h.gif");

var cache3 = new preload(
      "/_/images/sml1h.gif",
      "/_/images/sml2h.gif",
      "/_/images/sml3h.gif");

// -------------------opacity script-------------------------------
function hover(id,opacity){
       document.all[id].filters.alpha.opacity = opacity;
}


function fadeOut(id,delay,stop){
    if (document.all[id].filters.alpha.opacity > stop){
        document.all[id].filters.alpha.opacity -= 2;
        setTimeout("fadeOut('"+ id +"',"+ delay +","+ stop +")",delay);
        }
    else {
        hideLayer(id)
        }
    }

function fadeIn(id,delay,stop){
    if (document.all[id].filters.alpha.opacity < stop){
        document.all[id].filters.alpha.opacity += 2;
        setTimeout("fadeIn('"+ id +"',"+ delay +","+ stop +")",delay);
        }
    else {
        return;
        }
    }

function hideLayer(object) {
//  if (isMinNS4) document.layers[object].visibility = "hide";
//  if (isMinIE4) document.all[object].style.visibility = "hidden";
if (document.getElementById && document.getElementById(object) != null)
node = document.getElementById(object).style.visibility='hidden';
else if (document.layers && document.layers[object] != null)
document.layers[object].visibility = 'hidden';
else if (document.all)
document.all[object].style.visibility = 'hidden';

}

function showLayer(object) {
  //if (isMinNS4) document.layers[layer].visibility = "show";
  //if (isMinIE4) document.all[layer].style.visibility = "visible";
	if (document.getElementById && document.getElementById(object) != null)
	node = document.getElementById(object).style.visibility='visible';
	else if (document.layers && document.layers[object] != null)
	document.layers[object].visibility = 'visible';
	else if (document.all)
	document.all[object].style.visibility = 'visible';
  
}

// -----------------------------------------------------------------
	function openit(theURL, W, H, wname) {
		if (!wname) wname="_new";
		CLOSEdwn 		= "img/close_dwn.gif"
		CLOSEup 		= "img/close_up.gif"
		CLOSEovr 		= "img/close_ovr.gif"
		MINIdwn 		= "img/mini_dwn.gif"
		MINIup 			= "img/mini_up.gif"
		MINIovr 		= "img/mini_ovr.gif"
		NONEgrf 		= "img/spacer.gif"
		CLOCKgrf		= "img/clock.gif"
		titHTML 	    	= "<img border=0 src=../js/img/photo_title.gif>"
		titWIN			= "rmc"
		winBORDERCOLOR   	= "#000000"
		winBORDERCOLORsel	= "#000000"
		winBGCOLOR    		= "#FFCC00"
		winBGCOLORsel 		= "#FFCC00"
		openchromeless(theURL,wname,W,H,null,null,NONEgrf,CLOSEdwn,CLOSEup,CLOSEovr,MINIdwn,MINIup,MINIovr,CLOCKgrf,titHTML,titWIN,winBORDERCOLOR,winBORDERCOLORsel,winBGCOLOR,winBGCOLORsel)
	}

	function openit2(theURL, W, H, wname) {
		if (!wname) wname="_new";
		CLOSEdwn 		= "img/close_dwn.gif"
		CLOSEup 		= "img/close_up.gif"
		CLOSEovr 		= "img/close_ovr.gif"
		MINIdwn 		= "img/mini_dwn.gif"
		MINIup 			= "img/mini_up.gif"
		MINIovr 		= "img/mini_ovr.gif"
		NONEgrf 		= "img/spacer.gif"
		CLOCKgrf		= "img/clock.gif"
		titHTML 	    	= "<span style='font-size:11px;'>&nbsp;Система управления сайтом"
		titWIN			= "rmc"
		winBORDERCOLOR   	= "#000000"
		winBORDERCOLORsel	= "#000000"
		winBGCOLOR    		= "#FFCC00"
		winBGCOLORsel 		= "#FFCC00"
		openchromeless(theURL,wname,W,H,null,null,NONEgrf,CLOSEdwn,CLOSEup,CLOSEovr,MINIdwn,MINIup,MINIovr,CLOCKgrf,titHTML,titWIN,winBORDERCOLOR,winBORDERCOLORsel,winBGCOLOR,winBGCOLORsel)
	}


function popup(text) {
 url="popup.asp?text="+text;
 sw=550;
 sh=200;
 var v=parseInt(navigator.appVersion);
 isNetscape=navigator.appName.indexOf('Netscape')>=0;
 isExplorer=navigator.appName.indexOf('Explorer')>=0;
 positionCode='';

         w  = screen.availWidth/2-sw/2;
         h  = screen.availHeight/2-sh/2;

 if(isExplorer) {
        positionCode=',left='+w+',top='+h;
                          
    }
 if(isNetscape) {
        positionCode=',screenX='+w+',screenY='+h;
    }
	   positionCode+=''

   newWin=window.open('','a','width='+sw+',height='+sh+','+positionCode);
   newWin.document.location=url;
   newWin.focus();
}

function view(picName,wn,sw,sh,alt) {
  if (true) {
          var v=parseInt(navigator.appVersion);
          isNetscape=navigator.appName.indexOf('Netscape')>=0;
          isExplorer=navigator.appName.indexOf('Explorer')>=0;
          positionCode='';

                   w  = screen.availWidth/2-sw/2;
                   h  = screen.availHeight/2-sh/2;

           if(isExplorer) {
                  positionCode=',scrollbars=0, resizable=0, left='+w+',top='+h;

              }
           if(isNetscape) {
                  positionCode=',scrollbars=no,resizable=no,screenX='+w+',screenY='+h;
              }

          newWindow=window.open("",wn,'width='+sw+',height='+sh+positionCode);
          newWindow.document.write('<html><head><title>Франклин Грант</title>');
          newWindow.document.write('<link rel="stylesheet" href="../js/styles/styles.css" type="text/css">');
          newWindow.document.write('</head>');
          newWindow.document.write('<body scroll=no class=popup>');
          newWindow.document.write('<table border="0" width="100%" height="90%"><tr><td width="100%" valign="middle" align="center" height="90%"><img src="../js/%27%2BpicName%2B%27">');
          newWindow.document.write('</td>');
          newWindow.document.write('</tr></table>');
          newWindow.document.write('<p align="center" style="text-align:center"><a href="javascript:window.close();" style="popup">закрыть</a></p></body></html>');
  }
}
