
/*zmeni z pridaj hraca na dalsi krok*/


function spustiAjax( kto , odozva ){
	
	 $.post('/core/tmpl/chat_ajax.php', 
	  { 
	    "primatel": kto
	  },
	  function(data,status){
		  odozva(data);
	  });
}

function Close(co){
	co.parent().parent().remove();
}

function spustiAjaxOdosli( id, komu, text ){
	
	 $.post('/core/tmpl/chat_ajax.php', 
	  { 
	    "odosli": "ano",
	  "id": id,
	  "komu": komu,
	  "text": text
	  });
}

function spustiAjax2( idM, idJ, time, odozva ){
	
	 $.post('/core/tmpl/chat_ajax.php', 
	  { 
	    "primatel": idM,
	    "odosielatel": idJ,
	    "time": time,
	  },
	  function(data,status){
		  odozva(data);
		  
	  });
}

function AS(){
	var spravy = jQuery.parseJSON(data);
	  
	var text;
	for (i = 0; i < spravy.length; ++i) {
		text += spravy[i].text+'<br>'; 
	}					
	OpenConverzationBox(idJ, text);
	alert(text)
}


function OpenConverzationBox(idJ, text){
	//zabranenie otvorenia okien k tim istym uzivatelom
	ok=true;
	$.each( $('#chatBoxContainer').children(), function(i, l){
		if ($(this).find("span").text()==idJ) {
			ok=false;
			return;
		}
		});
	
	if(!ok) return;
	$('#chatBoxContainer').append('<div class="chatBox" > <div class="controls" > <a href="" onclick= "Close($(this)); return false;"><i class="icon-remove-sign"></i></a> komu: <span>'+ idJ +'</span> </div> <div class="textBox" >'+text+ ' </div> <input id="text" type="text" value="" maxlength="47" size="40">  </div> ');
}




