function go_url(menu) {
	choice = menu.selectedIndex;

	if (menu.options[choice].value != "") {
        window.location.href = menu.options[choice].value;
    }
}


function open_window(url) {
	sx = 800;
	sy = 600;

	var winl = (screen.width-sx)/2;
   var wint = (screen.height-sy)/2;

	window.open(url,'Links','scrollbars=1, resizable=0 , width='+sx+', height='+sy+' , top='+wint+',left='+winl).focus();
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

var ie=(document.all && document.all.item && !window.opera)?1:0;
var def_normal_class = 'nav2';
var def_hightlight_class = 'nav2_';

/* @todo заставить работать в Mozille */
function Show(div, evnt, elem1, class_highlight,type) {
	class_normal = def_normal_class;
	if(!class_highlight) class_highlight = def_hightlight_class;

	if (evnt) highlight(evnt, class_highlight);

	if ((obj=MM_findObj(div))!=null) {
		if(ie){
			if(type  == 0)  { x = 154; y = 12; }
			else			{ x = 0; y = 0; }

			//x = 226;y=13;
			
			//alert(x);

			obj.style.left = event.clientX - event.offsetX - x;// 
			obj.style.top = event.clientY - event.offsetY + document.body.scrollTop+ y;// 
		} else {
			if (event.srcElement.tagName=='TD') {
				obj.style.left = event.clientX - event.offsetX - 5;
				obj.style.top = event.clientY - event.offsetY + document.body.scrollTop + 23;
			}
		}
		ShowHide('show', obj, elem1, class_normal, class_highlight);
	}
}

function Hide(div, evnt, elem1, class_normal) {
	if(!class_normal) class_normal = def_normal_class;
	class_highlight = def_hightlight_class;

	if(evnt) highlight(evnt, class_normal);
	
	if ((obj=MM_findObj(div))!=null)
		ShowHide('hide', obj, elem1, class_normal, class_highlight);
}

function ShowHide(v, obj, elem1, class_normal, class_highlight) {
	if(!class_normal) class_normal = def_normal_class;
	if(!class_highlight) class_highlight = def_hightlight_class;
	//if (event.fromElement.tagName!='DIV') return;
	obj1 = MM_findObj(elem1);
	//obj2 = MM_findObj(elem2);
	if (obj1)
	if (obj1) {
		if (v=='hide') obj1.className=class_normal;
		else obj1.className=class_highlight;
	}
	if (obj.style) {
		obj=obj.style;
		v=(v=='show')?'block':(v=='hide')?'none':v;
	}
	obj.display=v;
}

function highlight(obj, class_name){
	obj.className = class_name;
}

var reqid;

function showResponse ( req )
{
	$('ta_'+reqid).value = req.responseText;
}

function showResponse2 ( req )
{
	var td = $('i_'+reqid);
	new Effect.toggle('d_'+reqid, 'blind' );
	wait(2);
	td.innerHTML="";
	//td.style.display='none';
}
function subb(id)
{

	var ta = $('ta_'+id);
	reqid=id;
	var myAjax = new Ajax.Request('/_usrcall/tdrive/'+id+'.html?mod_cmd=textarea', {method: 'post', parameters: 'Value='+ta.value, onComplete: showResponse2});	

	
}

function doPop(id)
{
	var td = $('i_'+id);
	if ( !td ) { alert('DOM Error'); return; }
	
	if (!td.innerHTML)
	{
		td.innerHTML = '<div style="display:none;" class="roll" id="d_'+id+'"><textarea id="ta_'+id+'" class="roolt">Blah</textarea><input class="butt cursor" value="сохранить" type="button" onClick="subb('+id+');" /><br /><br />Список значений разделяется переводами строк.</div>';
		//td.style.display='table-cell';
		reqid=id;
		var myAjax = new Ajax.Request('/_usrcall/tdrive/'+id+'.html?mod_cmd=textarea', {method: 'post', parameters: '', onComplete: showResponse});
		
	}
 	
 	new Effect.toggle('d_'+id, 'blind' );

 	
}