<?php

/**
 * Load classes from core directories 
 * @param string $classname Class to load
 * @return file path loaded
**/
function __autoload($className)
{
	if (strpos($className, '\\') === false)
		return FALSE;
    list($namespace, $class) = explode('\\', $className, 2);
    $path = null;
    switch ($namespace)
    {
    case "Entity":
        $path = "core/models/{$class}.php"; break;
    case "Tools":
        $path = "core/tools/{$class}.php"; break;
	case "Controller":
		$path = "core/controllers/{$class}.php"; break;
	case "Exception":
		$path = "core/exceptions/{$class}.php"; break;
    }
	if (file_exists($path))
		include_once ($path);
    return $path;
}

