//-------------------------------------------------------------------------------------------------------------------
var _winInfo;
function info_click( el ) //------ запуск в отдельном окне реквизитов документов или текстов документов ----------
{
 var _name = "../templates/srchinfo.php?id_doc="+el;

 if( _winInfo && !_winInfo.closed ) 
		_winInfo.location = _name; 
 else
		_winInfo = window.open( _name ,"Инфо",						  "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=0,top=0,width=600,height=500");
 
	_winInfo.focus();
}

function tooltip( id )
{
	
	document.getElementById("Frame2").contentWindow.location.href = "../templates/srchinfosmall.php?id_doc="+id;
	var _s = "doc"+id;
	
	var elem = document.getElementById( _s );
    var x = 0;
    var y = 0;
	var h = elem.offsetHeight;
	
		while(elem) {
            x += elem.offsetLeft;
            y += elem.offsetTop;
            elem = elem.offsetParent;
      }
		
 
	_s = "inf"+id;
	var obj = document.getElementById( _s );
	
	document.getElementById(_s).style.display = "block";
	//alert(y + h -15);
	
		
	obj.style.top = y + h + 3;
	
}

function not_tooltip( id )
{
	var _s = "inf"+id;
	document.getElementById(_s).style.display = "none";
}

function doLoad2()
{
	
	var cont = document.getElementById("Frame2").contentWindow.document.documentElement.innerHTML;
	var _s   = document.getElementById("Frame2").contentWindow.location.href;
	
	var _str = "id_doc=";
		if( _s.indexOf(_str) != -1 ){
			_s = _s.substring(_s.indexOf(_str)+_str.length, _s.length);
			_s = "inf" + _s;
		
			if( document.getElementById(_s) ){
						document.getElementById(_s).innerHTML = cont;
			}
		}
	
}

function srch_full()
{
//frm3.innerHTML = "";
  document.getElementById("search_full").style.display = "block";
//  document.styleSheets["typeicon"].href = "styles/icon.css"; //чтобы после работы с деревом показывались все документы
}

function doLoad3()
{
	
	var cont = document.getElementById("Frame3").contentWindow.document.documentElement.innerHTML;
	//document.getElementById("frm3").innerHTML = cont;
	var _s   = document.getElementById("Frame3").contentWindow.location.href;

	
	var _str  = "search_expanded.php";
	var _str1 = "srch_text.php";
		if( (_s.indexOf(_str) != -1) || (_s.indexOf(_str1) != -1) ){
					
			if( document.getElementById("frm3") ){
						document.getElementById("frm3").innerHTML = cont;
			}
		}
		
}

//-------------------------------------------------------------------------------------------------------------------
function doLoad()
{
	var cont = document.getElementById("Frame1").contentWindow.document.documentElement.innerHTML;
	
	//iframe.contentDocument.defaultView == iframe.contentWindow  -- очевидно для всех браузеров
	var cont = document.getElementById("Frame1").contentWindow.document.documentElement.innerHTML;
	var _s   = document.getElementById("Frame1").contentWindow.location.href;
	
	var _str = "_id=";
		if( _s.indexOf(_str) != -1 ){
			_s = _s.substring(_s.indexOf(_str)+_str.length, _s.length);
			_s = "st" + _s;
		
			if( document.getElementById(_s) ){
						document.getElementById(_s).innerHTML = cont;
			}
		}
}

 function sbornik(_id)
 {
	 var style_id;
	 
	 if( document.getElementById( "st" +_id ) ){
				style_id = document.getElementById( "st" +_id );
	 }
	 else if( document.getElementById( "f" +_id ) ){
		 		style_id = document.getElementById( "f" +_id );
	 }
	 
    //-----открываем ,закрываем ветки дерева--------------------------------------------------
         style_id.style.display = ("list-item" == style_id.style.display ? "none" : "list-item");
		 
				var id_img = "i" + _id;
					if( style_id.style.display == "none" ){
							document.getElementById( "i"+_id ).src = "../images/in.png";
					}
					else if( style_id.style.display == "list-item" ){
							document.getElementById( "i"+_id ).src = "../images/out.png";
					}
		
    //----------------------------------------------------------------------------------------

 }
 
 function icon_click(obj,srch) //--- выбор иконок ( действующих, отмененных или всех документов ) ----------
 {
	 
   	document.getElementById( 'icon' ).className    = "nullicon";
	document.getElementById( 'acticon' ).className = "nullicon";
	document.getElementById( 'noticon' ).className = "nullicon";
	
	if( document.location.href.indexOf( "srch.php" ) > 0 ){ //------- обычный поиск ------------
		document.location.href = "srch.php?num=1&search="+srch;
	    document.getElementById( 'menuleft' ).style.display = "none";
	}
	else if( document.location.href.indexOf( "search_type.php" ) > 0 ){
		document.location.href = "../templates/search_type.php?idtype="+ srch + "&num=1";	
		document.getElementById( 'menuleft' ).style.display = "none";
	}
	else{ //------------- выбор иконок для дерева ------------------
		switch( obj ){
			case 1:	document.styleSheets["typeicon"].href = "../styles/acticon.css";
			        document.getElementById( 'acticon' ).className  = "acticon";
				break;
			case 2:	document.styleSheets["typeicon"].href = "../styles/noticon.css";
					document.getElementById( 'noticon' ).className  = "noticon";
				break;
			case 3:	document.styleSheets["typeicon"].href = "../styles/icon.css";
					document.getElementById( 'icon' ).className     = "icon";
				break;
			default:break;
		}
	}
	
 }
 
 function srch_type( _id )
 {
	if( document.getElementById( _id ).value != "none")//-- проверка для Mozilla
	{
		document.location.href = "../templates/search_type.php?idtype="+ document.getElementById( _id ).value + "&num=1";
		document.getElementById( 'menuleft' ).style.display = "none";
	}
		 
 }
 
 function help()
 {
   window.open("../help.php","","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,left=0,top=0,width=600,height=500");
 
 }
