$(function(){
    var setAnal = function(target, type, parent){
        $.each(target, function(){
            var self = this;
            $(self).parent().click(function(){
                if (typeof urchinTracker !== 'undefined') {
			        urchinTracker("/Analytics/link/" + type + '/' + self);
			    }
            });
        });
    };

    var news = $('dd'), target=[], type, products,parent;
    if (news) {
        target = news.children()
        type = $('#information').size() ? 'top' : 'news';
    }
//    products = $('a[target="item"]');
    products = $('a[target="shimano"]').add('a[target="item"]');
    if (products.size()){
        target = products;
        type = 'products';
    }

    if (target) {
        setAnal(target, type);
    }

    //download
    if ($('#wp').size()) {
        target = $('#wp >>> a').add('#ss_attention >> a');

		target.bind('contextmenu',
			function(){
			  var url = $(this).attr('href').replace(/.+\/([^\/]+)$/, '$1')
                if (typeof urchinTracker !== 'undefined') {
                    urchinTracker("/Analytics/download/rightclick/"  + url);
                }
			}
		).bind('click',
            function(){
              var url = $(this).attr('href').replace(/.+\/([^\/]+)$/, '$1')
                if (typeof urchinTracker !== 'undefined') {
                    urchinTracker("/Analytics/download/click/"  + url);
                }
            }
        )
		;
    }
    
    // pdf
    $('.pdf_download').click(function(){
                  urchinTracker("/Analytics/pdf/"  + $(this).attr('href').split('/').pop());
    });
    

    // related movies
    var $rels = $('#related_movies div.right_movie_list');
    $rels.click(function(){
                  var index = $rels.index(this)+1;
                  urchinTracker("/Analytics/related/movies/"  + index);
                });

    $('#related_tags li a').click(function(){
                                    var word = $(this).text().replace(/\([0-9]+\)/, '').replace(/ /, '');
                                    urchinTracker("/Analytics/related/tags/"  + encodeURIComponent(word));
                                  });

});