/*
 * CU xLink Log jQuery Plugin Version 1.1
 * (c) 2011 comunique GmbH & Co. KG: http://www.comunique.com
 *
 * $('div').cu_xLinkLog({'url' : 'url2logger','url2':'domainfrom'});
 *
 */
 
(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.length>0 && this.href.substr(0,t.length) !== t && this.href.substr(0,11) !== 'javascript:'){
                    $("BODY").data('cu_xLinkLog', opt);
                    $(this).mousedown( function(){$(this).cu_xLinkLog('mousedown',$(this));});
                }
            });
        },
        mousedown : function( cont ) { 
            var opt=$("BODY").data('cu_xLinkLog');
            url2 = (opt.url2 !=='')?( opt.url2 + encodeURIComponent(window.location.hostname)):('');
            $.getJSON(opt.url+encodeURIComponent(cont.attr( 'href' ))+url2,
                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' : '',
        'url2' : ''
    }
    
})( jQuery );


