<?php
/*$optres['js'][] = $path . "amodules/wb_search_map/js/markerclusterer.js";
$optres['js'][] = $path . "amodules/wb_search_map/js/infobubble.js";*/

if(isset($wb_uid) && trim($wb_uid) != "") {
	$template_css = dirname(__FILE__) . "/templates_css/$wb_uid.css";
	if(file_exists($template_css)) {
		$optres ['css'][] = $path . "amodules/wb_search_map/templates_css/$wb_uid.css";
	}
}
$have_wb_search_map_image = isset($have_wb_search_map_image) ? $have_wb_search_map_image : false;

$wb_sm_size = 'large';
$have_wb_search_map_image = false;
if(isset($module_map_search_image) && $module_map_search_image != "") {
	$wb_logo_image_path = $_SERVER['DOCUMENT_ROOT'] . "/images/wb_res/$wb_uid" . $module_map_search_image;
	if(file_exists($wb_logo_image_path)) {
		$have_wb_search_map_image = true;
		$wb_sm_size = 'small';
		$wb_logo_image_url = $path . "images/wb_res/$wb_uid" . $module_map_search_image;
	}
	
}

?>
<div class="box box-info">
    <?php
    if(isset($map_title) && $map_title != "") {
        ?>
        <div class="box-header with-border">
            <i class="fa fa-globe fa-2x"></i> <b><?=$map_title; ?></b>

        </div>
        <?php
    }
    ?>
    <div class="box-body no-padding">
        <div class="container-fluid">
            <div id="wb_search_map" class="wb_search_map_<?php echo $wb_sm_size;?> row">

                <?php
                if($have_wb_search_map_image) {
                    echo '<div id="wb_search_map_image" class="col-sm-5">';
                    echo '<img id="wb_search_map_img" src="', $wb_logo_image_url, '" width="670" height="240" alt="', $webpage_title_en,'"/>';
                    echo '</div>';
                    ?>
                    <div id="wb_search_map_container" class="wb_search_map_container_small col-sm-5 no-padding">
                        <div id="cyprus_map" class="wb_search_map_gmap_small"></div>
                        <div id="map_menu_small" class="wb_search_map_menu">
                            <span class="map_menu_link" id="map_enlarge">
                                <i class="fa fa-expand fa-lg"></i>
                            </span>
                        </div>
                        <div id="map_menu_large" class="wb_search_map_menu" style="display: none;">
                            <span class="map_menu_link" id="map_close">
                                <i class="fa fa-compress fa-lg"></i>
                            </span>
                        </div>
                        <div id="map_menu_center" class="wb_search_map_menu">
                            <span class="map_menu_link" id="map_center">
                                <i class="fa fa-dot-circle-o fa-lg"></i>
                            </span>
                        </div>
                    </div>
                    <?php
                }
                else {
                    ?>
                    <div id="wb_search_map_container" class="wb_search_map_container_large">
                        <div id="cyprus_map" style="width:100%; height: 400px; margin: 0;" class="wb_search_map_gmap_large"></div>

                        <div id="map_menu_center" class="wb_search_map_menu">
                            <span class="map_menu_link" id="map_center">
                                <i class="fa fa-dot-circle-o fa-lg"></i>
                            </span>
                        </div>
                    </div>
                    <?php
                }
                ?>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
	<?php
	if(count($json_locations) > 0) {
		?>
		
		var json_locations = <?php echo json_encode($json_locations); ?>;
		//console.log(json_locations);
	
		<?php
		
	}
	else {
		echo 'var json_locations = {};';
	}
	
	if($have_wb_search_map_image) {
		$optres['js'][] = $path . "amodules/wb_search_map/js/wb_search_map_image.js";
	}
	else {
		?>
		var have_wb_search_map_image = false;
		<?php
	}
	?>
</script>