/*function pulse(){
  $('.tabla div').animate({
    opacity: "toggle",    
  }, 1000, function() {
    // Animation complete.
    pulse();
  });
}

*/
function chat_show(id){
  //alert("a");
  $("#user_" + id + " div").toggle();
  $("#user_" + id + " input").toggle();
  
  chat_position_scroll(id);
}

function chat_position_scroll(id){
  scrollheight = $("#chatzone #user_" + id + " div").attr("scrollHeight");
  $("#chatzone #user_" + id + " div").attr("scrollTop", scrollheight);
}
                                    
function chat_send(id){  
  string = $("#input_" + id).val()
  
  $.ajax({
    type: "POST",
    url: "/Modules/Ajax_functions/Chat_send.php",                 
    data: "string=" + string + "&user_id=" + id,
    cache: false,
  
    beforeSend: function(){},                 
    success: function(msg){
      $("#user_" + id + " div").append("<b>" + global_user_nev + "</b>: " + string + "<br />");
      chat_position_scroll(id);
      $("#input_" + id).val('');
    },
    error: function(){ /*alert("Elkúrtuk. Nem kicsit. Nagyon."); */ }
  });
}

function chat_options_send(id){	
	$.ajax({
    type: "POST",
    url: "/Modules/Ajax_functions/Chat_convert_active_message.php",                 
    //cache: false,
    
    dataType: "html",
    data:{
    	user:id,
    	subject:$(".chat_options .subject").val()
    },
    
    beforeSend: function(){},                 
    success: function(msg){
    	$(".chat_options input").toggle();
    	$(".chat_options .subject").val("");
    },
    error: function(){ /*alert("Elkúrtuk. Nem kicsit. Nagyon.");*/ }
  });
}

function chat_options(e, id){
	$(".chat_options").remove();
	$("body").append('<div class="chat_options"><h4 onclick="$(this).parent().remove();">Chat opciók</h4><ul><li onclick="chat_options_textarea();">aktív üzenetté alakítás</li><li>előzmények törlése</li></ul><input type="text" class="subject" name="subject" value="Üzenet tárgya" onclick="$(this).val(\'\');" /><input type="button" onclick="chat_options_send('+id+');" /></div>');

	$(".chat_options").css("top", (e.pageY));
  $(".chat_options").css("left", (e.pageX-300));
}

function chat_options_textarea(){
	//$(".chat_options .subject").toggle();
	$(".chat_options input").toggle();
}



function erase_active_conversation(elem, conversation_id){
  $.ajax({
    type: "GET",
    url: "/Modules/Ajax_functions/Active_message_erase_conversation.php",
    //cache: false,    
    data:{
      conversation_id:conversation_id
    },
    
    beforeSend: function(){},
    success: function(msg){
      $(elem).parent().parent().remove();
    },
    error: function(){ /*alert("Elkúrtuk. Nem kicsit. Nagyon.");*/ }
  });
}


function gritter(title, text, image, sticky, time, class1, class_name){
	$.gritter.add({
		// (string | mandatory) the heading of the notification
		//title: "This is a regular notice!",
		title: title,
		
		// (string | mandatory) the text inside the notification
		//text: "This will fade out after a certain amount of time.",
		text: text,
		
		// (string | optional) the image to display on the left
		//image: "http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png",
		image: image,
		
		// (bool | optional) if you want it to fade out on its own or just sit there
		sticky: false, 
		
		// (int | optional) the time you want it to be alive for before fading out (milliseconds)
		time: 8000,
		
		// (string | optional) the class name you want to apply directly to the notification for custom styling
		class_name: "my-class",
		class1: "my-class",
    
    // (function | optional) function called before it opens
		before_open: function(){
			//alert("I am a sticky called before it opens");
		},
		
		// (function | optional) function called after it opens
		after_open: function(e){
			//alert("I am a sticky called after it opens: \nI am passed the jQuery object for the created Gritter element...\n" + e);
		},
	
		// (function | optional) function called before it closes
		before_close: function(e){
			//alert("I am a sticky called before it closes: I am passed the jQuery object for the Gritter element... \n" + e);
		},

		// (function | optional) function called after it closes
		after_close: function(){
			//alert("I am a sticky called after it closes");
		}
	});
}



function reload(){
  $(".system_message").slideUp("slow", function(){
    $(".system_message").html("");
  });

  $.ajax({
    type: "GET",
    url: "/Modules/Ajax_functions/Core.php",                 
    //cache: false,
    
    dataType: "script",
    
    beforeSend: function(){},                 
    success: function(msg){},
    error: function(){ /*alert("Elkúrtuk. Nem kicsit. Nagyon.");*/ }
  });
}


function play_sound(sound){
  var audioElement = document.createElement('audio');
  audioElement.setAttribute('src', sound);
  audioElement.setAttribute('autoplay', 'autoplay');
  //audioElement.volume=0;
  audioElement.load();
}
