var d=document;
var nav=navigator.appName;    
var loading_img='<img src=/img/ajax.gif width=16 height=16 align=top>';
var loading_div='loading';


function url_window(url,w,h)
{
	window.open(url,'Text','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=no,width='+w+',height='+h+',left=32,top=16'); 
}
function frm_act(frm,act)
{
	document.forms[frm].action=act;
	
}
function SetNumber(value,min)
{
	value=parseInt(value);	
	if(isNaN(value))
		return min;
	else if(value<1)
		return min;
	else
		return	value;				
}
function loading_d(flag,div)
{
	if(flag==1)	
		elementInner(div,loading_img);
	else	
		elementInner(div,'');
}
//Установка блока в центр страницы
function block_center(div,height,width)
{
	
	ge(div).style.height=height+"px";                	                    	                	
	ge(div).style.width=width+"px";                	                    	                	
	if((nav!="Netscape")&&(nav!="Opera")) 
	{	   					
		ge(div).style.left = parseInt(d.body.clientWidth/2-width/2+d.body.scrollLeft)+"px"; 
		ge(div).style.top = parseInt(d.body.clientHeight/2-height/2+d.body.scrollTop)+"px";     	   				
	}
	else
	{	   						
		ge(div).style.left =parseInt(window.innerWidth/2-width/2)+"px";	   						
		ge(div).style.top = parseInt(window.innerHeight/2 - height/2 + window.pageYOffset)+"px";                		
	}		   				
}
function block_invert2(id,id2)
{
	if(d.getElementById(id))
	{
		
		if(d.getElementById(id).style.display=='block')
		{
			d.getElementById(id).style.display='none';			
			d.images[id2].src='img/tree/plus.gif';
		}	
		else	
		{
			d.getElementById(id).style.display='block';			
			d.images[id2].src='img/tree/minus.gif';			
		}	
	}	
}

function make_checkbox_all(partname,flag,dis)
{
	//	dis=1 - не отмечать поля  DISABLED
    el = document.getElementsByTagName('input');
    for(i=0;i<el.length;i++){
       if(el[i].id.indexOf(partname) > -1)
       {
       		if(dis==1)
       		{
       			if(el[i].disabled==false)
       			{
            		el[i].checked = flag;   
       			}	
       		}	
       		else	
            	el[i].checked = flag;   
       }    	
    }
}

function count_checked(partname)
{
	var found=0;
	el = document.getElementsByTagName('input');
   for(i=0;i<el.length;i++){
      if(el[i].id.indexOf(partname) > -1){
     	   if(el[i].checked == true){
           	found=1;
           	break;
     	   }	
      }   
   }
   return found;
}


function ge(p1){
	return d.getElementById(p1);
}
function block_none(id)
{
	if(d.getElementById(id))
		d.getElementById(id).style.display='none';   					
}
function block_yes(id)
{
	if(d.getElementById(id))
		d.getElementById(id).style.display='block';        								
		    					
}
function block_close(id)
{
	if(ge(id))
	{
		ge(id).style.display='none';
		
	}	
}
function block_show(id)
{
	if(ge(id))
	{
		ge(id).style.display='block';
		
	}	
}
function block_invert(id)
{
	if(ge(id))
	{
		if(ge(id).style.display=='block')
			ge(id).style.display='none';
		else	
			ge(id).style.display='block';
	}	
}
function elementInner(div,text)
{
	if(ge(div))
	{
		ge(div).innerHTML=text;
	}
}