
 /**
 * refresh flash select in editing tml
 **/
 
 function ref_select(cat_id, parent, current, init){
 	
 	$.get('/ajax/ajax_flash.x',{
	 	act:"get_cat_list",
		parent:cat_id
		}, function(data){
			//bof 1
			$("#cat_id").empty();
			$("item", data).each(
				function(){
					if(current==this.getAttribute('id') && init==1){
						$("#cat_id").append("<option value="+this.getAttribute('id')+" selected>"+this.getAttribute('name')+"</option>");
					}else{
						$("#cat_id").append("<option value="+this.getAttribute('id')+">"+this.getAttribute('name')+"</option>");
					}
				}
			);
			//eof 1
			}
	);
		
 }
 
 function re_count_flash(){
	$.get('/ajax/ajax_flash.x',{
	 	act:"re_count_flash"
		}, function(data){
				$("#re_count_box").html(data);
			}
		);
 }
 
 function put_preloader(in_what){
	$("#"+in_what).html("<img src='tml/img/preload.gif' width='43' height='11'>");	
 }
 
 function flash_menu_cache_del(){
	$.get('/ajax/ajax_flash.x',{
	 	act:"flash_menu_cache_del"
		}, function(data){
				$("#flash_menu_cache_del_box").html(data);
			}
		);
 }
 
 function load_variants_of_swf(url){
	$.get('/ajax/ajax_flash.x',{
	 	act:"load_variants_of_swf",
	 	url:url
		}, function(data){
				$("#load_variants_box").html("");
				//bof 1
				$("#variant_select").empty();
				$("item", data).each(
					function(){
							$("#variant_select").append("<option>"+this.getAttribute('url')+"</option>");	
					}
				);
				//eof 1
			}
		);
 }
 
 function show_add_tag_box(id){
 	$.get('/ajax/ajax_tags.x',{
	 	act:"get_tags_of_item_in_del",
	 	id:id
		}, function(data){
			//bof 1
if($("#tag_box_"+id).html().length>1){
		$("#tag_box_"+id).empty();
	}else{
	var to_append = "<div style='position: absolute; left: 45%; background-color: white; border: 1px solid black; padding: 2px;'>Добавить тег:<table style='width: 100%'><tr><td align='center'><input type='text' id='add_tag_name_"+id+"' size='30'> <input type='button' value='+' onclick='add_flash_tag("+id+");'></td></tr>";
	//делаем список тегов к этой флешке c возможностью удалить
	to_append += data;
	//
	to_append += "</table></div>";
	$("#tag_box_"+id).append(to_append);
	$("#add_tag_name_"+id).focus();	
	}
			//eof 1
			}
	);
 	
 }
 
 function add_flash_tag(id){
	$.get('/ajax/ajax_tags.x',{
	 	act:"add_tag_to_item",
	 	id:id,
		name:$("#add_tag_name_"+id).attr("value")
		}, function(data){
			//bof 1
			get_tags_of_item(id);
			$("#tag_box_"+id).empty();
			show_add_tag_box(id);
			//eof 1
			}
	);	
 }  
 
 function get_tags_of_item(id){
	$.get('/ajax/ajax_tags.x',{
	 	act:"get_tags_of_item",
	 	id:id
		}, function(data){
			//bof 1
			$("#i_tag_place_"+id).html(data);
			//eof 1
			}
	);
 }
 
 function delete_tag_from_flash(t_id,f_id){
	$.get('/ajax/ajax_tags.x',{
	 	act:"delete_tag_from_flash",
	 	t_id:t_id,
	 	f_id:f_id
		}, function(data){
			//bof 1
			$("#tag_box_"+f_id).empty();
			show_add_tag_box(f_id);
			get_tags_of_item(f_id);
			//eof 1
			}
	);	
 }