include "../inc/classes/Category.php";
include "../inc/classes/Helpers.php";
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'sort') {
    $objItemImageHighlight = new ItemImageHighlight();
    $objItemImageHighlight->SortValues(substr($_REQUEST['action'], 1), substr($_REQUEST['action'], 0, 1));
    unset($objItem);
} elseif (isset($_REQUEST['dragsort'])) {
    // handle drag sort ajax request:
    $objItemImageHighlight = new ItemImageHighlight($_REQUEST['id']);
    $new_sort_order = $_REQUEST['idx'] * 10 + 5;
    if ($new_sort_order > $objItemImageHighlight->SortOrder) {
        $new_sort_order += 10;
        // increasing sort order so must add another 10
    }
    $objItemImageHighlight->SortOrder = $new_sort_order;
    $objItemImageHighlight->update();
    echo "success";
    exit;
    // just exit since this is an ajax request
}
$objCategory = new Category($_REQUEST['cat']);
include "includes/pagetemplate.php";
function PageContent()
{
    global $objCategory;
    ?>
            <div class="layout center-flex">
                <?php 
    $aLabels = array();
    $aLinks = array();
    $aLabels[0] = 'Home';
        $obj->ItemImageId = $_REQUEST["itemimage"];
        $obj->HotspotLeft = $_REQUEST["hotspot_left"];
        $obj->HotspotTop = $_REQUEST["hotspot_top"];
        $obj->ItemImageHighlightInfo = $_REQUEST["item_image_highlight_info"];
        $obj->create();
        // redirect to listing list
        header("Location:itemimage_list.php?cat=" . $_REQUEST['cat'] . "&item=" . $_REQUEST['item'] . "&itemimage=" . $_REQUEST['itemimage']);
        exit;
    } else {
        // update
        $obj = new ItemImageHighlight($id);
        $obj->ItemImageId = $_REQUEST["itemimage"];
        $obj->HotspotLeft = $_REQUEST["hotspot_left"];
        $obj->HotspotTop = $_REQUEST["hotspot_top"];
        $obj->ItemImageHighlightInfo = $_REQUEST["item_image_highlight_info"];
        $obj->update();
        // redirect to listing list
        header("Location:itemimagehighlight_list.php?cat=" . $_REQUEST['cat'] . "&item=" . $_REQUEST['item'] . "&itemimage=" . $_REQUEST['itemimage']);
        exit;
    }
} else {
    if ($_REQUEST['mode'] == 'e') {
        //listing
        $objItemImageHighlight = new ItemImageHighlight($id);
        $item_image_id = $objItemImageHighlight->ItemImageId;
        $hotspot_left = $objItemImageHighlight->HotspotLeft;
        $hotspot_top = $objItemImageHighlight->HotspotTop;
        $item_image_highlight_info = $objItemImageHighlight->ItemImageHighlightInfo;
    } else {
        if ($_REQUEST['mode'] == 'a') {
            $item_id = $_REQUEST["item"];