// taggage xiti
Event.onReady(function(){
// menu principal
e = $('app_links').childElements();
for(j = 0; j < e.size(); j++)
{
  classes = e[j].className.gsub(/.* (.*)-app-name.*/,function(match){
    if(match[1].length > 0)
    {
      link = e[j].firstDescendant();
      if(link)
      {
	link.observe('click',function(event){
	  nomPage = "entrenous::menu-horizontal::" + match[1];
	  xt_click(this,'C','5',nomPage,'N');
	});
      }
    }
  });
}

links = $$('.xiti_action');
if(links)
{
  for(i = 0; i < links.size(); i++)
  {
    url = links[i].href;
    url.gsub(/\/feedbacks\/[0-9]*-([^\/]*)\/([^\/]*).*/,function(match){
      links[i].observe('click',function(event){
        nomPage = "blog";
        if(match[2] && match[2] == "reports")
        {
          nomPage += "::action-pop-in::indesirable::" + match[1];
        }
        else if(match[2] && match[2] == "monitorship")
        {
          nomPage += "::action-pop-in::suivre::" + match[1];
        }
        else if(match[2] && match[2] == "comments")
        {
          nomPage += "::commenter::" + match[1];
        }
        else
        {
          nomPage += "::home";
        }
        xt_med('F','5',nomPage);
      });
    });  
  }
}
// taggage bouton addthis
if($$('.addthis_button').size == 1)
{
  $$('.addthis_button').first().observe('click',function(event){
    xt_med('F','5',"posez-vos-questions::action-pop-in::partager");
  });
}

links = $$('a');
AUTHORIZED_OPTION = ['feedbacks','categories','statuses'];
if(links)
{
  for(i= 0; i < links.size();i++)
  {
    if(!links[i].className.include('xiti_action'))
    {
      url = links[i].href;
      url.gsub(/\/([^\/]*)/,function(match){
        if(match[1] && AUTHORIZED_OPTION.include(match[1]))
        {
          nomPageSimu = "blog";
          lien = links[i].href;
          lien.gsub(/^http:\/\/[^\/]*\/([^\/]*)\/[0-9]*-([^\/|#]*)$/,function(match){
            links[i].observe('click',function(event){
              if(match[1] && match[1] == 'feedbacks')
              {
                nomPageSimu += "::contribution::" + match[2];
              }
              else if(match[1] && match[1] == 'categories')
              {
                nomPageSimu += "::" + match[2];
              }
              else if(match[1] && match[1] == 'statuses')
              {
                nomPageSimu += "::statut::" + match[2];
              }
              else
              {
                nomPageSimu += "::home";
              }
              xt_click(this,'F','5',nomPageSimu);
            });
          });
        }
      });
    }
  }
}

links = $$('.xiti_action_link');
if(links.size()  > 0)
{
  for (i = 0; i < links.size(); i++)
  {
    url = links[i].href;
    url.gsub(/^http:\/\/[^\/]*\/([^\/]*)\/[0-9]*-([^\/|#]*)$/,function(match){
      links[i].observe('click',function(event){
        nomPageClick = "blog::lire-la-suite::" + match[2]; 
        xt_click(this,'C','5',nomPageClick,'A');
      });
    });
  }
}

});


