//Открытие pop-окон
function win_focus () {
	if (typeof(w_name.document)=="object") {
		if (!w_name.closed) {
			w_name.focus(); 
			return false;
		}
	}
}
function win_open (file, name, win_width, win_height, strig_param, win_type, evnt, offsetx, offsety) {
   if (typeof(evnt) == 'object') {
      xx = evnt.screenX - win_width / 2;
      if (typeof(offsetx) == 'number') xx = xx + offsetx;
      yy = evnt.screenY - win_height + 25;
      if (typeof(offsety) == 'number') yy = yy + offsety;
   }
   else {
      xx = (screen.width - win_width -10) / 2;
      yy = (screen.height - win_height - 32) / 2;
   }
   if ( xx+ win_width  > screen.width) xx = screen.width-win_width-10;
   if ( xx < 0 ) xx = 3; 
   if ( yy + win_height +55 > screen.height) yy = screen.height-win_height-55;
   if ( yy < 0 ) yy = 3;     
   w_name =  window.open(file, name, strig_param+',width='+win_width+',height='+win_height+',left='+xx+',top='+yy);
      if (win_type)  window.onfocus=win_focus;
   return w_name;
}
//Управление меню (по наезду и клику)
function MenuChMode(MenuName,OverOutMode,idNum) {
	if (idNum!=MenuActiveNum)  {
		if (OverOutMode=='Ovr') {document.all[MenuName+idNum].className=MenuName+'Ovr';} else 
								{document.all[MenuName+idNum].className=MenuName+'Out';}
								}}
								
function mMenuClick(MenuName,idNum) {
	if (idNum!=MenuActiveNum)  {i=1;
		while (typeof(document.all[MenuName+i])=='object')  {document.all[MenuName+i].className=MenuName+'Out';i++; }
		document.all[MenuName+idNum].className=MenuName+'Act';
		MenuActiveNum=idNum;
								}}
								
								
//Вывод и управление sub меню (по наезду и клику)								
function writeMenu() { 
  var args=writeMenu.arguments;
  //alert(args[args.length-1]);
  for(i=0;i<(args.length-1);i=i+2) 
  if ((i-args[args.length-1])+2==args[args.length-1]) 	{document.write("<INPUT class=sfsMenuAct type=button value="+args[i]+" >")} 
							else	{document.write("<INPUT class=sfsMenuOut type=button onMouseOver=(this.className='sfsMenuOvr') onMouseOut=(this.className='sfsMenuOut') onClick=(document.location='"+args[i+1]+"') value="+args[i]+" >")}
}	
//Вызовы pop-up окон в Project List

function Requirements(url) {win_open(url, 'req',800, 600,'resizable=yes,scrollbars=no,toolbar=no,status=no',true); w_name.focus()}
function Discussion(url) {win_open(url, 'rep',800, 600,'resizable=no,scrollbars=no,toolbar=no,status=no'); w_name.focus()}
function Assign(url) { win_open(url, 'apr', 850, 378,'resizable=no,scrollbars=no,toolbar=no,status=no'); w_name.focus();}

//Вывод и управление sub кнопки (по наезду и клику)		

function writeBtn() { 
  var args=writeBtn.arguments;
  for(i=0;i<(args.length);i=i+2) document.write("<INPUT class=ipt_b type=image src=../_img/b_"+args[i].toLowerCase()+".gif  alt="+args[i]+" onclick="+args[i]+"('"+args[i+1]+"') onMouseOver=src='../_img/b_"+args[i].toLowerCase()+"_ovr.gif' onMouseOut=src='../_img/b_"+args[i].toLowerCase()+".gif' vspace=3 hspace=2>")
}
			//OLD VERSION
			//function writeBtn() { 
			//  var args=writeBtn.arguments;
			//  for(i=0;i<(args.length);i=i+2) document.write("<INPUT class=ipt_b type=image src=../_img/b_"+args[i]+".gif  alt="+args[i]+" onclick="+args[i]+"('"+args[i+1]+"') onMouseOver=src='../_img/b_"+args[i]+"_ovr.gif' onMouseOut=src='../_img/b_"+args[i]+".gif' vspace=3 hspace=2>")
			//}							


//Смена ресурса картинки по наезду и съезду
function ChgImg(ImNm, ImgSrc){document.images[ImNm].src = "../_img/" + ImgSrc;}
	
function ChgImgAN(nm,st) {
	document.images[nm].src=document.images[nm].src.slice(0,document.images[nm].src.length-5)+st+'.gif';
}

//Смена ресурса кнопки по наезду и съезду
function ChgBtn(BtnID, ImgSrc){document.all[BtnID].src =  ImgSrc}

function ChgBtnAN(BtnID,st) {
	document.all[BtnID].src=document.all[BtnID].src.slice(0,document.all[BtnID].src.length-5)+st+'.gif';
}

//Управление кнопкой и строкой "фильтра"
function CicleCngBtnCrs(BtnID,TrID) { // передаем ID кнопки и строки
if ((document.all[BtnID].BtnState==null)||(document.all[BtnID].BtnState==1)) {
		document.all[BtnID].BtnState=2;
		document.all[TrID].style.display='';
		document.all[BtnID].alt = 'Hide' + document.all[BtnID].alt.slice(4,document.all[BtnID].alt.length)//меняем статус кнопки,Alt кнопки и состояние строки
		} else {
		document.all[BtnID].BtnState=1;
		document.all[TrID].style.display='none';
		document.all[BtnID].alt = 'Show' + document.all[BtnID].alt.slice(4,document.all[BtnID].alt.length)}; 
	//меняем картинку кнопки в соотв с новым статусом (Примеры имен для файлов картинки: b_filter_1_a.gif - 1й статус b_filter_2_a.gif - 2й статус)
	NewBtnSrc=document.all[BtnID].src.slice(0,document.all[BtnID].src.length-7)+document.all[BtnID].BtnState+'_a.gif'; 
	ChgBtn(BtnID,NewBtnSrc)	
}

