	function makeAjaxRequest(url, func, params, no_rnd){
		params['__url'] = url;
		params['__func'] = func;
		
		var callback = new ajax_callback(func, params);//new Callbacks();
		if(!no_rnd){
			var rnd = Math.random();
			url = url + '&rnd='+rnd;
		}
		//makeRequest(url, callback);

		var request = YAHOO.util.Connect.asyncRequest('GET', url, callback);
	}

	function ajax_callback(onSuccess, arguments){
		this.success = function(o){
				if(o.responseText !== undefined){
					onSuccess(o);
				}
			},
		
		this.failure = function(o){
				onSuccess(o);
			},
		this.argument = arguments || {};
	}
/*
	function $(id){
		return document.getElementById(id);	
	}
	function clone(o){
		var ret = new Object();
		for(prop in o){
			ret[prop] = o[prop];
		}
		return ret;
	}
	
	function show(id, visible){
		var o = $(id);
		if(o){
			o.style.display = (visible == undefined || visible == true)?(''):('none');
		}
	}

	function escape_quotes(str){
		//var reg1 = /[']/;
		//var reg2 = /["]/;
		str = String(str);
//		str = str.replace(/["]/, '\\"');
		str = str.replace(/[']/, "\\\\'");
		return str;
	}
*/
/*	function obj_to_str(o){
//print_r(o);		
		var props = Array();
		for(prop in o){
			props[props.length] = '' + prop + ": '" + o[prop] + "'";
		}
		alert('{' + props.join(',') + '}');
		return '{' + props.join(',') + '}';
	}
*/		/*
	function print_r(o){
		var text = '';
		for(prop in o){
			text += prop+" = ("+ typeof(o[prop]) +") "+o[prop]+"\n";
		}
		alert(text);
	}

	function Imageholder(){
		this.id = 0;
		this.exten = 'jpg';
		
		this.input_id = 0;//'ann_photo_val';
		this.img_id = 0;//'ann_photo';
		this.img_name_id = '';//'ann_photo';
//		this.sel_button_id = '';
		this.del_button_input_id = 0;//'delete_photo_button';
		this.old_button_id = 0;//'assign_old_button';
		
		this.old_img_id = 0;
		this.old_img_exten = 'jpg';
		this.img_width = 100;
		
		this.path_data_photo = '/data/photo/';
			
		

		this.assign_image = function(id, exten){
			this.id = id;
			if(exten != undefined){
				this.exten = exten;
			}
			
			var o_img = $(this.img_id);
			var o_img_input = $(this.input_id);
			var o_img_del_button = $(this.del_button_input_id);
			if(this.old_button_id){
				var o_assign_old_button = $(this.old_button_id);
				if(this.old_img_id != this.id){
					o_assign_old_button.style.display = '';
				}
			}
			
			if(this.id){
				o_img_del_button.style.display = '';
			} else {
				o_img_del_button.style.display = 'none';
			}
	
			o_img.src = this.path_data_photo + (this.exten == 'swf' ? 'flash' : this.id) + '_' + this.img_width + '.jpg?' + Math.random();// + this.exten;
			o_img.width = this.img_width;
			o_img_input.value = this.id;
		}

		this.assign_image2 = function(photo){
//print_r(photo);
			if(photo){
				this.assign_image(photo.id, photo.exten);
				
				var o_img_name_id = $(this.img_name_id);
				o_img_name_id.innerHTML = photo.name;
			}
			
		}
		
		this.ajax_get_image = function(id){
			if(id){
				makeAjaxRequest('?ajax=fotobank&ajax_act=get_photo&id=' + id, 
								function(o){o.argument['imgh'].assign_image2(eval('(' + o.responseText + ')'));}, 
								{"imgh":this});
			}
		}

		this.assign_old_image = function(){
			if(this.old_button_id){
				var o_assign_old_button = $(this.old_button_id);
				o_assign_old_button.style.display = 'none';
				this.assign_image(this.old_img_id, this.old_img_exten);
			}
		}
		
		
	}

	function ajax_get_image(id, callback){
		makeAjaxRequest('?ajax=fotobank&ajax_act=get_photo&id=' + id, 
						function(o){o.argument.callback(eval('(' + o.responseText + ')'))}, 
						{"callback":callback});
	}




function update_head_module_select( module )
{
	top.topframe.document.forms['navi'].direct.value = module;

}

function submit_tree( action )
{
	top.leftframe.document.forms['tree'].action.value = action;
	top.leftframe.document.forms['tree'].submit();
}
function set_prev( id, act )
{

	oldprev = top.leftframe.document.forms[0].previous.value;
	
	if ( oldprev !='' )
	{

	 top.leftframe.document.all('folder' + oldprev).style.color = "#000" ;

	}

	 top.leftframe.document.all('folder'+id).style.color = "#FFACAC" ;
	//  document.all(newId).style.color = "#000" ;

	top.leftframe.document.forms[0].previous.value = id;
	top.leftframe.document.forms[0].cut_copy.value = act;

	top.menuframe.document.getElementById('link_paste').innerHTML = "<a href=\"javascript:submit_tree( 'paste' );\"><img src=\"images/admin/c_icons/paste.gif\">????????</a>";
	
	top.leftframe.document.getElementById('link_paste').innerHTML = "<a href=\"javascript:submit_tree( 'paste' );\"><img src=\"images/admin/c_icons/paste.gif\"> ????????</a>";
	top.leftframe.document.getElementById('root_link_paste').innerHTML = "<a href=\"javascript:submit_tree( 'paste' );\"><img src=\"images/admin/c_icons/paste.gif\"> ????????</a>";

}
function show_root_div( button )
{
	id = 0;
	if( button != 1 )
	{

		if( document.getElementById('root_menu').style.display == "none" )
		{
				mainid = 'folder' + id;
				 newId = mainid + "data";
				
				 oldmainid = document.forms[0].current.value;
				 oldprev = document.forms[0].previous.value;
				
    			 oldmain = oldmainid.replace('folder', '');

					if ( oldmainid !='' &&  oldmain != oldprev)
					{
					 document.all(oldmainid).style.color = "#000" ;
					}
					  document.all(mainid).style.color = "red" ;
					  document.all(newId).style.color = "#000" ;
					  document.forms[0].current.value = 'folder0';

			document.getElementById('context_menu').style.display = "none";
			document.getElementById('root_menu').style.display = "block";
			document.getElementById('root_menu').style.top = event.clientY + document.body.scrollTop;
			document.getElementById('root_menu').style.left = event.clientX + document.body.scrollLeft;




		}else{
			document.getElementById('root_menu').style.display = "none";
		}
		
		last_menu = 0;
	}

}


function show_div( id, button )
{

	if( button != 1 )
	{

		if( document.getElementById('context_menu').style.display == "none" || last_menu != id )
		{
				mainid = 'folder' + id;
				 newId = mainid + "data";
				
				 oldmainid = document.forms[0].current.value;
				 oldprev = document.forms[0].previous.value;
				
    			 oldmain = oldmainid.replace('folder', '');

					if ( oldmainid !='' &&  oldmain != oldprev)
					{
					 document.all(oldmainid).style.color = "#000" ;
					}
					  document.all(mainid).style.color = "red" ;
					  document.all(newId).style.color = "#000" ;
					  document.forms[0].current.value = mainid;

			document.getElementById('root_menu').style.display = "none";
			document.getElementById('context_menu').style.display = "block";
			document.getElementById('context_menu').style.top = event.clientY + document.body.scrollTop;
			document.getElementById('context_menu').style.left = event.clientX + document.body.scrollLeft;
			//scroll( event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop - 200 );

			current_inner = document.getElementById('all_links').innerHTML;

			re = /\[ID\]/g;			
			new_inner=current_inner.replace(re, id);
		
		if( last_menu > 100 )
			{
				eval ('re = /' + last_menu + '/g;');		
				new_inner2=new_inner.replace(re, id);
			}else{
				new_inner2=new_inner;

			}
				
			document.getElementById('all_links').innerHTML = new_inner2;

document.getElementById('link1').href = '?direct=structure&action=new&current=' + id;
			document.getElementById('link2').href = '?direct=structure&action=edit&current=' + id;
			document.getElementById('link3').href = '?direct=structure&action=delete_confirm&current=' + id;
			document.getElementById('link4').href = '?direct=structure&action=clear_confirm&current=' + id;
			document.getElementById('link5').href = '?direct=structure&action=show_link_issue&current=' + id;*/

			//timerID = setTimeout( 'show_div( '+id+', '+button+' )' , 10000);
