  var isLoading=false;
  
  function get_add_panel()
  {
  	if(jQuery('#add_block').css('display') == 'none')
  	{
		jQuery.ajax({   
			type: "POST",
			url: "/blog/ajax/work.php", 
			data:"mode=get_add_panel",
			cache: false,   
			success: function(html){   
				
				jQuery('#add_block').html(html);
				jQuery('#add_block').show('slaw');
				jQuery('#add_link_b').html('Закрыть');
				
			}
		});
  	}else
  	{
  		//удаление загруженных файлов текущей сессии
		jQuery.ajax({   
			type: "POST",
			url: "/blog/ajax/work.php", 
			data:"mode=clear_session",
			cache: false,   
			success: function(html){   
				jQuery('#add_block').hide('slow');
				jQuery('#add_link_b').html('Добавить');
				
			}
		});  		
  	}
	return false;
  }
  
  function add_comment(rec_id,uid)
  {
  	var text_data = jQuery('#comment_data_'+rec_id).val();
  	//alert(rec_id+' '+uid+' '+text_data);
	jQuery.ajax({   
		type: "POST",
		url: "/blog/ajax/work.php", 
		data:"mode=add_comment&rec_id="+rec_id+"&text="+text_data+"&uid="+uid,
		cache: false,   
		success: function(html){
			//alert('Запись добавленна');
			jQuery('#comment_block_'+rec_id).html(html);
			
			jQuery('#com_count_'+rec_id).hide();
			
			jQuery('#comment_data_'+rec_id).val('');
		}
	});
  }
  
  //com_count_<#REC_ID/>
  
  function add_ok()
  {
  	var title_data = jQuery('#title_data').val(); 
	var text_data = jQuery('#text_data').val();
	//alert(text_data);
	//alert('Добавление записи');
	if(text_data.length>10)
	{
		jQuery.ajax({   
			type: "POST",
			url: "/blog/ajax/work.php", 
			data:"mode=add&title="+title_data+"&text="+text_data,
			cache: false,   
			success: function(html){   
				//alert('Запись добавленна');	
				jQuery('#add_block').show('slaw');
				jQuery('#add_link_b').html('Закрыть');
				location.href = 'http://www.mirsharov.ru/blog/';
			}
		});
	}else
		alert ('Слишком короткое сообщение');
  }
  
  function del_file(file_name)
  {
	if (confirm("Вы действительно хотите удалить файл?")) 
	{  
		jQuery.ajax({   
			type: "POST",
			url: "/blog/ajax/work.php", 
			data:"mode=del&filename="+file_name,
			cache: false,   
			success: function(html){   
				jQuery('#file_img_list').html(html);
			}
		});
	}
	return false;
  }
  
  function del_blog_rec(id)
  {
	if (confirm("Вы действительно хотите удалить запись блога?")) 
	{  
		jQuery.ajax({   
			type: "POST",
			url: "/blog/ajax/work.php", 
			data:"mode=del_blog_rec&id="+id,
			cache: false,   
			success: function(html){   
				document.location.reload();
			}
		});
	}
	return false;
  }
  
  
  function DelComment(id,rec_id)
  {
	if (confirm("Вы действительно хотите удалить комментарий?")) 
	{  
		jQuery.ajax({   
			type: "POST",
			url: "/blog/ajax/work.php", 
			data:"mode=DelComment&id="+id+"&rec_id="+rec_id,
			cache: false,   
			success: function(html){   
				jQuery('#comment_block_'+rec_id).html(html);
				
				jQuery('#com_count_'+rec_id).hide();
				
				jQuery('#comment_data_'+rec_id).val('');
				
			}
		});
	}
	return false;
  }
  
  
  var MegaImage='';
  function ViewElement(obj){
  		if(isLoading) return false; else isLoading=true;
  		MegaImage=jQuery(obj).css('background-image').replace('small_100_90','small_270_255');
  		
  		jQuery(jQuery(obj).parent().parent().parent().children('.img_preview').children('.div_a').children()[0]).fadeOut('slow',function(){jQuery(this).css('background-image',MegaImage)}).fadeIn('slow'); 
  		 
  		var href_var = MegaImage;
  		//alert(href_var); 
  		
  		
  		href_var=href_var.replace('url(','');
  		href_var=href_var.replace(')','');
  		href_var=href_var.replace('small_270_255/','small_500_500/');
		href_var=href_var.replace('"','');
		href_var=href_var.replace('"','');
		href_var=href_var.replace('http://'+location.host,'');
		//jQuery('title').html(location.host);
		//alert(href_var);
  		jQuery(jQuery(obj).parent().parent().parent().children('.img_preview').children('.div_a')).fadeOut('slow',function(){
  			jQuery(this).attr('href',href_var).attr('style','')
  		}).fadeIn('slow',function(){isLoading=false;});    		
  }
  
  function more_title(th)
  {
	jQuery(jQuery(jQuery(jQuery(jQuery(jQuery(jQuery(jQuery(th).parent()[0]).parent()[0]).parent()[0]).parent()[0]).children('.tr_gallery')[0]).children()[0]).children('.podrobnee')[0]).click();
  	return false;
  }
  
  function more_info2(th)
  {
	jQuery(th).parent().children('.podrobnee').click(); 
  	return false;
  }
  
  function more_info(th)
  {
		var obj=jQuery(th).parent().children('.hiddenText'); 
		var obj_gallery=jQuery(th).parent().children('.gallery_block'); 
		var obj_img_preview=jQuery(th).parent().parent().children('.img_preview'); 
		var obj_img_div=jQuery(th).parent().parent().children('.img_preview').children('.div_a').children('.image_div'); 
		
		var link_style=jQuery(th).parent().children('.link_style'); 
		
		
		
		if(jQuery(th).html()=='......') 
		{
			obj.show();
			obj_gallery.show();
			obj_img_preview.css('width','300px');
			obj_img_preview.css('height','300px');
			
			var uri = obj_img_div.css('background-image');			
			uri = uri.replace('170_120','270_255');
			
			jQuery(link_style).hide();
			
			obj_img_div.css('background-position','top center');
			obj_img_div.css('width','270px');
			obj_img_div.css('height','255px');
			obj_img_div.css('background-image',uri);
			obj_gallery.children('.gal_div').css('cursor','pointer');
			obj_gallery.children('.gal_div').css('cursor','hand');
			obj_gallery.children('.gal_div').bind('click',function(){
				ViewElement(this);
				});
			jQuery(th).html('Скрыть');
		} else {
			obj.hide();
			obj_gallery.hide();
			obj_img_preview.css('width','150px');
			obj_img_preview.css('height','100px');
			
			jQuery(link_style).show();
			
			var uri = obj_img_div.css('background-image');			
			uri = uri.replace('270_255','170_120');			
			
			obj_img_div.css('background-position','center center');
			obj_img_div.css('width','170px');
			obj_img_div.css('height','120px');
			obj_img_div.css('background-image',uri);			
			
			jQuery(th).html('......');			
		} 
		return false;
  }
  
  function more_info_text(th)
  {
		var obj=jQuery(th).parent().children('.gallery_block').children('.hiddenText'); 
		var obj_gallery=jQuery(th).parent().children('.gallery_block'); 
		//alert(obj_gallery);
		if(jQuery(th).html()=='......') 
		{
			obj.show();
			obj_gallery.show();
			jQuery(th).html('Скрыть');
		} else {
			obj.hide();
			obj_gallery.hide();
			jQuery(th).html('......');			
		} 
		return false;
  }  
  
  
  