function ChgBut(BtnID, BtnAlt1, BtnAlt2) { // передаем ID кнопки и альты
if ((document.all[BtnID].BtnState==null)||(document.all[BtnID].BtnState==1)) {
		document.all[BtnID].BtnState=2;
		document.all[BtnID].alt = BtnAlt1;
		} else {
		document.all[BtnID].BtnState=1;
		document.all[BtnID].alt = BtnAlt2; 
		}
	//меняем картинку кнопки в соотв с новым статусом (Примеры имен для файлов картинки: b_filter_1_a.gif - 1й статус b_filter_2_a.gif - 2й статус)
	NewBtnSrc=document.all[BtnID].src.slice(0,document.all[BtnID].src.length-7)+document.all[BtnID].BtnState+'_a.gif'; 
	ChgBtn(BtnID,NewBtnSrc)
}


//Смена ресурса флажка и знака плюс-минус
function Trigger (Name, id_num) {
	imag=document.images[Name+id_num].src;
	if (imag.slice(imag.length-7,imag.length-4)=='st1') {ChgImg((Name+id_num),'i_'+Name+'_st2.gif');} else {ChgImg((Name+id_num),'i_'+Name+'_st1.gif');}
} 
//Показать/убрать строку
function ShowHideStr() {
  var args=ShowHideStr.arguments;
	if(document.all['row'+args[0]].style.display=='none') {stat=''} else {stat='none'}  
    for (i=0; i<(args.length); i++) {document.all['row'+args[i]].style.display=stat} 

}	
//Чекнуть или un чекнуть все check-boxes
function ch_unch(chk) {
if (chk!=null) {state=chk};
for (i=0; i<document.f1.length; i++) if (document.f1.elements[i].type=='checkbox') document.f1.elements[i].checked=state;
if (state=='y') {
		state='';
		sel_im_n='unselect_all_n.gif';
		sel_im_a='unselect_all_a.gif';
		ChgImg('lab1','unselect_all_a.gif')
			
		} else {
		state='y';
		sel_im_n='select_all_n.gif';
		sel_im_a='select_all_a.gif';
		ChgImg('lab1','select_all_a.gif')
		}
}









var isNav,isIE4;
if (navigator.appName == "Netscape")  isNav = true;
if (navigator.appName == "Microsoft Internet Explorer" ) {
	vers = navigator.appVersion.split(' ');
	if (vers[3].charAt(0) == '4') isIE4 = true;
}

if (isNav) onresize=reloadPage;

function reloadPage() {
	location.reload();
}

function init() {
	if (!isNav && !isIE4) {
		for (i=1;i<6;i++) {
			document.all['mainMenu' + i].className = 'book';
			document.all['mainTab' + i].className = 'bookIE';
		}
	}
}


function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}




var img='';
var ttl='';
var i=0;

function time_out()
{
  h=img.height;
  w=img.width;
  s=img.src;
  wnn=""+i;
	wnd=window.open("",wnn,"width="+ w+",height="+h+",left=100,top=100,status=0,toolbal=0,menubar=0,location=0,resizable=0,scrollbar=0");
	wnd.document.open();
	wnd.document.write("<html><head><title>"+ttl+"</title></head><body marginheight=0 marginwidth=0 leftmargin=0 topmargin=0><img  src='"+s+"' border=0></body></html>"); 
	wnd.document.close();
  clearTimeout();
}

function open_wnd(href,srcimg)
{	i++;
	img= new Image();
	img.src=srcimg;
	ttl=href; 
	setTimeout("time_out()",100);
}

function win_open2 (file, name, win_width, win_height, strig_param, win_type, evnt, offsetx, offsety) {
   if (typeof(evnt) == 'object') {
      xx = evnt.screenX - win_width / 2;
      if (typeof(offsetx) == 'number') xx = xx + offsetx;
      yy = evnt.screenY - win_height + 25;
      if (typeof(offsety) == 'number') yy = yy + offsety;
   }
   else {
      xx = (screen.width - win_width -10) / 2;
      yy = (screen.height - win_height - 32) / 2;
   }
   if ( xx+ win_width  > screen.width) xx = screen.width-win_width-10;
   if ( xx < 0 ) xx = 3; 
   if ( yy + win_height +55 > screen.height) yy = screen.height-win_height-55;
   if ( yy < 0 ) yy = 3;     
   w_name =  window.open(file, name, strig_param+',width='+win_width+',height='+win_height+',left='+xx+',top='+yy);
   return w_name;
}

function ShowDate() {
	var mydate=new Date()
	var year = mydate.getYear();
	if (document.layers) {if (year >= 100) year = year + 1900};
	year = String (year).substr(2,2);
	var month=mydate.getMonth()+1; if (month<=9) month = '0'+month;
	var daym=mydate.getDate(); if (daym<=9) daym = '0'+daym;
	var hours=mydate.getHours(); if (hours<=9) hours = '0'+hours;
	var mins=mydate.getMinutes(); if (mins<=9) mins = '0'+mins;
	document.write(daym+'.'+month+'.'+year+' '+hours+':'+mins);
}

function pop(a,b,d) {
popWindow=window.open(a,d,"scrollbars=yes,toolbar=yes,resizable=yes,menubar=no,status=no," + b);
}
