/*
 * CU xLink Log jQuery Plugin Version 1.0
 * (c) 2011 comunique GmbH & Co. KG: http://www.comunique.com
 *
 * $('div').cu_xLinkLog({'url' : 'url2logger'});
 *
 */
 
(function( $ ){
    var methods = {
        init : function( opt ) { 
            return this.each(function(){
                var $this = $(this);
                opt = $.extend({}, $.fn.cu_xLinkLog.defaults, opt || {});
                t=document.location.protocol+"//"+document.location.host+"/";
                if (this.href.substr(0,t.length) != t){
                    $(this).data('cu_xLinkLog', opt);
                    $(this).mousedown( function(){$(this).cu_xLinkLog('mousedown',$(this));});
                }
            });
        },
        mousedown : function( cont ) { 
            var opt=cont.data('cu_xLinkLog');
            $.getJSON(opt.url+encodeURIComponent(cont.attr( 'href' )),
                function(data){
            });
        }
    };
    
    $.fn.cu_xLinkLog = 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.cu_xLinkLog' );
        }    
    };
    $.fn.cu_xLinkLog.defaults = {
        'url' : ''
    }
    
})( jQuery );


