<?php 
	
class Dispatcher{
	
	var $controller_name;
	
	public function Dispatcher($controller){

		$this->controller_name = $controller;

		if (!file_exists('./controllers/' . ucfirst($controller) . 'Controller.php')){
			$this->display404();
		}
			
		$this->initController();				
	}		
	
	private function display404(){
		include_once './templates/default/views/404.html';
		exit();
	}
	
	private function initController(){
		include_once './controllers/' . ucfirst($this->controller_name) . "Controller.php";
        $class_name =  ucfirst($this->controller_name) . "Controller";
        $this->controller = new $class_name;





        printf('<script>

        //Enable foundation
        $(document).foundation();

        //Close modal fix
        $("a.custom-close-reveal-modal").click(function(){
            $(this).foundation("reveal", "close");
        })

        </script>');

        //Enclosure body
        printf("</BODY>");
        printf("</HTML>");
	}
}

?>