// Frieni.com
// comments.js

$(document).ready(function() 
{
//--------------------------------------------------------------- Update Status
$(".update_button").click(function() 
{
var eidval = $("#wall_eid").val(); 
if($('#auth').is(':checked')){
//alert("OK");
var auth = $("#auth").val();  
}
var updateval = $("#update").val();
var dataString = 'update='+updateval+'&eid='+eidval+'&auth='+auth;
if(updateval=='')
{
// alert("Please Enter Some Text");
$("#flash").show();
$("#flash").fadeIn(400).html('Atencion: Debes escribir tu comentario!');
$("#flash").fadeOut(4000); 

}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('Actualizando...');

$.ajax({
type: "POST",
url: getAppPath()+"actions.php",
data: dataString,
cache: false,
success: function(html)
{            
$("#flash").fadeOut(2000);
$("#content").prepend(html);
$("#update").val('');	
$("#update").focus();

    	

$("#stexpand").oembed(updateval);
  }
 });
}
return false;
	});
	


//commment Submint

$('.comment_button').live("click",function() 
{

var ID = $(this).attr("id");

var comment= $("#ctextarea"+ID).val();
var dataString = 'comment='+ comment + '&msg_id=' + ID;

if(comment=='')
{
alert("Please Enter Comment Text");
}
else
{
$.ajax({
type: "POST",
url: "http://localhost/frieni/lib/comment_ajax.php",
data: dataString,
cache: false,
success: function(html){
$("#commentload"+ID).append(html);
$("#ctextarea"+ID).val('');
$("#ctextarea"+ID).focus();
 }
 });
}
return false;
});

// commentopen 
$('.commentopen').live("click",function() 
{
var ID = $(this).attr("id");
$("#commentbox"+ID).slideToggle('slow');
return false;
});	


// delete comment
$('.stcommentdelete').live("click",function() 
{
var ID = $(this).attr("id");
var dataString = 'com_id='+ ID;

if(confirm("Sure you want to delete this update? There is NO undo!"))
{

$.ajax({
type: "POST",
url: "http://localhost/frieni/lib/delete_comment_ajax.php",
data: dataString,
cache: false,
success: function(html){
 $("#stcommentbody"+ID).slideUp();
 }
 });

}
return false;
});



//-------------------------------------------------------------------- delete update
$('.stdelete').live("click",function() 
{
var ID = $(this).attr("id");
var dataString = 'msg_id='+ ID;

if(confirm("Estas seguro que deseas borrar este comentario?"))
{

$.ajax({
type: "POST",
url: getAppPath()+"actions.php",
data: dataString,
cache: false,
success: function(html){
 $("#stbody"+ID).slideUp();
 }
 });
}
return false;
});
});

