public static function loadConfig($filename)
    {
        self::fireEvent('Atomik::Loadconfig::Before', array(&$filename));
        
        // config file format
        if (!preg_match('/.+\.(php|ini|json)$/', $filename)) {
            $found = false;
            foreach (array('php', 'ini', 'json') as $format) {
                if (file_exists("$filename.$format")) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                throw new AtomikException("Configuration file '$filename' not found");
            }
            $filename .= ".$format";
        } else {
            $format = substr($filename, strrpos($filename, '.') + 1);
        }
        
        $config = array();
        if ($format === 'ini') {
            if (($data = parse_ini_file($filename, true)) === false) {
                throw new AtomikException('INI configuration malformed');
            }
            $config = self::dimensionizeArray($data, '.');
        } else if ($format === 'json') {
            if (($config = json_decode(file_get_contents($filename), true)) === null) {
                throw new AtomikException('JSON configuration malformed');
            }
        } else {
            if (is_array($return = include($filename))) {
                $config = $return;
            }
        }
        
        self::fireEvent('Atomik::Loadconfig::After', array($filename, &$config));
        return $config;
    }