<?php
    //phpinfo();//ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
    global $wpdb;
    $isSecure = is_ssl() ? true : false;
    $REQUEST_PROTOCOL = $isSecure ? 'https' : 'http';
    if(!$isSecure) {
        ?>
        <div class="nohttps" style="color:#ff0000;background-color:#000000;"><p><strong>
        <?php
            esc_html_e("Bad news. Your website is not using HTTPS. So this dragon ecommerce plugin can NOT be used for your website.");        
        ?>
        </strong></p></div>
        <?php
        exit;        
    }

    if (function_exists( 'mysqli_connect' ) && $wpdb->use_mysqli) {
    } else if (function_exists( 'mysqli_connect' ) && !$wpdb->use_mysqli) {
        ?>
        <div class="nomysqli" style="color:#ff0000;background-color:#000000;"><p><strong>
        <?php
            esc_html_e("Bad news. Mysqli is NOT used in your WordPress. So this dragon ecommerce plugin can NOT be used for your website.");        
        ?>
        </strong></p></div>
        <?php
        exit;
    } else if (!function_exists( 'mysqli_connect' ) && !$wpdb->use_mysqli) {
        ?>
        <div class="nomysqli" style="color:#ff0000;background-color:#000000;"><p><strong>
        <?php
            esc_html_e("Bad news. Mysqli does NOT exist in your WordPress. So this dragon ecommerce plugin can NOT be used for your website.");        
        ?>
        </strong></p></div>
        <?php
        exit;
    }

    session_start();
    if(session_id() == '' || !isset($_SESSION)) {
        setcookie(session_name(), session_id(), 0, '/', '', true, true);
        $_COOKIE[session_name()] = session_id();
        $_SESSION = array();
    } else {
        setcookie(session_name(), session_id(), 0, '/', '', true, true);
        $_COOKIE[session_name()] = session_id();        
    }
    $dragon_ecommerce_submitform_Result = '';
    $products = [];
    $settings_temp = [];
    $settings = [];
    $total = 0;
    $amountperpage = dragonecommercereservezyx987_getSettingAmountPerPage();
    $pagenumber = 1;
    $offset = 0;
    $mysortby = 'id';
    $myorder = 'asc';
    $searchwords = '';
    $departmentid = 0;
    $minprice = 0.00;
    $maxprice = 0.00;
    $total = 0;
    $totalpagenumber = 1;
    
    if((!empty($_POST['dragonecommercereservezyx987_hidden'])) && $_POST['dragonecommercereservezyx987_hidden'] === 'Y') {
        if((!empty($_POST['dragonecommercereservezyx987_loginuserbysubmitform'])) && $_POST['dragonecommercereservezyx987_loginuserbysubmitform'] === 'loginuserbysubmitform') {
            $dragon_ecommerce_submitform_Result = dragonecommercereservezyx987_loginUser_not_by_ajax();
            setcookie('dragon_ecommerce_submitform_Result', sanitize_text_field($dragon_ecommerce_submitform_Result), 0, '/', '', true, true);
            $protocol = is_ssl() ? 'https://' : 'http://'; 
            $urlparts = wp_parse_url(home_url());
            $protocol = esc_html($urlparts['scheme']) . '://';
            $domain = esc_html($urlparts['host']);
            $myurl = strtok($protocol . $domain . esc_html($_SERVER['REQUEST_URI']), '?');
            if(substr($myurl, -1) === '/') {$myurl = substr($myurl, 0, -1);}
            wp_safe_redirect(esc_html($myurl), 302);
            exit();
        } elseif(isset($_POST['dragonecommercereservezyx987_logoutuserbysubmitform']) && $_POST['dragonecommercereservezyx987_logoutuserbysubmitform'] === 'logoutuserbysubmitform') {
            $dragon_ecommerce_submitform_Result = dragonecommercereservezyx987_logoutUser_not_by_ajax();
            if($dragon_ecommerce_submitform_Result !== 'success') {}
            nocache_headers();
            header("Cache-Control: no-store");
            header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) );
            setcookie('dragon_ecommerce_submitform_Result', sanitize_text_field($dragon_ecommerce_submitform_Result), 0, '/', '', true, true);                                
            $protocol = is_ssl() ? 'https://' : 'http://'; 
            $urlparts = wp_parse_url(home_url());
            $protocol = esc_html($urlparts['scheme']) . '://';
            $domain = esc_html($urlparts['host']);
            $myurl = strtok($protocol . $domain . esc_html($_SERVER['REQUEST_URI']), '?');
            if(substr($myurl, -1) === '/') {$myurl = substr($myurl, 0, -1);}
            wp_safe_redirect(esc_html($myurl), 302);
            exit();
        } elseif((!empty($_POST['dragonecommercereservezyx987_setcookiebysubmitform'])) && $_POST['dragonecommercereservezyx987_setcookiebysubmitform'] === 'setcookiebysubmitform') {
            $dragon_ecommerce_submitform_Result = dragonecommercereservezyx987_setCookie_not_by_ajax();
            setcookie('dragon_ecommerce_submitform_Result', sanitize_text_field($dragon_ecommerce_submitform_Result), 0, '/', '', true, true);
            $protocol = is_ssl() ? 'https://' : 'http://'; 
            $urlparts = wp_parse_url(home_url());
            $protocol = esc_html($urlparts['scheme']) . '://';
            $domain = esc_html($urlparts['host']);
            $myurl = strtok($protocol . $domain . esc_html($_SERVER['REQUEST_URI']), '?');
            if(substr($myurl, -1) === '/') {$myurl = substr($myurl, 0, -1);}
            wp_safe_redirect(esc_html($myurl), 302);
            exit();
        }
        
        if(isset($_POST['dragonecommercereservezyx987_submitorderandpayment']) && $_POST['dragonecommercereservezyx987_submitorderandpayment'] === 'SUBMIT ORDER PAYMENT') {
            
        }        
    } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {  //GET request page, if there is error message when log in or log out, show error message
        if(isset($_COOKIE['dragon_ecommerce_submitform_Result']) && $_COOKIE['dragon_ecommerce_submitform_Result'] !== null && $_COOKIE['dragon_ecommerce_submitform_Result'] !== 'success') {
            $dragon_ecommerce_submitform_Result = sanitize_text_field($_COOKIE['dragon_ecommerce_submitform_Result']);
            setcookie('dragon_ecommerce_submitform_Result', '', time() - 42000, '/', '', true, true);
            unset($_COOKIE['dragon_ecommerce_submitform_Result']);
        }
        
        if($_GET['action'] === 'activateaccount') {
            if(empty($_GET['id']) || empty($_GET['token'])) {
                echo 'We need your id and token to activate your account.';
                exit();
            }
            $result = dragonecommercereservezyx987_activateAccount();
            if($result === 'success') {
                echo 'Congratulations! Your account is successfully activated.';
            } else {
                echo esc_html($result);
            }
            exit();
        }            
        
        $activedepartments = dragonecommercereservezyx987_getAllDepartments(true);
        $activegroups = dragonecommercereservezyx987_getAllGroups();            

        // a - amount per page; o - order (asc, desc); pg - page number; st - sortby
        $amountperpage_temp = trim($_GET['a']) === '' ? '' : sanitize_text_field($_GET['a']);
        $amountperpage_temp = strip_tags($amountperpage_temp);
        $amountperpage_temp = preg_replace('/[^0-9]/', '', $amountperpage_temp);
        if(intval($amountperpage_temp) === 20 || intval($amountperpage_temp) === 40 || intval($amountperpage_temp) === 100 || intval($amountperpage_temp) === 200) {
            $amountperpage = intval($amountperpage_temp);
        }
                    
        $pagenumber_temp = trim($_GET['pg']) === '' ? '' : sanitize_text_field($_GET['pg']);
        $pagenumber_temp = strip_tags($pagenumber_temp);
        $pagenumber_temp = preg_replace('/[^0-9]/', '', $pagenumber_temp);
        $pagenumber = trim($pagenumber_temp) === '' ? 1 : intval($pagenumber_temp);
                
        $offset = ($pagenumber - 1) * $amountperpage;
        
        $departmentid_temp = trim($_GET['did']) === '' ? '' : sanitize_text_field($_GET['did']);
        $departmentid_temp = strip_tags($departmentid_temp);
        $departmentid_temp = preg_replace('/[^0-9]/', '', $departmentid_temp);
        $departmentid = trim($departmentid_temp) === '' ? 0 : intval($departmentid_temp);
                
        $minprice_temp = trim($_GET['minp']) === '' ? '' : sanitize_text_field($_GET['minp']);
        $minprice_temp = strip_tags($minprice_temp);
        $minprice_temp = preg_replace('/[^0-9\.]/', '', $minprice_temp);
        $minprice = $minprice_temp === '' ? 0 : abs(intval($minprice_temp));

        $maxprice_temp = trim($_GET['maxp']) === '' ? '' : sanitize_text_field($_GET['maxp']);
        $maxprice_temp = strip_tags($maxprice_temp);
        $maxprice_temp = preg_replace('/[^0-9\.]/', '', $maxprice_temp);
        $maxprice = $maxprice_temp === '' ? -1 : abs(intval($maxprice_temp));
        
        $mysortby_temp = trim($_GET['st']) === '' ? '' : sanitize_text_field($_GET['st']);
        $mysortby_temp = strip_tags($mysortby_temp);
        if(trim($mysortby_temp) === ''){
            $mysortby = 'id';
        } elseif(trim($mysortby_temp) === 'id') {
            $mysortby = 'id';            
        } elseif(trim($mysortby_temp) === 'name') {
            $mysortby = 'name';            
        } elseif(trim($mysortby_temp) === 'price') {
            $mysortby = 'price';            
        } else {
            $mysortby = 'id';
        }
                
        $myorder_temp = trim($_GET['o']) === '' ? '' : sanitize_text_field($_GET['o']);
        $myorder_temp = strip_tags($myorder_temp);
        $myorder = trim($myorder_temp) === '' ? 'asc' : (strtolower($myorder_temp) === "desc" ? "desc" : "asc");    

        $searchwords_temp = trim($_GET['mysearch']) === '' ? '' : sanitize_text_field($_GET['mysearch']);
        $searchwords_temp = strip_tags($searchwords_temp);
        $searchwords_temp = preg_replace('/[^a-zA-Z0-9\/()$@?!\[\]{}#%^*+|~]/', '%', $searchwords_temp);
        $searchwords = trim($searchwords_temp) === '' ? '' : $searchwords_temp;

        $myresult = dragonecommercereservezyx987_getProducts_not_by_ajax($amountperpage, $pagenumber, $offset, $mysortby, $myorder, $searchwords, $departmentid, $minprice, $maxprice);

        $MIN_SEARCH_PRICE = 0;
        $MAX_SEARCH_PRICE = 500;
        if(count($myresult) > 0) {
            $products = $myresult["product"];
            $settings_temp = $myresult["settings"];
            $total = $myresult["total"];
            $MAX_SEARCH_PRICE = intval($myresult["highestprice"]);
            if($pagenumber > ceil($total/$amountperpage)) {$pagenumber = ceil($total/$amountperpage);}            

            for($i=0; $i<count($settings_temp); $i++) {
                if($settings_temp[$i]["settingname"] === 'CURRENCY_UNIT_ID_DEFAULT') {
                    $settings["CURRENCY_UNIT_ID_DEFAULT"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'DISTANCE_UNIT_ID_DEFAULT') {
                    $settings["DISTANCE_UNIT_ID_DEFAULT"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'WEIGHT_UNIT_ID_DEFAULT') {
                    $settings["WEIGHT_UNIT_ID_DEFAULT"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'MAX_PROMOTION_PER_ORDER') {
                    $settings["MAX_PROMOTION_PER_ORDER"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'MAX_DISCOUNT_PER_ORDER') {
                    $settings["MAX_DISCOUNT_PER_ORDER"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'MAX_COUPON_PER_ORDER') {
                    $settings["MAX_COUPON_PER_ORDER"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'WARN_PRODUCT_QUANTITY') {
                    $settings["WARN_PRODUCT_QUANTITY"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'PRODUCT_PER_ROW_LARGE') {
                    $settings["PRODUCT_PER_ROW_LARGE"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'PRODUCT_PER_ROW_MEDIUM') {
                    $settings["PRODUCT_PER_ROW_MEDIUM"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'PRODUCT_PER_ROW_SMALL') {
                    $settings["PRODUCT_PER_ROW_SMALL"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'PRODUCT_PER_ROW_EXTRA_SMALL') {
                    $settings["PRODUCT_PER_ROW_EXTRA_SMALL"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'AMOUNT_PER_PAGE') {
                    $settings["AMOUNT_PER_PAGE"] = intval($settings_temp[$i]["settingvalue"]);
                } else if($settings_temp[$i]["settingname"] === 'ENABLE_HANDLING_CHARGE') {
                    $settings["ENABLE_HANDLING_CHARGE"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'ENABLE_SHIPPING_CHARGE') {
                    $settings["ENABLE_SHIPPING_CHARGE"] = $settings_temp[$i];
                } else if($settings_temp[$i]["settingname"] === 'COMPANY_NAME') {
                    $settings["COMPANY_NAME"] = $settings_temp[$i]["settingvalue"];
                } else if($settings_temp[$i]["settingname"] === 'COMPANY_ADDRESS') {
                    $settings["COMPANY_ADDRESS"] = $settings_temp[$i]["settingvalue"];
                } else if($settings_temp[$i]["settingname"] === 'USE_GOOGLE_ANALYTICS') {
                    $settings["USE_GOOGLE_ANALYTICS"] = intval($settings_temp[$i]["settingvalue"]);
                } else if($settings_temp[$i]["settingname"] === 'GOOGLE_ANALYTICS_MEASUREMENT_ID') {
                    $settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"] = $settings_temp[$i]["settingvalue"];
                } else if($settings_temp[$i]["settingname"] === 'USE_GOOGLE_RECAPTCHA') {
                    $settings["USE_GOOGLE_RECAPTCHA"] = intval($settings_temp[$i]["settingvalue"]);
                } else if($settings_temp[$i]["settingname"] === 'GOOGLE_RECAPTCHA_SITEKEY') {
                    $settings["GOOGLE_RECAPTCHA_SITEKEY"] = $settings_temp[$i]["settingvalue"];
                } else if($settings_temp[$i]["settingname"] === 'DESKTOP_PRODUCT_IMAGE_SIZE') {
                    $temp = floatval($settings_temp[$i]["settingvalue"]); 
                    $settings["DESKTOP_PRODUCT_IMAGE_SIZE"] = round($temp*100)/100;
                } else if($settings_temp[$i]["settingname"] === 'TABLET_PRODUCT_IMAGE_SIZE') {
                    $temp = floatval($settings_temp[$i]["settingvalue"]); 
                    $settings["TABLET_PRODUCT_IMAGE_SIZE"] = round($temp*100)/100;
                } else if($settings_temp[$i]["settingname"] === 'CELLPHONE_PRODUCT_IMAGE_SIZE') {
                    $temp = floatval($settings_temp[$i]["settingvalue"]); 
                    $settings["CELLPHONE_PRODUCT_IMAGE_SIZE"] = round($temp*100)/100;
                }    
            }
        }    
    }    
    $slides = dragonecommercereservezyx987_getSlides();
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-dialog'); 
    wp_enqueue_style('wp-jquery-ui-dialog');
    wp_enqueue_script('custom-script-bootstrap', plugins_url('bootstrap/js/bootstrap.min.js', __FILE__ ));
    wp_enqueue_script('jquery-ui-core2', includes_url() . 'js/jquery/ui/core.min.js');
    wp_enqueue_script('jquery-ui-widget2', includes_url() . 'js/jquery/ui/widget.min.js');
    wp_enqueue_script('jquery-ui-mouse2', includes_url() . 'js/jquery/ui/mouse.min.js');
    wp_enqueue_script('jquery-ui-slider2', includes_url() . 'js/jquery/ui/slider.min.js');
    wp_enqueue_script('jquery-ui-datetimepicker2', plugins_url('js/jquery.datetimepicker.full.min.js', __FILE__ ));
    function high_priority_style() {
        wp_enqueue_style('bootstrap', plugins_url('bootstrap/css/bootstrap.min.css', __FILE__ ));
        wp_enqueue_style('bootstrap-icons', plugins_url('bootstrap/css/bootstrap-icons.css', __FILE__ ));
        wp_enqueue_style('jquery-ui2', plugins_url('css/jquery-ui.css', __FILE__ ));
        wp_enqueue_style('jquery-datetimepicker2', plugins_url('css/jquery.datetimepicker.min.css', __FILE__ ));
        wp_enqueue_style('dragonecommerce', plugins_url('css/dragonecommerce.css?v=' . date('Ymd'), __FILE__ ));
    }
    add_action('wp_enqueue_scripts', 'high_priority_style', 999);
    
    function dragonecommercereservezyx987_getproducts2() {
        if((!empty($_POST['dragonecommercereservezyx987_hidden'])) && $_POST['dragonecommercereservezyx987_hidden'] === 'Y') {
            $productid = 41;
            if($productid > 0) {                                
                global $wpdb;
                $charset_collate = $wpdb->get_charset_collate();
                require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
                $table_name = 'wp_dragonecommercereservezyx987_product';
                $table_name2 = 'wp_dragonecommercereservezyx987_department';
                $table_name3 = 'wp_dragonecommercereservezyx987_product_group';
                $table_name4 = 'wp_dragonecommercereservezyx987_product_country_province_city';
                $table_name5 = 'wp_dragonecommercereservezyx987_currency';                
                $result = $wpdb->get_results("SELECT a.id,min(a.departmentId) departmentId,min(a.name) name,min(a.currencyId) currencyId,min(e.name) currency,min(e.sign) currencysign,min(a.description) description,min(a.imagefilenames) imagefilenames,min(a.weightlb) weightlb,min(a.price) price,min(a.barcode) barcode,min(a.createtimeutc) createtimeutc,min(a.shipfromnearestbranch) shipfromnearestbranch,min(b.name) as 'departmentname',group_concat(c.groupId) as 'groups',group_concat(concat(d.countryId, '|', d.provinceId, '|', d.cityId,'|',d.shippingpolicyId,'|',d.productquantity)) as locations from $table_name a LEFT JOIN $table_name2 b on a.departmentId = b.id left join $table_name3 c on a.id = c.productId left join $table_name4 d on a.id = d.productId left join $table_name5 e on a.currencyId = e.id WHERE a.id = " . $productid . " group by a.id");
                return json_encode($result);
            }
        }
        return '';
    }
?>
<?php get_header(); ?>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', '<?php echo empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"])?'':esc_html($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"]); ?>');
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
<noscript>Your browser does not support JavaScript! Please enable Javascript in your browser and refresh the page!</noscript>
<style>
div#dragonecommerce_wrap div#dragonecommerce_product > div div.product-details-container {
    height: <?php echo empty($settings["DESKTOP_PRODUCT_IMAGE_SIZE"])?'300':esc_html($settings["DESKTOP_PRODUCT_IMAGE_SIZE"]); ?>px !important;
}
@media only screen and (max-width: 767px) and (orientation: portrait){
    div#dragonecommerce_wrap div#dragonecommerce_product > div  div.product-details-container {
        height: <?php echo empty($settings["CELLPHONE_PRODUCT_IMAGE_SIZE"])?'200':esc_html($settings["CELLPHONE_PRODUCT_IMAGE_SIZE"]); ?>px !important;
    }    
}
@media only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait){
    div#dragonecommerce_wrap div#dragonecommerce_product > div  div.product-details-container {
        height: <?php echo empty($settings["TABLET_PRODUCT_IMAGE_SIZE"])?'300':esc_html($settings["TABLET_PRODUCT_IMAGE_SIZE"]); ?>px !important;
    }    
}
</style>
<script>
    var ajaxurl = "<?php echo esc_html(admin_url('admin-ajax.php')); ?>";
    var jsurl3 = "<?php echo plugins_url('js/dragonecommercereserve.js?a=' . date('Ymd'), __FILE__ );  ?>";       
    var mediumdialog, largedialog = null;
    var dragonecommercereservezyx987_addproductlocationarray = [], dragonecommercereservezyx987_editproductlocationarray = [], dragonecommercereservezyx987_addshippingpolicylocationarray = [], dragonecommercereservezyx987_addtaxlocationarray = [];
    var mediummodalElementContainer = "<div id='mymediummodal' data-bs-backdrop='static' data-bs-keyboard='false' style='display:none;' title=''></div>";        
    var mediummodalCookiePolicyContainer = "<div id='mymediumcookiemodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' title='' role='dialog'></div>";
    var largemodalElementContainer = "<div id='mylargemodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalImageContainer = "<div id='mylargeimagemodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='opacity:1;z-index:2000 !important;overflow:auto;background-color: rgba(0,0,0,0.9);width:100% !important;height:100% !important;padding:100px 0px 0px 0px !important;margin-bottom:100px !important;' title='' role='dialog'><button type='button' id='mylargeimagemodal_close' class='mylargeimagemodal_close' aria-label='close the pop up window' tabindex=0'>&times;</button><img class='modal-content' alt='image inside a modal' id='mylargeimagemodal_img01' src=''><div style='clear:both;height: 200px;'></div><br/><br/></div>"; 
    var largemodalShoppingcartContainer = "<div id='mylargeshoppingcartmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalSearchContainer = "<div id='mylargesearchmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalCheckoutContainer = "<div id='mylargecheckoutmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalLoginContainer = "<div id='mylargeloginmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalRegisterContainer = "<div id='mylargeregistermodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalForgetpasswordContainer = "<div id='mylargeforgetpasswordmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalResetpasswordusingtokenContainer = "<div id='mylargeresetpasswordusingtokenmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalAccountactivationContainer = "<div id='mylargeaccountactivationmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalEcommercemenuContainer = "<div id='mylargeecommercemenumodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var largemodalDashboardContainer = "<div id='mylargedashboardmodal' data-bs-backdrop='static' data-bs-keyboard='false' class='modal fade' style='background-color:white;min-width:100% !important;width:100% !important;height:100% !important;overflow:auto;padding:0px !important;' title='' role='dialog'></div>";
    var mymediummodal, mymediumcookiemodal, mylargemodal, mylargeimagemodal, mylargeshoppingcartmodal, mylargesearchmodal, mylargecheckoutmodal, mylargeloginmodal, mylargeregistermodal, mylargeforgetpasswordmodal, mylargeresetpasswordusingtokenmodal, mylargeaccountactivationmodal, mylargeecommercemenumodal, mylargedashboardmodal;    
    var pluginurl = "<?php $protocol = is_ssl() ? 'https://' : 'http://'; $urlparts = wp_parse_url(home_url()); $protocol = esc_html($urlparts['scheme']) . '://'; $domain = esc_html($urlparts['host']); $myurl = strtok($protocol . $domain . esc_html($_SERVER['REQUEST_URI']), '?'); if(substr($myurl, -1) === '/') {$myurl = substr($myurl, 0, -1);} echo esc_html($myurl); ?>";
    var slideIndex = 0;
    var shoppingcartitems = <?php echo ($_COOKIE === null || empty($_COOKIE['dragonecommercereservezyx987_orderitems'])) ? '[]' : urldecode(stripslashes(sanitize_text_field($_COOKIE['dragonecommercereservezyx987_orderitems']))); ?>;
    var dragonecommercereservezyx987_addOrderByBraintreeByAjax_nonce = "<?php echo wp_create_nonce('dragonecommercereservezyx987_addOrderByBraintreeByAjax'); ?>";    
    var deviceDataFromTheClient = '';    
    var b1n9j5t7R9P1 = <?php $current_user = wp_get_current_user(); echo $current_user->data->ID === null ? 0 : $current_user->data->ID; ?>;
    var b1n9j5t7R9P2 = <?php $temp_user = json_decode($_SESSION["dragonecommercereservezyx987_user"], true); $temp_data = empty($temp_user) ? array() : (empty($temp_user["data"]) ? array() : $temp_user["data"]); echo empty($temp_data) ? 0 : (empty($temp_data["ID"]) ? 0 : esc_html(sanitize_text_field($temp_data["ID"])));  ?>;
    var oneproductoptions = [];
    var oneproductdetails = [];
    var shippingArr = [], handlingArr = [], taxArr = [];
    var taxrate = 0, taxincludeshipping = 0, taxincludehandling = 0;
    var discountArr = [], couponArr = [];
    var settings =  <?php echo json_encode($settings);  ?>;
    var currencysign = '';
    var amountperpage = <?php echo intval($amountperpage); ?>;
    var minsearchprice = <?php echo intval($MIN_SEARCH_PRICE); ?>;
    var maxsearchprice = <?php echo intval($MAX_SEARCH_PRICE); ?>;
    var minsearchpricedefault = minsearchprice;
    var maxsearchpricedefault = maxsearchprice;
    var slider1value = 0;
    var slider2value = 0;    
    var pg_onload = <?php echo intval($pagenumber); ?>;
    var st_onload = "<?php echo esc_html($mysortby); ?>";
    var o_onload = "<?php echo esc_html($myorder);  ?>";
    var a_onload = "<?php echo intval($amountperpage); ?>";
    var mysearch_onload = "<?php echo esc_html($searchwords); ?>";
    var did_onload = "<?php echo ($departmentid === 0) ? '' : intval($departmentid); ?>";
    var minp_onload = <?php echo intval($minprice); ?>;
    var maxp_onload = <?php echo intval($maxprice); ?>;
    var totalpagenumber_onload = <?php echo $amountperpage === 0 ? 1 : ceil($total / $amountperpage); ?>; 
    var USER_ORDER_ITEMS_PER_PAGE_PRESET_VALUE = '10', totalpagenumber_onload_user_order = 1;
    var taxid = 0;
    var searchIsReset = false;
    if(settings.length ===0) {
        alert("Setting is empty. Please contact web admin.");
    }
    
    function dragonecommercereservezyx987_getCookie(name) {
        var nameString = name + "=";
        //console.log("at 368, cookies: " + document.cookie);
        var cookieArr = document.cookie.split(';');
        for(var i=0;i < cookieArr.length;i++) {
            var c = cookieArr[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameString) == 0) return c.substring(nameString.length,c.length);
        }
        return null;
    }

    function dragonecommercereservezyx987_browserSupportsLocalStorage(){
        var e,a;a="81b5be350fdf6bfd8a350e4de9e8ec75";
        try{localStorage.setItem(a,a);localStorage.removeItem(a);return true;}catch(e){e;return false;}
    }
    
    function dragonecommercereservezyx987_eraseCookie(name) {   
        document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
    }
    
    function dragonecommercereservezyx987_isEnterSpaceEvent(event) {
        if(event.type === 'keydown') {
            var code = event.charCode || event.keyCode;
            if(code === 32 || code === 13) {
                event.preventDefault();
                return true;
            }            
        }
        return false;    
    }
    
    function dragonecommercereservezyx987_isClickEnterSpaceEvent(event) {
        if(event.type === 'click') {
            return true;
        } else if(event.type === 'keydown') {
            var code = event.charCode || event.keyCode;
            if(code === 32 || code === 13) {
                event.preventDefault();
                return true;
            }            
        }
        return false;    
    }
    
    function dragonecommercereservezyx987_showResultOnReloadedPage(type, pagenumber) {
        //search keyword should be urlencoded, remove &, can only be a-z, A-Z, 0-9, space,:/()$@?![]{}#%^*+=|~<>
        var mydata = {}, temp1 = '';
        mydata['pg'] = pagenumber ? pagenumber : 1;    
        mydata['st'] = 'name';
        mydata['o'] = 'asc';
        var sortby = jQuery("select#sortby").val();
        
        if(sortby === 'id|asc') {
            mydata['st'] = 'id';
            mydata['o'] = 'asc';                  
        } else if(sortby === 'id|desc') {
            mydata['st'] = 'id';
            mydata['o'] = 'desc';                    
        } else if(sortby === 'name|asc') {
            mydata['st'] = 'name';
            mydata['o'] = 'asc';                  
        } else if(sortby === 'name|desc') {
            mydata['st'] = 'name';
            mydata['o'] = 'desc';                  
        } else if(sortby === 'price|asc') {
            mydata['st'] = 'price';
            mydata['o'] = 'asc';                  
        } else if(sortby === 'price|desc') {
            mydata['st'] = 'price';
            mydata['o'] = 'desc';                  
        }          
        mydata['a'] = jQuery("select#amountperpage").val();          
        mydata['a'] = (mydata['a'] === '-1' || mydata['a'] === '0' || mydata['a'] === '') ? '40' : mydata['a'];          
        var searchword = jQuery('input#searchname').val();
        mydata['mysearch'] = (searchword === undefined || searchword === null) ? '' : searchword.replace(/[^a-zA-Z0-9\/()$@?!\[\]{}#%^*+|~]/g, '%');
        mydata['did'] = jQuery('select#searcharea').val();
          
        var minp_temp = jQuery("div#searchpricerange").slider("values", 0);
        mydata['minp'] = (minp_temp !== parseInt(minp_temp, 10)) ? 0 : parseInt(minp_temp);
          
        var maxp_temp = jQuery("div#searchpricerange").slider("values", 1);
        mydata['maxp'] = (maxp_temp !== parseInt(maxp_temp, 10)) ? 0 : parseInt(maxp_temp);

        var str = jQuery.param(mydata);
        var mytemp = window.location.href.split('?');
        if((jQuery("select#amountperpage").val() === '-1' || jQuery("select#amountperpage").val() === a_onload) && sortby === 'id|asc' && pagenumber === 1 && searchword === '' && 
           (jQuery('select#searcharea').val() === '' || jQuery('select#searcharea').val() === '-1') && 
           parseInt(minp_temp) === minsearchpricedefault && parseInt(maxp_temp) === maxsearchpricedefault) {
            searchIsReset = true;
        } else {
            searchIsReset = false;
        }
        if(searchIsReset) {
            window.location.href = mytemp[0];            
        } else {
            window.location.href = mytemp[0] + '?' + str;
        }
    }
    
    function dragonecommercereservezyx987_showCartIconQuantity() {
        var currentquantity = shoppingcartitems.length;
        if(currentquantity > 0 ) {
            jQuery('div#dragonecommerce_ecommercemenu_container #shoppingcart span#cartquantity').text(currentquantity);
            jQuery('div#dragonecommerce_ecommercemenu_container #shoppingcart span#cartquantity_container').show();
            //jQuery('div#dragonecommerce_ecommercemenu_container #shoppingcart span#cartquantity_container').removeClass('hide');
        } else {
            jQuery('div#dragonecommerce_ecommercemenu_container #shoppingcart span#cartquantity_container').hide();
            //jQuery('div#dragonecommerce_ecommercemenu_container #shoppingcart span#cartquantity_container').addClass('hide');
            jQuery('div#dragonecommerce_ecommercemenu_container #shoppingcart span#cartquantity').text('');
        }        
    }

    function dragonecommercereservezyx987_showEcommerceMenuHandler(event) {
        if(dragonecommercereservezyx987_isEnterSpaceEvent(event) === true) {
            dragonecommercereservezyx987_showEcommerceMenu();
        }
    }
    
    function dragonecommercereservezyx987_showEcommerceMenu(showModal = true) {
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';    
        modalElement += '<form id="dragonecommercereservezyx987_ecommercemenu" target="_self" method="post" autocomplete="off" onsubmit="return false">';                        
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close the pop up window" tabindex="0"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';        
        modalElement += '<div id="dragonecommerce_ecommercemenu_container" class="row">';        
        modalElement += '<div class="ecommercemenu-container col-12 col-sm-12 col-md-6 col-lg-6"><div class="row-container"><div class="ecommercemenu-details-container row">';
        modalElement += "<div class='ecommercemenu-content col-12 col-sm-12 col-md-6 col-lg-6'>";
        
        modalElement += 'Ecommerce Menu<br/>';
                
        <?php global $user_ID;if ($user_ID) { ?>
            modalElement += '<a id="userprofile"  role="button" tabindex="0"  class="menuitem userprofile" ><span class="fs-1 bi bi-person"></span><span id="userprofile_username">You are logged in as <?php $myuser = wp_get_current_user(); echo sanitize_text_field($myuser->user_login); ?></span></a><br/>';
            //log out button
            modalElement += '<a id="logout" aria-label="log out"  class="menuitem logout" tabindex="0" onclick="dragonecommercereservezyx987_logoutUserBySubmitForm();"><span class="fs-1 bi bi-box-arrow-right"></span><span id="userprofile_logout">Log out</span></a><br/>';
        <?php } else { ?>
            modalElement += '<a id="login" class="menuitem login" tabindex="0" onclick="dragonecommercereservezyx987_goToLogin();"><span class="fs-1 bi bi-person"></span><span id="userprofile_username">Log in</span></a><br/>';
        <?php } ?>
        
        modalElement += '<a id="shoppingcart" class="menuitem shoppingcart" tabindex="0" onclick="dragonecommercereservezyx987_goToShoppingcart();"><span class="fs-1 bi bi-cart"></span><span id="cartquantity_container"><span id="cartquantity"></span></span><span>Shopping Cart</span></a><br/>';
        modalElement += '<div class="row">';
        modalElement += '    <div id="dragonecommerce_search_container" class="col-12 col-sm-12 col-md-12 col-lg-12">';
        modalElement += '        <label id="searchnamelabel" for="searchname">Search:</label>';
        modalElement += '        <input id="searchname" aria-labelledby="searchnamelabel" name="searchname"  role="button" tabindex="0"  class="form-control input empty" type="text" placeholder="Search word" value="" />';
        modalElement += '        <label for="searcharea">Department:</label>';
        modalElement += '        <select name="searcharea" id="searcharea"  role="button" tabindex="0"  class="form-select form-select-lg" >';
        modalElement += '            <option value="" >Please choose one...</option>';
        <?php foreach ($activedepartments as $department) { ?>
        <?php $temp_dept_name = str_replace('"','\"',$department->name);  ?>
        modalElement += '            <option value="' + <?php echo intval($department->id); ?> + '" >' + "<?php echo esc_html($temp_dept_name); ?>" + '</option>';
        <?php } ?>           
        modalElement += '         </select>';
        modalElement += '        <label for="searchprice">Price range:</label>';
        modalElement += '       <input type="text" id="searchprice" readonly style="border:0; color:blue; font-weight:bold;">';
        modalElement += '        <div id="searchpricerange"  role="button" tabindex="0" ></div><br/>';
                
        modalElement += '        <input id="searchproduct" name="searchproduct"  role="button" tabindex="0"  class="form-control input empty" type="button" value="Search" onclick="dragonecommercereservezyx987_searchProducts();" /><br/><br/>';
        modalElement += '        <input id="resetsearch" name="resetsearch"  role="button" tabindex="0"  class="form-control reset input empty" type="button" value="Reset" onclick="dragonecommercereservezyx987_resetSearchContainer();" />';
        modalElement += '    </div>';
        modalElement += '</div>';

        
        modalElement += '</div>';
        modalElement += '</div></div></div>';
        modalElement += "<input type='hidden' name='dragonecommercereservezyx987_ecommercemenu_token' id='dragonecommercereservezyx987_ecommercemenu_token' value='' />";        
        modalElement += '</div>';            
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';
        //modalElement += '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close the pop up window" tabindex="0"></button>';
        //modalElement += '</div>';    

        modalElement += '</form>';
        
        <?php global $user_ID;if ($user_ID) { ?>
            modalElement += '<form id="dragonecommercereservezyx987_logout_form" class="form_logout" target="_self" method="post" autocomplete="off" ></form>';
        <?php } ?>
                
        modalElement += '</div></div>';
        
        modalElement += '<script>';
        modalElement += 'jQuery(document).ready(function(){';
        modalElement += '    jQuery("div#searchpricerange").slider({';
        modalElement += '      range: true,';
        modalElement += '      min: minsearchprice,';
        modalElement += '      max: maxsearchprice,';
        modalElement += '      values: [ minsearchpricedefault, maxsearchpricedefault ],';
        modalElement += '      slide: function(event, ui) {';
        modalElement += '        jQuery("input#searchprice").val(ui.values[0] + " - " + ui.values[1] );';
        modalElement += '      }';
        modalElement += '    });';                                    
        modalElement += "    jQuery('input#searchname').val(mysearch_onload);";
        modalElement += "    jQuery('select#searcharea').val(did_onload);";
        modalElement += '    slider1value = minsearchpricedefault;';
        modalElement += '    slider2value = maxsearchpricedefault;';
        modalElement += '    if(minp_onload !== -1) {slider1value = minp_onload;}';
        modalElement += '    if(maxp_onload !== -1) {slider2value = maxp_onload;}';
        modalElement += '    jQuery("div#searchpricerange").slider("option","values", [slider1value, slider2value ] );';
        modalElement += '    jQuery("input#searchprice").val(jQuery("div#searchpricerange").slider("values", 0) + " - " + jQuery("div#searchpricerange").slider("values", 1));';
        modalElement += '    dragonecommercereservezyx987_refreshLandingpageLeftTabMenu_onPageLoad();jQuery("input#searchname").focus();';
        modalElement += '});';
        modalElement += '<\/script>';
        jQuery('div#mylargeecommercemenumodal').html(modalElement);

        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        
        //show forget password modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery('div#mylargecheckoutmodal').hide();
        //jQuery('div#mylargecheckoutmodal').addClass('hide');
        jQuery('div#mylargecheckoutmodal').html('');
        jQuery('div#mylargesearchmodal').hide();
        //jQuery('div#mylargesearchmodal').addClass('hide');
        jQuery('div#mylargesearchmodal').html('');    
        jQuery('div#mylargeshoppingcartmodal').hide();
        //jQuery('div#mylargeshoppingcartmodal').addClass('hide');
        jQuery('div#mylargeshoppingcartmodal').html('');
        jQuery('div#mylargeloginmodal').hide();
        //jQuery('div#mylargeloginmodal').addClass('hide');
        jQuery('div#mylargeloginmodal').html('');                
        jQuery('div#mylargeregistermodal').hide();
        //jQuery('div#mylargeregistermodal').addClass('hide');
        jQuery('div#mylargeregistermodal').html('');
        jQuery('div#mylargeforgetpasswordmodal').hide();
        //jQuery('div#mylargeforgetpasswordmodal').addClass('hide');
        jQuery('div#mylargeforgetpasswordmodal').html('');
        jQuery('div#mylargedashboardmodal').hide();
        //jQuery('div#mylargedashboardmodal').addClass('hide');
        jQuery('div#mylargedashboardmodal').html('');        
        jQuery('div#mylargeaccountactivationmodal').hide();
        //jQuery('div#mylargeaccountactivationmodal').addClass('hide');
        jQuery('div#mylargeaccountactivationmodal').html('');
        jQuery('div#mylargeresetpasswordusingtokenmodal').hide();
        //jQuery('div#mylargeresetpasswordusingtokenmodal').addClass('hide');
        jQuery('div#mylargeresetpasswordusingtokenmodal').html('');
        jQuery('div#mymediumcookiemodal').hide();
        //jQuery('div#mymediumcookiemodal').addClass('hide');
        jQuery('div#mymediumcookiemodal').html('');
        mylargeecommercemenumodal = new bootstrap.Modal(document.getElementById('mylargeecommercemenumodal'));
        if(showModal) {mylargeecommercemenumodal.show();}
        jQuery("div#mylargeecommercemenumodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeecommercemenumodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);

        dragonecommercereservezyx987_showCartIconQuantity();            
    }
    
    //refresh landing page left tab menu color               
    function dragonecommercereservezyx987_refreshLandingpageLeftTabMenu_onPageLoad() {
        if(shoppingcartitems.length > 0) {
            jQuery("div#ecommercetabmenu span#glyphicon_shopping_cart").css('color', 'black');
        } else {
            jQuery("div#ecommercetabmenu span#glyphicon_shopping_cart").css('color', 'white');
        }
        //refresh search icon color
        var temp_searchname = jQuery('input#searchname').val();
        var temp_searcharea = jQuery('select#searcharea').val();
        var temp_minp = slider1value === minsearchpricedefault;
        var temp_maxp = slider2value === maxsearchpricedefault;
        if( temp_minp === true && temp_maxp === true &&
            temp_searchname === '' && temp_searcharea === '') {
            jQuery("div#ecommercetabmenu span#glyphicon_search").css('color', 'white');
        } else {
            jQuery("div#ecommercetabmenu span#glyphicon_search").css('color', 'black'); 
        }
    }
    
    function dragonecommercereservezyx987_validString(mystring) {
        if(typeof mystring === 'undefined' || mystring === null) {
            return '';
        }
        if (typeof mystring === 'string') {
            return mystring
             .replace(/&/g, "&amp;")
             .replace(/</g, "&lt;")
             .replace(/>/g, "&gt;")
             .replace(/"/g, "&quot;")
             .replace(/'/g, "&#039;");
        } else {
            return mystring; 
        }
    }
    
    function dragonecommercereservezyx987_closeMylargeecommercemenumodal() {
        if(mylargeecommercemenumodal !== null) {
            mylargeecommercemenumodal.hide();
        }
    }
    
    jQuery(document).ready(function(){    
        //add cookie banner
        var cookie_consent_status = '';
        if (typeof window.localStorage !== 'undefined' && dragonecommercereservezyx987_browserSupportsLocalStorage()) {
            var cc = window.localStorage.getItem("DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE");
            cookie_consent_status = cc === null ? '' : cc;    
            if(cookie_consent_status === '') {
                //visitor did not set cookie consent or it's the first time visit
                //show cookie consent popup for visitor to choose
                var cookieBanner  = '<div id="dragonecommerce-consentPrompt-container">';
                    cookieBanner += '    <div>';
                    cookieBanner += '         <div id="dragonecommerce-consentPrompt">';
                    cookieBanner += '             <div id="dragonecommerce-styles-main">';
                    cookieBanner += '                <div id="dragonecommerce-styles-content">';
                    cookieBanner += '                    <div id="dragonecommerce-styles-message-container">';
                    cookieBanner += '                        <span id="dragonecommerce-styles-message1">We use cookies to improve user experience, and analyze website traffic. For these reasons, we may share your site usage data with our analytics partners. By clicking “Accept”, you consent to store on your device all the technologies described in our </span>';
                    cookieBanner += '                        <a id="dragonecommerce-cookiepolicylink" href="' + "<?php echo plugins_url('files/cookiepolicy.pdf', __FILE__ ); ?>" + '" target="_blank">Cookie Policy</a>';
                    cookieBanner += '                        <span id="dragonecommerce-styles-message2">. You can change your cookie settings at any time by clicking “';
                    cookieBanner += '                            <span id="dragonecommerce-preferenceslink" role="button" tabindex="0" onclick="dragonecommercereservezyx987_goToCookiePolicyModal();">Cookie Preferences</span>.”';
                    cookieBanner += '                        </span>';
                    cookieBanner += '                    </div>';
                    cookieBanner += '                    <div id="dragonecommerce-styles-buttons">';
                    cookieBanner += '                        <div id="dragonecommerce-preference-button-container">';
                    cookieBanner += '                            <button tabindex="0" id="dragonecommerce-preference-button" onclick="dragonecommercereservezyx987_goToCookiePolicyModal();">Preferences</button>';
                    cookieBanner += '                        </div>';
                    cookieBanner += '                        <div id="dragonecommerce-acceptall-button-container">';
                    cookieBanner += '                            <button role="button" tabindex="0" id="dragonecommerce-acceptall-button">Accept</button>';
                    cookieBanner += '                        </div>';
                    cookieBanner += '                    </div>';
                    cookieBanner += '                </div>';
                    cookieBanner += '            </div>';
                    cookieBanner += '        </div>';
                    cookieBanner += '    </div>';
                    cookieBanner += '</div>';                
                jQuery('div#dragonecommerce_product_container').append(cookieBanner);            
            } else {//user already set localstorage                
                <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1 && (!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"]))) { ?>
                var consentArr = [];
                consentArr = cookie_consent_status.split("|");
                if(jQuery.inArray( "analytics", consentArr ) !== -1) {
                    (function () {
                        var s = document.createElement('script');
                        s.type = 'text/javascript';
                        s.async = true;
                        s.src = "https://www.googletagmanager.com/gtag/js?id=" + "<?php echo empty($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID'])?'':sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                        //s.id = '9598d17a-6c78-437c-83a3-52d50ae899fd';
                        //s.setAttribute("data-name", "dragonecommerce-embed-banner");
                        //var x = document.getElementsByTagName('script')[0];
                        //x.parentNode.insertBefore(s, x);
                        document.getElementsByTagName('head')[0].appendChild(s);
                    })();                
                } else {//remove google analytics cookie from browser
                    dragonecommercereservezyx987_eraseCookie("_ga");
                    <?php if(!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"])) { ?>
                        var gaid = "<?php echo sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                        var gaidArr = gaid.split("-");
                        var temp = gaidArr.length <= 1 ? '' : gaidArr[gaidArr.length - 1];
                        if(temp !== '') {
                            dragonecommercereservezyx987_eraseCookie("_ga_" + temp);
                        }
                    <?php } ?>
                }
                <?php } ?>                
            }
        } else {//if localStorage is not supported, fall back to cookie storage
            var cc = dragonecommercereservezyx987_getCookie("DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE");
            cookie_consent_status = cc === null ? '' : cc;
            //console.log("at 739, cookie_consent_status: " + cookie_consent_status);
            if(cookie_consent_status === '') {
                //visitor did not set cookie consent or it's the first time visit
                //show cookie consent popup for visitor to choose
                var cookieBanner  = '<div id="dragonecommerce-consentPrompt-container">';
                    cookieBanner += '    <div>';
                    cookieBanner += '         <div id="dragonecommerce-consentPrompt">';
                    cookieBanner += '             <div id="dragonecommerce-styles-main">';
                    cookieBanner += '                <div id="dragonecommerce-styles-content">';
                    cookieBanner += '                    <div id="dragonecommerce-styles-message-container">';
                    cookieBanner += '                        <span id="dragonecommerce-styles-message1">We use cookies to improve user experience, and analyze website traffic. For these reasons, we may share your site usage data with our analytics partners. By clicking “Accept”, you consent to store on your device all the technologies described in our </span>';
                    cookieBanner += '                        <a id="dragonecommerce-cookiepolicylink" href="' + "<?php echo plugins_url('files/cookiepolicy.pdf', __FILE__ ); ?>" + '" target="_blank">Cookie Policy</a>';
                    cookieBanner += '                        <span id="dragonecommerce-styles-message2">. You can change your cookie settings at any time by clicking “';
                    cookieBanner += '                            <span id="dragonecommerce-preferenceslink" role="button" tabindex="0" onclick="dragonecommercereservezyx987_goToCookiePolicyModal();">Cookie Preferences</span>.”';
                    cookieBanner += '                        </span>';
                    cookieBanner += '                    </div>';
                    cookieBanner += '                    <div id="dragonecommerce-styles-buttons">';
                    cookieBanner += '                        <div id="dragonecommerce-preference-button-container">';
                    cookieBanner += '                            <button id="dragonecommerce-preference-button" tabindex="0" onclick="dragonecommercereservezyx987_goToCookiePolicyModal();">Preferences</button>';
                    cookieBanner += '                        </div>';
                    cookieBanner += '                        <div id="dragonecommerce-acceptall-button-container">';
                    cookieBanner += '                            <button id="dragonecommerce-acceptall-button">Accept</button>';
                    cookieBanner += '                        </div>';
                    cookieBanner += '                    </div>';
                    cookieBanner += '                </div>';
                    cookieBanner += '            </div>';
                    cookieBanner += '        </div>';
                    cookieBanner += '    </div>';
                    cookieBanner += '</div>';                
                jQuery('div#dragonecommerce_product_container').append(cookieBanner);
            } else {
                <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1 && (!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"]))) { ?>
                var consentArr = [];
                consentArr = cookie_consent_status.split("|");
                if(jQuery.inArray( "analytics", consentArr ) !== -1) {
                    //allow google analytics
                    (function () {
                        var s = document.createElement('script');
                        s.type = 'text/javascript';
                        s.async = true;
                        s.src = "https://www.googletagmanager.com/gtag/js?id=" + "<?php echo empty($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID'])?'':sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                        //s.id = '9598d17a-6c78-437c-83a3-52d50ae899fd';
                        //s.setAttribute("data-name", "dragonecommerce-embed-banner");
                        //var x = document.getElementsByTagName('script')[0];
                        //x.parentNode.insertBefore(s, x);
                        document.getElementsByTagName('head')[0].appendChild(s);
                    })();                
                } else {//remove google analytics cookie from browser
                    dragonecommercereservezyx987_eraseCookie("_ga");
                    <?php if(!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"])) { ?>
                        var gaid = "<?php echo sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                        var gaidArr = gaid.split("-");
                        var temp = gaidArr.length <= 1 ? '' : gaidArr[gaidArr.length - 1];
                        if(temp !== '') {
                            dragonecommercereservezyx987_eraseCookie("_ga_" + temp);
                        }
                    <?php } ?>            
                }
                <?php } ?>
            }            
        }
        
        //ecommerce menu position
        if(jQuery('header#site-header').length) {
            var headerheight = jQuery('header#site-header').height();
            jQuery('div#ecommercetabmenu').css('top', '' + (headerheight + 5) + 'px');
            jQuery('div#ecommercetabmenu-toggle-button-container').css('top', '' + (headerheight + 10) + 'px');            
        }
        
        jQuery("body").append(mediummodalElementContainer);
        jQuery('div#mymediummodal').html('');
        jQuery("body").append(mediummodalCookiePolicyContainer);
        jQuery('div#mymediumcookiemodal').html('');        
        jQuery("body").append(largemodalElementContainer);
        jQuery('div#mylargemodal').html('');
        jQuery("body").append(largemodalImageContainer);
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery("body").append(largemodalSearchContainer);
        jQuery('div#mylargesearchmodal div#mycontent').html('');
        jQuery("body").append(largemodalShoppingcartContainer);
        jQuery('div#mylargeshoppingcartmodal div#mycontent').html('');        
        jQuery("body").append(largemodalCheckoutContainer);        
        jQuery('div#mylargecheckoutmodal div#mycontent').html('');
        
        jQuery("body").append(largemodalLoginContainer);        
        jQuery('div#mylargeloginmodal div#mycontent').html('');
        jQuery("body").append(largemodalRegisterContainer);        
        jQuery('div#mylargeregistermodal div#mycontent').html('');
        jQuery("body").append(largemodalForgetpasswordContainer);        
        jQuery('div#mylargeforgetpasswordmodal div#mycontent').html('');
        
        jQuery("body").append(largemodalResetpasswordusingtokenContainer);        
        jQuery('div#mylargeresetpasswordusingtokenmodal div#mycontent').html('');
        
        jQuery("body").append(largemodalAccountactivationContainer);        
        jQuery('div#mylargeaccountactivationmodal div#mycontent').html('');
        
        jQuery("body").append(largemodalEcommercemenuContainer);        
        jQuery('div#mylargeecommercemenumodal div#mycontent').html('');

        jQuery("body").append(largemodalDashboardContainer);        
        jQuery('div#mylargedashboardmodal div#mycontent').html('');
        
        var myCarousel = document.querySelector('#myCarousel')
        var carousel = new bootstrap.Carousel(myCarousel);
        
        jQuery('div.oneproduct_orderdetails').next().html('').hide();
        //jQuery('div.oneproduct_orderdetails').next().addClass('hide');
        jQuery('div.oneproduct_orderdetails').next().next().html('').hide();
        //jQuery('div.oneproduct_orderdetails').next().next().addClass('hide');
        
        jQuery('div#dragonecommerce_ecommercemenu_container div#shoppingcart span#cartquantity_container').hide();
        //jQuery('div#dragonecommerce_ecommercemenu_container div#shoppingcart span#cartquantity_container').addClass('hide');
        function getPHPSessId() {
            var phpSessionId = document.cookie.match(/PHPSESSID=[A-Za-z0-9]+\;/i);

            if(phpSessionId == null) 
                return '';

            if(typeof(phpSessionId) == 'undefined')
                return '';

            if(phpSessionId.length <= 0)
                return '';

            phpSessionId = phpSessionId[0];

            var end = phpSessionId.lastIndexOf(';');
            if(end == -1) end = phpSessionId.length;

            return phpSessionId.substring(10, end);
        }
        jQuery('span#phpsessionid').text(getPHPSessId());        

        jQuery('body').on('click', 'div#mylargeimagemodal button#mylargeimagemodal_close, div#mylargeimagemodal button#mylargeimagemodal_close2', function() {
            jQuery('div#mylargeimagemodal').hide();
            //jQuery('div#mylargeimagemodal').addClass('hide');
            jQuery('div#mylargeimagemodal img').attr('src', '');
        });

        jQuery('.modal').on('show.bs.modal', function (e) {});
        
        jQuery(window).resize(function() {
            jQuery("div#mylargemodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargemodal").css("width", jQuery(window).width());
            if(jQuery("div#mylargemodal").height() > jQuery(window).height()) {
                jQuery("div#mylargemodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargemodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargemodal").width() > jQuery(window).width()) {
                jQuery("div#mylargemodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargemodal").css("overflow-x", "auto");
            }
            
            jQuery("div#mylargeimagemodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeimagemodal").css("width", jQuery(window).width());
            jQuery("div#mylargeimagemodal").css("overflow", "auto");
            if(jQuery("div#mylargeimagemodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeimagemodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeimagemodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeimagemodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeimagemodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeimagemodal").css("overflow-x", "auto");
            }
            
            jQuery("div#mylargeshoppingcartmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeshoppingcartmodal").css("width", jQuery(window).width());
            jQuery("div#mylargeshoppingcartmodal").css("overflow", "auto");
            if(jQuery("div#mylargeshoppingcartmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeshoppingcartmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeshoppingcartmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeshoppingcartmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeshoppingcartmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeshoppingcartmodal").css("overflow-x", "auto");
            }
            
            jQuery("div#mylargecheckoutmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargecheckoutmodal").css("width", jQuery(window).width());
            jQuery("div#mylargecheckoutmodal").css("overflow", "auto");
            if(jQuery("div#mylargecheckoutmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargecheckoutmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargecheckoutmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargecheckoutmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargecheckoutmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargecheckoutmodal").css("overflow-x", "auto");
            }
                        
            jQuery("div#mylargeloginmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeloginmodal").css("width", jQuery(window).width());
            jQuery("div#mylargeloginmodal").css("overflow", "auto");
            if(jQuery("div#mylargeloginmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeloginmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeloginmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeloginmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeloginmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeloginmodal").css("overflow-x", "auto");
            }
                        
            jQuery("div#mylargeregistermodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeregistermodal").css("width", jQuery(window).width());
            jQuery("div#mylargeregistermodal").css("overflow", "auto");
            if(jQuery("div#mylargeregistermodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeregistermodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeregistermodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeregistermodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeregistermodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeregistermodal").css("overflow-x", "auto");
            }
                        
            jQuery("div#mylargeforgetpasswordmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeforgetpasswordmodal").css("width", jQuery(window).width());
            jQuery("div#mylargeforgetpasswordmodal").css("overflow", "auto");
            if(jQuery("div#mylargeforgetpasswordmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeforgetpasswordmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeforgetpasswordmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeforgetpasswordmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeforgetpasswordmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeforgetpasswordmodal").css("overflow-x", "auto");
            }
            
            jQuery("div#mylargeresetpasswordusingtokenmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeresetpasswordusingtokenmodal").css("width", jQuery(window).width());
            jQuery("div#mylargeresetpasswordusingtokenmodal").css("overflow", "auto");
            if(jQuery("div#mylargeresetpasswordusingtokenmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeresetpasswordusingtokenmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeresetpasswordusingtokenmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeresetpasswordusingtokenmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeresetpasswordusingtokenmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeresetpasswordusingtokenmodal").css("overflow-x", "auto");
            }
            
            jQuery("div#mylargeaccountactivationmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeaccountactivationmodal").css("width", jQuery(window).width());
            jQuery("div#mylargeaccountactivationmodal").css("overflow", "auto");
            if(jQuery("div#mylargeaccountactivationmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeaccountactivationmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeaccountactivationmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeaccountactivationmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeaccountactivationmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeaccountactivationmodal").css("overflow-x", "auto");
            }
                        
            jQuery("div#mylargesearchmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargesearchmodal").css("width", jQuery(window).width());
            jQuery("div#mylargesearchmodal").css("overflow", "auto");
            if(jQuery("div#mylargesearchmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargesearchmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargesearchmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargesearchmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargesearchmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargesearchmodal").css("overflow-x", "auto");
            }
            
            jQuery("div#mylargeecommercemenumodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargeecommercemenumodal").css("width", jQuery(window).width());
            jQuery("div#mylargeecommercemenumodal").css("overflow", "auto");
            if(jQuery("div#mylargeecommercemenumodal").height() > jQuery(window).height()) {
                jQuery("div#mylargeecommercemenumodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargeecommercemenumodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargeecommercemenumodal").width() > jQuery(window).width()) {
                jQuery("div#mylargeecommercemenumodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargeecommercemenumodal").css("overflow-x", "auto");
            }

            jQuery("div#mylargedashboardmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("top", 0);
            jQuery("div#mylargedashboardmodal").css("width", jQuery(window).width());
            jQuery("div#mylargedashboardmodal").css("overflow", "auto");
            if(jQuery("div#mylargedashboardmodal").height() > jQuery(window).height()) {
                jQuery("div#mylargedashboardmodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mylargedashboardmodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mylargedashboardmodal").width() > jQuery(window).width()) {
                jQuery("div#mylargedashboardmodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mylargedashboardmodal").css("overflow-x", "auto");
            }

            /*jQuery("div#mymediumcookiemodal").parent().css("width", 0.3 * jQuery(window).width()).css("height", 0.8 * jQuery(window).height());  //.css("top", 0);
            jQuery("div#mymediumcookiemodal").css("width", 0.3 * jQuery(window).width());
            jQuery("div#mymediumcookiemodal").css("overflow", "auto");
            if(jQuery("div#mymediumcookiemodal").height() > 0.8 * jQuery(window).height()) {
                jQuery("div#mymediumcookiemodal").css("overflow-y", "scroll");
            } else {
                jQuery("div#mymediumcookiemodal").css("overflow-y", "auto");
            }
            if(jQuery("div#mymediumcookiemodal").width() > 0.3 * jQuery(window).width()) {
                jQuery("div#mymediumcookiemodal").css("overflow-x", "scroll");
            } else {
                jQuery("div#mymediumcookiemodal").css("overflow-x", "auto");
            }        */
        });    //end of jQuery(window).resize    
        jQuery("select").val('-1');
        jQuery("select#searcharea").val('');        
        jQuery(".dragonecommercereservezyx987_datetimepicker" ).datetimepicker({ format:'Y-m-d H:i' });
        
        var sortstring = st_onload + '|' + o_onload;
        jQuery('select#sortby').val(sortstring);
        jQuery("select#amountperpage").val(a_onload);
        
        // a - amount per page; o - order (asc, desc); p - page number; s - sortby
        function dragonecommercereservezyx987_createPagination(totalpagenumber, topagenumber) {
            if(totalpagenumber !== parseInt(totalpagenumber, 10) || topagenumber !== parseInt(topagenumber, 10)) {jQuery('div.master_pwrapper > div.master_mypagination').html('');return;}
            var temp = '<ul class="pagination">',i;
            if(topagenumber > totalpagenumber) {topagenumber = 1;totalpagenumber=1;}            
            if(totalpagenumber < 7) {
                if(topagenumber===1) {
                    temp += '<li class="page-item disabled"><a class="page-link" aria-label="previous page, button is disabled" role="img" ><span aria-hidden="true">&laquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item prev"><a class="page-link" tabindex="0"  aria-label="previous page" role="img" ><span aria-hidden="true">&laquo;</span></a></li>';                    
                }
                for(i=1;i<=totalpagenumber;i++) {
                    temp += '<li' + (topagenumber===i ? ' class="page-item active" ' : ' class="page-item" ') + '><a class="page-link" role="button" tabindex="0" >' + i + '</a></li>';
                }
                if(topagenumber===totalpagenumber) {
                    temp += '<li class="page-item disabled"><a class="page-link" aria-label="next page, button is disabled" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item next"><a class="page-link" tabindex="0" aria-label="next page" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';                     
                }
            } else if(topagenumber < 4) {
                if(topagenumber===1) {
                    temp += '<li class="page-item disabled"><a class="page-link" aria-label="previous page, button is disabled" role="img" ><span aria-hidden="true">&laquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item prev"><a class="page-link" tabindex="0" aria-label="previous page" role="img" ><span aria-hidden="true">&laquo;</span></a></li>';                    
                }
                for(i=1;i<=5;i++) {
                    temp += '<li' + (topagenumber===i ? ' class="page-item active" ' : ' class="page-item" ') + '><a class="page-link" role="button" tabindex="0" >' + i + '</a></li>';
                }
                temp += ((totalpagenumber - topagenumber) > 3) ? '<li class="page-item noborder"><a class="page-link" >...</a></li>' : '';
                if(topagenumber===totalpagenumber) {
                    temp += '<li class="page-item active" ><a class="page-link" role="button" tabindex="0" >' + totalpagenumber + '</a></li><li class="page-item disabled"><a class="page-link" aria-label="next page, button is disabled" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item"><a class="page-link" role="button" tabindex="0" >' + totalpagenumber + '</a></li><li class="page-item next"><a class="page-link" tabindex="0" aria-label="next page" role="img"><span aria-hidden="true">&raquo;</span></a></li>';                    
                }
            } else if(topagenumber < (totalpagenumber - 2)) {
                if(topagenumber===1) {
                    temp += '<li class="page-item disabled"><a class="page-link" aria-label="previous page, button is disabled" role="img" ><span aria-hidden="true">&laquo;</span></a></li><li class="page-item active" ><a class="page-link" role="img" tabindex="0" >1</a></li>';
                } else {
                    temp += '<li class="page-item prev"><a class="page-link" role="img" tabindex="0" ><span aria-hidden="true">&laquo;</span></a></li><li class="page-item"><a class="page-link" role="button" tabindex="0" >1</a></li>';                    
                }
                temp += (topagenumber > 4) ? '<li class="page-item noborder"><a class="page-link" >...</a></li>' : '';
                for(i=(topagenumber-2);i<=((topagenumber+2)>(totalpagenumber-1) ? (totalpagenumber-1) : (topagenumber+2));i++) {
                    temp += '<li' + (topagenumber===i ? ' class="page-item active" ' : ' class="page-item" ') + '><a class="page-link" role="button" tabindex="0" >' + i + '</a></li>';
                }
                temp += ((totalpagenumber - topagenumber) > 3) ? '<li class="page-item noborder"><a class="page-link" >...</a></li>' : '';
                if(topagenumber===totalpagenumber) {
                    temp += '<li class="page-item active" ><a class="page-link" role="button" tabindex="0" >' + totalpagenumber + '</a></li><li class="page-item disabled"><a class="page-link" aria-label="next page, button is disabled" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item"><a class="page-link" role="button" tabindex="0" >' + totalpagenumber + '</a></li><li class="page-item next"><a class="page-link" tabindex="0" aria-label="next page" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';                    
                }
            } else if(topagenumber >= (totalpagenumber - 2)) {
                if(topagenumber===1) {
                    temp += '<li class="page-item disabled"><a class="page-link" aria-label="previous page, button is disabled" role="img" ><span aria-hidden="true">&laquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item prev"><a class="page-link" tabindex="0" aria-label="previous page" role="img" ><span aria-hidden="true">&laquo;</span></a></li>';                    
                }
                temp += '<li' + (topagenumber===1 ? ' class="page-item active" ' : ' class="page-item" ') + '><a class="page-link" role="button" tabindex="0" >1</a></li>';
                temp += ((topagenumber - 1) > 3) ? '<li class="page-item noborder"><a class="page-link" >...</a></li>' : '';
                for(i=(totalpagenumber-4);i<=totalpagenumber;i++) {
                    temp += '<li' + (topagenumber===i ? ' class="page-item active" ' : ' class="page-item" ') + '><a class="page-link" role="button" tabindex="0" >' + i + '</a></li>';
                }
                if(topagenumber===totalpagenumber) {
                    temp += '<li class="page-item disabled"><a class="page-link" aria-label="next page, button is disabled" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';
                } else {
                    temp += '<li class="page-item next"><a class="page-link" tabindex="0" aria-label="next page" role="img" ><span aria-hidden="true">&raquo;</span></a></li>';                    
                }
            }
            temp += '</ul>';

            if(jQuery('div.master_pwrapper > div.master_mypagination').length > 0) {
                jQuery('div.master_pwrapper > div.master_mypagination').html(temp);
            }
        }

        dragonecommercereservezyx987_createPagination(totalpagenumber_onload, pg_onload);
        
        if(jQuery('div.master_pwrapper').length > 0) {            
            jQuery('div.master_pwrapper').on( 'click keydown', 'div.master_mypagination > ul.pagination > li:not(.noborder):not(.disabled)', function (event) {
                if(dragonecommercereservezyx987_isClickEnterSpaceEvent(event) === true) {
                    var topagenumber = isNaN(parseInt(jQuery(this).children().first().text())) ? 0 : parseInt(jQuery(this).children().first().text());
                    var currentpage;
                    if(jQuery(this).hasClass('prev')){
                        currentpage = isNaN(parseInt(jQuery('div.master_pwrapper > div.master_mypagination > ul.pagination > li.active > a').first().text())) ? 0 : parseInt(jQuery('div.master_pwrapper > div.master_mypagination > ul.pagination > li.active > a').first().text());
                        topagenumber = Math.max(1, (currentpage-1));
                    } else if (jQuery(this).hasClass('next')){ 
                        currentpage = isNaN(parseInt(jQuery('div.master_pwrapper > div.master_mypagination > ul.pagination > li.active > a').first().text())) ? 0 : parseInt(jQuery('div.master_pwrapper > div.master_mypagination > ul.pagination > li.active > a').first().text());
                        topagenumber = Math.min(totalpagenumber_onload, (currentpage+1));
                    }
                    dragonecommercereservezyx987_showResultOnReloadedPage('', topagenumber);
                }
            });
        }
        dragonecommercereservezyx987_showEcommerceMenu(false);
        
        //var myModalEl = document.querySelector('#mylargeecommercemenumodal')
        //mylargeecommercemenumodal = bootstrap.Modal.getOrCreateInstance(document.querySelector('#mylargeecommercemenumodal'));

        //mylargeecommercemenumodal.hide();
        //jQuery('div#mylargeecommercemenumodal').hide();
        //if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length > 0) { 
        //jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); 
        //}    
        
        if(jQuery('button#dragonecommerce-acceptall-button').length > 0) {
            jQuery('div#dragonecommerce_product_container').on('click', 'button#dragonecommerce-acceptall-button', function() {
                jQuery("div#dragonecommerce-consentPrompt-container").hide();
                if (typeof window.localStorage !== 'undefined' && dragonecommercereservezyx987_browserSupportsLocalStorage()) {
                <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1) { ?>                    
                    window.localStorage.setItem('DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE', "essential|analytics");
                <?php } else { ?>
                    window.localStorage.setItem('DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE', "essential");
                <?php } ?>
                } else {
                    var CookieDate = new Date;
                    CookieDate.setFullYear(CookieDate.getFullYear() + 10);
                <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1) { ?>                        
                    document.cookie = 'DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE=essential|analytics; expires=' + CookieDate.toUTCString() + '; path=/';
                <?php } else { ?>
                    document.cookie = 'DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE=essential; expires=' + CookieDate.toUTCString() + '; path=/';
                <?php } ?>
                }
                <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1 && (!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"]))) { ?>
                    //allow google analytics
                    (function () {
                        var s = document.createElement('script');
                        s.type = 'text/javascript';
                        s.async = true;
                        s.src = "https://www.googletagmanager.com/gtag/js?id=" + "<?php echo empty($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID'])?'':sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                        //s.id = '9598d17a-6c78-437c-83a3-52d50ae899fd';
                        //s.setAttribute("data-name", "dragonecommerce-embed-banner");
                        //var x = document.getElementsByTagName('script')[0];
                        //x.parentNode.insertBefore(s, x);
                        document.getElementsByTagName('head')[0].appendChild(s);
                    })();                
                <?php } ?>       
                jQuery('div#dragonecommerce_product > div.col-6:first').focus();                
            }); 
        }
        if(jQuery('button#dragonecommerce-acceptall-button').length>0) {
            jQuery('button#dragonecommerce-acceptall-button').focus();
        } else {
            jQuery('div#dragonecommerce_product > div.col-6:first').focus();
        }
    });  //end of jQuery(document).ready
    
    function dragonecommercereservezyx987_searchProducts() {
        dragonecommercereservezyx987_showResultOnReloadedPage('', 1);
    }
    
    function dragonecommercereservezyx987_resetSearchContainer() {
        jQuery("input#searchname").val('');
        jQuery("select#searcharea").val('');
        jQuery("div#searchpricerange").slider("option","values", [minsearchpricedefault, maxsearchpricedefault ] );
        jQuery("input#searchprice").val(jQuery("div#searchpricerange").slider("values", 0) + " - " + jQuery("div#searchpricerange").slider("values", 1));
        jQuery("select#sortby").val('id|asc');
        searchIsReset = true;
        dragonecommercereservezyx987_refreshLandingpageLeftTabMenu_onPageLoad();
    }
    
    function dragonecommercereservezyx987_validateEmail(email) {
        const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(String(email).toLowerCase());
    }
    
    function dragonecommercereservezyx987_validatePassword(password) {
        var result = true;
        const re = /.{8,}/;
        if(re.test(String(password).toLowerCase()) === false) {
            return false;
        };
        const re2 = /^[0-9a-zA-Z!@#*()$%^&]+$/;
        if(re2.test(String(password).toLowerCase()) === false) {
            return false;
        };
        const re3 = /^[0-9a-zA-Z]+$/;
        if(re3.test(String(password).toLowerCase()) === true) {
            return false;
        };
        return true;        
    }

    function dragonecommercereservezyx987_plusSlides(n) {
        dragonecommercereservezyx987_showSlides(slideIndex += n);
    }

    function dragonecommercereservezyx987_currentSlide(n) {
        dragonecommercereservezyx987_showSlides(slideIndex = n);
    }
    
    function dragonecommercereservezyx987_showSlides_initial(n) {
        slideIndex = 0;
        dragonecommercereservezyx987_showSlides(n);
    }

    function dragonecommercereservezyx987_showSlides(n) {
        var i;
        var slides = document.getElementsByClassName("myslides");
        if(slides == null || slides.length == 0) {return;}
        var dots = document.getElementsByClassName("demo");
        if (n >= slides.length) { slideIndex = 0; }
        if (n < 0) {slideIndex = slides.length - 1}
        for (i = 0; i < slides.length; i++) {
            slides[i].style.display = "none";
        }
        for (i = 0; i < dots.length; i++) {
            dots[i].className = dots[i].className.replace(/ active/g, "");
        } 
        slides[slideIndex].style.display = "block";
        dots[slideIndex].className += " active";      
          jQuery('div#mylargemodal div#gallery_container div.slideshow_row ul.slideshow_thumbnail_list li.active').removeClass('active');
        var thumb = jQuery('div#mylargemodal div#gallery_container div.slideshow_row ul.slideshow_thumbnail_list li').find('a.ad-thumb'+ slideIndex);
        thumb.parent().addClass('active');
        jQuery('div#mylargemodal div#gallery_container div.slideshow_row').find('li:not(.active) img').fadeTo(300, 0.6);
        thumb.find('img').fadeTo(300, 1);            
        var left = thumb[0].parentNode.offsetLeft;
        left -= (jQuery("div.slideshow_row").width() / 2) - (thumb[0].offsetWidth / 2);
        jQuery('div.slideshow_thumbnail').animate({scrollLeft: left +'px'});            
    }
    
    function dragonecommercereservezyx987_thumbnailShift(element) {
        var width = jQuery("div.slideshow_row div.slideshow_thumbnail ul li").width();
        var temp = jQuery('div.slideshow_thumbnail').scrollLeft();
        if(jQuery(element).is('.slideshow_forward')) {
            var left = jQuery('div.slideshow_thumbnail').scrollLeft() + width;
        } else if(jQuery(element).is('.slideshow_back')) {
            var left = jQuery('div.slideshow_thumbnail').scrollLeft() - width;
        };
        jQuery('div.slideshow_thumbnail').animate({scrollLeft: left +'px'});
        return false;
    }
    
    function dragonecommercereservezyx987_showPopupImage(imagepath) {
        var modal = document.getElementById("mylargeimagemodal");
        var modalImg = document.getElementById("mylargeimagemodal_img01");
        modal.style.display = "block";
        modalImg.src = imagepath;                
        jQuery("div#mylargeimagemodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeimagemodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);
    }

    function dragonecommercereservezyx987_showproductavailabilityHandler(event, element, classname, propertyidstring, propertyvalueidstring, productoptionsString) {
        var code = event.charCode || event.keyCode;
        if(code === 32 || code === 13) {
            event.preventDefault();
            dragonecommercereservezyx987_showproductavailability(element, classname, propertyidstring, propertyvalueidstring, productoptionsString);
        }
    }

    function dragonecommercereservezyx987_showproductavailability(element, classname, propertyidstring, propertyvalueidstring, productoptionsString) {
        jQuery('div.' + classname).removeClass('selected');
        jQuery(element).addClass('selected');
        jQuery('div.dimension').removeClass("unavailable");
        //get all selected property values
        var selectedPropertyvalueArr = [];
        jQuery('div.oneproduct_orderdetails div.dimension.selected').each(function(index) {
            var myidtemp = jQuery(this).find("input:first").attr('id');
            var myidArr = myidtemp.split("_");
            var myidstring = '';
            if(myidArr.length === 2 && myidArr[0] === 'pv') {
                myidstring = myidArr[1];
            }            
            if(myidstring !== '' && parseInt(myidstring) !== NaN) {
                selectedPropertyvalueArr.push(parseInt(myidstring));
            }
        });
        
        //get current property id and clicked propertyvalueid
        var myProductoptionsArr = [];
        if(productoptionsString !== null && productoptionsString !=='') {
            myProductoptionsArr = productoptionsString.split(",");
        }
        var pvArr0 = [];
        if(myProductoptionsArr.length > 0) {
            pvArr0 = myProductoptionsArr[0].split("|");
        }
        var allPropertyChosen = false;
        if(selectedPropertyvalueArr.length === pvArr0.length) {
            //all selected property values are in one pv combination a|b|c|d|e|f|g
            allPropertyChosen = true;
        }                
        
        if(allPropertyChosen) {
            var allmatch = false;
            var minUnmatchCounter = 0;
            var finalMatchedPropertyvaluesString = '';
            var finalMatchIndexArr = [];
            for(var i=0; i < myProductoptionsArr.length; i++) {
                var pvArr0 = myProductoptionsArr[i].split("|");
                var pvArr = pvArr0.map(function(num){return parseInt(num, 10);});
                var matchCounter = 0;
                var matchIndexArr = [];
                var matchedArr = [];
                
                for(var j=0; j < selectedPropertyvalueArr.length; j++) {
                    if(pvArr.indexOf(selectedPropertyvalueArr[j]) >= 0) {
                        matchCounter++;
                        matchedArr.push(selectedPropertyvalueArr[j]);
                        matchIndexArr.push(j);
                    }                                                
                }
                
                if(matchCounter === pvArr0.length) {
                    allmatch = true;
                }
                var unmatchCounter = pvArr0.length - matchCounter;
                if(minUnmatchCounter === 0){
                    minUnmatchCounter = unmatchCounter;
                    finalMatchedPropertyvaluesString = matchedArr.join("|");
                    finalMatchIndexArr = matchIndexArr.slice();
                } else if(minUnmatchCounter > unmatchCounter) {
                    minUnmatchCounter = unmatchCounter;        
                    finalMatchedPropertyvaluesString = matchedArr.join("|");    
                    finalMatchIndexArr = matchIndexArr.slice();                        
                } else if(minUnmatchCounter === unmatchCounter) {
                    if(finalMatchIndexArr.length === 0) {
                        if(matchIndexArr.length > 0) {
                            finalMatchedPropertyvaluesString = matchedArr.join("|");    
                            finalMatchIndexArr = matchIndexArr.slice();        
                        }                            
                    } else if(matchIndexArr.length === finalMatchIndexArr.length) {
                        var needUpdate = false;
                        for(var k=0; k < matchIndexArr.length; k++) {    
                            if(matchIndexArr[k] < finalMatchIndexArr[k]) {
                                needUpdate = true;break;                                        
                            }
                        }
                        if(needUpdate) {
                            finalMatchedPropertyvaluesString = matchedArr.join("|");    
                            finalMatchIndexArr = matchIndexArr.slice();
                        }                            
                    }
                }                                                            
            }
        
            jQuery('div.dimension').each(function(index) {
                var myidtemp = jQuery(this).find("input:first").attr('id');
                var myidArr = myidtemp.split("_");
                var myidstring = '';
                if(myidArr.length === 2 && myidArr[0] === 'pv') {
                    myidstring = myidArr[1];
                }
                if(myidstring !== '') {
                    if(allmatch) {
                        jQuery(this).removeClass("unavailable");
                        jQuery(this).find("svg").remove();                        
                    } else {
                        var finalMatchedPropertyvaluesArr = finalMatchedPropertyvaluesString.split("|");
                        if(finalMatchedPropertyvaluesArr.indexOf(myidstring) >= 0) {
                            jQuery(this).removeClass("unavailable");
                            jQuery(this).find("svg").remove();
                        } else {
                            //if add myidstring to finalMatchedPropertyvaluesString and match whole or part of a myProductoptionsArr, then set myidstring to available
                            if(parseInt(myidstring) !== NaN) {
                                finalMatchedPropertyvaluesArr.push(myidstring);
                            }
                            var foundMatchFormystring = false;
                            for(var i=0; i < myProductoptionsArr.length; i++) {
                                var pvArr0 = myProductoptionsArr[i].split("|");
                                var matchCounter = 0;                                
                                for(var j=0; j < finalMatchedPropertyvaluesArr.length; j++) {
                                    if(pvArr0.indexOf(finalMatchedPropertyvaluesArr[j]) >= 0) {
                                        matchCounter++;
                                    }                                                
                                }
                                if(matchCounter === finalMatchedPropertyvaluesArr.length) {
                                    jQuery(this).removeClass("unavailable");
                                    jQuery(this).find("svg").remove();
                                    foundMatchFormystring = true;                                    
                                }                                
                            }
                            if(!foundMatchFormystring) {                
                                jQuery(this).addClass("unavailable");
                                jQuery(this).find("svg").remove();
                                jQuery(this).append('<svg class="dimension_out-of-stock-indicator" version="1.1" xmlns="http://www.w3.org/2000/svg"><line class="dimension_text" stroke="#000000" stroke-width="1" x1="0" x2="100%" y1="100%" y2="0"></line>Sorry, your browser does not support inline SVG.</svg>');                            
                            }
                        }
                    }
                }
            });
        } else {//allPropertyChosen: false
            jQuery('div.dimension').each(function(index) {
                var myidtemp = jQuery(this).find("input:first").attr('id');
                var myidArr = myidtemp.split("_");
                var myidstring = '';
                if(myidArr.length === 2 && myidArr[0] === 'pv') {
                    myidstring = myidArr[1];
                }
                if(myidstring !== '') {
                    var available = false;
                    for(var i=0; i < myProductoptionsArr.length; i++) {                        
                        var pvArr0 = myProductoptionsArr[i].split("|");                        
                        if(pvArr0.indexOf(propertyvalueidstring) >= 0 && pvArr0.indexOf(myidstring) >= 0) {
                            available = true;
                        }
                    }
                    if(!available) {
                        jQuery(this).addClass("unavailable");
                        jQuery(this).find("svg").remove();
                        jQuery(this).append('<svg class="dimension_out-of-stock-indicator" version="1.1" xmlns="http://www.w3.org/2000/svg"><line class="dimension_text" stroke="#000000" stroke-width="1" x1="0" x2="100%" y1="100%" y2="0"></line>Sorry, your browser does not support inline SVG.</svg>');
                    } else {
                        jQuery(this).removeClass("unavailable");
                        jQuery(this).find("svg").remove();
                    }
                }
            });                                    
        }
    }
    
    function dragonecommercereservezyx987_showproductavailability3(element, classname, propertyidstring, propertyvalueidstring, productoptionsString) {
        jQuery('div.' + classname).removeClass('selected');
        jQuery(element).addClass('selected');
        jQuery('div.oneproduct_orderdetails div.dimension').removeClass("unavailable");
        //get all selected property values
        var selectedPropertyvalueArr = [];
        jQuery('div.oneproduct_orderdetails div.dimension.selected').each(function(index) {
            var myidtemp = jQuery(this).find("input:first").attr('id');
            var myidArr = myidtemp.split("_");
            var myidstring = '';
            if(myidArr.length === 2 && myidArr[0] === 'pv') {
                myidstring = myidArr[1];
            }            
            if(myidstring !== '' && parseInt(myidstring) !== NaN) {
                selectedPropertyvalueArr.push(parseInt(myidstring));
            }
        });        
        //get current property id and clicked propertyvalueid
        var myProductoptionsArr = productoptionsString.split(",");
        var allPropertyChosen = false;        
        var allmatch = false;
        var minUnmatchCounter = 0;
        var finalMatchedPropertyvaluesString = '';        
        for(var i=0; i < myProductoptionsArr.length; i++) {
            var pvArr0 = myProductoptionsArr[i].split("|");
            var pvArr = pvArr0.map(function(num){return parseInt(num, 10);});
            var matchCounter = 0;
            var matchedArr = [];            
            for(var j=0; j < selectedPropertyvalueArr.length; j++) {
                if(pvArr.indexOf(selectedPropertyvalueArr[j]) >= 0) {
                    matchCounter++;
                    matchedArr.push(selectedPropertyvalueArr[j]);
                }                                                
            }

            if(selectedPropertyvalueArr.length === pvArr0.length) {
                //all selected property values are in one pv combination a|b|c|d|e|f|g
                allPropertyChosen = true;
                if(matchCounter === pvArr0.length) {
                    allmatch = true;
                }
            } else {
                var unmatchCounter = pvArr0.length - matchCounter;
                if(minUnmatchCounter === 0){
                    minUnmatchCounter = unmatchCounter;
                    finalMatchedPropertyvaluesString = matchedArr.join("|");
                } else if(minUnmatchCounter > unmatchCounter) {
                    minUnmatchCounter = unmatchCounter;        
                    finalMatchedPropertyvaluesString = matchedArr.join("|");                    
                }                                
            }                                                            
        }
        jQuery('div.oneproduct_orderdetails div.dimension').each(function(index) {
            var myidtemp = jQuery(this).find("input:first").attr('id');
            var myidArr = myidtemp.split("_");
            var myidstring = '';
            if(myidArr.length === 2 && myidArr[0] === 'pv') {
                myidstring = myidArr[1];
            }
            var myid = parseInt(myidstring);            
            if(myidstring !== '' && myid !== NaN) {        
                if(allPropertyChosen) {
                    selectedPropertyvalueArr.sort(function(a, b){return a - b;});
                    //double check if the pv values combination exists
                    var temp_newitem = selectedPropertyvalueArr.join('|');
                    var myProductoptionsArr = productoptionsString.split(",");
                    var foundMatch = false;
                    for(var i=0; i < myProductoptionsArr.length; i++) {
                        if(myProductoptionsArr[i] === temp_newitem){foundMatch = true;}
                    }

                    if(foundMatch) {
                        var myidSelected = false;
                        for(var j=0; j < selectedPropertyvalueArr.length; j++) {
                            if(myid === selectedPropertyvalueArr[j]) {
                                myidSelected = true;break;
                            }
                        }
                        if(myidSelected) {
                            jQuery(this).removeClass("unavailable");
                            jQuery(this).find("svg").remove();                                
                        } else {
                            
                        }                        
                    } else {
                        var myidSelected = false;
                        for(var j=0; j < selectedPropertyvalueArr.length; j++) {
                            if(myid === selectedPropertyvalueArr[j]) {
                                myidSelected = true;break;
                            }
                        }
                        if(myidSelected) {
                            jQuery(this).removeClass("unavailable");
                            jQuery(this).find("svg").remove();                                
                        } else {                            
                        }                        
                    }                    
                } else {//partial match or did not finish choosing from every property                    
                    for(var i=0; i < myProductoptionsArr.length; i++) {
                        var pvArr0 = myProductoptionsArr[i].split("|");
                        var pvArr = pvArr0.map(function(num){return parseInt(num, 10);});
                        var shownPropertyvalueArr0 = finalMatchedPropertyvaluesString.split("|");
                        var shownPropertyvalueArr = shownPropertyvalueArr0.map(function(num){return parseInt(num, 10);});
                        var matchCounter2 = 0;
                        for(var k=0; k < shownPropertyvalueArr.length; k++) {
                            if(pvArr.indexOf(shownPropertyvalueArr[k]) >= 0) {
                                matchCounter2++;                            
                            }
                        }
                        if(shownPropertyvalueArr.length === matchCounter2) {
                            if(pvArr.indexOf(myid) >= 0) {
                                jQuery(this).removeClass("unavailable");
                                jQuery(this).find("svg").remove();                                    
                            } else {//not match
                                jQuery(this).addClass("unavailable");
                                jQuery(this).find("svg").remove();
                                jQuery(this).append('<svg class="dimension_out-of-stock-indicator" version="1.1" xmlns="http://www.w3.org/2000/svg"><line class="dimension_text" stroke="#000000" stroke-width="1" x1="0" x2="100%" y1="100%" y2="0"></line>Sorry, your browser does not support inline SVG.</svg>');                                                            
                            }
                        }                        
                    }                    
                }
            }
        });
        jQuery('div.' + classname).removeClass('unavailable');
        jQuery('div.' + classname).find("svg").remove();
    }
    
    function dragonecommercereservezyx987_showproductavailability2(element, classname, propertyidstring, propertyvalueidstring, productoptionsString) {
        jQuery('div.' + classname).removeClass('selected');
        jQuery(element).addClass('selected');
        jQuery('div.dimension').removeClass("unavailable");
        //get all selected property values
        var chosenValuesCount = jQuery('div.oneproduct_orderdetails div.dimension.selected').length;        
        //get current property id and clicked propertyvalueid
        var myProductoptionsArr = productoptionsString.split(",");        
        jQuery('div.dimension').each(function(index) {
            var myidtemp = jQuery(this).find("input:first").attr('id');
            var myidArr = myidtemp.split("_");
            var myidstring = '';
            if(myidArr.length === 2 && myidArr[0] === 'pv') {
                myidstring = myidArr[1];
            }
            if(myidstring !== '') {
                var available = false;
                for(var i=0; i < myProductoptionsArr.length; i++) {
                    if((myProductoptionsArr[i] === propertyvalueidstring 
                       || (myProductoptionsArr[i].length > ('|' + propertyvalueidstring).length && myProductoptionsArr[i].slice(-('|' + propertyvalueidstring).length) === ('|' + propertyvalueidstring))
                       || (myProductoptionsArr[i].length > ('|' + propertyvalueidstring + '|').length && myProductoptionsArr[i].indexOf('|' + propertyvalueidstring + '|') !== -1)
                       || (myProductoptionsArr[i].length > (propertyvalueidstring + '|').length && myProductoptionsArr[i].indexOf(propertyvalueidstring + '|') === 0)
                       ) &&
                       (myProductoptionsArr[i] === myidstring 
                       || (myProductoptionsArr[i].length > ('|' + myidstring).length && myProductoptionsArr[i].slice(-('|' + myidstring).length) === ('|' + myidstring))
                       || (myProductoptionsArr[i].length > ('|' + myidstring + '|').length && myProductoptionsArr[i].indexOf('|' + myidstring + '|') !== -1)
                       || (myProductoptionsArr[i].length > (myidstring + '|').length && myProductoptionsArr[i].indexOf(myidstring + '|') === 0)
                       )) {
                           available = true;                       
                    }
                }
                if(!available) {
                    jQuery(this).addClass("unavailable");
                    jQuery(this).find("svg").remove();
                    jQuery(this).append('<svg class="dimension_out-of-stock-indicator" version="1.1" xmlns="http://www.w3.org/2000/svg"><line class="dimension_text" stroke="#000000" stroke-width="1" x1="0" x2="100%" y1="100%" y2="0"></line>Sorry, your browser does not support inline SVG.</svg>');
                } else {
                    jQuery(this).removeClass("unavailable");
                    jQuery(this).find("svg").remove();
                }
            }
        });
        jQuery('div.' + classname).removeClass('unavailable');
        jQuery('div.' + classname).find("svg").remove();
    }
    
    function dragonecommercereservezyx987_capitalizeFirstLetter(string) {
      return string.charAt(0).toUpperCase() + string.slice(1);
    }
    
    function dragonecommercereservezyx987_showProductHandler(event, productid, fromshoppingcartquantity, fromshoppingcartpropertyvalueids) {
        var code = event.charCode || event.keyCode;
        if(code === 32 || code === 13) {
            event.preventDefault();
            dragonecommercereservezyx987_showProduct(productid, fromshoppingcartquantity, fromshoppingcartpropertyvalueids);
        }
    }
    
    //for 2 cases: when customer click a product; when cutomer edit the item in the shopping cart
    function dragonecommercereservezyx987_showProduct(productid, fromshoppingcartquantity, fromshoppingcartpropertyvalueids) {
        jQuery('div#loading').show();
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: {dragonecommercereservezyx987_hidden_security_getoneproduct:"<?php echo wp_create_nonce('dragonecommercereservezyx987_getoneproduct'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_getoneproduct", id:productid}
        }).done(function (mydata) {
            var productObj = mydata["productdetails1"][0];
            var locationsArr_temp = productObj["locations"] == null? [] : productObj["locations"].split(","), locationsArr = [], i, j;
            for (i = 0; i < locationsArr_temp.length; i++) {
               var temp = locationsArr_temp[i].split("|");
               locationsArr.push(temp);
            }
            var modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';
            modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
            modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
            modalElement += '</div>';

            modalElement += '<div class="modal-body">';
            //begin of one row                
            modalElement += '<div class="row">';
            modalElement += '<div class="col-12 col-sm-12 col-md-2 col-lg-2"></div>';            
            modalElement += '<div class="col-12 col-sm-12 col-md-3 col-lg-3"><div id="gallery_container"><div id="gallery_images_wrapper" class="">';
             
            var i, counter = 0;
            if(productObj["imagefilenames"] != null) {
                var res = productObj["imagefilenames"].split("|");
                for (i = 0; i < res.length; i++) {
                    modalElement += '<div class="myslides"><div class="numbertext">' + (counter + 1) + ' / ' + res.length + '</div><img role="button" tabindex="0" src="<?php echo dragonecommercereservezyx987_upload_url() . "/images/product/"; ?>' + dragonecommercereservezyx987_validString(productObj["id"]) + "/preview/" + res[i] + '" style="width:100%" onclick="dragonecommercereservezyx987_showPopupImage(\'<?php echo dragonecommercereservezyx987_upload_url() . "/images/product/"; ?>' + dragonecommercereservezyx987_validString(productObj["id"]) + "/" + res[i].replace(/'/g, "\\'") + '\');" alt="' + dragonecommercereservezyx987_validString(productObj["name"]).replace(/"/g, '&#34;')  + '"></div>';
                    counter++;
                }
            }
            modalElement += '<a class="prev" href="javascript:void(0);" tabindex="0" onclick="dragonecommercereservezyx987_plusSlides(-1)"><</a><a class="next" href="javascript:void(0);" tabindex="0" onclick="dragonecommercereservezyx987_plusSlides(1)">></a></div>';
            
            modalElement += '<div class="slideshow_row">';
            modalElement += '<div class="slideshow_back" role="button" tabindex="0" onclick="dragonecommercereservezyx987_thumbnailShift(this);"></div>';            
            modalElement += '<div class="slideshow_thumbnail"><ul class="slideshow_thumbnail_list">';
            var j, counter2 = 0, product_actual_price = 0;
            if(productObj["imagefilenames"] != null) {
                var res2 = productObj["imagefilenames"].split("|");
                for (j = 0; j < res2.length; j++) {
                    modalElement += '<li role="button" aria-pressed="' + (j === 0 ? 'true' : 'false') + '" tabindex="0" class="demo slideshow_thumbnail_' + dragonecommercereservezyx987_validString(productObj["id"]) + '" id="slideshow_thumbnail_' + dragonecommercereservezyx987_validString(productObj["id"]) + '_' + counter2 + '" onclick="dragonecommercereservezyx987_currentSlide(' + counter2 + ');"><a class="ad-thumb' + counter2 + '" href="javascript:void(0);"><img class="" src="<?php echo dragonecommercereservezyx987_upload_url() . "/images/product/"; ?>' + dragonecommercereservezyx987_validString(productObj["id"]) + "/thumbnail/" + res2[j] + '" title="' + dragonecommercereservezyx987_validString(productObj["name"]).replace(/"/g, '&#34;')  + '" alt="' + dragonecommercereservezyx987_validString(productObj["name"]).replace(/"/g, '&#34;')  + '" /></a></li>';
                    counter2++;
                }                
            }
            modalElement += '</ul></div>';
            modalElement += '<div class="slideshow_forward" role="button" tabindex="0" onclick="dragonecommercereservezyx987_thumbnailShift(this);"></div>';    
            modalElement += '</div>';
            modalElement += '</div></div>';
            modalElement += '<div class="col-12 col-sm-12 col-md-1 col-lg-1"></div>';            

            modalElement += '<div class="col-12 col-sm-12 col-md-6 col-lg-6">';
            modalElement += '<div class="row">';
            modalElement += '<div class="col-12 col-sm-12 col-md-6 col-lg-6">';
            modalElement += '<div>Name: ' + productObj["name"] + '</div>';
            modalElement += '<div>Price: ';
            if(productObj["isonsale"] === 1 && productObj["saleprice"] > 0) {    
                product_actual_price = productObj["saleprice"];            
                modalElement += '<span class="currencysign strike-center">' + (settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] === null ? '' : settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"]) + '</span><span aria-label="price in the past was ' + (settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] === null ? '' : settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"]) + (productObj["price"] == null ? '' : productObj["price"]) + '" role="img" class="price strike-center">' + (productObj["price"] == null ? '' : productObj["price"]) + '</span>';
                modalElement += '&nbsp;&nbsp;&nbsp;&nbsp;';
                modalElement += '<span class="currencysign">' + (settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] === null ? '' : settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"]) + '</span><span aria-label="current on sale price is ' + (settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] === null ? '' : settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"]) + (productObj["saleprice"] == null ? '' : productObj["saleprice"]) + '" role="img" class="saleprice">' + (productObj["saleprice"] == null ? '' : productObj["saleprice"]) + '</span></div>';                            
            } else {
                product_actual_price = productObj["price"];    
                modalElement += '<span class="currencysign">' + (settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] === null ? '' : settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"]) + '</span><span aria-label="price is ' + (settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] === null ? '' : settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"]) + (productObj["price"] == null ? '' : productObj["price"]) + '" role="img" class="price">' + (productObj["price"] == null ? '' : productObj["price"]) + '</span></div>';                            
            }                        
            modalElement += '<div id="oneproduct_orderdetails_' + productObj["id"] + '" class="oneproduct_orderdetails">';
            modalElement += '<input type="hidden" name="dragonecommercereservezyx987_productid" value="' + productObj["id"] + '" />';
            modalElement += '<div>Quantity: </div>';
            modalElement += '<div><input type="number" class="form-control" tabindex="0" id="dragonecommercereservezyx987_quantity_' + productObj["id"] + '" name="dragonecommercereservezyx987_quantity_' + productObj["id"] + '" value="1" autofocus /></div>';

            modalElement += '<div class="propertycontainer">';
            var productdetails2Arr = mydata["productdetails2"];
            var productoptionsArr = mydata["productoptions"];
            var propertycounter = 1;
            var tabindexcounter = 2;
            if(productdetails2Arr.length > 0) {
                //all productdetails2Arr elements should have the same groupid. If there are more than one groupid, there will be error.
                var currentpropertyid = productdetails2Arr[0]["propertyid"];
                for(var j=0; j < productdetails2Arr.length; j++) {
                    if(productdetails2Arr[j]["propertyid"] !== currentpropertyid) {
                        currentpropertyid = productdetails2Arr[j]["propertyid"];
                        propertycounter++;
                    }
                }    
            } else {
                propertycounter = 0;
            }            
            if(productdetails2Arr.length > 0) {
                if(propertycounter > 1) {
                    var currentpropertyid = productdetails2Arr[0]["propertyid"];
                    var counter = 0;
                    for(var j=0; j < productdetails2Arr.length; j++) {
                        if(productdetails2Arr[j]["propertyid"] === currentpropertyid) {
                            if(counter === 0) {
                                modalElement += '<br/><div class="property">' + dragonecommercereservezyx987_capitalizeFirstLetter(productdetails2Arr[j]["propertyname"]) + ':</div>';
                            }
                            counter++;
                        } else {
                            currentpropertyid = productdetails2Arr[j]["propertyid"];
                            modalElement += '</div><br/><div class="propertycontainer"><div class="property">' + dragonecommercereservezyx987_capitalizeFirstLetter(productdetails2Arr[j]["propertyname"]) + ':</div>';
                            counter = 1;
                        }
                        modalElement += '<div tabindex="0" class="p' + productdetails2Arr[j]["propertyid"] + ' dimension" role="button" onclick="dragonecommercereservezyx987_showproductavailability(this, \'p' + productdetails2Arr[j]["propertyid"] + '\', \'' + productdetails2Arr[j]["propertyid"] + '\',\'' + productdetails2Arr[j]["propertyvalueid"] + '\',\'' + productoptionsArr.toString() + '\');" onkeydown="dragonecommercereservezyx987_showproductavailabilityHandler(event, this, \'p' + productdetails2Arr[j]["propertyid"] + '\', \'' + productdetails2Arr[j]["propertyid"] + '\',\'' + productdetails2Arr[j]["propertyvalueid"] + '\',\'' + productoptionsArr.toString() + '\');">';
                        modalElement += '<input type="radio" tabindex="-1" class="dimension_radio" id="pv_' + productdetails2Arr[j]["propertyvalueid"] + '" name="p_' + productdetails2Arr[j]["propertyid"] + '" value="' + productdetails2Arr[j]["propertyvaluename"].replace(/"/g, '\\&#34;') + '" />';
                        modalElement += '<label class="dimension_label">';
                        modalElement += '<span class="dimension_span" >' + productdetails2Arr[j]["propertyvaluename"] + '</span>';
                        modalElement += '</label>';
                        modalElement += '</div>';
                        tabindexcounter++;
                    }
                } else if(propertycounter === 1) {
                    modalElement += '<br/><div class="property">' + dragonecommercereservezyx987_capitalizeFirstLetter(productdetails2Arr[0]["propertyname"]) + ':</div>';
                    for(var j=0; j < productdetails2Arr.length; j++) {
                        for(var k=0; k < productoptionsArr.length; k++) {
                            if(parseInt(productoptionsArr[k]) === productdetails2Arr[j]["propertyvalueid"]) {
                                modalElement += '<div role="button" tabindex="0" class="p' + productdetails2Arr[j]["propertyid"] + ' dimension" onclick="dragonecommercereservezyx987_showproductavailability(this, \'p' + productdetails2Arr[j]["propertyid"] + '\', \'' + productdetails2Arr[j]["propertyid"] + '\',\'' + productdetails2Arr[j]["propertyvalueid"] + '\',\'' + productoptionsArr.toString() + '\');" onkeydown="dragonecommercereservezyx987_showproductavailabilityHandler(event, this, \'p' + productdetails2Arr[j]["propertyid"] + '\', \'' + productdetails2Arr[j]["propertyid"] + '\',\'' + productdetails2Arr[j]["propertyvalueid"] + '\',\'' + productoptionsArr.toString() + '\');">';                                
                                modalElement += '<input type="radio" tabindex="-1" class="dimension_radio" id="pv_' + productdetails2Arr[j]["propertyvalueid"] + '" name="p_' + productdetails2Arr[j]["propertyid"] + '" value="' + productdetails2Arr[j]["propertyvaluename"].replace(/"/g, '\\&#34;') + '" />';
                                modalElement += '<label class="dimension_label">';
                                modalElement += '<span class="dimension_span" >' + productdetails2Arr[j]["propertyvaluename"] + '</span>';
                                modalElement += '</label>';
                                modalElement += '</div>';
                                tabindexcounter++;
                            }
                        }                        
                    }
                }
            }                        
            modalElement += '</div>';
            modalElement += '<br/><input type="button" role="button" tabindex="0" name="dragonecommercereservezyx987_addtocart" class="btn btn-primary btn-lg" onclick="dragonecommercereservezyx987_addProductToShoppingCart(\'oneproduct_orderdetails_' + productObj["id"] + '\', ' + productObj["id"] + ',\'' + productObj["name"].replace(/'/g, "\\&#39;").replace(/"/g, '\\&#34;') + '\',' + product_actual_price + ',' + propertycounter + ',' + productObj["istaxfree"] + ',' + productObj["isonsale"] + ',\'' + settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] + '\',\'' + settings["WEIGHT_UNIT_ID_DEFAULT"]["weightsign"] + '\'' + (typeof fromshoppingcartquantity === 'undefined' ? ',0' : (',' + fromshoppingcartquantity)) + (typeof fromshoppingcartpropertyvalueids === 'undefined' ? ',\'\'' : (',\'' + fromshoppingcartpropertyvalueids + '\'' )) + ',\'' + (productObj["imagefilenames"] === null ? '' : productObj["imagefilenames"].replace(/'/g, "\\&#39;").replace(/"/g, '\\&#34;')) + '\',\'' + productoptionsArr.toString() + '\');" value="<?php esc_html_e('ADD TO CART', 'dragonecommerce_trdom' ) ?>" ' + ((productdetails2Arr.length !== 0 && productoptionsArr.length === 0) ? 'disabled' : '') + '/>';            

            if(productdetails2Arr.length !== 0 && productoptionsArr.length === 0) {
                modalElement += '<br/><span style="color:red">Out of stock</span>';
            }
            tabindexcounter++;
            modalElement += '<br/><br/><input type="button" role="button" tabindex="0" name="dragonecommercereservezyx987_gotoshoppingcart" id="dragonecommercereservezyx987_gotoshoppingcart" class="btn btn-primary btn-lg" style="display:none;" onclick="dragonecommercereservezyx987_goToShoppingcart();" value="GO TO SHOPPING CART">'
            modalElement += '</div>';                        
            modalElement += '<div id="oneproduct_ordermessagesuccess_' + productObj["id"] + '" class="oneproduct_ordermessagesuccess alert alert-success alert-dismissible fade show" aria-label="success" role="alert">';
            modalElement += '</div>';
            modalElement += '<div id="oneproduct_ordermessageerror_' + productObj["id"] + '" class="oneproduct_ordermessageerror alert alert-danger alert-dismissible fade show" aria-label="error" role="alert">';
            modalElement += '</div>';            
            modalElement += '</div>';
            modalElement += '</div>';            
            modalElement += '</div>';
            modalElement += '</div>';
            //end of one row
            tabindexcounter++;
            modalElement += '<div class="row"><div class="col-12 col-sm-12 col-md-12 col-lg-12">';
            modalElement += '<div>Description: <p>' + dragonecommercereservezyx987_validString(productObj["description"]) + '</p></div>';                        
            modalElement += '</div></div>';
            modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';            
            modalElement += '</div>';
            
            //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';
            //modalElement += '<button type="button" aria-label="close the pop up window" role="img" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
            //modalElement += '</div>';
            modalElement += '<script>jQuery(document).ready(function(){ dragonecommercereservezyx987_showSlides_initial(0); jQuery("input#dragonecommercereservezyx987_quantity_' + productObj["id"] + '").focus();});<\/script>';
            modalElement += '</div></div>';
            
            jQuery('div#mylargemodal').html(modalElement);        
            jQuery("div#mylargemodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});            
            jQuery("div#mylargemodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
            jQuery('div.oneproduct_orderdetails').next().html('').hide();
            //jQuery('div.oneproduct_orderdetails').next().addClass('hide');
            jQuery('div.oneproduct_orderdetails').next().next().html('').hide();
            //jQuery('div.oneproduct_orderdetails').next().next().addClass('hide');
            if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }        
            if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }    
            if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
            if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
            mylargemodal = new bootstrap.Modal(document.getElementById('mylargemodal'));
            mylargemodal.show();        
            jQuery("div#mylargemodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
            jQuery("div#mylargemodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);
            jQuery('div#loading').hide();
        }).fail(function( jqXHR, textStatus ) {
            alert( "Get one product request failed: " + textStatus );
            jQuery('div#loading').hide();            
        });
    }
    
    function dragonecommercereservezyx987_saveAndFinishCookiePolicyModal() {
        var allChecked = true, temp = [];
        var unCheckedAmount = jQuery("div#mymediumcookiemodal input:checkbox:not(:checked)").length;        
        mymediumcookiemodal.hide();
        jQuery("div#mymediumcookiemodal input:checkbox:checked").each(function() {
            temp.push(jQuery(this).val());                
        });
        var temp2 = temp.length === 0 ? '' : temp.join("|");
        if (temp2 === ''){return;}
        //console.log("at 1860, temp2: " + temp2);
        if (typeof window.localStorage !== 'undefined' && dragonecommercereservezyx987_browserSupportsLocalStorage()) {
            window.localStorage.setItem('DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE', temp2);
        } else {
            var CookieDate = new Date;
            CookieDate.setFullYear(CookieDate.getFullYear() + 10);
            document.cookie = 'DRAGONECOMMERCERESERVE_COOKIECONSENT_CACHE=' + temp2 + '; expires=' + CookieDate.toUTCString() + '; path=/';                
        }
        <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1 && (!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"]))) { ?>
            if(jQuery.inArray("analytics", temp) !== -1) {
                (function () {
                    var s = document.createElement('script');
                    s.type = 'text/javascript';
                    s.async = true;
                    s.src = "https://www.googletagmanager.com/gtag/js?id=" + "<?php echo empty($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID'])?'':sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                    //s.id = '9598d17a-6c78-437c-83a3-52d50ae899fd';
                    //s.setAttribute("data-name", "dragonecommerce-embed-banner");
                    //var x = document.getElementsByTagName('script')[0];
                    //x.parentNode.insertBefore(s, x);
                    document.getElementsByTagName('head')[0].appendChild(s);
                })();                
            } else {//remove google analytics cookie from browser
                dragonecommercereservezyx987_eraseCookie("_ga");
                <?php if(!empty($settings["GOOGLE_ANALYTICS_MEASUREMENT_ID"])) { ?>
                    var gaid = "<?php echo sanitize_text_field($settings['GOOGLE_ANALYTICS_MEASUREMENT_ID']); ?>";
                    var gaidArr = gaid.split("-");
                    var temp = gaidArr.length <= 1 ? '' : gaidArr[gaidArr.length - 1];
                    if(temp !== '') {
                        dragonecommercereservezyx987_eraseCookie("_ga_" + temp);
                    }
                <?php } ?>
            }                
        <?php } ?>
        jQuery('div#dragonecommerce_product > div.col-6:first').focus();
    }
    
    function dragonecommercereservezyx987_hideCookiePolicyModal() {
        mymediumcookiemodal.hide();
        jQuery("div#dragonecommerce-consentPrompt-container").show();
        if(jQuery('button#dragonecommerce-acceptall-button').length>0) {
            jQuery('button#dragonecommerce-acceptall-button').focus();
        } else {
            jQuery('div#dragonecommerce_product > div.col-6:first').focus();
        }    
    }
    
    function dragonecommercereservezyx987_goToCookiePolicyModal() {
       var modalElement = '<div class="modal-dialog modal-dialog-centered"><div class="modal-content" style="padding: 0px 25px 0px 25px;overflow:hidden;background-color: #0034E8;">';    
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" onclick="dragonecommercereservezyx987_hideCookiePolicyModal();"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';    
        modalElement += '<form id="dragonecommercereservezyx987_submitcookiepolicy_form" target="_self" method="post" autocomplete="off" onsubmit="return false">';        
        modalElement += '<div id="dragonecommerce_cookiepolicy_container">';        
        modalElement += '<div><br/><h2 class="dragonecommerce-styles-preferenceTitle" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">Your Cookie Preferences</h2>';
        modalElement += '<p class="dragonecommerce-styles-description" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">We use different types of cookies to optimize your experience on our website. Click on the categories below to learn more about their purpose. You may choose which types of cookies to allow and can change your preferences at any time. Remember that disabling cookies may affect your experience on the website. You can learn more about how we use cookies by visiting our <span class="dragonecommerce-styles-root-9530f3 t-cookiePolicyLink" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">Cookie Policy</span> and <span class="dragonecommerce-styles-root-9530f3 t-privacyPolicyLink" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">Privacy Policy</span>.</p>';

        modalElement += '<div class="dragonecommerce-styles-root"><div>';
        modalElement += '<div data-tracking="accordion-essential" class="dragonecommerce-styles-head" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">';
        modalElement += '<div class="dragonecommerce-styles-topHeader">';
        modalElement += '<div class="dragonecommerce-checkBox-essential-container">';
        modalElement += '<input type="checkbox" id="essential" name="essential" class="" value="essential" checked disabled />';
        modalElement += '<span class="dragonecommerce-styles-cbLabel">Essential</span>&nbsp;&nbsp;<span class="dragonecommerce-styles-cookieCount"></span>';
        modalElement += '&nbsp;&nbsp;<a class="dragonecommerce-detailsLink" href="' + "<?php echo plugins_url('files/cookiepolicy.pdf', __FILE__ ); ?>" + '" target="_blank" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">Details</a>';
        modalElement += '</div>';
        modalElement += '</div></div>';
        modalElement += '<div class="dragonecommerce-styles-body" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">These cookies are strictly necessary to provide you with services available through our website and to use some of its features, such as access to secure areas. For example, Google recaptcha is used to filter spam traffic and allow only legitimate visitors to checkout.</div>';
        modalElement += '</div></div><br/><br/>';

        <?php if((!empty($settings["USE_GOOGLE_ANALYTICS"])) && $settings["USE_GOOGLE_ANALYTICS"] === 1) { ?>
        modalElement += '<div class="dragonecommerce-styles-root"><div>';
        modalElement += '<div data-tracking="accordion-analytics" class="dragonecommerce-styles-head" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">';
        modalElement += '<div class="dragonecommerce-styles-topHeader">';
        modalElement += '<div class="dragonecommerce-checkBox-analytics-container">';
        modalElement += '<input role="button" tabindex="0" type="checkbox" id="analytics" name="analytics" class="" value="analytics" checked />';
        modalElement += '<span class="dragonecommerce-styles-cbLabel">Analytics and customization</span>&nbsp;&nbsp;<span class="dragonecommerce-styles-cookieCount">(2)</span>';
        modalElement += '&nbsp;&nbsp;<a class="dragonecommerce-detailsLink" href="' + "<?php echo plugins_url('files/cookiepolicy.pdf', __FILE__ ); ?>" + '" target="_blank" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">Details</a>';
        modalElement += '</div>';
        modalElement += '</div></div>';
        modalElement += '<div class="dragonecommerce-styles-body" style="color: rgb(255, 255, 255); font-family: Roboto, &quot;Open Sans&quot;, Arial, Helvetica;">These cookies collect information that is used either in aggregate form to help us understand how our website are being used or how effective our marketing campaigns are, or to help us customize our website for you. For example, Google analytics can help us to know the amount of visitors every day and where the visitors are from.</div>';
        modalElement += '</div></div><br/><br/>';
        <?php } else { ?>
        //modalElement += '<style>div#mymediumcookiemodal {height: 510px !important;}</style>';
        <?php } ?>
        modalElement += '</div>';                
        modalElement += '</div>';
        modalElement += '</form>';        
        modalElement += '</div>';
        
        modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';        
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<input type="button" role="button" tabindex="0" class="dragonecommerce-cookiepolicy-button" id="dragonecommerce-button-saveandfinish" name="dragonecommerce-button-saveandfinish" onclick="dragonecommercereservezyx987_saveAndFinishCookiePolicyModal();" class="" value="Save and Finish" />';
        modalElement += '<input type="button" role="button" tabindex="0" class="dragonecommerce-cookiepolicy-button" id="dragonecommerce-button-cancel" name="dragonecommerce-button-cancel" onclick="dragonecommercereservezyx987_hideCookiePolicyModal();" class="" value="Cancel" />';                
        modalElement += '</div>';        

        modalElement += '</div>';
        modalElement += '<script>jQuery(document).ready(function(){ jQuery("input#dragonecommerce-button-saveandfinish").focus();});<\/script>';        
        
        jQuery('div#mymediumcookiemodal').html(modalElement);
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }        
        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        mymediumcookiemodal = new bootstrap.Modal(document.getElementById('mymediumcookiemodal'));
        mymediumcookiemodal.show();
        //jQuery("div#mymediumcookiemodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        //jQuery("div#mymediumcookiemodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
        jQuery("div#dragonecommerce-consentPrompt-container").hide();
    }
    
    function dragonecommercereservezyx987_registerUser() {
        var registeruserdata = {dragonecommercereservezyx987_hidden_security_registernewuser:"<?php echo wp_create_nonce('dragonecommercereservezyx987_registernewuser'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_registernewuser"};
        registeruserdata.username = jQuery('input#registerusername').val();
        registeruserdata.password = jQuery('input#registerpassword').val();
        registeruserdata.password_confirmation = jQuery('input#registerpassword_confirmation').val();    
        registeruserdata.email = jQuery.trim(jQuery('input#registeremail').val());
        registeruserdata.terms = document.getElementById('registerterms').checked ? '1' : '0';
        registeruserdata.pluginurl = pluginurl;        
        if(jQuery.trim(jQuery('input#registerusername').val()) === '' || jQuery.trim(jQuery('input#registeremail').val()) === '' || jQuery.trim(jQuery('input#registerpassword').val()) === '' || jQuery.trim(jQuery('input#registerpassword_confirmation').val()) === '') {
            return alert('Please enter username, password and email address.');
        }        
        if(!dragonecommercereservezyx987_validatePassword(jQuery('input#registerpassword').val())){
            return alert("Please enter a valid password.");
        }
        if(jQuery('input#registerpassword').val() !== jQuery('input#registerpassword_confirmation').val()) {
            return alert("Two passwords are not identical.");
        }        
        if(!dragonecommercereservezyx987_validateEmail(jQuery('input#registeremail').val())){
            return alert("Please enter a valid email address.");
        }
        if(!document.getElementById('registerterms').checked) {
            return alert("You must agree with the terms and conditions to get registered.");
        }
        jQuery('div#loading').show();
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: registeruserdata
        }).done(function (mydata) {
            alert(mydata);
            jQuery('div#loading').hide();
            if(mydata === 'Registered. Please check your email to activate your account.') {
                window.location.href = window.location.href;
            }
        }).fail(function( jqXHR, textStatus ) {
            alert( "Register request failed: " + textStatus );
            jQuery('div#loading').hide();
        });
    }
    
    function dragonecommercereservezyx987_accountactivation() {
        var accountactivationdata = {dragonecommercereservezyx987_hidden_security_accountactivation:"<?php echo wp_create_nonce('dragonecommercereservezyx987_accountactivation'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_accountactivation"};
        accountactivationdata.email = jQuery.trim(jQuery('input#accountactivationemail').val());
        accountactivationdata.pluginurl = pluginurl;        
        if(jQuery.trim(jQuery('input#accountactivationemail').val()) === '') {
            return alert('Please enter email address.');
        }        
        if(!dragonecommercereservezyx987_validateEmail(jQuery('input#accountactivationemail').val())){
            return alert("Please enter a valid email address.");
        }
        jQuery('div#loading').show();
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: accountactivationdata
        }).done(function (mydata) {
            alert(mydata);
            jQuery('div#loading').hide();
            if(mydata === 'Success. Please check your email to activate your account.') {
                window.location.href = window.location.href;
            }
        }).fail(function( jqXHR, textStatus ) {
            alert( "Account activation request failed: " + textStatus );
            jQuery('div#loading').hide();
        });
    }
    
    function dragonecommercereservezyx987_resetPassword() {
        var resetpassworddata = {dragonecommercereservezyx987_hidden_security_resetpassword:"<?php echo wp_create_nonce('dragonecommercereservezyx987_resetpassword'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_resetpassword"};
        resetpassworddata.email = jQuery.trim(jQuery('input#resetemail').val());
        resetpassworddata.pluginurl = pluginurl;        
        if(jQuery.trim(jQuery('input#resetemail').val()) === '') {
            return alert('Please enter email address.');
        }        
        if(!dragonecommercereservezyx987_validateEmail(jQuery('input#resetemail').val())){
            return alert("Please enter a valid email address.");
        }
        jQuery('div#loading').show();
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: resetpassworddata
        }).done(function (mydata) {
            alert(mydata);
            jQuery('div#loading').hide();
            if(mydata === 'Success. Please check your email to get your token and reset your password.') {
                window.location.href = window.location.href;
            }
        }).fail(function( jqXHR, textStatus ) {
            alert( "Send reset password email request failed: " + textStatus );
            jQuery('div#loading').hide();
        });
    }

    function dragonecommercereservezyx987_resetPasswordUsingToken() {
        var resetpasswordusingtokendata = {dragonecommercereservezyx987_hidden_security_resetpasswordusingtoken:"<?php echo wp_create_nonce('dragonecommercereservezyx987_resetpasswordusingtoken'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_resetpasswordusingtoken"};
        resetpasswordusingtokendata.username = jQuery('input#resetusername').val();
        resetpasswordusingtokendata.password = jQuery('input#resetpassword').val();
        resetpasswordusingtokendata.password_confirmation = jQuery('input#resetpassword_confirmation').val();    
        resetpasswordusingtokendata.resettoken = jQuery.trim(jQuery('input#resettoken').val());
        resetpasswordusingtokendata.pluginurl = pluginurl;        
        if(jQuery.trim(jQuery('input#resetusername').val()) === '' || jQuery.trim(jQuery('input#resetpassword').val()) === '' ||
           jQuery.trim(jQuery('input#resetpassword_confirmation').val()) === '' || jQuery.trim(jQuery('input#resettoken').val()) === '') {
            return alert('Please enter all the fields.');
        }        
        if(!dragonecommercereservezyx987_validatePassword(jQuery('input#resetpassword').val())){
            return alert("Please enter a valid password.");
        }        
        if(jQuery('input#resetpassword').val() !== jQuery('input#resetpassword_confirmation').val()) {
            return alert("Two passwords are not identical.");
        }
        jQuery('div#loading').show();        
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: resetpasswordusingtokendata
        }).done(function (mydata) {
            alert(mydata);
            jQuery('div#loading').hide();
            if(mydata === 'Success.') {
                window.location.href = window.location.href;
            }
        }).fail(function( jqXHR, textStatus ) {
            alert( "Reset password using token failed: " + textStatus );
            jQuery('div#loading').hide();
        });
    }
    
    function dragonecommercereservezyx987_loginUserBySubmitForm() {
        if(jQuery.trim(jQuery('input#loginusername').val()) === '' || jQuery.trim(jQuery('input#loginpassword').val()) === '') {
            return alert('Please enter username and password.');
        }        
        if(!dragonecommercereservezyx987_validatePassword(jQuery('input#loginpassword').val())){
            return alert("Please enter a valid password.");
        }
        jQuery('div#loading').show();        
        var extradata = '<input type="hidden" name="dragonecommercereservezyx987_hidden_security_loginuser" value="<?php echo wp_create_nonce('dragonecommercereservezyx987_loginuser'); ?>" />';        
        extradata += '<input type="hidden" id="dragonecommercereservezyx987_orderitems" name="dragonecommercereservezyx987_orderitems" value="" />';        
        extradata += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        extradata += '<input type="hidden" name="dragonecommercereservezyx987_loginuserbysubmitform" value="loginuserbysubmitform" />';        
        jQuery("form#dragonecommercereservezyx987_login_form").append(extradata);
        var dragonecommercereservezyx987_orderitems = JSON.stringify(shoppingcartitems);
        if(shoppingcartitems.length === 0) {
            dragonecommercereservezyx987_orderitems = '';
        }
        jQuery("form#dragonecommercereservezyx987_login_form input#dragonecommercereservezyx987_orderitems").val(dragonecommercereservezyx987_orderitems);
        jQuery("form#dragonecommercereservezyx987_login_form").submit();
    }
    
    function dragonecommercereservezyx987_refreshLandingpageLeftTabMenu() {
        if(shoppingcartitems.length > 0) {
            jQuery("div#ecommercetabmenu span#glyphicon_shopping_cart").css('color', 'black');
        } else {
            jQuery("div#ecommercetabmenu span#glyphicon_shopping_cart").css('color', 'white');
        }        
    }
    
    function dragonecommercereservezyx987_logoutUserBySubmitForm() {            
        var extradata = '<input type="hidden" name="dragonecommercereservezyx987_hidden_security_logoutuser" value="<?php echo wp_create_nonce('dragonecommercereservezyx987_logoutuser'); ?>" />';            
        extradata += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        extradata += '<input type="hidden" name="dragonecommercereservezyx987_logoutuserbysubmitform" value="logoutuserbysubmitform" />';

        jQuery("form#dragonecommercereservezyx987_login_form").html('');
        jQuery("form#dragonecommercereservezyx987_logout_form").append(extradata);        
        jQuery("form#dragonecommercereservezyx987_logout_form").submit();
    }
    
    function dragonecommercereservezyx987_emptyParentNode(element) {
        jQuery(element).parent().html('').hide();
        //jQuery(element).parent().addClass('hide');
    }
    
    function dragonecommercereservezyx987_isNormalInteger(stringvalue) {
        stringvalue = stringvalue.trim();
        if (!stringvalue) {
            return false;
        }
        stringvalue = stringvalue.replace(/^0+/, "") || "0";
        var n = Math.floor(Number(stringvalue));
        return n !== Infinity && String(n) === stringvalue && n > 0;
    }
    
    function dragonecommercereservezyx987_addProductToShoppingCart(container_id, productid, productname, price, propertyquantity, istaxfree, isonsale, currencysign, weightsign, fromshoppingcartquantity, fromshoppingcartpropertyvalueids, imagefilenames, productoptionsString) {    
        var selectedvaluescounter = jQuery('div#mylargemodal div.modal-content div#' + container_id + ' div.selected:not(.unavailable) input.dimension_radio').length;
        if(propertyquantity !== selectedvaluescounter) {
            return alert("Please choose in all the fields.");
        }
        if(!dragonecommercereservezyx987_isNormalInteger(jQuery('input#dragonecommercereservezyx987_quantity_' + productid).val())) {
            return alert("Please enter a valid quantity.");
        }
                        
        jQuery('div#' + container_id).next().html('').hide();
        //jQuery('div#' + container_id).next().addClass('hide');
        jQuery('div#' + container_id).next().next().html('').hide();
        //jQuery('div#' + container_id).next().next().addClass('hide');
        jQuery('div.oneproduct_orderdetails input#dragonecommercereservezyx987_gotoshoppingcart').hide();
        //jQuery('div.oneproduct_orderdetails input#dragonecommercereservezyx987_gotoshoppingcart').addClass('hide');

        var newitem = {};
        var propertyvalueidArr = [];
        newitem["details"] = '';
        jQuery('div#mylargemodal div.modal-content div#' + container_id + ' div.selected:not(.unavailable) input.dimension_radio').each(function(index) {
            var myidtemp = jQuery(this).attr('id');
            var myidtempArr = myidtemp.split("_");
            var myid = 0;
            if(myidtempArr.length === 2 && myidtempArr[0] === 'pv') {
                myid = parseInt(myidtempArr[1]);
            }
            if(myid !== 0) {
                propertyvalueidArr.push(myid);
            }
            var propertyname = jQuery(this).parent().parent().children('div.property').first().text();
            var propertyvalue = jQuery(this).val();
            if(newitem["details"] === '') {
                newitem["details"] += propertyname.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ") + ": " + propertyvalue.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ");
            } else {
                newitem["details"] += "|" + propertyname.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ") + ": " + propertyvalue.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ");
            }
        });
        
        propertyvalueidArr.sort(function(a, b){return a - b;});
        //double check if the pv values combination exists
        var temp_newitem = propertyvalueidArr.join('|');
        var myProductoptionsArr = productoptionsString.split(",");
        var foundMatch = false;
        for(var i=0; i < myProductoptionsArr.length; i++) {
            if(myProductoptionsArr[i] === temp_newitem){foundMatch = true;}
        }
        if(!foundMatch){return alert("This product: " + newitem["details"] + " is not available.");}
        newitem["propertyvalueids"] = propertyvalueidArr.join('|');
        newitem["id"] = String(productid);
        newitem["name"] = productname;
        newitem["price"] = String(price);    
        newitem["currencysign"] = currencysign == null ? '' : currencysign;        
        newitem["weightsign"] = weightsign == null ? '' : weightsign;            
        newitem["istaxfree"] = istaxfree == null ? '0' : String(istaxfree);        
        newitem["isonsale"] = isonsale == null ? '0' : String(isonsale);
        newitem["imagefilenames"] = imagefilenames == null ? '' : imagefilenames;
        
        if(newitem == null || newitem.id == null || newitem.id < 1) {return;}
        newitem.quantity = jQuery('input#dragonecommercereservezyx987_quantity_' + newitem["id"]).val();        
        //filter newitem's every key and value to remove , ; : 
        for (var key in newitem) {
            if(key !== 'details') {
                var temp = String(newitem[key]);
                newitem[key] = temp.replace(/,/g, " ").replace(/;/g, " ").replace(/:/g, " ");
            }
        }                
        //if shoppingcartitems already has the same product id and same propertyvalueids, merge them
        foundmatch = false;
        var shouldremoveoldediteditem = true;
        for(var j=0; j<shoppingcartitems.length; j++) {
            if(parseInt(shoppingcartitems[j]["id"]) === parseInt(newitem.id) && shoppingcartitems[j]["propertyvalueids"] === newitem.propertyvalueids) {
                //if shopping cart old being edited item is this item, replace quantity
                if(fromshoppingcartpropertyvalueids === newitem.propertyvalueids
                    && parseInt(fromshoppingcartquantity) === parseInt(shoppingcartitems[j]["quantity"])) {
                    shoppingcartitems[j]["quantity"] = newitem.quantity;
                    shouldremoveoldediteditem = false;
                } else {
                    var temp_quantity = parseInt(shoppingcartitems[j]["quantity"]) + parseInt(newitem.quantity);
                    shoppingcartitems[j]["quantity"] = String(temp_quantity);
                }
                foundmatch = true;
                break;
            }
        }
        
        var shouldremoveoldediteditemindex = null;
        if(shouldremoveoldediteditem) {
            //remove shopping cart old being edited item            
            for(var j=0; j<shoppingcartitems.length; j++) {
                if(parseInt(shoppingcartitems[j]["id"]) === parseInt(productid) && shoppingcartitems[j]["propertyvalueids"] === fromshoppingcartpropertyvalueids
                    && parseInt(fromshoppingcartquantity) === parseInt(shoppingcartitems[j]["quantity"])) {
                    shouldremoveoldediteditemindex = j;
                    shoppingcartitems.splice(j, 1);break;
                }
            }
        }
        if(!foundmatch) {        
            if(shouldremoveoldediteditemindex === null) {
                shoppingcartitems.push(newitem);        
            } else if(shouldremoveoldediteditemindex >= 0) {
                shoppingcartitems.splice(shouldremoveoldediteditemindex, 0, newitem);
            }
        }
        jQuery('div#' + container_id).next().append('<button type="button" class="btn-close" tabindex="0" aria-label="click to clear the message" onclick="dragonecommercereservezyx987_emptyParentNode(this);"></button><span aria-label="success" role="img" >success</span>').show();
        jQuery('div.oneproduct_orderdetails input#dragonecommercereservezyx987_gotoshoppingcart').show();
        dragonecommercereservezyx987_showCartIconQuantity();
        dragonecommercereservezyx987_refreshLandingpageLeftTabMenu();
        dragonecommercereservezyx987_updateOrderitemsCookie();
    }

    function dragonecommercereservezyx987_addProductToShoppingCart2(container_id, productid, productname, price, propertyquantity, istaxfree, isonsale, currencysign, weightsign, fromshoppingcartquantity, fromshoppingcartpropertyvalueids, imagefilenames, productoptionsString) {    
        var selectedvaluescounter = jQuery('div#mylargemodal div.modal-content div#' + container_id + ' div.selected:not(.unavailable) input.dimension_radio').length;
        if(propertyquantity !== selectedvaluescounter) {
            return alert("Please choose in all the fields.");
        }
        if(!dragonecommercereservezyx987_isNormalInteger(jQuery('input#dragonecommercereservezyx987_quantity_' + productid).val())) {
            return alert("Please enter a valid quantity.");
        }
                        
        jQuery('div#' + container_id).next().html('').hide();
        //jQuery('div#' + container_id).next().addClass('hide');
        jQuery('div#' + container_id).next().next().html('').hide();
        //jQuery('div#' + container_id).next().next().addClass('hide');
        jQuery('div.oneproduct_orderdetails input#dragonecommercereservezyx987_gotoshoppingcart').hide();
        //jQuery('div.oneproduct_orderdetails input#dragonecommercereservezyx987_gotoshoppingcart').addClass('hide');

        var newitem = {};
        var propertyvalueidArr = [];
        newitem["details"] = '';
        jQuery('div#mylargemodal div.modal-content div#' + container_id + ' div.selected:not(.unavailable) input.dimension_radio').each(function(index) {
            var myidtemp = jQuery(this).attr('id');
            var myidtempArr = myidtemp.split("_");
            var myid = 0;
            if(myidtempArr.length === 2 && myidtempArr[0] === 'pv') {
                myid = parseInt(myidtempArr[1]);
            }
            if(myid !== 0) {
                propertyvalueidArr.push(myid);
            }
            var propertyname = jQuery(this).parent().parent().children('div.property').first().text();
            var propertyvalue = jQuery(this).val();
            if(newitem["details"] === '') {
                newitem["details"] += propertyname.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ") + ": " + propertyvalue.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ");
                //newitem["details"] += propertyname.replace(":", "").replace(/"/g, '\\"') + ": " + propertyvalue;
            } else {
                newitem["details"] += "|" + propertyname.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ") + ": " + propertyvalue.replace(/:/g, " ").replace(/,/g, " ").replace(/;/g, " ");
                //newitem["details"] += ", " + propertyname.replace(":", "").replace(/"/g, '\\"') + ": " + propertyvalue;                
            }
        });
        
        propertyvalueidArr.sort(function(a, b){return a - b;});
        //double check if the pv values combination exists
        var temp_newitem = propertyvalueidArr.join('|');
        var myProductoptionsArr = productoptionsString.split(",");
        var foundMatch = false;
        for(var i=0; i < myProductoptionsArr.length; i++) {
            if(myProductoptionsArr[i] === temp_newitem){foundMatch = true;}
        }
        if(!foundMatch){return alert("This product: " + newitem["details"] + " is not available.");}
        newitem["propertyvalueids"] = propertyvalueidArr.join('|');
        newitem["id"] = String(productid);
        newitem["name"] = productname;
        newitem["price"] = String(price);    
        newitem["currencysign"] = currencysign == null ? '' : currencysign;        
        newitem["weightsign"] = weightsign == null ? '' : weightsign;            
        newitem["istaxfree"] = istaxfree == null ? '0' : String(istaxfree);        
        newitem["isonsale"] = isonsale == null ? '0' : String(isonsale);
        newitem["imagefilenames"] = imagefilenames == null ? '' : imagefilenames;
        
        if(newitem == null || newitem.id == null || newitem.id < 1) {return;}
        newitem.quantity = jQuery('input#dragonecommercereservezyx987_quantity_' + newitem["id"]).val();        
        //filter newitem's every key and value to remove , ; : 
        for (var key in newitem) {
            if(key !== 'details') {
                var temp = String(newitem[key]);
                newitem[key] = temp.replace(/,/g, " ").replace(/;/g, " ").replace(/:/g, " ");
            }
        }                
        //if shoppingcartitems already has the same product id and same propertyvalueids, merge them
        var foundmatch = false;
        var shouldremoveoldediteditem = true;
        for(var j=0; j<shoppingcartitems.length; j++) {
            if(parseInt(shoppingcartitems[j]["id"]) === parseInt(newitem.id) && shoppingcartitems[j]["propertyvalueids"] === newitem.propertyvalueids) {
                //if shopping cart old being edited item is this item, replace quantity
                if(fromshoppingcartpropertyvalueids === newitem.propertyvalueids
                    && parseInt(fromshoppingcartquantity) === parseInt(shoppingcartitems[j]["quantity"])) {
                    shoppingcartitems[j]["quantity"] = newitem.quantity;
                    shouldremoveoldediteditem = false;
                } else {
                    var temp_quantity = parseInt(shoppingcartitems[j]["quantity"]) + parseInt(newitem.quantity);
                    shoppingcartitems[j]["quantity"] = String(temp_quantity);
                }
                foundmatch = true;
                break;
            }
        }
        
        var shouldremoveoldediteditemindex = null;
        if(shouldremoveoldediteditem) {
            //remove shopping cart old being edited item            
            for(var j=0; j<shoppingcartitems.length; j++) {
                if(parseInt(shoppingcartitems[j]["id"]) === parseInt(productid) && shoppingcartitems[j]["propertyvalueids"] === fromshoppingcartpropertyvalueids
                    && parseInt(fromshoppingcartquantity) === parseInt(shoppingcartitems[j]["quantity"])) {
                    shouldremoveoldediteditemindex = j;
                    shoppingcartitems.splice(j, 1);break;
                }
            }
        }
        if(!foundmatch) {        
            if(shouldremoveoldediteditemindex === null) {
                shoppingcartitems.push(newitem);        
            } else if(shouldremoveoldediteditemindex >= 0) {
                shoppingcartitems.splice(shouldremoveoldediteditemindex, 0, newitem);
            }
        }
        jQuery('div#' + container_id).next().append('<button type="button" class="btn-close" tabindex="0" aria-label="click to clear the message" onclick="dragonecommercereservezyx987_emptyParentNode(this);"></button><span aria-label="success" role="img" >success</span>').show();
        jQuery('div.oneproduct_orderdetails input#dragonecommercereservezyx987_gotoshoppingcart').show();
        dragonecommercereservezyx987_showCartIconQuantity();
        dragonecommercereservezyx987_refreshLandingpageLeftTabMenu();
        dragonecommercereservezyx987_updateOrderitemsCookie();
    }
    
    function dragonecommercereservezyx987_goToShoppingcart() {
        //show shopping cart modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
                
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';                        
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" tabindex="0" class="btn-close" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';                
        modalElement += '<div id="dragonecommerce_shoppingcart_container" class="row">';    
        if(shoppingcartitems.length === 0) {
            modalElement += '<div>Empty cart</div>';
        } else {            
            for (i = 0; i < shoppingcartitems.length; i++) {
                modalElement += '<div class="cartitem-container col-12 col-sm-12 col-md-6 col-lg-6"><div class="row-container"><div class="cartitem-product-details-container row">';
                var temp_images = dragonecommercereservezyx987_validString(shoppingcartitems[i].imagefilenames);
                temp_images = temp_images === null ? '' : temp_images;
                var res = temp_images.split("|");
                var previewimage = res.length > 0 ? res[0] : '';
                var previewimage_urllink = previewimage === '' ? ("<?php echo plugins_url('images/', __FILE__ ); ?>" + 'no_img.png') : ("<?php echo dragonecommercereservezyx987_upload_url() . "/images/product/"; ?>" + dragonecommercereservezyx987_validString(shoppingcartitems[i].id) + "/preview/" + previewimage);
                modalElement += "<div class='cartitem-productimage'><img src=\"" + previewimage_urllink + '" alt="' + dragonecommercereservezyx987_validString(shoppingcartitems[i].name).replace(/"/g, '&#34;') + '"></div>';    
                modalElement += '</div><div class="cartitem-product-namedetails-container row"><div class="cartitem-productdetails"><div class="name">Name: ' + dragonecommercereservezyx987_validString(shoppingcartitems[i].name) + '</div><div>Price: <span class="currencysign">' + dragonecommercereservezyx987_validString(shoppingcartitems[i].currencysign) + '</span><span class="price">' + dragonecommercereservezyx987_validString(shoppingcartitems[i].price) + '</span></div><div class="quantity">Quantity: ' + dragonecommercereservezyx987_validString(shoppingcartitems[i].quantity) + '</div><div class="details">Details: ' + dragonecommercereservezyx987_validString(shoppingcartitems[i].details).replace(/\\/g, '') + '</div>';
                modalElement += '</div></div><div class="cartitem-product-action-container row"><div class="action">';
                modalElement += '<button type="button" class="btn btn-lg" tabindex="0" aria-label="edit" onclick="dragonecommercereservezyx987_showProduct(' + shoppingcartitems[i]["id"] + ',' + shoppingcartitems[i]["quantity"] + ',' + (shoppingcartitems[i]["propertyvalueids"] === '' ? '\'\'' : ('\'' + shoppingcartitems[i]["propertyvalueids"] + '\'')) + ');"><span aria-label="edit" role="img" class="fs-2 bi bi-pencil"></span></button>';
                modalElement += '<button type="button" class="btn btn-lg" tabindex="0" aria-label="delete" onclick="dragonecommercereservezyx987_removeCartItem(this);"><span aria-label="delete" role="img" class="fs-2 bi bi-trash"></span></button>';
                modalElement += '</div></div>';                
                modalElement += '</div></div>';            
            }                                
        }
        
        modalElement += '</div>';
            
        if(shoppingcartitems.length > 0) {
            modalElement += '<div id="dragonecommerce_shoppingcart_actions_container" class="row">';
            //buttons: back to shopping, confirm order
            modalElement += '<div class="col">';
            modalElement += '<input type="button" name="dragonecommercereservezyx987_backtoshopping" tabindex="0" aria-label="back to shopping" class="btn btn-primary" style="float: left;" onclick="dragonecommercereservezyx987_closemodal(\'mylargeshoppingcartmodal\');" value="BACK SHOPPING">';
            modalElement += '</div><div class="col">';
            modalElement += '<input type="button" id="dragonecommercereservezyx987_confirmcheckout" tabindex="0" aria-label="confirm" name="dragonecommercereservezyx987_confirmcheckout" class="btn btn-primary" style="float: right;" onclick="dragonecommercereservezyx987_goToCheckout();" value="CONFIRM">';            
            modalElement += '</div>';
            modalElement += '</div>';
        }
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';
        //modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        //modalElement += '</div>';    

        modalElement += '</div></div>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("div#mylargeshoppingcartmodal div#dragonecommerce_shoppingcart_actions_container input#dragonecommercereservezyx987_confirmcheckout").focus();});<\/script>';

        jQuery('div#mylargeshoppingcartmodal').html(modalElement);
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }        
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }    
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        mylargeshoppingcartmodal = new bootstrap.Modal(document.getElementById('mylargeshoppingcartmodal'));
        mylargeshoppingcartmodal.show();
        jQuery("div#mylargeshoppingcartmodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeshoppingcartmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
    }
    
    function dragonecommercereservezyx987_goToCheckout() {
        if(shoppingcartitems.length === 0) {return alert("Shopping cart is empty.");}
        jQuery('div#loading').show();
        //clear all the variable values
        shippingArr = [], handlingArr = [], taxArr = [];
        taxrate = 0, taxincludeshipping = 0, taxincludehandling = 0;
        discountArr = [], couponArr = [];
                
        //show shopping cart modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        
        //if user is not logged in, go to log in modal:
        if(b1n9j5t7R9P1 === null || b1n9j5t7R9P1 === 0 || b1n9j5t7R9P1 < 0) {
            jQuery('div#loading').hide();
            return dragonecommercereservezyx987_goToLogin();
        }
        if(b1n9j5t7R9P1 > 0 && b1n9j5t7R9P2 === 0) {
            jQuery('div#loading').hide();
            return alert("Your session expired or you do not have the right to reserve from this ecommerce website. Please log out and log in as a user who can reserve.");
        }
        if(b1n9j5t7R9P2 === null || b1n9j5t7R9P2 === 0 || b1n9j5t7R9P2 < 0) {
            jQuery('div#loading').hide();
            return alert("Your session expired or you do not have the right to reserve from this ecommerce website. Please log out and log in as a user who can reserve.");
        }
        if(b1n9j5t7R9P1 !== b1n9j5t7R9P2) {
            jQuery('div#loading').hide();
            return dragonecommercereservezyx987_goToLogin();
        }                        
        var modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';
        
        var i, subtotal = 0, subtotalfortax = 0;                                
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">' +
                '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>' +
                '</div>';
        
        modalElement += '<div class="modal-body">';
        modalElement += '<form id="dragonecommercereservezyx987_submitorderandpayment_form" target="_self" method="post" autocomplete="off" onsubmit="return false">';        
        modalElement += '<div id="dragonecommerce_checkout_container" class="row">';
        
        if(shoppingcartitems.length === 0) {
            modalElement += '<div class="checkoutitem-container col-12 col-sm-12 col-md-3 col-lg-3"><div class="row-container"><div class="checkoutitem-product-details-container row">';
            modalElement += "<div class='checkoutitem-productimage col-12 col-sm-12 col-md-6 col-lg-6'>Empty cart</div>";
            modalElement += '</div></div></div>';
            modalElement += "<input type='hidden' name='dragonecommercereservezyx987_paymentamount' id='dragonecommercereservezyx987_paymentamount' value='' />";
        } else {            
            for (i = 0; i < shoppingcartitems.length; i++) {
                currencysign = shoppingcartitems[0]["currencysign"];
                modalElement += '<div class="checkoutitem-container col-12 col-sm-12 col-md-3 col-lg-3"><div class="row-container"><div class="checkoutitem-product-details-container row">';
                var temp_images = dragonecommercereservezyx987_validString(shoppingcartitems[i].imagefilenames);
                var res = temp_images.split("|");
                var previewimage = res.length > 0 ? res[0] : '';
                var previewimage_urllink = previewimage === '' ? ("<?php echo plugins_url('images/', __FILE__ ); ?>" + 'no_img.png') : ("<?php echo dragonecommercereservezyx987_upload_url() . "/images/product/"; ?>" + dragonecommercereservezyx987_validString(shoppingcartitems[i].id) + "/preview/" + previewimage);
                modalElement += "<div class='checkoutitem-productimage'><img src=\"" + previewimage_urllink + '" alt="' + dragonecommercereservezyx987_validString(shoppingcartitems[i].name).replace(/"/g, '&#34;') + '"></div>';    
                modalElement += '</div><div class="checkoutitem-product-namedescription-container row"><div class="checkoutitem-productdetails"><div class="name">Name: ' + dragonecommercereservezyx987_validString(shoppingcartitems[i].name) + '</div><div>Price: <span class="currencysign">' + dragonecommercereservezyx987_validString(shoppingcartitems[i].currencysign) + '</span><span class="price">' + dragonecommercereservezyx987_validString(shoppingcartitems[i].price) + '</span></div><div class="quantity">Quantity: ' + dragonecommercereservezyx987_validString(shoppingcartitems[i].quantity) + '</div><div class="details">Details: ' + dragonecommercereservezyx987_validString(shoppingcartitems[i].details).replace(/\\/g, '') + '</div>';
                modalElement += '<input type="hidden" name="orderitem[]" value="' + shoppingcartitems[i].id + '_' + shoppingcartitems[i].quantity + '_' + shoppingcartitems[i].propertyvalueids + '" />';
                modalElement += '</div></div>';
                modalElement += '</div></div>';
                subtotal += parseInt(shoppingcartitems[i].quantity) * parseFloat(shoppingcartitems[i].price);    
                if(parseInt(shoppingcartitems[i].istaxfree) === 0) {
                    subtotalfortax += parseInt(shoppingcartitems[i].quantity) * parseFloat(shoppingcartitems[i].price);
                }                    
            }
        }        
        modalElement += '</div>';

        //add shipping address
        if(shoppingcartitems.length > 0) {
            modalElement += '<hr/><div id="dragonecommerce_checkout_shippingaddress_container" class="row">';            
            modalElement += 'SHIPPING ADDRESS:';            
            modalElement += '<div class="wrap">';

            modalElement += '<div class="cell col-12 col-sm-12 col-md-12 col-lg-12" id="checkout_shippingaddress">';
    
            modalElement += '<div data-locale-reversible>'; 
            modalElement +=     '<div class="sr-combo-inputs-row" style="padding:5px;">';
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-12 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-name" data-tid="elements_examples.form.name_label">Name</label>';
            modalElement +=                 '<input id="shippingaddress-name" aria-label="your name for the shipping address" name="shippingaddress-name" tabindex="0" data-tid="elements_examples.form.name_placeholder" class="form-control input empty" type="text" placeholder="Name" required="" autocomplete="name-line1">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-email" data-tid="elements_examples.form.email_label">Email</label>';
            modalElement +=                 '<input id="shippingaddress-email" aria-label="your email address for the shipping address" name="shippingaddress-email" tabindex="0" data-tid="elements_examples.form.email_placeholder" class="form-control input empty" type="text" placeholder="Email" required="" autocomplete="email-line1">';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-phone" data-tid="elements_examples.form.phone_label">Phone</label>';
            modalElement +=                 '<input id="shippingaddress-phone" aria-label="your phone number for the shipping address" name="shippingaddress-phone" tabindex="0" data-tid="elements_examples.form.phone_placeholder" class="form-control input empty" type="text" placeholder="Phone" required="" autocomplete="phone-line1">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-12 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-address" data-tid="elements_examples.form.address_label">Address</label>';
            modalElement +=                 '<input id="shippingaddress-address" aria-label="your address for the shipping address" name="shippingaddress-address" tabindex="0" data-tid="elements_examples.form.address_placeholder" class="form-control input empty" type="text" placeholder="Address" required="" autocomplete="address-line1">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-12 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-address2" data-tid="elements_examples.form.address2_label">Address 2</label>';
            modalElement +=                 '<input id="shippingaddress-address2" aria-label="your address 2 for the shipping address" name="shippingaddress-address2" tabindex="0" data-tid="elements_examples.form.address2_placeholder" class="form-control input empty" type="text" placeholder="Address 2" required="" autocomplete="address-line2">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';
            modalElement +=         '<div class="row" data-locale-reversible>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container ">';
            modalElement +=                 '<label for="shippingaddress-country" data-tid="elements_examples.form.country_label">Country/Region</label>';
            modalElement +=                 '<select name="shippingaddress-country" aria-label="your country or region for the shipping address" id="shippingaddress-country" tabindex="0" class="form-select form-select-lg" onchange="dragonecommercereservezyx987_showShippingHandlingTaxPreorderBasedOnCountryProvince(this, \'shippingaddress-country\',\'shippingaddress-state\',\'shippingaddress-countryname\',\'shippingaddress-statename\');">';
            modalElement +=                     '<option value="-1">Please choose one...</option>';            
            <?php $activecountries = dragonecommercereservezyx987_getCountries();
            foreach ($activecountries as $country) { ?>            
                modalElement +=                     '<option value="<?php echo sanitize_text_field($country->abbreviation);  ?>">' + "<?php echo htmlentities($country->name);  ?></option>";            
            <?php } ?>            
            
            modalElement +=                 '</select>';
            
            modalElement +=                 '<input id="shippingaddress-countryname" name="shippingaddress-countryname" value="" type="hidden" >';

            modalElement +=             '</div>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-state" data-tid="elements_examples.form.state_label">State/Province</label>';


            modalElement +=                 '<select name="shippingaddress-state" aria-label="your state or province for the shipping address" id="shippingaddress-state" tabindex="0" class="form-select form-select-lg" onchange="dragonecommercereservezyx987_showShippingHandlingTaxPreorderBasedOnCountryProvince(this, \'shippingaddress-country\',\'shippingaddress-state\',\'shippingaddress-countryname\',\'shippingaddress-statename\');">';
            modalElement +=                     '<option value="-1">Please choose one...</option>';
            
            <?php $activeprovinces = dragonecommercereservezyx987_getAllProvinces();
            foreach ($activeprovinces as $province) { ?>            
                modalElement +=                     '<option class="<?php echo sanitize_text_field($province->abbreviation);  ?>" value="<?php echo intval($province->id);  ?>" style="display:none;">' + "<?php echo htmlentities($province->name);  ?></option>";            
            <?php } ?>
            modalElement +=                 '</select>';
            modalElement +=                 '<input id="shippingaddress-statename" name="shippingaddress-statename" value="" type="hidden" >';

            modalElement +=             '</div>';
            modalElement +=         '</div>';
            modalElement +=         '<div class="row" data-locale-reversible>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<label for="shippingaddress-city" data-tid="elements_examples.form.city_label">City</label>';
            modalElement +=                 '<input id="shippingaddress-city" aria-label="your city for the shipping address" name="shippingaddress-city" tabindex="0" data-tid="elements_examples.form.city_placeholder" class="form-control input empty" type="text" placeholder="City" required="" autocomplete="address-level2">';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container ">';
            modalElement +=                 '<label for="shippingaddress-zip" data-tid="elements_examples.form.postal_code_label">ZIP</label>';
            modalElement +=                 '<input id="shippingaddress-zip" aria-label="your zip code or postal code for the shipping address" name="shippingaddress-zip" tabindex="0" data-tid="elements_examples.form.postal_code_placeholder" class="form-control input empty" type="text" placeholder="ZIP" required="" autocomplete="postal-code">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';
                        
            modalElement +=     '</div>';
              
            modalElement +=     '<div class="error" role="alert">';
            modalElement +=         '<div class="alert alert-danger message" role="alert"></div>';
            modalElement +=     '</div>';
            modalElement += '</div>';
            
            modalElement += '<div class="success" >';
            modalElement += '<div class="alert alert-success" role="alert"></div>';
            modalElement += '<a class="reset" href="javascript:void(0);"></a>';
            modalElement += '</div>';
            modalElement += '</div>';              
            modalElement += '</div>';                        
            modalElement += '</div>';            
                        
        }
        

        if(shoppingcartitems.length > 0) {
            modalElement += '<hr/><div id="dragonecommerce_checkout_shippinghandling_container" class="row">';
            modalElement += 'SERVICE:';
            modalElement += '<div class="wrap">';
            modalElement += '<div class="cell col-12 col-sm-12 col-md-12 col-lg-12" id="checkout_shippinghandling">';    
            modalElement += '<div>'; 
            modalElement +=     '<div class="sr-combo-inputs-row" style="padding:5px;">';
                        
            //add shipping,handling
            <?php if($settings["ENABLE_SHIPPING_CHARGE"]["settingvalue"] === '1') {  ?>            
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<label>Shipping</label>';        
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<select name="shipping_dropdown" aria-label="your shipping method for the shipping address" id="shipping_dropdown" tabindex="0" class="form-select form-select-lg" onchange="dragonecommercereservezyx987_showShippingOnOrdersummary(\'shipping_dropdown\',\'shipping\',\'' + shoppingcartitems[0]["currencysign"] + '\', \'handling_dropdown\', \'handling\');">';
            modalElement +=                 '</select>';
            modalElement +=                 '<input id="shippingid" name="shippingid" type="hidden" value="" />';            
            modalElement +=             '</div>';
            modalElement +=         '</div>';
            <?php }  ?>
        
            <?php if($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"] === '1') {  ?>
            modalElement +=         '<br/><br/><div class="row">';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<label>Handling</label>';        
            modalElement +=             '</div>';        
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<select name="handling_dropdown" aria-label="your handling method for the shipping address" id="handling_dropdown" tabindex="0" class="form-select form-select-lg" onchange="dragonecommercereservezyx987_showHandlingOnOrdersummary(\'handling_dropdown\',\'handling\',\'' + shoppingcartitems[0]["currencysign"] + '\', \'shipping_dropdown\', \'shipping\');">';
            modalElement +=                 '</select>';
            modalElement +=                 '<input id="handlingid" name="handlingid" type="hidden" value="" />';            
            modalElement +=             '</div>';
            
            modalElement +=         '</div>';    
            <?php }    ?>                    
            
            modalElement +=     '</div>';
              
            modalElement +=     '<div class="error" role="alert">';
            modalElement +=         '<div class="alert alert-danger message" role="alert"></div>';
            modalElement +=     '</div>';
            modalElement += '</div>';
            
            modalElement += '<div class="success">';
            modalElement += '<div class="alert alert-success" role="alert"></div>';
            modalElement += '<a class="reset" href="javascript:void(0);"></a>';
            modalElement += '</div>';
            modalElement += '</div>';              
            modalElement += '</div>';                        
            modalElement += '</div>';            
        }
        
        //list subtotal,shipping,handling,tax,pre-order,discount for whole store and total price
        if(shoppingcartitems.length > 0) {
            modalElement += '<hr/><div id="dragonecommerce_checkout_ordersummary_container" class="row">';
            modalElement += 'SUMMARY:';
            modalElement += '<div class="wrap">';

            modalElement += '<div class="cell col-12 col-sm-12 col-md-12 col-lg-12" id="checkout_ordersummary">';
    
            modalElement += '<div>'; 
            modalElement +=     '<div class="sr-combo-inputs-row" style="padding:5px;">';
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<label>Subtotal</label>';

            modalElement +=             '</div>';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<span id="subtotalcurrency" name="subtotalcurrency">' + shoppingcartitems[0]["currencysign"] + '</span>';
            modalElement +=                 '<span id="subtotal" name="subtotal">' + (subtotal === 0 ? '' : subtotal.toFixed(2)) + '</span>';
            modalElement +=                 '<span id="subtotalOriginal" name="subtotalOriginal" style="display:none;">' + (subtotal === 0 ? '' : subtotal) + '</span>';
            modalElement +=                 '<span id="subtotalfortax" name="subtotalfortax" style="display:none;">' + (subtotalfortax <= 0 ? '0' : subtotalfortax) + '</span>';

            modalElement +=             '</div>';
            modalElement +=         '</div>';            

            //foreach loop for discount list
            modalElement +=     '<div id="discount_container">';            
            for(var i=0; i < discountArr.length; i++) {            
                modalElement +=         '<div class="row">';
                modalElement +=             '<div class="col-6 textbox-container">';
                modalElement +=                 '<label>Discount';
                if(parseInt(discountArr[i]["userate"]) === 1) {
                    modalElement +=             ' (rate)';
                } else if(parseInt(discountArr[i]["usefee"]) === 1) {
                    modalElement +=             ' (fee)';
                }                
                modalElement +=                 '</label>';
                modalElement +=             '</div>';
                modalElement +=             '<div class="col-6 textbox-container">';
                modalElement +=                 '<span class="discount" id="discount' + i + '" name="discount' + i + '" style="color:red;">'
                if(parseInt(discountArr[i]["userate"]) === 1) {
                    modalElement +=             discountArr[i]["rate"];
                } else if(parseInt(discountArr[i]["usefee"]) === 1) {
                    modalElement +=                 '<span id="discountcurrency' + i + '" name="discountcurrency' + i + '">' + shoppingcartitems[0]["currencysign"] + '</span>';
                    modalElement +=             discountArr[i]["fee"];
                }                
                modalElement +=                 '</span>';
                modalElement +=             '</div>';
                modalElement +=         '</div>';    
            }
            modalElement +=         '</div>';
            
            //foreach loop for coupon list
            modalElement +=     '<div id="coupon_container">';            
            for(var i=0; i < couponArr.length; i++) {    
                modalElement +=         '<div class="row">';
                modalElement +=             '<div class="col-6 textbox-container">';
                modalElement +=                 '<label>Coupon';
                if(parseInt(couponArr[i]["userate"]) === 1) {
                    modalElement +=             ' (rate)';
                } else if(parseInt(couponArr[i]["usefee"]) === 1) {
                    modalElement +=             ' (fee)';
                }                
                modalElement +=                 '</label>';
                modalElement +=             '</div>';
                modalElement +=             '<div class="col-6 textbox-container">';
                modalElement +=                 '<span class="coupon" id="coupon' + i + '" name="coupon' + i + '" style="color:red;">';
                if(parseInt(couponArr[i]["userate"]) === 1) {
                    modalElement +=             couponArr[i]["rate"];
                } else if(parseInt(couponArr[i]["usefee"]) === 1) {
                    modalElement +=             '<span id="couponcurrency' + i + '" name="couponcurrency' + i + '">' + shoppingcartitems[0]["currencysign"] + '</span>';
                    modalElement +=             couponArr[i]["fee"];
                }                
                modalElement +=                 '</span>';
                
                modalElement +=                 '&nbsp;&nbsp;&nbsp;&nbsp;<span role="button" tabindex="0"  aria-label="remove coupon" role="img" class="coupon_remove" id="coupon' + i + '_remove" name="coupon' + i + '_remove" style="color:red;" onclick="dragonecommercereservezyx987_removeCoupon(this, ' + i + ');" onkeydown="dragonecommercereservezyx987_removeCouponHandler(event, this, ' + i + ');">';

                modalElement +=                 'REMOVE</span>';
                
                modalElement +=             '</div>';
                modalElement +=         '</div>';    
            }
            modalElement +=         '</div>';
                    
            <?php if(intval($settings["ENABLE_SHIPPING_CHARGE"]["settingvalue"]) === 1) {  ?>                    
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<label>Shipping</label>';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<span id="shippingcurrency" name="shippingcurrency">' + shoppingcartitems[0]["currencysign"] + '</span>';
            modalElement +=                 '<span id="shipping" name="shipping"></span>';
            modalElement +=             '</div>';
            modalElement +=         '</div>';    
            <?php }    ?>
            
            <?php if(intval($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"]) === 1) {  ?>
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<label>Handling</label>';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<span id="handlingcurrency" name="handlingcurrency">' + shoppingcartitems[0]["currencysign"] + '</span>';
            modalElement +=                 '<span id="handling" name="handling"></span>';
            modalElement +=             '</div>';
            modalElement +=         '</div>';
            <?php }    ?>
            
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<label>Tax after reduction</label>';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<span id="taxcurrency" name="taxcurrency">' + shoppingcartitems[0]["currencysign"] + '</span>';
            modalElement +=                 '<span id="tax" name="tax"></span>';
            modalElement +=                 '<input id="taxid" name="taxid" type="hidden" value="" />';            
            modalElement +=             '</div>';
            modalElement +=         '</div>';    

            modalElement +=         '<hr/><div class="row">';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<label>Total</label>';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-6 textbox-container">';
            modalElement +=                 '<span id="totalcurrency" name="totalcurrency">' + shoppingcartitems[0]["currencysign"] + '</span>';
            modalElement +=                 '<span id="total" name="total"></span>';
            modalElement +=                 '<span id="totalOriginal" name="totalOriginal" style="display:none;"></span>';
            modalElement +=             '</div>';
            modalElement +=         '</div>';    
            
            modalElement +=     '</div>';
              
            modalElement +=     '<div class="error" role="alert">';
            modalElement +=         '<div class="alert alert-danger message" role="alert"></div>';
            modalElement +=     '</div>';
            modalElement += '</div>';
            
            modalElement += '<div class="success">';
            modalElement += '<div class="alert alert-success" role="alert"></div>';
            modalElement += '<a class="reset" href="javascript:void(0);"></a>';
            modalElement += '</div>';
            modalElement += '</div>';              
            modalElement += '</div>';                        
            modalElement += '</div>';            
        }

        //enter coupon
        if(shoppingcartitems.length > 0) {
            modalElement += '<hr/><div id="dragonecommerce_checkout_coupon_container" class="row">';
            modalElement += 'COUPON:';

            modalElement += '<div class="wrap">';

            modalElement += '<div class="cell col-12 col-sm-12 col-md-12 col-lg-12" id="checkout_coupon">';
    
            modalElement += '<div>'; 
            modalElement +=     '<div class="sr-combo-inputs-row" style="padding:5px;">';
            modalElement +=         '<div class="row">';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<input id="dragonecommercereservezyx987_coupon" aria-label="enter your coupon" tabindex="0" name="dragonecommercereservezyx987_coupon" class="form-control input empty" type="text" placeholder="Coupon" >';
            modalElement +=             '</div>';
            modalElement +=             '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            modalElement +=                 '<input id="dragonecommercereservezyx987_submit_coupon" aria-label="validate your coupon" tabindex="0" name="dragonecommercereservezyx987_submit_coupon" class="form-control input empty" type="button" value="VALIDATE COUPON" onclick="dragonecommercereservezyx987_validatecoupon(\''+ shoppingcartitems[0]["currencysign"] + '\');">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';    

            modalElement +=         '<br/><br/><br/><div class="row">';
            modalElement +=             '<div class="col-12 textbox-container">';
            modalElement +=                 '<input id="dragonecommercereservezyx987_confirm_order" aria-label="next step" tabindex="0" name="dragonecommercereservezyx987_confirm_order" class="form-control input empty" type="button" value="NEXT" onclick="dragonecommercereservezyx987_validateconfirmorder(\''+ shoppingcartitems[0]["currencysign"] + '\');">';
            modalElement +=             '</div>';
            modalElement +=         '</div>';    
            
            modalElement +=     '</div>';
              
            modalElement +=     '<div class="error" role="alert">';
            modalElement +=         '<div class="alert alert-danger message" role="alert"></div>';
            modalElement +=     '</div>';
            modalElement += '</div>';
            
            modalElement += '<div class="success">';
            modalElement += '<div class="alert alert-success" role="alert"></div>';
            modalElement += '<a class="reset" href="javascript:void(0);"></a>';
            modalElement += '</div>';
            modalElement += '</div>';              
            modalElement += '</div>';                        
            modalElement += '</div>';        
        }
        
        if(shoppingcartitems.length > 0) {
            //if shipping address country and province not chosen, show error message: Please choose shipping method first.            
            modalElement += '<div id="dragonecommerce_checkout_actions_container" class="row" style="display:none;">';
            <?php if((!empty($settings["USE_GOOGLE_RECAPTCHA"])) && intval($settings["USE_GOOGLE_RECAPTCHA"]) === 1 && (!empty($settings["GOOGLE_RECAPTCHA_SITEKEY"])) && $settings["GOOGLE_RECAPTCHA_SITEKEY"] !== '' ) { ?>            
            modalElement += '<div>If reserve failed, please close this pop up window and check out again to create a new Google recaptcha for validation.</div>';
            modalElement += '<div id="dragonecommerce_recaptcha" aria-label="Google recaptcha for validation" ></div><br/>';
            <?php } ?>
            //buttons: back to shopping, confirm order
            modalElement += '<div class="col">';
            modalElement += '<input type="button" name="dragonecommercereservezyx987_backtoshopping" aria-label="back to shopping" role="button" tabindex="0" class="btn btn-primary" style="float: left;" onclick="dragonecommercereservezyx987_closemodal(\'mylargecheckoutmodal\');" value="BACK SHOPPING">';    
            modalElement += '</div>';
            //modalElement += '<div class="col-12 col-sm-12 col-md-6 textbox-container">';
            <?php if((!empty($settings["USE_GOOGLE_RECAPTCHA"])) && intval($settings["USE_GOOGLE_RECAPTCHA"]) === 1 && (!empty($settings["GOOGLE_RECAPTCHA_SITEKEY"])) && $settings["GOOGLE_RECAPTCHA_SITEKEY"] !== '' ) { ?>            
            modalElement += '<div class="col">';
            modalElement += '<input type="button" id="dragonecommercereservezyx987_submitorderandpayment" aria-label="make reservation" name="dragonecommercereservezyx987_submitorderandpayment" role="button" tabindex="0" class="btn btn-primary" style="float: right;" onclick="jQuery(\'form#dragonecommercereservezyx987_submitorderandpayment_form\').submit();" value="RESERVE" disabled>';
            modalElement += '</div>';
            <?php } else {?>
            modalElement += '<div class="col">';            
            modalElement += '<input type="button" id="dragonecommercereservezyx987_submitorderandpayment" aria-label="make reservation" name="dragonecommercereservezyx987_submitorderandpayment" role="button" tabindex="0" class="btn btn-primary" style="float: right;" onclick="jQuery(\'form#dragonecommercereservezyx987_submitorderandpayment_form\').submit();" value="RESERVE" >';            
            modalElement += '</div>';
            <?php } ?>
            //modalElement += '</div>';            
            modalElement += '</div>';
            <?php if((!empty($settings["USE_GOOGLE_RECAPTCHA"])) && intval($settings["USE_GOOGLE_RECAPTCHA"]) === 1 && (!empty($settings["GOOGLE_RECAPTCHA_SITEKEY"])) && $settings["GOOGLE_RECAPTCHA_SITEKEY"] !== '' ) { ?>            
            modalElement += '<script>';
            modalElement += "function dragonecommercereservezyx987_verifyCallback() {jQuery('input#dragonecommercereservezyx987_submitorderandpayment').prop('disabled', false);}";
            modalElement += "function dragonecommercereservezyx987_expiredCallback() {jQuery('input#dragonecommercereservezyx987_submitorderandpayment').prop('disabled', true);}";
            modalElement += "var onloadCallback = function() {grecaptcha.render('dragonecommerce_recaptcha', {'sitekey' : '" + "<?php echo empty($settings['GOOGLE_RECAPTCHA_SITEKEY']) ? '' : sanitize_text_field($settings['GOOGLE_RECAPTCHA_SITEKEY']); ?>" + "','callback' : dragonecommercereservezyx987_verifyCallback,'expired-callback' : dragonecommercereservezyx987_expiredCallback});};";
            modalElement += '<\/script>';
            <?php } ?>
        }
            
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '</form>';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';        
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';
        //modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        //modalElement += '</div>';    

        modalElement += '</div></div>';
        modalElement += '<script src="' + jsurl3 + '"><\/script>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("input#shippingaddress-name").focus();});<\/script>';        
        
        jQuery('div#mylargecheckoutmodal').html(modalElement);
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }        
        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }        
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }    
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        mylargecheckoutmodal = new bootstrap.Modal(document.getElementById('mylargecheckoutmodal'));
        mylargecheckoutmodal.show();
        jQuery("div#mylargecheckoutmodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargecheckoutmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
        jQuery('div#loading').hide();
    }
    
    function dragonecommercereservezyx987_removeCouponHandler(event, element, index) {
        if(dragonecommercereservezyx987_isEnterSpaceEvent(event)) {
            dragonecommercereservezyx987_removeCoupon(element, index);
        }            
    }
    
    function dragonecommercereservezyx987_removeCoupon(element, index) {
        jQuery(element).parent().parent().remove();
        //remove from couponArr
        if (index > -1) {
          couponArr.splice(index, 1);
        }    
        //update tax and total
        if(shoppingcartitems.length > 0) {
            dragonecommercereservezyx987_showTaxOnOrdersummary('tax', shoppingcartitems[0]["currencysign"]);    
        }
    }    
    
    function dragonecommercereservezyx987_goToLogin() {                
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';                        
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';        
        modalElement += '<div id="dragonecommerce_login_container" class="row">';
        
        modalElement += '<div class="login-container col-12 col-sm-12 col-md-12 col-lg-12"><div class="row-container"><div class="login-details-container row">';
        modalElement += "<div class='login-content col-12 col-sm-12 col-md-12 col-lg-12'>";

        modalElement += '<div class="login_form_container">';
        modalElement += '<form id="dragonecommercereservezyx987_login_form" class="form_login" target="_self" method="post" autocomplete="off" >';
        modalElement += '<div class="login_label"><h1 class="form_login_heading text-center">Log in</h1></div>';
        modalElement += '<label for="loginusername" class="sr-only">Username</label>';
        modalElement += '<input type="text" aria-label="login username" id="loginusername" role="button" tabindex="0"  name="loginusername" class="form-control" placeholder="Username" required="" autofocus="" autocomplete="none">';
        modalElement += '<label for="loginpassword" class="sr-only">Password</label>';
        modalElement += '<input type="password" aria-label="login password" id="loginpassword" role="button" tabindex="0"  name="loginpassword" class="form-control" placeholder="Password" required="" autocomplete="new-password">';
        modalElement += '<div class="login_reminder_label"><h4 class="form_login_label">Make sure you already got approval email from admin. Password must be at least eight characters. Password should only contain 0-9, a-z, A-Z, and at least one of special characters !@#*()$%^&. So wordpress admin user maybe can not log on this website because admin password may contain other special characters.</h4></div>';
        modalElement += '<input class="btn btn-lg btn-primary btn-block w-100" type="button" tabindex="0"  name="dragonecommercereservezyx987_login" value="Log in" onclick="dragonecommercereservezyx987_loginUserBySubmitForm();" />';
        modalElement += '<div class="resetpassword_reminder_label"><h4 class="form_login_label" style="color:red;">Please do not use this website\'s WordPress login page /wp-login.php to reset your password.</h4></div>';        
        modalElement += '<br/><div class="register_link"><a href="javascript:void(0);" role="button" tabindex="0"  onclick="dragonecommercereservezyx987_goToResetpassword();">Forgot Password</a></div>';
        modalElement += '<br/><div class="register_link"><a href="javascript:void(0);" role="button" tabindex="0"  onclick="dragonecommercereservezyx987_goToResendActivationEmail();">Resend Activation Email</a></div>';
        
        modalElement += '<br/><div class="register_link"><a href="javascript:void(0);" role="button" tabindex="0"  onclick="dragonecommercereservezyx987_goToRegister();">Register</a></div>';
        modalElement += '<br/><div class="register_link"><a href="javascript:void(0);" role="button" tabindex="0"  onclick="dragonecommercereservezyx987_goToResetpasswordusingtoken();">Reset Password Using Token</a></div>';

        modalElement += '</form>';
        modalElement += '</div>';
        modalElement += '</div>';
        modalElement += '</div></div></div>';
        modalElement += "<input type='hidden' name='dragonecommercereservezyx987_login_token' id='dragonecommercereservezyx987_login_token' value='' />";
        
        modalElement += '</div>';            
            
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';        
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';
        //modalElement += '<button type="button" aria-label="close the pop up window" tabindex="0" class="btn-close" data-bs-dismiss="modal"></button>';
        //modalElement += '</div>';    

        modalElement += '</div></div>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("input#loginusername").focus();});<\/script>';        

        jQuery('div#mylargeloginmodal').html(modalElement);
        jQuery('div#mylargeloginmodal div#dragonecommerce_login_container div.login_form_container form#dragonecommercereservezyx987_login_form input#email').val('');
        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        
        //show login modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery('div#mylargecheckoutmodal').hide();
        //jQuery('div#mylargecheckoutmodal').addClass('hide');
        jQuery('div#mylargecheckoutmodal').html('');
        jQuery('div#mylargesearchmodal').hide();
        //jQuery('div#mylargesearchmodal').addClass('hide');
        jQuery('div#mylargesearchmodal').html('');    
        jQuery('div#mylargeshoppingcartmodal').hide();
        //jQuery('div#mylargeshoppingcartmodal').addClass('hide');
        jQuery('div#mylargeshoppingcartmodal').html('');        
        jQuery('div#mylargeregistermodal').hide();
        //jQuery('div#mylargeregistermodal').addClass('hide');
        jQuery('div#mylargeregistermodal').html('');                
        jQuery('div#mylargeforgetpasswordmodal').hide();
        //jQuery('div#mylargeforgetpasswordmodal').addClass('hide');
        jQuery('div#mylargeforgetpasswordmodal').html('');
        jQuery('div#mylargeecommercemenumodal').hide();
        //jQuery('div#mylargeecommercemenumodal').addClass('hide');
        jQuery('div#mylargeecommercemenumodal').html('');
        jQuery('div#mylargedashboardmodal').hide();
        //jQuery('div#mylargedashboardmodal').addClass('hide');
        jQuery('div#mylargedashboardmodal').html('');
        jQuery('div#mylargeaccountactivationmodal').hide();
        //jQuery('div#mylargeaccountactivationmodal').addClass('hide');
        jQuery('div#mylargeaccountactivationmodal').html('');
        jQuery('div#mylargeresetpasswordusingtokenmodal').hide();
        //jQuery('div#mylargeresetpasswordusingtokenmodal').addClass('hide');
        jQuery('div#mylargeresetpasswordusingtokenmodal').html('');
        jQuery('div#mymediumcookiemodal').hide();
        //jQuery('div#mymediumcookiemodal').addClass('hide');
        jQuery('div#mymediumcookiemodal').html('');
        mylargeloginmodal = new bootstrap.Modal(document.getElementById('mylargeloginmodal'));
        mylargeloginmodal.show();
        jQuery('div#mylargeloginmodal div#dragonecommerce_login_container div.login_form_container form#dragonecommercereservezyx987_login_form input#email').val('');
        jQuery("div#mylargeloginmodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeloginmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
    }
    
    function dragonecommercereservezyx987_goToRegister() {        
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';                
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';        
        modalElement += '<div id="dragonecommerce_register_container" class="row">';        
        modalElement += '<div class="register-container col-12 col-sm-12 col-md-12 col-lg-12"><div class="row-container"><div class="register-details-container row">';
        modalElement += "<div class='register-content col-12 col-sm-12 col-md-12 col-lg-12'>";
        modalElement += '<div class="register_form_container">';
        modalElement += '<form id="dragonecommercereservezyx987_register_form" class="form_register" target="_self" method="post" autocomplete="off" onsubmit="return false">';
        modalElement += '<div class="register_label"><h1 class="form_register_heading text-center">Register</h1></div>';
        modalElement += '<label for="username" class="sr-only">Username</label>';
        modalElement += '<input type="text" id="registerusername" role="button" tabindex="0" name="registerusername" class="form-control" placeholder="Username" required="" autofocus="" autocomplete="none">';
        modalElement += '<label for="registerpassword" class="sr-only">Password</label>';
        modalElement += '<input type="password" id="registerpassword" role="button" tabindex="0" name="registerpassword" class="form-control" placeholder="Password" required="" autocomplete="new-password">';
        modalElement += '<input type="password" id="registerpassword_confirmation" role="button" tabindex="0" name="registerpassword_confirmation" class="form-control" placeholder="Confirm Password" required="" autocomplete="new-password">';
        modalElement += '<label for="email" class="sr-only">Email address</label>';
        modalElement += '<input type="email" id="registeremail" name="registeremail" role="button" tabindex="0" class="form-control" placeholder="Email address" required="" autocomplete="none">';                
        modalElement += '<input type="hidden" id="dragonecommercereservezyx987_hidden" name="dragonecommercereservezyx987_hidden" value="Y" >';
        modalElement += '<div class="register_reminder_label"><h4 class="form_register_label">Password must be at least eight characters. Password should only contain 0-9, a-z, A-Z, and at least one of special characters !@#*()$%^&. So wordpress admin user maybe can not log on this website because admin password may contain other special characters.</h4><h4>You must agree with the terms and conditions to get registered.</h4></div>';
        modalElement += '<div class="register_link"><h4><input type="checkbox" name="registerterms" id="registerterms" value="terms" />&nbsp;&nbsp;I agree with the <a href="' + "<?php echo plugins_url('files/privacy.pdf', __FILE__ ); ?>" + '" target="_blank">privacy policy</a>, <a href="' + "<?php echo plugins_url('files/terms.pdf', __FILE__ ); ?>" + '" target="_blank">terms and conditions</a>.</h4></div>';
        modalElement += '<input class="btn btn-lg btn-primary btn-block w-100" tabindex="0" type="button" onclick="dragonecommercereservezyx987_registerUser();" value="Register" />';
        modalElement += '<div class="resetpassword_reminder_label"><h4 class="form_register_label" style="color:red;">Please do not use this website\'s WordPress login page /wp-login.php to reset your password.</h4></div>';
        modalElement += '<br/><div class="login_link"><a href="javascript:void(0);" role="button" tabindex="0" onclick="dragonecommercereservezyx987_goToLogin();">Log in</a></div>';    
        modalElement += '<br/><div class="register_link"><a href="javascript:void(0);" role="button" tabindex="0" onclick="dragonecommercereservezyx987_goToResendActivationEmail();">Resend Activation Email</a></div>';        
        modalElement += '</form>';
        modalElement += "</div></div></div></div></div>";
        modalElement += "<input type='hidden' name='dragonecommercereservezyx987_register_token' id='dragonecommercereservezyx987_register_token' value='' />";        
        modalElement += '</div>';            
            
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';        
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">';
        //modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        //modalElement += '</div>';    
        modalElement += '</div></div>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("input#registerusername").focus();});<\/script>';

        jQuery('div#mylargeregistermodal').html(modalElement);

        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        
        //show register modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery('div#mylargecheckoutmodal').hide();
        //jQuery('div#mylargecheckoutmodal').addClass('hide');
        jQuery('div#mylargecheckoutmodal').html('');
        jQuery('div#mylargesearchmodal').hide();
        //jQuery('div#mylargesearchmodal').addClass('hide');
        jQuery('div#mylargesearchmodal').html('');    
        jQuery('div#mylargeshoppingcartmodal').hide();
        //jQuery('div#mylargeshoppingcartmodal').addClass('hide');
        jQuery('div#mylargeshoppingcartmodal').html('');
        jQuery('div#mylargeloginmodal').hide();
        //jQuery('div#mylargeloginmodal').addClass('hide');
        jQuery('div#mylargeloginmodal').html('');                
        jQuery('div#mylargeforgetpasswordmodal').hide();
        //jQuery('div#mylargeforgetpasswordmodal').addClass('hide');
        jQuery('div#mylargeforgetpasswordmodal').html('');        
        jQuery('div#mylargeaccountactivationmodal').hide();
        //jQuery('div#mylargeaccountactivationmodal').addClass('hide');
        jQuery('div#mylargeaccountactivationmodal').html('');
        jQuery('div#mylargeresetpasswordusingtokenmodal').hide();
        //jQuery('div#mylargeresetpasswordusingtokenmodal').addClass('hide');
        jQuery('div#mylargeresetpasswordusingtokenmodal').html('');        
        jQuery('div#mylargedashboardmodal').hide();
        //jQuery('div#mylargedashboardmodal').addClass('hide');
        jQuery('div#mylargedashboardmodal').html('');
        jQuery('div#mymediumcookiemodal').hide();
        //jQuery('div#mymediumcookiemodal').addClass('hide');
        jQuery('div#mymediumcookiemodal').html('');
        mylargeregistermodal = new bootstrap.Modal(document.getElementById('mylargeregistermodal'));
        mylargeregistermodal.show();
        jQuery("div#mylargeregistermodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeregistermodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
    }
    
    function dragonecommercereservezyx987_goToResetpassword() {        
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';                                
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';        
        modalElement += '<div id="dragonecommerce_forgetpassword_container" class="row">';
        
        modalElement += '<div class="forgetpassword_-container col-12 col-sm-12 col-md-12 col-lg-12"><div class="row-container"><div class="forgetpassword-details-container row">';
        modalElement += "<div class='forgetpassword_-content col-12 col-sm-12 col-md-12 col-lg-12'>";

        modalElement += '<div class="forgetpassword_form_container">';

        modalElement += '<form id="dragonecommercereservezyx987_forgetpassword_form" class="form_forgetpassword" target="_self" method="post" autocomplete="off" onsubmit="return false">';
        modalElement += '<div class="forgetpassword_label"><h1 class="form_forgetpassword_heading text-center">Send Reset Password Email</h1></div>';
        modalElement += '<label for="resetemail" class="sr-only">Email address</label>';
        modalElement += '<input type="email" id="resetemail" tabindex="0" name="resetemail" class="form-control" placeholder="Email address" required="" autocomplete="none">';                
        modalElement += '<input type="hidden" id="dragonecommercereservezyx987_hidden" name="dragonecommercereservezyx987_hidden" value="Y" >';
        
        modalElement += '<input class="btn btn-lg btn-primary btn-block w-100" tabindex="0" type="button" onclick="dragonecommercereservezyx987_resetPassword();" value="Send Reset Email" />';
        modalElement += '</form>';

        modalElement += '</div>';

        modalElement += "</div>";
                
        modalElement += '</div></div></div>';
        modalElement += "<input type='hidden' name='dragonecommercereservezyx987_forgetpassword_token' id='dragonecommercereservezyx987_forgetpassword_token' value='' />";
        
        modalElement += '</div>';
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';        
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">' +
        //                '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>' +
        //                '</div>';    
        modalElement += '</div></div>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("input#resetemail").focus();});<\/script>';
        jQuery('div#mylargeforgetpasswordmodal').html(modalElement);

        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        
        //show forget password modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery('div#mylargecheckoutmodal').hide();
        //jQuery('div#mylargecheckoutmodal').addClass('hide');
        jQuery('div#mylargecheckoutmodal').html('');
        jQuery('div#mylargesearchmodal').hide();
        //jQuery('div#mylargesearchmodal').addClass('hide');
        jQuery('div#mylargesearchmodal').html('');    
        jQuery('div#mylargeshoppingcartmodal').hide();
        //jQuery('div#mylargeshoppingcartmodal').addClass('hide');
        jQuery('div#mylargeshoppingcartmodal').html('');
        jQuery('div#mylargeloginmodal').hide();
        //jQuery('div#mylargeloginmodal').addClass('hide');
        jQuery('div#mylargeloginmodal').html('');                
        jQuery('div#mylargeaccountactivationmodal').hide();
        //jQuery('div#mylargeaccountactivationmodal').addClass('hide');
        jQuery('div#mylargeaccountactivationmodal').html('');
        jQuery('div#mylargeresetpasswordusingtokenmodal').hide();
        //jQuery('div#mylargeresetpasswordusingtokenmodal').addClass('hide');
        jQuery('div#mylargeresetpasswordusingtokenmodal').html('');        
        jQuery('div#mylargedashboardmodal').hide();
        //jQuery('div#mylargedashboardmodal').addClass('hide');
        jQuery('div#mylargedashboardmodal').html('');
        jQuery('div#mylargeregistermodal').hide('');
        jQuery('div#mylargeregistermodal').html('');
        jQuery('div#mymediumcookiemodal').hide();
        //jQuery('div#mymediumcookiemodal').addClass('hide');
        jQuery('div#mymediumcookiemodal').html('');
        mylargeforgetpasswordmodal = new bootstrap.Modal(document.getElementById('mylargeforgetpasswordmodal'));
        mylargeforgetpasswordmodal.show();
        jQuery("div#mylargeforgetpasswordmodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeforgetpasswordmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
    }
    
    function dragonecommercereservezyx987_goToResetpasswordusingtoken() {        
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';                    
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0"  data-bs-dismiss="modal"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';        
        modalElement += '<div id="dragonecommerce_resetpasswordusingtoken_container" class="row">';        
        modalElement += '<div class="resetpasswordusingtoken_container col-12 col-sm-12 col-md-12 col-lg-12"><div class="row-container"><div class="resetpasswordusingtoken-details-container row">';
        modalElement += "<div class='resetpasswordusingtoken_content col-12 col-sm-12 col-md-12 col-lg-12'>";

        modalElement += '<div class="resetpasswordusingtoken_form_container">';

        modalElement += '<form id="dragonecommercereservezyx987_resetpasswordusingtoken_form" class="form_resetpasswordusingtoken" target="_self" method="post" autocomplete="off" onsubmit="return false">';
        modalElement += '<div class="resetpasswordusingtoken_label"><h1 class="form_forgetpassword_heading text-center">Reset Password Using Token</h1></div>';
        modalElement += '<label for="resetusername" class="sr-only">Username</label>';
        modalElement += '<input type="text" id="resetusername" tabindex="0" name="resetusername" class="form-control" placeholder="Username" required="" autocomplete="none">';                
        modalElement += '<label for="resetpassword" class="sr-only">New Password</label>';

        modalElement += '<input type="password" id="resetpassword" tabindex="0" name="resetpassword" class="form-control" placeholder="New Password" required="" autocomplete="new-password">';
        modalElement += '<input type="password" id="resetpassword_confirmation" tabindex="0" name="resetpassword_confirmation" class="form-control" placeholder="Confirm New Password" required="" autocomplete="new-password">';
        modalElement += '<label for="resettoken" class="sr-only">Token</label>';
        modalElement += '<input type="text" id="resettoken" name="resettoken" tabindex="0" class="form-control" placeholder="Token" required="" autocomplete="none">';                

        modalElement += '<input type="hidden" id="dragonecommercereservezyx987_hidden" name="dragonecommercereservezyx987_hidden" value="Y" >';

        modalElement += '<div class="resetpasswordusingtoken_reminder_label"><h4 class="form_resetpasswordusingtoken_label">Password must be at least eight characters. Password should only contain 0-9, a-z, A-Z, and at least one of special characters !@#*()$%^&. So wordpress admin user maybe can not log on this website because admin password may contain other special characters.</h4></div>';
        
        modalElement += '<input class="btn btn-lg btn-primary btn-block w-100" tabindex="0" type="button" onclick="dragonecommercereservezyx987_resetPasswordUsingToken();" value="Reset Password" />';
        modalElement += '</form>';

        modalElement += '</div>';

        modalElement += "</div>";
                
        modalElement += '</div></div></div>';
        modalElement += "<input type='hidden' name='dragonecommercereservezyx987_resetpasswordusingtoken_token' id='dragonecommercereservezyx987_resetpasswordusingtoken_token' value='' />";
        
        modalElement += '</div>';            
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';        
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">' +
        //                '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>' +
        //                '</div>';    
        modalElement += '</div></div>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("input#resetusername").focus();});<\/script>';
        jQuery('div#mylargeresetpasswordusingtokenmodal').html(modalElement);

        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeaccountactivationmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        
        //show forget password modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery('div#mylargecheckoutmodal').hide();
        //jQuery('div#mylargecheckoutmodal').addClass('hide');
        jQuery('div#mylargecheckoutmodal').html('');
        jQuery('div#mylargesearchmodal').hide();
        //jQuery('div#mylargesearchmodal').addClass('hide');
        
        jQuery('div#mylargesearchmodal').html('');    
        jQuery('div#mylargeshoppingcartmodal').hide();
        //jQuery('div#mylargeshoppingcartmodal').addClass('hide');
        jQuery('div#mylargeshoppingcartmodal').html('');
        jQuery('div#mylargeloginmodal').hide();
        //jQuery('div#mylargeloginmodal').addClass('hide');
        jQuery('div#mylargeloginmodal').html('');                
        jQuery('div#mylargeforgetpasswordmodal').hide();
        //jQuery('div#mylargeforgetpasswordmodal').addClass('hide');
        jQuery('div#mylargeforgetpasswordmodal').html('');
        jQuery('div#mylargeaccountactivationmodal').hide();
        //jQuery('div#mylargeaccountactivationmodal').addClass('hide');
        jQuery('div#mylargeaccountactivationmodal').html('');        
        jQuery('div#mylargedashboardmodal').hide();
        //jQuery('div#mylargedashboardmodal').addClass('hide');
        jQuery('div#mylargedashboardmodal').html('');
        jQuery('div#mylargeregistermodal').hide();
        jQuery('div#mylargeregistermodal').html('');
        jQuery('div#mymediumcookiemodal').hide();
        //jQuery('div#mymediumcookiemodal').addClass('hide');
        jQuery('div#mymediumcookiemodal').html('');
        mylargeresetpasswordusingtokenmodal = new bootstrap.Modal(document.getElementById('mylargeresetpasswordusingtokenmodal'));
        mylargeresetpasswordusingtokenmodal.show();
        jQuery("div#mylargeresetpasswordusingtokenmodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeresetpasswordusingtokenmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
    }
    
    function dragonecommercereservezyx987_goToResendActivationEmail() {        
        var i, modalElement = '<div class="modal-dialog modal-fullscreen"><div class="modal-content" style="height:100% !important;">';                    
        modalElement += '<div class="modal-header row" style="padding:15px 25px;">';
        modalElement += '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';
        modalElement += '</div>';

        modalElement += '<div class="modal-body">';        
        modalElement += '<div id="dragonecommerce_accountactivation_container" class="row">';
        
        modalElement += '<div class="accountactivation_-container col-12 col-sm-12 col-md-12 col-lg-12"><div class="row-container"><div class="accountactivation-details-container row">';
        modalElement += "<div class='accountactivation_-content col-12 col-sm-12 col-md-12 col-lg-12'>";

        modalElement += '<div class="accountactivation_form_container">';

        modalElement += '<form id="dragonecommercereservezyx987_accountactivation_form" class="form_accountactivation" target="_self" method="post" autocomplete="off" onsubmit="return false">';
        modalElement += '<div class="accountactivation_label"><h1 class="form_accountactivation_heading text-center">Resend Account Activation Email</h1></div>';
        modalElement += '<label for="accountactivationemail" class="sr-only">Email address</label>';
        modalElement += '<input type="email" id="accountactivationemail" tabindex="0" name="accountactivationemail" class="form-control" placeholder="Email address" required="" autocomplete="none">';                
        modalElement += '<input type="hidden" id="dragonecommercereservezyx987_hidden" name="dragonecommercereservezyx987_hidden" value="Y" >';
        
        modalElement += '<input class="btn btn-lg btn-primary btn-block w-100" tabindex="0" type="button" onclick="dragonecommercereservezyx987_accountactivation();" value="Resend Account Activation Email" />';
        modalElement += '</form>';

        modalElement += '</div>';

        modalElement += "</div>";
                
        modalElement += '</div></div></div>';
        modalElement += "<input type='hidden' name='dragonecommercereservezyx987_accountactivation_token' id='dragonecommercereservezyx987_accountactivation_token' value='' />";
        
        modalElement += '</div>';        
        modalElement += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        modalElement += '<button type="button" style="float: right;" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>';        
        modalElement += '</div>';
        
        //modalElement += '<div class="modal-footer row" style="padding:15px 25px;">' +
        //                '<button type="button" aria-label="close the pop up window" class="btn-close" tabindex="0" data-bs-dismiss="modal"></button>' +
        //                '</div>';    
        modalElement += '</div></div>';
        modalElement += '<script>jQuery(document).ready(function(){jQuery("input#accountactivationemail").focus();});<\/script>';
        jQuery('div#mylargeaccountactivationmodal').html(modalElement);

        if(jQuery('div#mylargemodal div.modal-header button.btn-close').length) { jQuery('div#mylargemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeimagemodal div.modal-header button.btn-close').length) { jQuery('div#mylargeimagemodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargesearchmodal div.modal-header button.btn-close').length) { jQuery('div#mylargesearchmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeshoppingcartmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeloginmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeloginmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeforgetpasswordmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').length) { jQuery('div#mylargeecommercemenumodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').length) { jQuery('div#mylargedashboardmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeregistermodal div.modal-header button.btn-close').length) { jQuery('div#mylargeregistermodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').length) { jQuery('div#mylargeresetpasswordusingtokenmodal div.modal-header button.btn-close').click(); }
        if(jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').length) { jQuery('div#mylargecheckoutmodal div.modal-header button.btn-close').click(); }
        
        //show forget password modal
        jQuery('div#mylargemodal').hide();
        //jQuery('div#mylargemodal').addClass('hide');
        jQuery('div#mylargeimagemodal').hide();
        //jQuery('div#mylargeimagemodal').addClass('hide');
        jQuery('div#mylargeimagemodal img').attr('src', '');
        jQuery('div#mylargecheckoutmodal').hide();
        //jQuery('div#mylargecheckoutmodal').addClass('hide');
        jQuery('div#mylargecheckoutmodal').html('');
        jQuery('div#mylargesearchmodal').hide();
        //jQuery('div#mylargesearchmodal').addClass('hide');
        jQuery('div#mylargesearchmodal').html('');    
        jQuery('div#mylargeshoppingcartmodal').hide();
        //jQuery('div#mylargeshoppingcartmodal').addClass('hide');
        jQuery('div#mylargeshoppingcartmodal').html('');
        jQuery('div#mylargeloginmodal').hide();
        //jQuery('div#mylargeloginmodal').addClass('hide');
        jQuery('div#mylargeloginmodal').html('');                
        jQuery('div#mylargeforgetpasswordmodal').hide();
        //jQuery('div#mylargeforgetpasswordmodal').addClass('hide');
        jQuery('div#mylargeforgetpasswordmodal').html('');
        jQuery('div#mylargedashboardmodal').hide();
        //jQuery('div#mylargedashboardmodal').addClass('hide');
        jQuery('div#mylargedashboardmodal').html('');
        jQuery('div#mylargeregistermodal').html('');
        jQuery('div#mylargeresetpasswordusingtokenmodal').hide();
        //jQuery('div#mylargeresetpasswordusingtokenmodal').addClass('hide');
        jQuery('div#mylargeresetpasswordusingtokenmodal').html('');
        jQuery('div#mymediumcookiemodal').hide();
        //jQuery('div#mymediumcookiemodal').addClass('hide');
        jQuery('div#mymediumcookiemodal').html('');
        mylargeaccountactivationmodal = new bootstrap.Modal(document.getElementById('mylargeaccountactivationmodal'));
        mylargeaccountactivationmodal.show();
        jQuery("div#mylargeaccountactivationmodal").css({"height": "100%", "width": jQuery(window).width(), "padding": "0px !important"});
        jQuery("div#mylargeaccountactivationmodal").parent().css("width", jQuery(window).width()).css("height", jQuery(window).height()).css("padding", "0px !important").css("top", 0);            
    }
    
    function dragonecommercereservezyx987_closemodal(modalid) {
        jQuery('div#' + modalid + ' div.modal-header button.btn-close').click();
    }
    
    function dragonecommercereservezyx987_removeCartItem(element) {
        const index = jQuery(element).parent().parent().parent().parent().index();
        if (index > -1) {
            shoppingcartitems.splice(index, 1);
        }
        jQuery(element).parent().parent().parent().parent().remove();
        dragonecommercereservezyx987_showCartIconQuantity();
        dragonecommercereservezyx987_refreshLandingpageLeftTabMenu();
        dragonecommercereservezyx987_updateOrderitemsCookie();
    }
    
    function dragonecommercereservezyx987_showShippingHandlingTaxPreorderBasedOnCountryProvince(element, countrydropdownlistid, statedropdownlistid, countrynameid, statenameid) {
        jQuery('select#shipping_dropdown').val('-1');
        jQuery('select#handling_dropdown').val('-1');
        jQuery('span#shipping').text('');
        jQuery('span#handling').text('');
        jQuery('span#tax').text('');
        jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #shippingid').val('');
        jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #handlingid').val('');
        jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #taxid').val('');
        var myTocountryAlpha2 = jQuery.trim(jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + countrydropdownlistid).val());
        var myTostateprovinceid = parseInt(jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid).val());
        var mySubtotal = parseFloat(jQuery('div#checkout_ordersummary span#subtotal').text());;

        if(myTocountryAlpha2 == null || myTocountryAlpha2 === '' || myTocountryAlpha2 === '-1') {
            return alert("Please choose a country.");
        }
        //only show related states/provinces
        if(jQuery(element).attr('id') === countrydropdownlistid) {
            jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid).val('-1')
        }
        var className = jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + countrydropdownlistid).val();
        jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid + " option").prop("disabled", true);
        jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid + " option").hide();
        jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid + " option." + className).removeClass('hide');
        jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid + " option." + className).prop("disabled", false);
        jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid + " option." + className).show();
        
        if(isNaN(myTostateprovinceid) || myTostateprovinceid <= 0) {
            return;
        }
        var myTocountryname = jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + countrydropdownlistid + " option:selected").text();
        var myTostateprovincename = jQuery('div#dragonecommerce_checkout_shippingaddress_container select#' + statedropdownlistid + " option:selected").text();
        jQuery('div#dragonecommerce_checkout_shippingaddress_container input#' + countrynameid).val(myTocountryname);
        jQuery('div#dragonecommerce_checkout_shippingaddress_container input#' + statenameid).val(myTostateprovincename);
        
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: {dragonecommercereservezyx987_hidden_security_getshippinghandlingtaxpreorderdata:"<?php echo wp_create_nonce('dragonecommercereservezyx987_getshippinghandlingtaxpreorderdata'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_getshippinghandlingtaxpreorderdata",tocountry: myTocountryAlpha2,tostateprovinceid: myTostateprovinceid, subtotal: mySubtotal}
        }).done(function (mydata) {
            discountArr = [];
            if(mydata["status"] === 'success') {
                if(mydata["result"] != null && mydata["result"] !== "") {
                    var myresult = mydata["result"];
                    shippingArr = [], handlingArr = [], taxArr = [];
                    for(var i=0; i < myresult.length; i++) {                        
                        if(myresult[i]["settingname"] === 'GROUP_CATEGORY_ID_FOR_ORDER_SHIPPING_DETAILS') {
                            shippingArr.push(myresult[i]);
                        } else if(myresult[i]["settingname"] === 'GROUP_CATEGORY_ID_FOR_ORDER_HANDLING_DETAILS') {
                            handlingArr.push(myresult[i]);                            
                        } else if(myresult[i]["settingname"] === 'GROUP_CATEGORY_ID_FOR_ORDER_TAX_DETAILS') {
                            taxArr.push(myresult[i]);                            
                        } else if(myresult[i]["settingname"] === 'GROUP_CATEGORY_ID_FOR_DISCOUNT') {
                            //get setting value for 'MAX_PROMOTION_PER_ORDER', 'MAX_DISCOUNT_PER_ORDER', 'MAX_COUPON_PER_ORDER', if = 1, then can only use one discount per order
                            var MAX_PROMOTION_PER_ORDER = parseInt(settings["MAX_PROMOTION_PER_ORDER"]["settingvalue"]);
                            var MAX_DISCOUNT_PER_ORDER = parseInt(settings["MAX_DISCOUNT_PER_ORDER"]["settingvalue"]);                            
                            var subtotal = parseFloat(jQuery('span#subtotal').text());                    
                            if(isNaN(MAX_PROMOTION_PER_ORDER) || MAX_PROMOTION_PER_ORDER === -1) {
                                if(MAX_DISCOUNT_PER_ORDER >= 0) {
                                    if(discountArr.length < MAX_DISCOUNT_PER_ORDER) {
                                        if(parseInt(myresult[i]["usefee"]) === 1) {
                                            if(myresult[i]["minordersubtotal"] != null && parseFloat(myresult[i]["minordersubtotal"]) <= subtotal) {
                                                discountArr.push(myresult[i]);
                                            }
                                        } else if(parseInt(myresult[i]["userate"]) === 1) {
                                            discountArr.push(myresult[i]);
                                        }
                                    }
                                } else if (MAX_DISCOUNT_PER_ORDER === -1) {
                                    if(parseInt(myresult[i]["usefee"]) === 1) {
                                        if(myresult[i]["minordersubtotal"] != null && parseFloat(myresult[i]["minordersubtotal"]) <= subtotal) {
                                            discountArr.push(myresult[i]);
                                        }
                                    } else if(parseInt(myresult[i]["userate"]) === 1) {
                                        discountArr.push(myresult[i]);
                                    }
                                }                                
                            } else {
                                if(MAX_DISCOUNT_PER_ORDER >= 0) {
                                    if(discountArr.length < MAX_DISCOUNT_PER_ORDER) {
                                        if((discountArr.length + couponArr.length) < MAX_PROMOTION_PER_ORDER) {
                                            if(parseInt(myresult[i]["usefee"]) === 1) {
                                                if(myresult[i]["minordersubtotal"] != null && parseFloat(myresult[i]["minordersubtotal"]) <= subtotal) {
                                                    discountArr.push(myresult[i]);
                                                }
                                            } else if(parseInt(myresult[i]["userate"]) === 1) {
                                                discountArr.push(myresult[i]);                                    
                                            }
                                        }
                                    }
                                } else if (MAX_DISCOUNT_PER_ORDER === -1) {
                                    if((discountArr.length + couponArr.length) < MAX_PROMOTION_PER_ORDER) {
                                        if(parseInt(myresult[i]["usefee"]) === 1) {
                                            if(myresult[i]["minordersubtotal"] != null && parseFloat(myresult[i]["minordersubtotal"]) <= subtotal) {
                                                discountArr.push(myresult[i]);
                                            }
                                        } else if(parseInt(myresult[i]["userate"]) === 1) {
                                            discountArr.push(myresult[i]);
                                        }
                                    }
                                }
                            }                                                                                                                                        
                        }
                    }
                                                                                
                    if(discountArr.length > 0) {
                        var temp_modalElement = '';
                        for(var i=0; i < discountArr.length; i++) {            
                            temp_modalElement +=         '<div class="row">';
                            temp_modalElement +=             '<div class="col-6 textbox-container">';
                            temp_modalElement +=                 '<label>Discount';
                            if(parseInt(discountArr[i]["userate"]) === 1) {
                                temp_modalElement +=             ' (rate)';
                            } else if(parseInt(discountArr[i]["usefee"]) === 1) {
                                temp_modalElement +=             ' (fee)';
                            }                
                            temp_modalElement +=                 '</label>';
                            temp_modalElement +=             '</div>';
                            temp_modalElement +=             '<div class="col-6 textbox-container">';
                            temp_modalElement +=                 '<span class="coupon" id="discount' + i + '" name="discount' + i + '" style="color:red;">'
                            if(parseInt(discountArr[i]["userate"]) === 1) {
                                temp_modalElement +=             discountArr[i]["rate"];
                            } else if(parseInt(discountArr[i]["usefee"]) === 1) {
                                temp_modalElement +=                 '<span id="discountcurrency' + i + '" name="discountcurrency' + i + '">' + shoppingcartitems[0]["currencysign"] + '</span>';
                                temp_modalElement +=             discountArr[i]["fee"];
                            }                
                            temp_modalElement +=                 '</span>';
                            temp_modalElement +=             '</div>';
                            temp_modalElement +=         '</div>';    
                        }
                        jQuery('div#discount_container').html(temp_modalElement);                                                                
                    }    
                    <?php if($settings["ENABLE_SHIPPING_CHARGE"]["settingvalue"] === '1') {  ?>    
                    if(shippingArr.length === 0) {
                        return alert("There are not any shipping charge rules. Please fill all the fields. If it still does not work, contact website admin.");
                    }
                    <?php } ?>
            
                    <?php if($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"] === '1') {  ?>
                    if(handlingArr.length === 0) {
                        return alert("There are not any handling charge rules. Please fill all the fields. If it still does not work, contact website admin.");
                    }    
                    <?php } ?>            
                    var options = '<option value="-1">Please choose one...</option>';
                    for(var i=0; i < shippingArr.length; i++) {
                        options += '<option class="' + (shippingArr[i]["chargetypeid"] == null ? "" : shippingArr[i]["chargetypeid"]) + '_' + (shippingArr[i]["minshippingdays"] == null ? "" : shippingArr[i]["minshippingdays"]) + '_' + (shippingArr[i]["maxshippingdays"] == null ? "" : shippingArr[i]["maxshippingdays"])  + '" value="' + shippingArr[i]["propertyvalueid"] + '">' + shippingArr[i]["shownname"] + '</option>';                                                                        
                    }
                    jQuery('select#shipping_dropdown').html(options);

                    var options2 = '<option value="-1">Please choose one...</option>';
                    for(var i=0; i < handlingArr.length; i++) {
                        options2 += '<option class="' + (handlingArr[i]["chargetypeid"] == null ? "" : handlingArr[i]["chargetypeid"]) + '_' + (handlingArr[i]["minshippingdays"] == null ? "" : handlingArr[i]["minshippingdays"]) + '_' + (handlingArr[i]["maxshippingdays"] == null ? "" : handlingArr[i]["maxshippingdays"])  + '" value="' + handlingArr[i]["propertyvalueid"] + '">' + handlingArr[i]["shownname"] + '</option>';                        
                    }
                    if(jQuery('select#handling_dropdown').length === 1) {
                        jQuery('select#handling_dropdown').html(options2);
                    }
                    
                    if(taxArr.length === 0) {
                        return alert("There is no tax rules. Please fill all the fields. If it still does not work, contact website admin.");
                    } else if(taxArr.length > 1) {
                        return alert("There are more than one tax rules. Please fill all the fields. If it still does not work, contact website admin.");
                    } else if(taxArr.length === 1) {
                        if(parseInt(taxArr[0]["userate"]) === 1) {
                            taxrate = taxArr[0]["rate"];
                        } else {
                            taxrate = 0;
                        }
                        if(parseInt(taxArr[0]["taxincludeshipping"]) === 1) {
                            taxincludeshipping = 1;
                        } else {
                            taxincludeshipping = 0;
                        }
                        if(parseInt(taxArr[0]["taxincludehandling"]) === 1) {
                            taxincludehandling = 1;
                        } else {
                            taxincludehandling = 0;
                        }
                        taxid = taxArr[0]["id"];                        
                    }

                    if(shoppingcartitems.length > 0) {
                        dragonecommercereservezyx987_showTaxOnOrdersummary('tax', shoppingcartitems[0]["currencysign"], true);    
                    }                        
                } else {
                    return alert("Something wrong with this reservation. Please contact website admin.");
                }                
            } else if(mydata["status"] === 'fail') {
                if(mydata["result"] != null && mydata["result"] !== "") {
                    return alert(mydata["result"]);
                } else {
                    return alert("Something wrong with this reservation. Please contact website admin.");
                }
            } else {
                return alert("Something wrong with this reservation. Please contact website admin.");                
            }
        }).fail(function( jqXHR, textStatus ) {
            alert( "Get shipping handling tax data request failed: " + textStatus );
        });                        
    }
    
    function dragonecommercereservezyx987_validatecoupon(currencysign) {
        var myCoupon = jQuery('div#dragonecommerce_checkout_coupon_container input#dragonecommercereservezyx987_coupon').val();
        myCoupon = jQuery.trim(myCoupon);
        if(myCoupon === '') {
            alert("Please enter a coupon.");
            return jQuery('div#dragonecommerce_checkout_coupon_container input#dragonecommercereservezyx987_coupon').val('');
        }
        jQuery('div#loading').show();
        jQuery.ajax({
            type: "POST",
            url: ajaxurl,
            data: {dragonecommercereservezyx987_hidden_security_validatecoupon:"<?php echo wp_create_nonce('dragonecommercereservezyx987_validatecoupon'); ?>",dragonecommercereservezyx987_hidden:"Y",action:"dragonecommercereservezyx987_validatecoupon",coupon:myCoupon}
        }).done(function (mydata) {
            jQuery('div#loading').hide();
            if(mydata["status"] === 'success') {
                if(mydata["result"] != null && mydata["result"] !== "") {
                    var myresult = mydata["result"][0];
                    var MAX_PROMOTION_PER_ORDER = parseInt(settings["MAX_PROMOTION_PER_ORDER"]["settingvalue"]);
                    var MAX_COUPON_PER_ORDER = parseInt(settings["MAX_COUPON_PER_ORDER"]["settingvalue"]);
                    var subtotal = parseFloat(jQuery('span#subtotal').text());
                    
                    if(isNaN(MAX_PROMOTION_PER_ORDER) || MAX_PROMOTION_PER_ORDER === -1) {
                        if(MAX_COUPON_PER_ORDER >= 0) {
                            if(couponArr.length < MAX_COUPON_PER_ORDER) {
                                var foundDuplicate = false;
                                for(var i=0; i<couponArr.length; i++) {
                                    if(couponArr[i]["code"] === myresult["code"]) {
                                        foundDuplicate = true;
                                        break;
                                    }
                                }
                                if(!foundDuplicate) {
                                    if(parseInt(myresult["usefee"]) === 1) {
                                        if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                            couponArr.push(myresult);
                                        } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                            return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                        }
                                    } else if(parseInt(myresult["userate"]) === 1) {
                                        if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                            couponArr.push(myresult);
                                        } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                            return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                        }
                                    }
                                } else {
                                    alert("This coupon is already added.");
                                }
                            } else {
                                alert("Max coupon per reservation: " + MAX_COUPON_PER_ORDER);
                            }
                        } else if (MAX_COUPON_PER_ORDER === -1) {
                            var foundDuplicate = false;
                            for(var i=0; i<couponArr.length; i++) {
                                if(couponArr[i]["code"] === myresult["code"]) {
                                    foundDuplicate = true;
                                    break;
                                }
                            }
                            if(!foundDuplicate) {
                                if(parseInt(myresult["usefee"]) === 1) {
                                    if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                        couponArr.push(myresult);
                                    } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                        return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                    }
                                } else if(parseInt(myresult["userate"]) === 1) {
                                    if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                        couponArr.push(myresult);
                                    } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                        return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                    }
                                } 
                            } else {
                                alert("This coupon is already added.");
                            }
                        }                                
                    } else {
                        if(MAX_COUPON_PER_ORDER >= 0) {
                            if(couponArr.length < MAX_COUPON_PER_ORDER) {
                                if((discountArr.length + couponArr.length) < MAX_PROMOTION_PER_ORDER) {
                                    var foundDuplicate = false;
                                    for(var i=0; i<couponArr.length; i++) {
                                        if(couponArr[i]["code"] === myresult["code"]) {
                                            foundDuplicate = true;
                                            break;
                                        }
                                    }
                                    if(!foundDuplicate) {
                                        if(parseInt(myresult["usefee"]) === 1) {
                                            if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                                couponArr.push(myresult);
                                            } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                                return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                            }
                                        } else if(parseInt(myresult["userate"]) === 1) {
                                            if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                                couponArr.push(myresult);
                                            } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                                return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                            }
                                        } 
                                    } else {
                                        alert("This coupon is already added.");
                                    }
                                }
                            }
                        } else if (MAX_COUPON_PER_ORDER === -1) {
                            if((discountArr.length + couponArr.length) < MAX_PROMOTION_PER_ORDER) {
                                var foundDuplicate = false;
                                for(var i=0; i<couponArr.length; i++) {
                                    if(couponArr[i]["code"] === myresult["code"]) {
                                        foundDuplicate = true;
                                        break;
                                    }
                                }
                                if(!foundDuplicate) {
                                    if(parseInt(myresult["usefee"]) === 1) {
                                        if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                            couponArr.push(myresult);
                                        } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                            return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                        }
                                    } else if(parseInt(myresult["userate"]) === 1) {
                                        if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) <= subtotal) {
                                            couponArr.push(myresult);
                                        } else if(myresult["minordersubtotal"] != null && parseFloat(myresult["minordersubtotal"]) > subtotal) {
                                            return alert("Subtotal is less than coupon minimum reservation subtotal: " + myresult["minordersubtotal"]);
                                        }
                                    } 
                                } else {
                                    alert("This coupon is already added.");
                                }
                            }
                        }
                    }
                    
                    var temp_modalElement = '';
                    for(var i=0; i < couponArr.length; i++) {
                        temp_modalElement +=         '<div class="row">';
                        temp_modalElement +=             '<div class="col-6 textbox-container">';
                        temp_modalElement +=                 '<label>Coupon';
                        if(parseInt(couponArr[i]["userate"]) === 1) {
                            temp_modalElement +=             ' (rate)';
                        } else if(parseInt(couponArr[i]["usefee"]) === 1) {
                            temp_modalElement +=             ' (fee)';
                        }                
                        temp_modalElement +=                 '</label>';
                        temp_modalElement +=             '</div>';
                        temp_modalElement +=             '<div class="col-6 textbox-container">';
                        temp_modalElement +=                 '<span class="coupon' + i + '" id="coupon' + i + '" name="coupon' + i + '" style="color:red;">';
                        if(parseInt(couponArr[i]["userate"]) === 1) {
                            temp_modalElement +=             couponArr[i]["rate"];
                        } else if(parseInt(couponArr[i]["usefee"]) === 1) {
                            temp_modalElement +=             '<span id="couponcurrency' + i + '" name="couponcurrency' + i + '">' + shoppingcartitems[0]["currencysign"] + '</span>';
                            temp_modalElement +=             couponArr[i]["fee"];
                        }                
                        temp_modalElement +=                 '</span>';
                        temp_modalElement +=                 '&nbsp;&nbsp;&nbsp;&nbsp;<span aria-label="remove coupon" role="img" class="coupon_remove" role="button" tabindex="0" id="coupon' + i + '_remove" name="coupon' + i + '_remove" style="color:red;" onclick="dragonecommercereservezyx987_removeCoupon(this, ' + i + ');" onkeydown="dragonecommercereservezyx987_removeCouponHandler(event, this, ' + i + ');">';

                        temp_modalElement +=                 'REMOVE</span>';
                        temp_modalElement +=             '</div>';
                        temp_modalElement +=         '</div>';    
                    }
                    jQuery('div#coupon_container').html(temp_modalElement);
                    dragonecommercereservezyx987_showTaxOnOrdersummary('tax', currencysign);
                } else {
                    return alert("Something wrong with this coupon. Please contact website admin.");
                }                
            } else if(mydata["status"] === 'fail') {
                if(mydata["result"] != null && mydata["result"] !== "") {
                    return alert(mydata["result"]);
                } else {
                    return alert("Something wrong with this coupon. Please contact website admin.");
                }
            } else {
                return alert("Something wrong with this coupon. Please contact website admin.");                
            }
        }).fail(function( jqXHR, textStatus ) {
            alert( "Validate coupon request failed: " + textStatus );
            jQuery('div#loading').hide();
        });                        
    }
    
    function dragonecommercereservezyx987_validateOrderFields() {        
        if(shoppingcartitems.length === 0) {
            alert("Shopping cart is empty.");
            return false;            
        }
        <?php if($settings["ENABLE_SHIPPING_CHARGE"]["settingvalue"] === '1') {  ?>    
        if(shippingArr.length === 0) {
            alert("There are not any shipping charge rules. Please fill all the fields. If it still does not work, contact website admin.");
            return false;
        }
        <?php } ?>            
        <?php if($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"] === '1') {  ?>
        if(handlingArr.length === 0) {
            alert("There are not any handling charge rules. Please fill all the fields. If it still does not work, contact website admin.");
            return false;
        }    
        <?php } ?>
        if(taxArr.length ===  0) {
            alert("There is no tax rule. Please fill all the fields. If it still does not work, contact website admin.");
            return false;
        } else if(taxArr.length > 1) {
            alert("There are more than one tax rules. Please contact website admin.");
            return false;
        }                    
        jQuery('div#dragonecommerce_checkout_payment_braintree_container').hide();
        //jQuery('div#dragonecommerce_checkout_payment_braintree_container').addClass('hide');
        jQuery('div#dragonecommerce_checkout_terms_container').hide();
        //jQuery('div#dragonecommerce_checkout_terms_container').addClass('hide');
        jQuery('div#dragonecommerce_checkout_actions_container').hide();
        //jQuery('div#dragonecommerce_checkout_actions_container').addClass('hide');
        var myname =  jQuery.trim(jQuery('input#shippingaddress-name').val());
        var myemail =  jQuery.trim(jQuery('input#shippingaddress-email').val());
        var myphone =  jQuery.trim(jQuery('input#shippingaddress-phone').val());
        var myaddress =  jQuery.trim(jQuery('input#shippingaddress-address').val());
        var mycity =  jQuery.trim(jQuery('input#shippingaddress-city').val());
        var myzip =  jQuery.trim(jQuery('input#shippingaddress-zip').val());        
        if(myname === '' || myemail === '' || myphone === '' || myaddress === '' || mycity === '' || myzip === '') {
            alert("Please fill all the fields in the address.");
            return false;
        }        
        //There should be first name and last name
        var mynameArr = myname.split(" ");
        var myfirstname = '';
        var mylastname = '';
        if(mynameArr.length >= 2) {
            myfirstname = mynameArr[0];
            mylastname = mynameArr[mynameArr.length - 1];    
        }
        if(myfirstname === '' || mylastname === '') {
            alert("Please enter first name and last name.");
            return false;
        }
        if(!dragonecommercereservezyx987_validateEmail(myemail)){
            alert("Please enter a valid email address.");
            return false;
        }        
        var myTocountry = jQuery('div#dragonecommerce_checkout_shippingaddress_container select#shippingaddress-country').val();
        var myTostateprovinceid = parseInt(jQuery('div#dragonecommerce_checkout_shippingaddress_container select#shippingaddress-state').val());

        if(myTocountry == null || myTocountry === '') {
            alert("Please choose a country for the address.");
            return false;
        }        
        if(isNaN(myTostateprovinceid) || myTostateprovinceid <= 0) {
            alert("Please choose a state/province for the address.");
            return false;
        }                
        var myshipping =  jQuery.trim(jQuery('select#shipping_dropdown').val());
        var myhandling =  jQuery('select#handling_dropdown').length > 0 ? jQuery.trim(jQuery('select#handling_dropdown').val()) : '-1';
        if((jQuery('select#shipping_dropdown').length > 0 && myshipping === '-1') || (jQuery('select#handling_dropdown').length > 0 && myhandling === '-1')) {
            alert("Please choose from the dropdown list in the Service section.");
            return false;
        }                
        var mysubtotal = jQuery.trim(jQuery('span#subtotal').text());
        var myshipping2 = jQuery.trim(jQuery('span#shipping').text());
        var myhandling2 = jQuery('span#handling').length > 0 ? jQuery.trim(jQuery('span#handling').text()) : '';
        var mytax = jQuery.trim(jQuery('span#tax').text());
        var mytotal = jQuery.trim(jQuery('span#total').text());        
        if(mysubtotal === '' || (jQuery('span#shipping').length > 0 && myshipping2 === '') || (jQuery('span#handling').length > 0 && myhandling2 === '') || mytax === '' || mytotal === '') {
            alert("One or more fields are empty in the summary.");
            return false;
        }
        var mysubtotalValue = mysubtotal === '' ? 0 : parseFloat(mysubtotal);
        var myshipping2Value = myshipping2 === '' ? 0 : parseFloat(myshipping2);
        var myhandling2Value = myhandling2 === '' ? 0 : parseFloat(myhandling2);    
        var mytaxValue = mytax === '' ? 0 : parseFloat(mytax);        
        var mytotalValue = mytotal === '' ? 0 : parseFloat(mytotal);    
        if(mysubtotalValue > 0 && myshipping2Value >= 0 && myhandling2Value >= 0 && mytaxValue >= 0 && mytotalValue > 0) {
        } else {
            alert("One or more fields are not valid in the summary.");
            return false;            
        }        
        return true;
    }
    
    function dragonecommercereservezyx987_validateconfirmorder() {
        var validateResult = dragonecommercereservezyx987_validateOrderFields();
        if(validateResult) {
            <?php if((!empty($settings["USE_GOOGLE_RECAPTCHA"])) && $settings["USE_GOOGLE_RECAPTCHA"] === 1 && (!empty($settings["GOOGLE_RECAPTCHA_SITEKEY"])) && $settings["GOOGLE_RECAPTCHA_SITEKEY"] !== '' ) { ?>            
            onloadCallback();
            <?php } ?>
            jQuery("div#dragonecommerce_checkout_shippingaddress_container input").prop("disabled", true);
            jQuery("div#dragonecommerce_checkout_shippingaddress_container select").prop("disabled", true);
            jQuery("div#dragonecommerce_checkout_shippinghandling_container select").prop("disabled", true);
            jQuery("input#dragonecommercereservezyx987_submit_coupon").prop("disabled", true);
            jQuery("input#dragonecommercereservezyx987_confirm_order").prop("disabled", true);    
            jQuery("input#dragonecommercereservezyx987_coupon").prop("disabled", true);            
            jQuery('div#dragonecommerce_checkout_payment_braintree_container').show();
            jQuery('div#dragonecommerce_checkout_terms_container').show();
            jQuery('div#dragonecommerce_checkout_actions_container').show();
        }        
    }
    
    function dragonecommercereservezyx987_showShippingOnOrdersummary(dropdownlistid, targetid, currencysign, relateddropdownlistid, relatedtargetid) {
        if(jQuery('select#' + dropdownlistid).length > 0) {
            if(jQuery('select#' + dropdownlistid).val() === '-1') {
                jQuery('select#' + relateddropdownlistid).val('-1');
                jQuery('span#' + targetid).text('');
                if(jQuery('span#' + relatedtargetid).length > 0) {
                    jQuery('span#' + relatedtargetid).text('');
                }
                return alert("Please choose a shipping method.");            
            }            
            for(var i=0; i<shippingArr.length; i++) {
                if(shippingArr[i]["propertyvalueid"] === parseInt(jQuery('select#' + dropdownlistid).val())) {
                    if(shippingArr[i]["usefee"] === 1) {
                        jQuery('span#' + targetid).text(shippingArr[i]["fee"]);
                    } else if(shippingArr[i]["userate"] === 1) {
                        jQuery('span#' + targetid).text('*' + ' ' + shippingArr[i]["rate"]);
                    }                    
                    break;                    
                }
            }
            //validate if handling dropdown list is correct
            var selectedoptionclassname = jQuery('select#' + dropdownlistid).val() === '-1' ? '' : jQuery('select#' + dropdownlistid + ' option:selected').attr('class');
            var selected = false;
            if(jQuery('select#' + relateddropdownlistid).length === 1) {
                jQuery('select#' + relateddropdownlistid + ' option').each(function(index, element) {
                    if(jQuery(this).val() !== '-1') {
                        if(jQuery(this).attr("class") === selectedoptionclassname) {
                            jQuery('select#' + relateddropdownlistid).val(jQuery(this).val());
                            selected = true;
                        }
                    }
                });
                if(!selected) {
                    jQuery('select#' + relateddropdownlistid).val('-1');
                }
                for(var i=0; i<handlingArr.length; i++) {
                    if(handlingArr[i]["propertyvalueid"] === parseInt(jQuery('select#' + relateddropdownlistid).val())) {
                        if(parseInt(handlingArr[i]["usefee"]) === 1) {
                            if(jQuery('span#' + relatedtargetid).length > 0) {
                                jQuery('span#' + relatedtargetid).text(handlingArr[i]["fee"]);
                            }
                        } else if(parseInt(handlingArr[i]["userate"]) === 1) {
                            if(jQuery('span#' + relatedtargetid).length > 0) {
                                jQuery('span#' + relatedtargetid).text('*' + ' ' + handlingArr[i]["rate"]);
                            }
                        }                    
                        break;                    
                    }
                }
            }
        }    
        dragonecommercereservezyx987_showTaxOnOrdersummary('tax', currencysign);
        dragonecommercereservezyx987_validateOrderFields();
        if(jQuery('select#shipping_dropdown').length > 0 && jQuery('select#shipping_dropdown').val() !== '-1') {
            jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #shippingid').val(jQuery('select#shipping_dropdown').val());    
        }
        if(jQuery('select#handling_dropdown').length > 0 && jQuery('select#handling_dropdown').val() !== '-1') {
            jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #handlingid').val(jQuery('select#handling_dropdown').val());    
        }        
    }
    
    function dragonecommercereservezyx987_showHandlingOnOrdersummary(dropdownlistid, targetid, currencysign, relateddropdownlistid, relatedtargetid) {
        if(jQuery('select#' + dropdownlistid).length > 0) {
            if(jQuery('select#' + dropdownlistid).length > 0 && jQuery('select#' + dropdownlistid).val() === '-1') {
                jQuery('select#' + relateddropdownlistid).val('-1');
                jQuery('span#' + targetid).text('');
                if(jQuery('span#' + relatedtargetid).length > 0) {
                    jQuery('span#' + relatedtargetid).text('');
                }
                return alert("Please choose a handling method.");            
            }
            
            for(var i=0; i<handlingArr.length; i++) {
                if(handlingArr[i]["propertyvalueid"] === parseInt(jQuery('select#' + dropdownlistid).val())) {
                    if(parseInt(handlingArr[i]["usefee"]) === 1) {
                        jQuery('span#' + targetid).text(handlingArr[i]["fee"]);
                    } else if(parseInt(handlingArr[i]["userate"]) === 1) {
                        jQuery('span#' + targetid).text('*' + ' ' + handlingArr[i]["rate"]);
                    }                    
                    break;                    
                }
            }
            //validate if shipping dropdown list is correct
            var selectedoptionclassname = jQuery('select#' + dropdownlistid).val() === '-1' ? '' : jQuery('select#' + dropdownlistid + ' option:selected').attr('class');
            var selected = false;
            jQuery('select#' + relateddropdownlistid + ' option').each(function(index, element) {
                if(jQuery(this).val() !== '-1') {
                    if(jQuery(this).attr("class") === selectedoptionclassname) {
                        jQuery('select#' + relateddropdownlistid).val(jQuery(this).val());
                        selected = true;
                    }
                }
            });
            if(!selected) {
                jQuery('select#' + relateddropdownlistid).val('-1');
            }
            for(var i=0; i<shippingArr.length; i++) {
                if(shippingArr[i]["propertyvalueid"] === parseInt(jQuery('select#' + relateddropdownlistid).val())) {
                    if(parseInt(shippingArr[i]["usefee"]) === 1) {
                        if(jQuery('span#' + relatedtargetid).length > 0) {
                            jQuery('span#' + relatedtargetid).text(shippingArr[i]["fee"]);
                        }
                    } else if(parseInt(shippingArr[i]["userate"]) === 1) {
                        if(jQuery('span#' + relatedtargetid).length > 0) {
                            jQuery('span#' + relatedtargetid).text('*' + ' ' + shippingArr[i]["rate"]);
                        }
                    }                    
                    break;                    
                }
            }
        }
        dragonecommercereservezyx987_showTaxOnOrdersummary('tax', currencysign);
        dragonecommercereservezyx987_validateOrderFields();
        if(jQuery('select#shipping_dropdown').length > 0 && jQuery('select#shipping_dropdown').val() !== '-1') {
            jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #shippingid').val(jQuery('select#shipping_dropdown').val());    
        }
        if(jQuery('select#handling_dropdown').length > 0 && jQuery('select#handling_dropdown').val() !== '-1') {
            jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #handlingid').val(jQuery('select#handling_dropdown').val());    
        }
    }
    
    function dragonecommercereservezyx987_showTaxOnOrdersummary(targetid, currencysign, isFirstStepFillingAddress = false) {
        if(jQuery('span#subtotal').text() === '' || jQuery('span#subtotalOriginal').text() === '' || jQuery('span#subtotalfortax').text() === '' || (jQuery('span#shipping').length > 0 && jQuery('span#shipping').text() === '') || (jQuery('span#handling').length > 0 && jQuery('span#handling').text() === '')) {
            if(isFirstStepFillingAddress) {
                return;
            } else {
                return alert("Please fill all the address fields (Address 2 is optional).");  //at least one field in order summary section is empty. 
            }
        }
        if(taxrate < 0) {
            return alert("Tax rate is not defined. Please fill the address and check if it's correct.");
        }
        //calculate tax based on (subtotal - discount - coupon + shipping + handling) * taxrate or  (subtotal - discount - coupon) * taxrate
        var subtotal = jQuery('span#subtotalOriginal').text() === ''? 0 : parseFloat(jQuery('span#subtotalOriginal').text());
        var subtotalfortax = jQuery('span#subtotalfortax').text() === '' ? 0 : parseFloat(jQuery('span#subtotalfortax').text());
        
        var shipping = jQuery('span#shipping').length > 0 ? parseFloat(jQuery('span#shipping').text()) : 0;
        var handling = (jQuery('span#handling').length > 0) ? parseFloat(jQuery('span#handling').text()) : 0;
        var mydiscountfee = 0;        
        var mycouponfee = 0;
        var mytax = 0;
        var myreducedfeebydiscount = 0;
        var myreducedfeebycoupon = 0;
        var myreducedfeebydiscountfortax = 0;
        var myreducedfeebycouponfortax = 0;
        
        //if discount is by fee
        //discountArr = [], couponArr = [];
        //discount: fee, rate, usefee, userate
        //coupon: fee, rate, usefee, userate            
        if(discountArr.length > 0) {
            for(var i=0; i<discountArr.length; i++) {
                if(parseInt(discountArr[i]["usefee"]) === 1) {
                    mydiscountfee += parseFloat(discountArr[i]["fee"]);
                } else if(parseInt(discountArr[i]["userate"]) === 1) {
                    var mydiscountrate = parseFloat(discountArr[i]["rate"]);
                    if(mydiscountrate >= 1 || mydiscountrate <= 0) {
                        return alert("Discount is not correct: " + mydiscountrate + ". Please contact website admin.");
                    }
                    myreducedfeebydiscount += subtotal * (1 - mydiscountrate);
                    myreducedfeebydiscountfortax += subtotalfortax * (1 - mydiscountrate);
                }
            }
        }
                
        if(couponArr.length > 0) {
            for(var i=0; i<couponArr.length; i++) {
                if(parseInt(couponArr[i]["usefee"]) === 1) {
                    mycouponfee += parseFloat(couponArr[i]["fee"]);
                } else if(parseInt(couponArr[i]["userate"]) === 1) {
                    var mycouponrate = parseFloat(couponArr[i]["rate"]);
                    if(mycouponrate >= 1 || mycouponrate <= 0) {
                        return alert("Coupon is not correct: " + mycouponrate + ". Please contact website admin.");
                    }
                    myreducedfeebycoupon += subtotal * (1 - mycouponrate);
                    myreducedfeebycouponfortax += subtotalfortax * (1 - mycouponrate);
                }                
            }
        }
        //console.log("at 4120, before reduce, subtotal: " + subtotal + ", subtotalfortax: " + subtotalfortax + ", couponArr: " + couponArr);        
        if(mydiscountfee !== 0) {
            subtotal = subtotal - mydiscountfee;
            if(subtotalfortax > 0) {
                subtotalfortax = subtotalfortax - mydiscountfee;
            }
        }
        
        if(mycouponfee !== 0) {
            subtotal = subtotal - mycouponfee;
            if(subtotalfortax > 0) {            
                subtotalfortax = subtotalfortax - mycouponfee;
            }
        }
        
        subtotal = subtotal - myreducedfeebydiscount - myreducedfeebycoupon;
                
        if(subtotal < 0) {
            return alert("Discount and coupon are not correct. Subtotal after discount and coupon: " + subtotal + ". Please contact website admin.");
        }
        if(subtotalfortax > 0 && myreducedfeebydiscountfortax >= 0 && myreducedfeebycouponfortax >= 0) {
            subtotalfortax = subtotalfortax - myreducedfeebydiscountfortax - myreducedfeebycouponfortax;
        }
        if(subtotalfortax < 0) {
            return alert("Discount and coupon are not correct. Subtotalfortax after discount and coupon:  " + subtotalfortax + ". Please contact website admin.");
        }
        //console.log("at 4146, after reduce, subtotal: " + subtotal + ", subtotalfortax: " + subtotalfortax + ", mydiscountfee: " + mydiscountfee + ", myreducedfeebydiscount: " + myreducedfeebydiscount + ", mycouponfee: " + mycouponfee + ", myreducedfeebycoupon: " + myreducedfeebycoupon);        
        //tax should be charged after the discount and coupon are applied
        if(taxincludeshipping === 1) {
            <?php if($settings["ENABLE_SHIPPING_CHARGE"]["settingvalue"] === '1') {  ?>            
                if(taxincludehandling === 1) {
                    <?php if($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"] === '1') {  ?>    
                        mytax = (subtotalfortax * taxrate) + (shipping * taxrate) + (handling * taxrate);
                    <?php } else { ?>
                        mytax = (subtotalfortax * taxrate) + (shipping * taxrate);
                    <?php } ?>    
                } else {
                    mytax = (subtotalfortax * taxrate) + (shipping * taxrate);
                }    
            <?php } else { ?>    
                if(taxincludehandling === 1) {
                    <?php if($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"] === '1') {  ?>    
                        mytax = (subtotalfortax * taxrate) + (handling * taxrate);
                    <?php } else { ?>
                        mytax = (subtotalfortax * taxrate);
                    <?php } ?>    
                } else {
                    mytax = (subtotalfortax * taxrate);
                }
            <?php } ?>            
        } else {
            if(taxincludehandling === 1) {
                <?php if($settings["ENABLE_HANDLING_CHARGE"]["settingvalue"] === '1') {  ?>    
                    mytax = (subtotalfortax * taxrate) + (handling * taxrate);
                <?php } else { ?>
                    mytax = (subtotalfortax * taxrate);
                <?php } ?>    
            } else {
                mytax = (subtotalfortax * taxrate);
            }            
        }
        if(mytax >= 0) {
            var myoriginaltax = mytax;
            mytax = parseFloat(mytax.toFixed(2));
            jQuery('span#' + targetid).text(mytax.toFixed(2));
            jQuery('form#dragonecommercereservezyx987_submitorderandpayment_form #taxid').val(taxid.toString());
            var mytotal = subtotal + shipping + handling + myoriginaltax;
            if(mytotal < 0) {
                return alert("Total is not correct: " + mytotal + ". Please contact website admin.");
            }
            jQuery('span#totalOriginal').text(mytotal);
            var mytotal2 = (Math.round( mytotal * 100 ) / 100).toFixed(2);
            //console.log("at 4192, after reduce, total: " + mytotal + ", mytotal2 to show on the page: " + mytotal2 + ", minus these 2 values: " + Math.abs(mytotal2 - mytotal));
            if(Math.abs(mytotal2 - mytotal) <= 0.006) {
                jQuery('span#total').text(mytotal2);    
            } else {
                jQuery('span#total').text(mytotal);
            }                
        } else {
            return alert("Tax calculation is not correct: " + mytax + ". Please contact website admin.");
        }
    }
    
    function dragonecommercereservezyx987_createOrderItemsCookie() {
        //if(shoppingcartitems.length === 0) {
        //    return alert('Shopping cart is empty.');
        //}
        jQuery('div#loading').show();    
        var myform = jQuery('<form id="dragonecommercereservezyx987_setcookie_form" method="post" action=""></form>');        
        var extradata = '<input type="hidden" name="dragonecommercereservezyx987_hidden_security_createcookie" value="<?php echo wp_create_nonce('dragonecommercereservezyx987_createcookie'); ?>" />';        
        extradata += '<input type="hidden" id="dragonecommercereservezyx987_orderitems" name="dragonecommercereservezyx987_orderitems" value="" />';        
        extradata += '<input type="hidden" name="dragonecommercereservezyx987_hidden" value="Y" />';
        extradata += '<input type="hidden" name="dragonecommercereservezyx987_setcookiebysubmitform" value="setcookiebysubmitform" />';
        extradata += '<script>jQuery(document).ready(function(){var dragonecommercereservezyx987_orderitems = JSON.stringify(shoppingcartitems);if(shoppingcartitems.length === 0) {dragonecommercereservezyx987_orderitems = "";} jQuery("form#dragonecommercereservezyx987_setcookie_form input#dragonecommercereservezyx987_orderitems").val(dragonecommercereservezyx987_orderitems);});<\/script>';        
        myform.append(extradata).appendTo('body').submit();                            
    }
    
    function dragonecommercereservezyx987_readCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
                c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
                return c.substring(name.length, c.length);
            }
        }
        return "";
    }
    
    function dragonecommercereservezyx987_updateOrderitemsCookie() {
        dragonecommercereservezyx987_createOrderItemsCookie();
    }
