/*
Page:           comment.js
Created:        Sep 2009
Last Mod:       Sep 01 2009
Comment system like youtube.	
--------------------------------------------------------- 
Enkhdulguun, duugi.com
duugi.com@gmail.com 
GNU.
--------------------------------------------------------- */
$(function() {

$(".votecomment").click(function() 
{

var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);


if(name=='up')
{

$(this).fadeIn(200).html('<img src="media/site_images/ajax-loader.gif" align="absmiddle" border="0px">');
$.ajax({
   type: "POST",
   url: "modules/comment/up_vote.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
    parent.html(html);
  
  }  });
  
}
else
{

$(this).fadeIn(200).html('<img src="media/site_images/ajax-loader.gif" align="absmiddle" border="0px">');
$.ajax({
   type: "POST",
   url: "modules/comment/down_vote.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
       parent.html(html);
  }
   
 });
}
return false;
	});
});

// Comment section

$(function() {

$(".submit").click(function() {

var name = $("#name").val();
var email = $("#email").val();
var comment = $("#comment").val();
var video_id = $("#video_id").val();
var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment + '&video_id=' + video_id;
	
	if(name=='' || email=='' || comment=='')
     {
    alert('Please Give Valide Details');
     }
	else
	{
	$("#flash").show();
	$("#flash").fadeIn(400).html('<img src="media/site_images/ajax-loader.gif" align="absmiddle" border="0px">&nbsp;<span class="loading">Loading Comment...</span>');
$.ajax({
		type: "POST",
  url: "commentajax.php",
   data: dataString,
  cache: false,
  success: function(html){
 
  $("ol#update").append(html);
  $("ol#update li:last").fadeIn("slow");
  document.getElementById('email').value='';
   document.getElementById('name').value='';
    document.getElementById('comment').value='';
	$("#name").focus();
 
  $("#flash").hide();
	
  }
 });
}
return false;
	});



});

