//
if (isset($_GET["cat"])) {
    //Category movie view -----------------------------
    $category = base64_decode($_GET["cat"]);
    $title = base64_decode($_GET["title"]);
    fetchMovieCategoryItems($category, $title);
} else {
    if (isset($_GET["item"])) {
        //Movie detail view -------------------------------
        $item = base64_decode($_GET["item"]);
        $title = base64_decode($_GET["title"]);
        $image = base64_decode($_GET["image"]);
        fetchMovie($item, $title, $image);
    } else {
        // Show home view --------------------------
        fetchMovieCategories();
    }
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/**
 */
function fetchMovieCategories()
{
    $template = new MarocTemplate();
    $content = @file_get_contents("http://www.01maroc.com/modules/films/index.php");
    $newlines = array("\t", "\n", "\r", "  ", "", "\v");
    $content = str_replace($newlines, "", html_entity_decode($content));
    $content = strstr($content, "<!-- Start category loop -->");
    $content = substr($content, 0, strpos($content, "<!-- End category loop -->"));
    //echo $content;
                                fetchMovieCategoryItems($type, $category, $title);
                                break;
                            case "ser":
                                fetchSerieCategoryItems($type, $category, $title);
                                break;
                        }
                    } else {
                        if (isset($_GET["type"])) {
                            // Category list view ---------------------
                            $type = $_GET["type"];
                            switch ($type) {
                                case "doc":
                                    fetchDocumentaryCategories($type);
                                    break;
                                case "mov":
                                    fetchMovieCategories($type);
                                    break;
                                case "ser":
                                    fetchSerieCategories($type);
                                    break;
                            }
                        } else {
                            // Show home principal view ---------------------------------------
                            fetchHome();
                        }
                    }
                }
            }
        }
    }
}