$(function(){
  var directclicked = false;

  $("a").click( function()
  {
   directclicked = false;
  });

  $("div.ad-link a").click( function()
  {
    directclicked = true;
    $.post("direct_control/dc.phtm",{
        tp:1,
        text: encodeURI( $(this).text() ),
        descr:encodeURI( $(this).parent().next().text()),
        url:encodeURI($(this).parent().next().next().text())
       });
  });
  $("a[href^='http://an.yandex.ru/count/']").click( function()
  {
   if($(this).parent().is("div.ad-link") ) 
     return true;
   $(this).parent().parent().find('div.ad-link a').click();
  });
  
  $("div.y5_how a").click( function()
  {
   directclicked = true;
   $.post("direct_control/dc.phtm",{tp:2});
   window.location = $('.sf_left a').attr('href')+'add1/';
   return false;
  });
  $("div.y5_all a").click( function()
  {
   directclicked = true;
   $.post("direct_control/dc.phtm",{tp:3});
   window.location = $('.sf_left a').attr('href');
   return false;
  });
  $(".y5_ya a").click( function()
  {
   if(!directclicked)
     {
      $.post("direct_control/dc.phtm",{tp:4});
     }
  });
});
