/* front/Core.js */
;(function($){var i,debugMode=window.console&&window.console.firebug&&location.href.indexOf('debug')>-1,pluginPath='/jscore/plugin/',cssPath='/jscore/css/';$.core={plugins:[],stylesheets:[],load:function(plugins,options){var pluginsToLoad=[],defaults={async:false,pack:debugMode?0:1,encoding:0,combine:true,callback:null};if(options)$.extend(defaults,options);if(typeof plugins=='string')plugins=[plugins];for(i=0;i<plugins.length;i++){var plugin=pluginPath+$.core.urlencode(plugins[i]);if($.inArray(plugin,$.core.plugins)==-1){$.core.plugins.push(plugin);if(defaults.combine){pluginsToLoad.push($.core.urlencode(plugins[i]));continue}$.core.loader(plugin,defaults)}else{$.log.warn('Plugin "'+plugin+'" był już pobierany!')}}if(defaults.combine&&pluginsToLoad.length){plugin=pluginPath+pluginsToLoad.join(',');$.core.loader(plugin,defaults)}},loader:function(url,defaults){$.ajax({async:defaults.async,url:url,data:{encoding:defaults.encoding,pack:defaults.pack},dataType:'script',success:function(){$.log.info('Plugin "'+url+'" został pobrany!');if($.isFunction(defaults.callback)){var callback=function(){$.log.info('Wykonuję callback dla "'+url+'"...');defaults.callback.call()};$.core.addOnload(callback)}}})},addCss:function(stylesheets,options){var defaults={media:'screen,print'};if(options)$.extend(defaults,options);if(typeof stylesheets=='string')stylesheets=[stylesheets];for(i=0;i<stylesheets.length;i++){var stylesheet=cssPath+$.core.urlencode(stylesheets[i]);if($.inArray(stylesheet,$.core.stylesheets)==-1){headID=document.getElementsByTagName("head")[0];cssNode=document.createElement('link');$(cssNode).attr({type:'text/css',rel:'stylesheet',href:stylesheet,media:defaults.media});headID.appendChild(cssNode);$.core.stylesheets.push(stylesheet)}else{$.log.warn('Arkusz "'+stylesheet+'" został już raz dołączony!')}}},urlencode:function(url){url=encodeURIComponent(url);return url.replace(/~/g,'%7E').replace(/%20/g,'+').replace(/%2F/g,'_')},addOnload:function(fn){if(window.addEventListener)window.addEventListener('load',fn,false);else if(window.attachEvent)window.attachEvent('onload',fn)}};$.log={debug:function(v){if(debugMode)console.debug(v)},info:function(v){if(debugMode)console.info(v)},warn:function(v){if(debugMode)console.warn(v)},error:function(v){if(debugMode)console.error(v)}}})(jQuery);
