/**
 * 
 * @param {Object} local_conf
 */
Wykop = function (local_conf) {
    if (typeof jQuery === 'undefined') {
         throw 'Wykop exception: jQuery not found.';
    }

	//
    var conf = {};
	
	conf.target = '_blank';

    /**
	 * 
	 * @param {Object} data
	 */
    var init = function (local_conf) {
		conf = jQuery.extend(conf, local_conf);

		//
    	jQuery('.wykop').click(function() {
    		
    		// encodeURIComponent(document.getSelection?document.getSelection():document.selection.createRange().text)
    		var desc = jQuery('.commonLinkFactory .list .wykop').text();
			var url = 'http://www.wykop.pl/dodaj?url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title)+'&desc=' + desc;

			switch(conf.target) {
				case '_blank':
					window.open(url, '', ''); 
					break;

				default:
			    	location.href = url;
			}

			return false;
	    });
		
        //
        init = function () {};
    }; 

	//
    jQuery(document).ready(
        function () {
            init(local_conf);
        });
}