/*
		}else{
			document.getElementById('context_menu').style.display = "none";
		}
		
		last_menu = id;
	}

}

function openIt( module, reloads )
{
	if( document.getElementById('context_menu') )
		document.getElementById('context_menu').style.display = "none";

	currEl = event.srcElement;
	if (currEl.className == "folder" || currEl.className == "foldericon" || currEl.className == "span_text") 
	{
		
		mainid = currEl.id;

		if( currEl.className == "foldericon" )
		{
			numb = currEl.id.length - 5;
			mainid = currEl.id.substr(0,numb); 
		}
		if( currEl.className == "span_text" )
		{
			numb = currEl.id.length - 4;
			mainid = currEl.id.substr(0,numb); 
		}		

		newId = mainid + "data";
		imgId = mainid + "picon";
		foldId = mainid + "ficon";
		oldmainid = document.forms[0].current.value;

		if( document.forms[0].previous )
		{
			 oldprev = document.forms[0].previous.value;
		}else{
			 oldprev = 0;
		}

		if( reloads && currEl.className != "foldericon" )
			top.mainframe.document.location='?direct=' + module + '&current=' + mainid +'&no_reload_tree=1&oldprev=' + oldprev;
			 
		oldmain = oldmainid.replace('folder', '');

		if ( oldmainid !='' &&  oldmain != oldprev)
		{
			document.all(oldmainid).style.color = "#000" ;
		}

		document.all(mainid).style.color = "red";
		document.all(newId).style.color = "#000";
		document.forms[0].current.value = mainid;
		showIt = document.all(newId) ;

		if (showIt.style.display == "none")
		{
			showIt.style.display = "";
			document.images(imgId).src = "images/admin/minus.gif";
			document.images(foldId).src = "images/admin/"+module+"/fopen.gif";

		} else {
			showIt.style.display = "none" ;
			document.images(imgId).src = "images/admin/plus.gif";
			document.images(foldId).src = "images/admin/"+module+"/fclose.gif";

		}
	}
}



function openwin(url, name , width, height, scrollbars){
	if( width == 0 )
		width = screen.width /2;//- 50;
    if( height == 0 )
		height = screen.height/2;// - 50;

    var Win = window.open(url, name, 'width=' + width + ',height=' + height + ',resizable=1,scrollbars=' + scrollbars +',menubar=0,status=yes' );
	return Win;
 }

function change_img_parent (value, fieldname, imgname, extens)
	{
	
		if (window.opener) {
			
			if( !in_array( window.opener.linked_fotos, value) || !multiple)
			{
				var this_id = window.opener.added_foto;			

				re = /\[ID\]/g;			
				new_fieldname = fieldname.replace(re, this_id);
				new_imgname = imgname.replace(re, this_id);
				
				if( multiple )
				{
					window.opener.linked_fotos.push( value );
					add_foto_field();	
				}
				
				eval( 'window.opener.document.' + new_fieldname + '.value='+value);				
				eval( 'window.opener.document.' + new_imgname + '.className = "imgborder"');				
				eval( 'window.opener.document.' + new_imgname + '.width = 100');				
				eval( 'window.opener.document.' + new_imgname + '.src = "/data/photo/'+value+'_100.'+extens+'"');
				if( window.opener.document.getElementById('delete_photo_button') )
					window.opener.document.getElementById('delete_photo_button').style.display='';
			
				
				if( !multiple )
				{
					if ( window.opener.document.forms[0].imgback )
					{
						window.opener.document.forms[0].imgback.disabled=false;
					}
					window.close();					
				}


			}else{
				alert( 'Это изображение уже выбрано' );
			}

		}
	}

*/

/*
function select_branch ( point , value )
{

	for ( var i=0; i < tree_arr.length; i++)
	{
		if( tree_arr[i][1] == point )
		{
			eval('document.getElementById("tree' + tree_arr[i][0] + '").checked=' + value);
			select_branch(tree_arr[i][0], value);

		}
	
	}

}
function change_checks ( point )
{

	if( eval('document.getElementById("tree' + point + '").checked') )
	{

		select_branch ( point , 1 )

	}else{
		select_branch ( point , 0 )

	}

}

function in_array( arr, val )
{
	if( arr )
	{
		for ( var i=0; i < arr.length; i++)
		{
			if( arr[i] == val )
					return true;
		
		}
	}
	return false;
}
*/