/*
document.observe('dom:loaded', function() {
  var holder  = $('comment_box');

  $('testLink').observe('click', function(event) {
    new Ajax.Updater(holder, this.readAttribute('href'), { method:'get' });
	event.stop();
  });
  
});

document.observe('dom:loaded', function() {
  var holder  = $('comment_box');
	if (!holder) return;
  $('post_comment_link').observe('click', function(event) {
	//new Ajax.Updater(holder, this.readAttribute('href'), {parameters:Form.serialize(this.form), method: 'post', asynchronous: true}); return false;
	
	new Ajax.Updater(holder, this.readAttribute('href'), {parameters:$('myForm').serialize(), method: 'post', asynchronous: true}); return false;

  });
  
});

*/
/*
document.observe('dom:loaded', function() {
  $('myForm').observe('submit', function(event) {
    this.request({
	
      onComplete: function(r) {
        $('myForm').stopObserving('submit'); // AVOID MEMORY LEAKS
        $('comment_box').update(r.responseText);
      }
		

    });
    event.stop();
  });
});
*/
document.observe('dom:loaded', function() {
  $('votesForm').observe('submit', function(event) {
    this.request({
      onComplete: function(r) {
        $('votesForm').stopObserving('submit'); // AVOID MEMORY LEAKS
        $('votes_box').update(r.responseText);
      }
    });
    event.stop();
  });
});


document.observe('dom:loaded', function() {
  $('commentsForm').observe('submit', function(event) {
    this.request({
      onComplete: function(r) {
        $('commentsForm').stopObserving('submit'); // AVOID MEMORY LEAKS
        $('comment_box').update(r.responseText);
      }
    });
    event.stop();
  });
});



// handle each link from a list of <a> inside a #example element
document.observe('click', function(event) {
  var element = event.findElement('#examples a'); // Identifiant #examples rajouté dans le HTML
  if (!element) return;
  new Ajax.Updater('right', element.readAttribute('href'), { method:'get' });
  event.stop();
});


	
		
document.observe('dom:loaded',function(){
		var tabs  = $('tabs_receipes');
			if (!tabs) return;
		new Control.Tabs('tabs_receipes');
		});

document.observe('dom:loaded',function(){
		var tabs  = $('tabs_themes');
			if (!tabs) return;
		new Control.Tabs('tabs_themes');
		});
		

document.observe('dom:loaded',function(){
		var tabs  = $('tabs_club');
			if (!tabs) return;
		new Control.Tabs('tabs_club');
		});	


document.observe('dom:loaded',function(){
		var tabs  = $('receipe_tabs_detail');
			if (!tabs) return;
		new Control.Tabs('receipe_tabs_detail');
		});
// using event delegation
/*
document.observe('click', function(event) {
  var element = event.findElement('#testLink');
  if (!element) return;
  new Ajax.Updater($('holder'), this.readAttribute('href'), { method:'get'});
  event.stop();
});


document.observe('click', function(event) {
  var element = event.findElement('ul#paire_de_pompes li a');
  if (!element) return;
  new Ajax.Updater($('holder'), this.readAttribute('href'), { method:'get'});
  event.stop();
});


document.observe('click', function(event) {
  var element = event.findElement('ul#paire_de_pompes li a');
  if (!element) return;
  new Ajax.Updater(element.next('div.holder'), element.readAttribute('href'), { method:'get'});
  event.stop();
});
*/
