function open_l(name) {


 		//elem = eval("document.all."+name);
		if (document.getElementById(name)!=null)
		{
 		elem = document.getElementById(name);
		if (elem.style.display == "none" || !elem.style.display) {
			elem.style.display = "block";
		} else {
			elem.style.display = "none";
		}
		}
	}

	var winH;
	var winW;
	var winUrl;
	var winProp;
	var scrol;

function popUpOpen (winUrl, winW, winH)
{
//функция открывает заданный файл в заданных размерах окна
		scrol = 1;
		winProp = "toolbar=0,resizable=0,fullscreen=0,scrollbars="+scrol+",left=50,top=50,height="+winH+",width="+winW;
		window.open(winUrl,'',winProp);
}

function popUpOpenNS (winUrl, winW, winH)
{
//функция открывает заданный файл в заданных размерах окна без скроллинга
		scrol = 0;
		winProp = "toolbar=0,resizable=0,fullscreen=0,scrollbars="+scrol+",left=50,top=50,height="+winH+",width="+winW;
		window.open(winUrl,'',winProp);
}

function popUpOpenARS (winUrl)
{
//функция открывает заданный файл в окне с возможностью ресайза.
		winProp = "width=300,height=200,scrollbars=no,left=50,top=50, toolbar=no,location=no,status=no,resizable=yes,screenX=50,screenY=50";
		window.open(winUrl,'',winProp);
}

function ctdriver() {
}

function fillids(el, type, id) {
	new Ajax.Request('/getdata/dop/?type='+type+'&proid='+$F(el)+'&toid='+id, {
	  method: 'get',
	  onSuccess: function(transport) {
	    var data = transport.responseText.split('|');
	    if (data[0]) {
	    	var sel = $(data[0]);
	    	sel.options.length = 0;
	    	for (var i=1; i< data.length; i++) {
	    		var item = data[i].split('*');
	    		if (item[0]) {
	    			sel.options[sel.options.length] = new Option(item[1], item[0]);
	    		}
	    	}
	  	}
		}
		});
}
function fillidsj(el, type, id) {
	new Ajax.Request('/getdata/dop/?type='+type+'&proid='+$F(el)+'&toid=ul_'+id, {
	  method: 'get',
	  onSuccess: function(transport) {
	    var data = transport.responseText.split('|');
	    if (data[0]) {
	    	var sel = $(data[0]);
	    	sel.innerHTML = '';
	    	var t = '';
	    	for (var i=1; i< data.length; i++) {
	    		var item = data[i].split('*');
	    		if (item[0]) {
	    			t += '<li value="'+item[0]+'">'+item[1]+'</li>';
	    		}
	    	}
	    	sel.innerHTML = t;
	    	InitSelect(id);
	  	}
		}
		});
}

 function ShowHide(id){
   var elt = $(id);
   var ret = '';
   switch(elt.style.display) {
   case 'block':elt.hide();ret='none';break;
   case 'none':elt.show();ret='block';break;
   default:elt.hide();ret='none';
   }
   return ret;
 }

 function InitSelect(select_id) {
   var sel = $("select"+select_id);
   var cont = $("ff"+select_id);
   
   sel.hide();

 var tmp=cont.childElements();
  var but = 0;
   for (var i = 0; i < tmp.length; i++) {
   if (tmp[i].className == 'selbutton') {
     but = tmp[i];
   }
  }
 
 $(select_id+"textsel").onclick = but.onclick = function () {
   var r = ShowHide("select"+select_id);
   if (r == 'block') {
   		$$('div._for_hide_').each(Element.hide);
   		$$('div.selbuttonclose').each(function (e) {e.className='selbutton';});
   		ShowHide("select"+select_id);
   		but.className="selbuttonclose";
   }
   else but.className="selbutton";
 }

 var newli = document.createElement('li');
 newli.innerHTML = 'Отменить фильтр';
 newli.value = 0;
 $('ul_'+select_id).appendChild(newli);
 tmp = sel.getElementsByTagName('li');
 for (i = 0; i < tmp.length; i++) {
   tmp[i].className = 'sellitype';
   tmp[i].onmouseover = function() {
    this.className="sellitype_on";
   }
   tmp[i].onmouseout = function() {
    this.className="sellitype";
   }
   if (i != tmp.length-1) {
	   tmp[i].onclick = function () {
		$(select_id+"textsel").innerHTML = this.innerHTML;
	    $('chosen_'+select_id).value = this.value;
	    ShowHide("select"+select_id);
	    $(select_id+"showselect").className="selbutton";
	    var el = $('chosen_'+select_id);
	    if (el.onchange) el.onchange();
	   }
   } else {
   	    tmp[i].onclick = function () {
   	    	var t = $('ul_'+select_id).getElementsByTagName('li');
   	    	t[0].onclick();
   	    }
   }
   if (i == 0) tmp[i].style.display = 'none';	
 }

}

function initbody() {
	document.observe('click', function (event) {
		var element = event.element();
		if (!element.onclick) {
			$$('div._for_hide_').each(Element.hide);
			$$('div.selbuttonclose').each(function (e) {e.className='selbutton';});
		}
	});
}