<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Home extends CI_Controller {

    function __construct() {
        parent::__construct();
        
        //load authentication library
        $this->load->library('ion_auth');
    }

    public $data = array('subview' => 'Opps, forgot to set a subview');

    public function index() {
        $this->layouts();
    }

    public function layouts() {
        
        $this->data['subview'] = 'home';
        
        //check if user is logged in 
         if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin())
		{
	             //load the view passing $data values
                     $this->load->view("layouts/main_admin", $this->data);
		}
         else if ($this->ion_auth->logged_in() && !$this->ion_auth->is_admin())
		{
		     //load the view passing $data values
                     $this->load->view("layouts/main_logged_in", $this->data);
		}
         else
                {
                     //load the view passing $data values
                     $this->load->view("layouts/main", $this->data);
                }
        
     
    }

    public function about() {
        $this->data['subview'] = 'about';

        if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin()) {
            //load the view passing $data values
            $this->load->view("layouts/main_admin", $this->data);
        } else if ($this->ion_auth->logged_in() && !$this->ion_auth->is_admin()) {
            //load the view passing $data values
            $this->load->view("layouts/main_logged_in", $this->data);
        } else {
            //load the view passing $data values
            $this->load->view("layouts/main", $this->data);
        }
    }
    
    public function contact() {
        $this->data['subview'] = 'contact';
        
        if ($this->ion_auth->logged_in() && !$this->ion_auth->is_admin()) {
            //load the view passing $data values
            $this->load->view("layouts/main_logged_in", $this->data);
        } else {
            //load the view passing $data values
            $this->load->view("layouts/main", $this->data);
        }
        
    }

}