</script>

<div id="dragonecommerce_wrap" class="dragonecommerce_wrap">
    <div class="ecommercetabmenu" id="ecommercetabmenu">
        <div class="ecommercetabmenu-toggle-button-container" role="button" tabindex="0" aria-label="show ecommerce menu" id="ecommercetabmenu-toggle-button-container" onclick="dragonecommercereservezyx987_showEcommerceMenu();"  onkeydown="dragonecommercereservezyx987_showEcommerceMenuHandler(event);">
            <button type="button" class="btn btn-default btn-sm" style="color:white;width: 23px;height: 74px;text-align:center;padding:0px !important;">
                <span id="glyphicon_search" aria-label="search product" role="img" class="glyphicon bi bi-search"></span><br/>
                <span id="glyphicon_shopping_cart" aria-label="go to shopping cart" role="img" class="glyphicon bi bi-cart"></span><br/>
                <span id="glyphicon_user" aria-label="user status" role="img" class="glyphicon bi bi-person" style="<?php global $user_ID;if ($user_ID) { echo "color:black !important;"; } else { echo "color:white !important;";}?>"></span>
            </button>
        </div>
    </div>
    
    <div class="row master_pwrapper">
    <?php if((!empty($_POST['dragonecommercereservezyx987_hidden'])) && $_POST['dragonecommercereservezyx987_hidden'] === 'Y') { ?>
        <div class="updated col-12" style="<?php echo $dragon_ecommerce_submitform_Result === '' ? 'color:#155724;background-color:#d4edda;padding-top:5px;padding-bottom:5px;' : 'color:#ff0000;background-color:#000000;padding-top:5px;padding-bottom:5px;'; ?>"><p style="margin-top:5px !important;margin-bottom:5px !important;text-align:center;"><strong><?php echo esc_html($dragon_ecommerce_submitform_Result); ?></strong></p></div>
    <?php } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {  //GET request page, if there is error message when log in or log out, show error message
        if($dragon_ecommerce_submitform_Result !== '') {
    ?>
        <div class="updated col-12" style="<?php echo $dragon_ecommerce_submitform_Result === '' ? 'color:#155724;background-color:#d4edda;padding-top:5px;padding-bottom:5px;' : 'color:#ff0000;background-color:#000000;padding-top:5px;padding-bottom:5px;'; ?>"><p style="margin-top:5px !important;margin-bottom:5px !important;text-align:center;"><strong><?php echo esc_html($dragon_ecommerce_submitform_Result); ?></strong></p></div>
    <?php
        }        
    } ?>
    </div>
          
    <?php $carousel_counter = 0; $totalquantity = count($slides);$slideimagesAllFound = true; 
    foreach ($slides as $slide) {
        $slideimageFolderPath = dragonecommercereservezyx987_upload_folder() . "/images/slideshow/" . $slide->filename;
        if(!file_exists($slideimageFolderPath)) {$slideimagesAllFound = false;}
    }
    if($slideimagesAllFound === true && $totalquantity > 0) {?>
    <div class="row">
        <div id="dragonecommerce_slideshow_container" class="col-12 col-sm-12 col-md-12 col-lg-12">        
            <div id="myCarousel" class="carousel slide" data-bs-ride="carousel">
                <!-- Indicators -->
                <div class="carousel-indicators">                    
                    <?php for($carousel_counter = 0; $carousel_counter < $totalquantity; $carousel_counter++) { ?>
                    <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="<?php echo $carousel_counter; ?>" class="<?php echo $carousel_counter === 0 ? 'active' : ''; ?>" <?php if($carousel_counter === 0) { ?> aria-current="true" <?php } ?> aria-label="Slide <?php echo $carousel_counter+1; ?>"></button>
                    <?php } ?>
                </div>
                <div class="carousel-inner">
                    <?php $carousel_counter2 = 1; ?>
                    <?php foreach ($slides as $slide) { ?>          
              
                    <div class="carousel-item <?php echo $carousel_counter2 === 1 ? 'active' : ''; ?>" style="overflow: hidden;">
                        <img class="d-block w-100" style="width: 100% !important;" src="<?php echo dragonecommercereservezyx987_upload_url() . "/images/slideshow/" . esc_html($slide->filename); ?>" alt="<?php echo htmlentities(sanitize_text_field($slide->name)); ?>">
                        <div class="carousel-caption d-none d-md-block">
                            <h5><?php if($slide->showname) {echo htmlentities(esc_html($slide->name));} ?></h5>
                            <p><?php if($slide->showdescription) {echo htmlentities(esc_html($slide->description));} ?></p>
                        </div>
                    </div>
                    <?php $carousel_counter2++; } ?>                                    
                </div>
                <button class="carousel-control-prev" data-bs-target="#myCarousel" type="button" data-bs-slide="prev">
                    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                    <span class="visually-hidden">Previous</span>
                </button>
                <button class="carousel-control-next" data-bs-target="#myCarousel" type="button" data-bs-slide="next">
                    <span class="carousel-control-next-icon" aria-hidden="true"></span>
                    <span class="visually-hidden">Next</span>
                </button>
            </div>
        </div>
    </div>
    <?php } ?>
    
    <div class="row master_pwrapper">
        <div class="col-12 col-sm-12 col-md-6 master_amountperpage" style="display: inline-block;">
            <label for="amountperpage">Items per Page:</label>
            <select name="amountperpage" id="amountperpage" class="form-select form-select-lg" onchange="dragonecommercereservezyx987_searchProducts();">
                <option value="-1" >Please choose one...</option>
                <option value="20" >20</option>
                <option value="40" selected>40</option>
                <option value="100" >100</option>
                <option value="200" >200</option>            
            </select>
        </div>
        <div class="col-12 col-sm-12 col-md-6 master_mysort" style="display: inline-block;">
            <label for="sortby">Sort By:</label>
            <select name="sortby" id="sortby" class="form-select form-select-lg" onchange="dragonecommercereservezyx987_searchProducts();">
                <option value="id|asc" >ID low-high</option>
                <option value="id|desc" >ID high-low</option>    
                <option value="name|asc" >name a-z</option>
                <option value="name|desc" >name z-a</option>
                <option value="price|asc" >price low-high</option>
                <option value="price|desc" >price high-low</option>            
            </select>
        </div>
    </div><br/>
    
    <div class="row master_pwrapper">
        <div class="col-12 master_mypagination" style="display: inline-block;"></div>
    </div>

    <div id="dragonecommerce_product_container">                
        <div class="">
            <div class="row" id="dragonecommerce_product">    
            <?php
                if(count($products) > 0) {
                    $tempRows = '';
                    for ($i = 0; $i < count($products); $i++) {
                        $tempRows .= '<div class="col-6 col-sm-6 col-md-4 col-lg-3"  tabindex="0" role="button" onclick="dragonecommercereservezyx987_showProduct(' . (empty($products[$i]["id"]) ? 0 : intval($products[$i]["id"])) . ');" onkeydown="dragonecommercereservezyx987_showProductHandler(event, ' . (empty($products[$i]["id"]) ? 0 : intval($products[$i]["id"])) . ');"><div class="row-container"><div class="product-details-container row">';
                        $temp_images = $products[$i]["imagefilenames"] == null ? '' : sanitize_text_field($products[$i]["imagefilenames"]);
                        $res = explode("|", $temp_images);
                        $previewimage = count($res) > 0 ? sanitize_text_field($res[0]) : '';
                        $imageFolderPath = dragonecommercereservezyx987_upload_folder() . "/images/product/" . ($products[$i]["id"] == null ? '' : intval($products[$i]["id"])) . "/preview/" . $previewimage;
                        $imageFileNotFound = file_exists($imageFolderPath) ? false : true;
                        $previewimage_urllink = ($previewimage === '' || $imageFileNotFound) ? (plugins_url('images/', __FILE__ ) . 'no_img.png') : (dragonecommercereservezyx987_upload_url() . "/images/product/" . ($products[$i]["id"] == null ? '' : intval($products[$i]["id"])) . "/preview/" . $previewimage);
                        $tempRows .= "<div class='productimage col-12 col-sm-12 col-md-6 col-lg-6'><div class='imagepadding'></div><img src=\"" . $previewimage_urllink . '" alt="' . ($products[$i]["name"] == null ? 'product image' : str_replace('"', '&#34;', sanitize_text_field($products[$i]["name"]))) . '"><div class="imagepadding"></div></div>';    
                        $tempRows .= '</div>';
                        $tempRows .= '<div class="product-namedescription-container row"><div class="productdetails col-12 col-sm-12 col-md-12 col-lg-12" >';
                        $tempRows .= '<div class="name"><h2>' . ($products[$i]["name"] == null ? '' : sanitize_text_field($products[$i]["name"])) . '</h2></div>';
                        if($products[$i]["isonsale"] === 1 && $products[$i]["saleprice"] > 0) {                                                                                                                
                            $tempRows .= '<div class="price"><h2><span class="currencysign strike-center">' . ($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] == null ? '' : sanitize_text_field($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"])) . '</span><span aria-label="price in the past was ' . ($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] == null ? '' : sanitize_text_field($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"])) . ($products[$i]["price"] == null ? '' : sanitize_text_field(strval($products[$i]["price"]))) . '" role="img" class="price strike-center">' . ($products[$i]["price"] == null ? '' : sanitize_text_field(strval($products[$i]["price"]))) . '</span></h2>';
                            $tempRows .= '<h2><span class="currencysign">' . ($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] == null ? '' : sanitize_text_field($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"])) . '</span><span aria-label="current on sale price is ' . ($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] == null ? '' : sanitize_text_field($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"])) . ($products[$i]["saleprice"] == null ? '' : sanitize_text_field(strval($products[$i]["saleprice"]))) . '" role="img" class="saleprice">' . ($products[$i]["saleprice"] == null ? '' : sanitize_text_field(strval($products[$i]["saleprice"]))) . '</span></h2>';                            
                        } else {
                            $tempRows .= '<div class="price"><h2><span class="currencysign">' . ($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] == null ? '' : sanitize_text_field($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"])) . '</span><span aria-label="price is ' . ($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"] == null ? '' : sanitize_text_field($settings["CURRENCY_UNIT_ID_DEFAULT"]["currencysign"])) . ($products[$i]["price"] == null ? '' : sanitize_text_field(strval($products[$i]["price"]))) . '" role="img" class="price">' . ($products[$i]["price"] == null ? '' : sanitize_text_field(strval($products[$i]["price"]))) . '</span></h2>';                            
                        }
                        $tempRows .= '</div></div></div>';                
                        $tempRows .= '</div></div>';
                    }
                    echo $tempRows;
                } else {
                    echo '<p style="color:red">NO DATA</p>';
                }
            ?>
            </div>
        </div>                        
    </div>
    
    <div class="row master_pwrapper">
        <div class="col-12 master_mypagination" style="display: inline-block;"></div>
    </div>    
    <hr/>
    
    <div class="copyright">
        <h4>© <?php echo date("Y"); ?> <?php echo empty($settings["COMPANY_NAME"]) ? '' : sanitize_text_field($settings["COMPANY_NAME"]); ?>. All rights reserved.</h4>
        <h4><?php echo empty($settings["COMPANY_ADDRESS"]) ? '' : sanitize_text_field($settings["COMPANY_ADDRESS"]); ?></h4>
    </div>    
</div>
<div id="loading" style="display:none;"></div>
<?php if((!empty($settings["USE_GOOGLE_RECAPTCHA"])) && $settings["USE_GOOGLE_RECAPTCHA"] === 1 && (!empty($settings["GOOGLE_RECAPTCHA_SITEKEY"])) && $settings["GOOGLE_RECAPTCHA_SITEKEY"] !== '' ) { ?>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<?php } ?>
</body>
</html>