/*************************************************\
| Меню и вспомогательные функции                  |
| для сайта                                       |
| http://www.sevzapkanat.ru                            |
\*************************************************/

/***  Владимир Тихонов                         ***\
\***  http://wt.nm.ru   			      ***/



function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

/***  Предварительная загрузка картинки в теге body onload= ***/
var preloadFlag = false;
function preloadImages(arg) {
	if (document.images) {
		pict = newImage(arg);
		preloadFlag = true;
	}
}

/***  Вывод окна по центру экрана с заданными размерами показываемой картинки с меню и скроллингом ***/
function wndd(name_pic, w_pic, h_pic){
var left_w ="";
var top_w ="";
scr_w=screen.width;
if (w_pic=="s") {w_pic=Math.round(scr_w/1.1);}
left_w = Math.round((screen.width - w_pic)/2);
top_w  = Math.round((screen.height - h_pic)/2);
cfg="left="+left_w+",top="+top_w+",width="+w_pic+",height="+h_pic+",location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1";
window.open(name_pic,'',config=cfg);
}

/***  Вывод окна по центру экрана с заданными размерами показываемой картинки без меню и скроллинга ***/

function wnds(name_pic, w_pic, h_pic){

var left_w ="";
var top_w ="";
left_w = Math.round((screen.width - w_pic)/2);
top_w  = Math.round((screen.height - h_pic)/2);
cfg="left="+left_w+",top="+top_w+",width="+w_pic+",height="+h_pic+",location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
msgWindow=window.open("", "", config=cfg);
msgWindow.document.writeln("<html><head>");
msgWindow.document.writeln("<title>«СЕВЗАПКАНАТ»</title>");
msgWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
msgWindow.document.writeln("<link rel='stylesheet' type='text/css' href='main.css'>");
msgWindow.document.writeln('</head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">');
msgWindow.document.writeln('<img border="0" src="'+name_pic+'" width="'+w_pic+'" height="'+h_pic+'">');
msgWindow.document.writeln("</body ></html>");

} 


/***  Вывод окна по центру экрана с автоматически определяемыми размерами показываемой картинки  ***/

function wnd(name_pic){

pict.src=name_pic;
var left_w ="";
var top_w ="";
left_w = Math.round((screen.width - pict.width)/2);
top_w  = Math.round((screen.height - pict.height)/2);
cfg="left="+left_w+",top="+top_w+",width="+pict.width+",height="+pict.height+",location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";

msgWindow=window.open("", "", config=cfg);
msgWindow.document.writeln("<html><head>");
msgWindow.document.writeln("<title>СЕВЗАПКАНАТ</title>");
msgWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
msgWindow.document.writeln("<link rel='stylesheet' type='text/css' href='main.css'>");
msgWindow.document.writeln('</head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">');
msgWindow.document.writeln('<img border="0" src="'+pict.src+'" width="'+pict.width+'" height="'+pict.height+'">');
msgWindow.document.writeln("</body ></html>");

} 


/***  Вывод окна по центру экрана с  с автоматически определяемыми размерами показываемой картинки; с заголовком и ссылкой, закрывающей окно ***/
function wndtxt(name_pic, txt){

pict.src=name_pic;
var left_w ="";
var top_w ="";
left_w = Math.round((screen.width - pict.width)/2);
top_w  = Math.round((screen.height - pict.height)/2);
top_close_h=pict.height - 30;
cfg="left="+left_w+",top="+top_w+",width="+pict.width+",height="+pict.height+",location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";

msgWindow=window.open("", "", config=cfg);
msgWindow.document.writeln("<html><head>");
msgWindow.document.writeln("<title>СЕВЗАПКАНАТ</title>");
msgWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
msgWindow.document.writeln("<link rel='stylesheet' type='text/css' href='main.css'>");
msgWindow.document.writeln('</head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">');
msgWindow.document.writeln('<div><div style="position:absolute;"><img border="0" src="'+pict.src+'" width="'+pict.width+'"></div>');
msgWindow.document.writeln('<div style="background-color:yellow; text-align:center; position:absolute; left:0px; top:0px; width:'+pict.width+'px;"><p style="font-weight: bold; text-align: center">'+txt+'</p></div>');
msgWindow.document.writeln('<div style="background-color:white; text-align:center; position:absolute; left:0px; top:'+top_close_h+'px; width:'+pict.width+'px;>');
msgWindow.document.writeln('<p style="text-align:center"><a style="display:block; text-decoration: none" href="#" onclick="window.close();">закрыть...</a></p></div>');
msgWindow.document.writeln('</div>');
msgWindow.document.writeln("</body ></html>");

} 



/*** Кнопка с бэкграундом, переключающим видимость объекта***/

function buttonz(name, pic_fore, pic_back, color_fore, color_back, pwidth, pheight, disp, path){

if (disp=='viz') {disp1=''; disp2='none';} else {disp2=''; disp1='none';};
document.writeln('<span width="'+pwidth+'"  height="'+pheight+'"  style="cursor:hand;"');
document.write('onclick="');
document.writeln("if ("+name+"_hid.style.display=='none') {"+name+"2.style.display='none'; "+name+"1.style.display=''; "+name+"_hid.style.display='';} else {"+name+"2.style.display=''; "+name+"1.style.display='none';"+name+"_hid.style.display='none';}"+'"');
document.writeln('onmouseover="'+name+'1.style.background='+"'"+color_fore+"'"+'; '+name+'2.style.background='+"'"+color_fore+"'"+';"');
document.writeln('onmouseout="'+name+'1.style.background='+"'"+color_back+"'"+'; '+name+'2.style.background='+"'"+color_back+"'"+';">');
document.write('<img id='+name+'1 style='+"'"+'display:'+disp1+'; background-color:'+color_back+"'"+' border="0" src="'+ path + pic_back+'" width="'+pwidth+'" height="'+pheight+'," alt="Свернуть...">');
document.write('<img id='+name+'2 style='+"'"+'display:'+disp2+'; background-color:'+color_back+"'"+' border="0" src="'+ path + pic_fore+'" width="'+pwidth+'" height="'+pheight+'" alt="Развернуть...">');
document.writeln('</span>');  
}  


function vis(name)  
{

eval('if (document.all.'+name+'.style.display == "none") {document.all.'+name+'.style.display = ""}  else  { document.all.'+name+'.style.display = "none" }') ;

}






