<?php
/**
 * (C) CopyRight 2008 MagicToolBox - www.magictoolbox.com - support@magictoolbox.com
 */
 //         includes/modules/
 
 $defaultView = false;
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?> 
<div id="productMainImage" class="centeredContent back">
<?php if (ZEN_MAGICTHUMB_STATUS == 'true') { ?>
    <?php
        $products_name = $current_page_base == 'product_reviews' ? $products_name_reviews_page : $products_name;
        $tplDIR = $db->Execute("select template_dir from " . TABLE_TEMPLATE_SELECT);
        $tplDIR = $tplDIR->fields['template_dir'];
        
        require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'magictoolbox/magictoolbox_addons.php');
        /* load module */
        $mod = & magictoolboxLoadModule('MagicThumb');
        if(file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . str_replace(DIR_WS_IMAGES, '', $products_image_large))) {
            $image = str_replace(DIR_WS_IMAGES, '', $products_image_large);
        } else {
            $image = str_replace(DIR_WS_IMAGES, '', $products_image);
        }



        if(file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $image) && !$mod->params->checkValue("use-effect-on-product-page", "No")) {
            $img = DIR_WS_CATALOG . DIR_WS_IMAGES . $image;
            $thumb = DIR_WS_CATALOG . magictoolboxGetThumb($image, $mod->params->getValue('thumb-size'), $mod->params->getValue('thumb-size-depends-on'), $mod->params->getValue('image-magick-path'));
            
            $id = 'MainImage';
            $title = $products_name;
            $description = $products_description;        
            
            /* zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) */
            /* javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\') */
    
            if(!defined('MAGICTHUMB_ADDONS_TEMPLATE_LOADED')) {
                echo $mod->addonsTemplate(DIR_WS_CATALOG . DIR_WS_TEMPLATE . 'images');
                define('MAGICTHUMB_ADDONS_TEMPLATE_LOADED', true);
            }
    
            echo $mod->template(compact("img","thumb","id","title","description"));
            //$mod->();
        } else {
            $defaultView = true;
        }
    ?>
<?php } else { $defaultView = true; } ?>
<?php if($defaultView) { ?>
    <script language="javascript" type="text/javascript"><!--
        document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
    //--></script>
    <noscript><?php echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?></noscript>
<?php } ?>
</div>
