$(document).ready(function(){

  $('.comments-link').attr('href','#');
  $('.comments-link').click(function(e){
//    $(this).
    $('.comments_list.'+$(this).attr('value')).slideToggle('slow', function() {
      // Animation complete.
      return false;
    });
    return false;
  })
  
  $('.comment-form-comment #comment').live('click',function(){
    if ( $(this).html() == 'rediger un commentaire...')
      $(this).html('');
  })
  
});

function add_ajax(ajax_url){
  
    $('.jcarousel-item img').live('click',function(){
 
    if ($('#big_image img').length != 0){
      $('#big_image img').attr('src',$(this).attr('src').replace(/-[0-9]{3}x[0-9]{3}/, ''));  
    }else{
      $('#big_image').empty();
      $('#big_image').prepend(dailymotion_flash_tag($(this).attr('value'), 640, 360))
    }
    jQuery.post(
                ajax_url,
                 {
                   'action' : 'get_ajax_comments',
                   'post_id': $(this).attr('class').split('-').pop()
                 },
                 function( response )
                 {
                   //alert(response)
                   $('.comments_list').empty();
                   $('.comments_list').prepend(response)
                 })
    })
}

function dailymotion_flash_tag(id, width, height){
  var url = 'http://www.dailymotion.com/swf/'+id;
  return ("<object width='"+width+"' height='"+height+"' data='"+url+"' type='application/x-shockwave-flash'>    <param id='movie_id' name='movie' value='"+url+"' />    <param name='allowFullScreen'value='true' />    <param name='allowScriptAccess' value='always' />    <param name='wmode' value='transparent' />  </object>");
}

