(function( $ ){
    /*
        jquery.urlT.js
        Dependencies: jquery (1.5.2) tested, 1.0 min req
        ------------------------------------------------
        (c) Innova Ideas & Services
        http://www.innovaideasandservices.com/
        Authored by David Svoboda @ 29.04.2011
        ------------------------------------------------
        Description
        ------------------------------------------------
        What is this for? Google analytics currently
        doesn't track specific links in different
        locations on the same page. By using query
        strings you can track clicks from specific
        elements/areas on the page (i.e. navigation,
        footer, content areas, callouts, etc). Just
        track the name value pair in your analytics
        reports ^_^
        ------------------------------------------------
        Setup
        ------------------------------------------------
        Syntax:
        $('parentElement').urlT({n: 'name', v: 'value});
        
        When using, specify the parent element of
        the anchor tags you want to append the
        query string to for identification:
        
        You can pass a specific name/value pair
        to replace the default, or a single
        parameter. Note: Parameters have default
        values in case they are not included in
        the call.
        
        Optional parameters (with default value)
        n: 'name'
        v: 'value'
        
        $('div.foo').urlT({
            n: 'a',
            v: 'nav'
        });
        
        would change it to:
        
        <div class='foo'>
            <a href="/bar.php?a=nav">Hyperlink</a>
        </div>
    */
    // Default name / value pair to be used if none are passed.
    var settings = {
        'n'     : "Category",
        'v'     : "');return false;"
    }; // end settings var
    var methods = {
        init : function(options) {
            return this.each(function(){
                // if options are passed in the call, replace the defaults with them.
                options = $.extend( settings, options);
                
                // Maintain chainability by keeping scope of 'this'.
                var $this = $(this);
                
                var functionCall = "recordOutboundLink(this, '" + options.n + "', '";
                
                // go through each anchor tag and add the query string.
                $('a', this).each(function() {
                    $(this).attr('onclick', ' ' + functionCall + $(this).attr('href') + options.v);
                });
            });
        }
    }; // end methods var
  
    $.fn.urlT = function( method ) {
        if ( methods[method] ){
            return methods[method].apply( this, Array.prototype.slice.call( arguments, 1));
        } else if( typeof method == 'object' || ! method ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( 'Method ' + method + ' does not exist on Jquery.urlT' );
            return false;
        }
    }; // end function urlT
})( jQuery );

