function check_keywords()
{
  if (document.search.search.value=="поиск по сайту...")
    document.search.search.value="";
  
}

function set_color(col)
{
  $(".main_color").css("background-color", col );
  $(".main_border").css("border-color", col );
  
  var result = $.ajax({
              url: "http://www.life-stories.ru/ajax.php",
              type: "POST",
              data: ({color : col,action:"setcolor"}),
              async: true
              }).responseText;
    
}


function ask_send(id)
{
  var comm=$("#moder_text").val();
        var result=$.ajax({
              url: "http://www.life-stories.ru/ajax/ask.php",
              type: "POST",
              data: ({action:"send_ask",comment:id,text:comm}),
              async: false
              }).responseText;
              
        alert(result);
$("#ask_"+id).css("display","none");        
}                   

function send_fast_message(id)
{
       var subject=$("#subject").val();
       var text=tinyMCE.get('txt').getBody().innerHTML;
       if (text.length<1)
       text=$("#txt").innerHTML;
       if (text.length<1)               
       text=$("#txt").val();                                                                
                                                                                            
       
        $("#ls_res").html('<center><img src="http://www.life-stories.ru/images/final.gif"><br>отправляем сообщение</center>');
  
  var result = $.ajax({
         url: "http://www.life-stories.ru/ajax/messages.php",
              type: "POST",
              data: ({action:"send_message",msg:text,subject:subject,user_to:id}),
              async: false
              }).responseText;
         tinyMCE.execCommand( 'mceRemoveControl', true, 'txt');
        
        $("#ls_res").html(result);    
        $("#ls_div").css({display:"block"});
      

}
               
function  show_msg_box(id)
{
// tinyMCE.execCommand( 'mceRemoveControl', true, 'txt');
   var result = $.ajax({
         url: "http://www.life-stories.ru/ajax/messages.php",
              type: "POST",
              data: ({action:"show_msg_box",user:id}),
              async: false
              }).responseText;
        
        $("#ls_res").html(result);
        $("#ls_div").css({display:"block"});
        
        			  $("#put_from_a").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'centerOnScroll'  : true,
				onComplete	:	function() {
           	$("a[rel=box_window]").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'centerOnScroll'  : true,
				'showNavArrows'   : false
					
			});
		},
				'showNavArrows'   : false
					
			});
    $('#txt').tinymce({
			// Location of TinyMCE script
			script_url : 'http://www.life-stories.ru/plugins/tiny_MCE/tiny_mce.js',

			// General options
			theme : "advanced",
		  plugins : "safari,style,table,advhr,emotions,iespell,inlinepopups,contextmenu,paste",
 	    theme_advanced_buttons1 : "copy,paste,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor|,charmap,emotions,|,fontsizeselect,|,undo,redo",
  		theme_advanced_buttons2 : "",
      theme_advanced_buttons3 : "",

			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			// Example content CSS (should be your site CSS)
			content_css : "css/content.css",

			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js",

			// Replace values for the template plugin
			template_replace_values : {
				username : "www.life-stories.ru",
				staffid : "991234"
			}
		});
      
       
  //var content = tinyMCE.get('textarea_id').getContent();      
       
}    

function show_ask_dlg(id)
{
 
 var result = $.ajax({
              url: "http://www.life-stories.ru/ajax/ask.php",
              type: "POST",
              data: ({action:"get_ask_dlg",comment:id}),
              async: false
              }).responseText;

            
        $("#ask_"+id).html(result);
        $("#ask_"+id).css("display","block");
        }
                   


  function setTextareaToTinyMCE(sEditorID) {
    
        tinyMCE.execCommand('mceAddControl', true, sEditorID);
        $.ajax({
              url: "http://www.life-stories.ru/ajax/editor.php",
              type: "POST",
              data: ({action:1}),
              async: false
              });
              
        
    
}

function unsetTextareaToTinyMCE(sEditorID) {

        tinyMCE.execCommand('mceRemoveControl', true, sEditorID);
        $.ajax({
              url: "http://www.life-stories.ru/ajax/editor.php",
              type: "POST",
              data: ({action:0}),
              async: false
              });
                
        
    
}


function go_next(id)
{

    var id=$("#"+id).attr('id');
    var th=$("#"+id)
    //if ($(this).attr('class').length>0)
    {
    $(th).removeClass('esche');
    $(th).html("идет загрузка страницы...");
    $.ajax({
         type: "POST",
          url: "http://www.life-stories.ru/ajax/continue.php",
          data: "action=get_continue&id="+id,
          async: true,
          success: function(msg){
                      $(msg).appendTo('#grss');
                      $("#"+id).empty();
                      $(".esche").click(function()
                      {
                        var id=$(this).attr('id');
                        go_next(id);
                      })
                      
                
                                 
                          }
          })
     
   }                             
    
}



$(document).ready(function() {


    $(".esche").click(function()
    {
      var id=$(this).attr('id');
      go_next(id);
    })


    $("#sex_w").click(function() {
                 $.ajax({
              url: "http://www.life-stories.ru/ajax/editor.php",
              type: "POST",
              data: ({sex:0}),
              async: false
              });
      
  });
  $("#sex_m").click(function() {
                 $.ajax({
              url: "http://www.life-stories.ru/ajax/editor.php",
              type: "POST",
              data: ({sex:1}),
              async: false
              });
              
      
  });
  
 
    
   
     $("#social .tips").hover(function() {
                                  $(this).find(".one").hide();
                                  $(this).find(".two").show();
                                  $(this).find(".tooltip").show();
                                  if ($(this).find(".tooltip").find("#vk_groups").html()=='1')
                                  {
                                    $(this).find(".tooltip").find("#vk_groups").html("");
                                    VK.Widgets.Group("vk_groups", {mode: 0, width: "220", height: "290"}, 25003449);
                                  }
                              }, function() {
                                
                                $(this).find(".one").show();
                                  $(this).find(".two").hide();
                                  $(this).find(".tooltip").hide();
                                
                              });
                                 
    jQuery(".vopros").click(function(){
                                  var id=jQuery(this).attr('id');
                                  
                                  $.ajax({
                                          type: "POST",
                                          url: "http://www.life-stories.ru/ajax/morder.php",
                                          data: "action=getst&id="+id,
                                          async: true,
                                          success: function(msg){
                                                
                                                    $("#"+id).html(msg);
                                                  
                                          }
                                          })
                                  
                              });     
                              
      jQuery(".voprosc").click(function(){
                                  var id=jQuery(this).attr('id');
                                  
                                  $.ajax({
                                          type: "POST",
                                          url: "http://www.life-stories.ru/ajax/morder.php",
                                          data: "action=getc&id="+id,
                                          async: true,
                                          success: function(msg){
                                                
                                                    $("#"+id).html(msg);
                                                  
                                          }
                                          })
                                  
                              });                                   
});
                                                          


