<?php
//define this module's name and path
$mn = basename(__FILE__ , ".php");
include("modules/modules.php");


/*
Available variables:
All system classes
All request variables
$p (the template path)
$mp (the module path)
$sufixID (id sufix for this module's divs)
*/

if($moduleParameters['moduleAlign'] && $moduleParameters['moduleHR']){ // there are system parameters...
$marginTop = ($moduleParameters['marginTop'] == "__EMPTY__" || empty($moduleParameters['marginTop'])) ? 0 : $moduleParameters['marginTop'];
$marginRight = ($moduleParameters['marginRight'] == "__EMPTY__" || empty($moduleParameters['marginRight'])) ? 0 : $moduleParameters['marginRight'];
$marginBottom = ($moduleParameters['marginBottom'] == "__EMPTY__" || empty($moduleParameters['marginBottom'])) ? 0 : $moduleParameters['marginBottom'];
$marginLeft = ($moduleParameters['marginLeft'] == "__EMPTY__" || empty($moduleParameters['marginLeft'])) ? 0 : $moduleParameters['marginLeft'];
$paddingTop = ($moduleParameters['paddingTop'] == "__EMPTY__" || empty($moduleParameters['paddingTop'])) ? 0 : $moduleParameters['paddingTop'];
$paddingRight = ($moduleParameters['paddingRight'] == "__EMPTY__" || empty($moduleParameters['paddingRight'])) ? 0 : $moduleParameters['paddingRight'];
$paddingBottom = ($moduleParameters['paddingBottom'] == "__EMPTY__" || empty($moduleParameters['paddingBottom'])) ? 0 : $moduleParameters['paddingBottom'];
$paddingLeft = ($moduleParameters['paddingLeft'] == "__EMPTY__" || empty($moduleParameters['paddingLeft'])) ? 0 : $moduleParameters['paddingLeft'];
$useModuleContainer = ($moduleParameters['useModuleContainer'] == "__EMPTY__" || empty($moduleParameters['useModuleContainer'])) ? 0 : (int)$moduleParameters['useModuleContainer'];
$widthInPixels = ($moduleParameters['widthInPixels'] == "__EMPTY__" || empty($moduleParameters['widthInPixels'])) ? null : (int)$moduleParameters['widthInPixels'];


if(empty($marginTop) && empty($marginRight) && empty($marginBottom) && empty($marginLeft)){
	$Mmargin = "0";
}else{
	$Mmargin = $marginTop." ".$marginRight." ".$marginBottom." ".$marginLeft." ";
}
if(empty($paddingTop) && empty($paddingRight) && empty($paddingBottom) && empty($paddingLeft)){
	$Mpadding = "0";
}else{
	$Mpadding = $paddingTop." ".$paddingRight." ".$paddingBottom." ".$paddingLeft." ";
}


$useWheelZoom = ($moduleParameters['useWheelZoom'] == "__EMPTY__" || empty($moduleParameters['useWheelZoom'])) ? false : true;
$useLegend = ($moduleParameters['useLegend'] == "__EMPTY__" || empty($moduleParameters['useLegend'])) ? false : true;
$customXML = ($moduleParameters['customXML'] == "__EMPTY__" || empty($moduleParameters['customXML'])) ? false : true;
$XMLfilename = $moduleParameters["XMLfilename"];	
$dataSource = ($moduleParameters['dataSource'] == "auto") ? $section : $moduleParameters['dataSource'];
//$dataSource = "preview_map";
$cityFieldName = $moduleParameters['cityFieldName'];
$scriptName = $moduleParameters['scriptName'];
$viewName = $moduleParameters['viewName'];
$initialZoom = $moduleParameters['initialZoom'];
$linkTarget = $moduleParameters['linkTarget'];
$countyColor = $moduleParameters['countyColor'];
$HoverCountyColor = $moduleParameters['HoverCountyColor'];
$inactiveCountyColor = $moduleParameters['inactiveCountyColor'];
$strokeColor = $moduleParameters['strokeColor'];
$legendColor = $moduleParameters["legendColor"];
$listColor = $moduleParameters["listColor"];
$mapMode = $moduleParameters['mapMode'];

global $langID;

if($useModuleContainer ){
?>
<div id="<?php echo $mn.$sufixID;?>" data-editable="editable">
<?php
}
?>
<style type="text/css">
#<?php echo $mn.$sufixID;?>{
	<?php 
	$alignRule = ($moduleParameters['moduleAlign'] == "center") ? "text-align" : "float";
	echo $alignRule.": ".$moduleParameters['moduleAlign'].";".PHP_EOL;
	?>
	margin : <?php echo $Mmargin;?>;
	padding : <?php echo $Mpadding;?>;
<?php
if($widthInPixels){
	?>
	width: <?php echo $widthInPixels;?>px;
	<?php
}	
if($moduleParameters['moduleHR'] == "top" || $moduleParameters['moduleHR'] == "bottom"){
?>
	border-<?php echo $moduleParameters['moduleHR'];?> : 1px solid black;
<?php	
}
?>
}
#map_canvas{
	border-top: 1px dotted #<?php echo $countyColor;?>;
	position:relative;
	width: 370px;
	min-height: 390px;
	max-width: 370px;	
	transform-origin: top left;
	display:none;
	text-align:left;
	<?php if($mapMode != "minified") echo "margin-left: 200px;";?>
}
#countyName{
	position:absolute;
	top: 5px;
	left:20px;
	font-family: Arial, Verdana;
	color: #<?php echo $moduleParameters['countyColor'];?>;
	font-size: 13px;
	z-index: 9999;
}
<?php if($useLegend){ ?>
#legend{
	text-align:left;
	line-height:20px;
	margin-top: 5px;
	padding-top: 5px;
	border-top: 1px dotted grey;
}
<?php } ?>
.mwheel{
	display:block;
	padding-left:20px;
	padding-top: 5px; 
	font-style:italic;
	line-height:14px;
	background:url(<?php echo $mp;?>images/magnify.png) top left no-repeat;
	margin:5px 0;
	border-top: 1px dotted grey;
	min-height:20px;
}
.legend{
	text-align:left;
	font-family: Arial, Verdana;
	font-size: 11px;
	color: #<?php echo $legendColor;?>;
	
}
.tile{
	display: inline-block; 
	width:12px; 
	height:12px;
	margin: 0 5px;
}
<?php
if($mapMode != "minified"){
	?>
@media only screen and (max-width: 599px) {
	#countiesList{
		display:none;
	}
	#map_canvas{
		margin-left: 0;
	}
}
#legend{
	margin-top:30px;
}
#countiesList{
	height:390px;
	width: 200px;
	margin-bottom: -390px;
	margin-top:5px;	
	text-align:left;	
}
#countiesList a{
	display:block;
	width: 160px;
	background-color: #<?php echo $listColor;?>;
	color: #<?php echo $strokeColor;?>;
	padding: 5px 10px;
	margin: 2px 0;
	-moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  -khtml-border-radius: 10px;
  border-radius: 10px;
	cursor:pointer;
	text-decoration:none;
	font-size:13px;
  -moz-transition: background-color 800ms ease-in;
  -webkit-transition: background-color 800ms ease-in;
  -o-transition: background-color 800ms ease-in;
  transition: background-color 800ms ease-in;		
}
#countiesList a:hover{
	background-color: #<?php echo $countyColor;?>;	
  -moz-transition: background-color 100ms ease-in;
  -webkit-transition: background-color 100ms ease-in;
  -o-transition: background-color 100ms ease-in;
  transition: background-color 100ms ease-in;	
}
.mCSB_container {
	margin-right: 10px;
}
.mCustomScrollBox .mCSB_scrollTools {
top: 23px;
height:90%;
}
<?php
}
?>
</style>
<?php
}

$XMLfilename = (is_file($p.$XMLfilename)) ? $p.$XMLfilename : NULL;

if((!$XMLfilename || !$customXML) && $system->isMysqlFieldExists($cityFieldName, $dataSource)){
	$records=$db->getRecords("select distinct counties.id as countyID, content_counties.title as countyName from `counties`, `content_counties`, `cities`, `".$dataSource."` where ".$dataSource.".active=1 and  counties.id=cities.countyID and cities.id=".$dataSource.".".$cityFieldName." and content_counties.mainID=counties.id and content_counties.langID=".$langID." order by content_counties.title");
	if(!$records){ // no translations found so get result in english
		$records=$db->getRecords("select distinct counties.id as countyID, content_counties.title as countyName from `counties`, `content_counties`, `cities`, `".$dataSource."` where ".$dataSource.".active=1 and  counties.id=cities.countyID and cities.id=".$dataSource.".".$cityFieldName." and content_counties.mainID=counties.id and content_counties.langID='2' order by content_counties.title");	
	}
	
	$counties = $db->getRecords("select counties.id as countyID, content_counties.title as countyName from `counties`, `content_counties` where counties.active and content_counties.mainID=counties.id and content_counties.langID='".$langID."' order by content_counties.title");
	if(!$counties){ // no translations found so get counties in english
	$counties = $db->getRecords("select counties.id as countyID, content_counties.title as countyName from `counties`, `content_counties` where counties.active and content_counties.mainID=counties.id and content_counties.langID='2' order by content_counties.title");
	}
	$activeCounties = array();
	foreach($records as $row)	$activeCounties[] = $row->countyID;	
		
	$xml='<greekmap>';
	$xml.='<strokeColor>'.$strokeColor.'</strokeColor>';
	$xml.='<legendColor>'.$legendColor.'</legendColor>';
	$xml.='<statuses>';
	$xml.='<status color="'.$inactiveCountyColor.'" hoverColor="'.$inactiveCountyColor.'" title="'.t("Ανενεργή περιοχή").'">0</status>';
	$xml.='<status color="'.$countyColor.'" hoverColor="'.$HoverCountyColor.'" title="'.t("Επιλέξιμη περιοχή").'">1</status>';
	$xml.='</statuses>';
	$xml.='<counties>';
	foreach($counties as $county){
		$status = (in_array($county->countyID, $activeCounties)) ? 1 : 0;
		$xml.='<county id="'.$county->countyID.'" status="'.$status.'">'.$county->countyName.'</county>';
	}
	$xml.='</counties>';
	$xml.='</greekmap>';
}else{
	$xml='<greekmap></greekmap>'; // create an empty xml object
}


$dom = new DOMDocument;
$dom->loadXML($xml);

$data = ($XMLfilename && $customXML) ? simplexml_load_file($XMLfilename) : simplexml_import_dom($dom);
$statuses = array();
$counties = array();
$strokeColor = $data->strokeColor;
$legendColor = $data->legendColor;
foreach($data->statuses->status as $node){
	$status = strval($node);
	$statuses[$status]["color"] = strval($node->attributes()->color);
	$statuses[$status]["hoverColor"] = strval($node->attributes()->hoverColor);
	$statuses[$status]["title"] = strval($node->attributes()->title);
}

$countyList = array();
foreach($data->counties->county as $node){
	$countyName = strval($node);
	$id = strval($node->attributes()->id);
	$counties[$id]["id"] = $id;
	$counties[$id]["name"] = strval($node);
	$counties[$id]["status"] = strval($node->attributes()->status);
	if($counties[$id]["status"]){
		$cname = str_replace("Έ", "Ε", $counties[$id]["name"]);
		$countyList[] = $cname."~|~".$id;
	}
}
sort($countyList);
	
$color = $statuses[1]["color"]; // color of active county
$stroke = NULL;
$lines=file($mp.'svgs/stroke.svg');
foreach($lines as $line) $stroke.=trim(str_replace("#1F1A17", "#".$strokeColor, $line));

if($mapMode != "minified"){
	?>
<div id="countiesList">
<?php
foreach($countyList as $county){
	list($cname, $cid) = explode("~|~", $county);
?>
<a href="javascript:void(0)" onclick="gotoCounty(this)" data-id="<?php echo $cid;?>"><?php echo t($cname);?></a>
<?php
}
?>
</div>
<?php
}



?>
<script type="text/javascript">
var XMLfilename = "<?php echo $XMLfilename;?>";
var cityFieldName = <?php echo ($system->isMysqlFieldExists($cityFieldName, $dataSource)) ? "true" : "false";?>;
var customXML = <?php echo ($customXML) ? "true" : "false";?>;
window.displayMap = true;

	function supportSVG(){
		return document.createElement('svg').getAttributeNS;
	}
	
	function gotoCounty(elm){
		<?php
		if($dataSource == "preview_map") echo "alert('No links for this demo'); return false;";
		?>
		if(!parseInt(window.counties[$(elm).attr("data-id")]["status"])) return false;
			var url="<?php echo $scriptName;?>?section=<?php echo $dataSource;?>&view=<?php echo $viewName;?>&langID=<?php echo $langID;?>&countyID=" + $(elm).attr("data-id");
			<?php
			if($linkTarget == "_blank"){
			?>
			window.open(url);
			<?php
			}
			if(($linkTarget == "_top")){
			?>
			document.location.href = url;
			<?php	
			}
			if(($linkTarget == "_self")){
			?>
			window.location.href = url;
			<?php	
			}			
			?>
	}
	if(!supportSVG() && customXML){
		jQuery().ready(function(){
			$('#map_canvas').html("<strong>Module: Greek Map Navigation</strong><br><?php echo t("Ο συγκεκριμένος χάρτης δεν υποστηρίζεται<br>από τον browser που χρησιμοποιείτε");?>")
			.css({'border': 'none', 'height': '40px', 'padding-left': '55px', 'background':'url(images/notfound.png) left top no-repeat'});
			$('#legend').css("display", "none");
			$('#map_canvas').css("margin-left", "0");
			$('#countiesList').css("display", "none");					
		});
		window.displayMap = false;
	}
	if((!XMLfilename || !customXML) && !cityFieldName){
		jQuery().ready(function(){
			$('#map_canvas').html("<strong>Module: Greek Map Navigation</strong><br><?php echo t("Η συγκεκριμένη ενότητα<br>δεν περιέχει γεωγραφικά δεδομένα");?>")
			.css({'border': 'none', 'height': '40px', 'padding-left': '55px', 'background':'url(images/notfound.png) left top no-repeat'});
			$('#legend').css("display", "none");
			$('#map_canvas').css("margin-left", "0");
			$('#countiesList').css("display", "none");					
		});
		window.displayMap = false;
	}		
	
	if(!supportSVG() && !customXML && window.displayMap){
	
		$('#legend').css("display", "none");
		$('#map_canvas').css("margin-left", "0");
		$('#countiesList').css("display", "none");	
			
		var flashvars = {};
		flashvars.section = "<?php echo $dataSource;?>"; // το section name από το οποίο θα αντλήσει γεωγραφικές πληροφορίες ο χάρτης
		flashvars.cityFieldName = "<?php echo $moduleParameters['cityFieldName'];?>"; // το όνομα του mySQL πεδίου που περιέχει το id της πόλης, στο επιλεγμένο section
		flashvars.scriptName = "<?php echo $moduleParameters['scriptName'];?>"; // το php αρχείο που θα κληθεί από το flash on click σε κάποιο ενεργό Νομό
		flashvars.viewName = "<?php echo $moduleParameters['viewName'];?>"; // το όνομα του view που θα απεικονίσει τα αποτελέσματα της αναζήτησης
		flashvars.linkTarget = "<?php echo $moduleParameters['linkTarget'];?>"; // το target του link...
		flashvars.countyColor = "<?php echo $moduleParameters['countyColor'];?>";
		flashvars.hoverCountyColor ="<?php echo $moduleParameters['HoverCountyColor'];?>";
		flashvars.inactiveCountyColor = "<?php echo $moduleParameters['inactiveCountyColor'];?>";
		flashvars.strokeColor = "<?php echo $moduleParameters['strokeColor'];?>";
		var attributes = {};
		attributes.wmode = "transparent";		
		<?php
		if($mapMode != "minified"){
		?>
		swfobject.embedSWF("<?php echo $mp;?>map.swf", "map_container<?php echo $sufixID; ?>", "600", "390", "9", "expressInstall.swf", flashvars, attributes);
		<?php
		}else{
		?>
		swfobject.embedSWF("<?php echo $mp;?>map_minified.swf", "map_container<?php echo $sufixID; ?>", "370", "420", "9", "expressInstall.swf", flashvars, attributes);
		<?php
		}
		?>
		document.write('<div id="map_container<?php echo $sufixID; ?>"></div>');
		
	}else{ // html5 map

		if(window.displayMap) window.zm = <?php echo $initialZoom;?>;
		window.activeCounties = 51; // assume all counties are active in the beginning 
		window.listMaxCounties = 1; // maximum number of counties in list to start scrolling
		window.counties = {};
		window.counties.name = {};
		window.counties.status = {};
		<?php
		for($n=1; $n<=51; $n++){
		?>
		window.counties[<?php echo $n;?>] = {};
		window.counties[<?php echo $n;?>]["name"] = "<?php echo t($counties[$n]["name"]);?>";
		window.counties[<?php echo $n;?>]["status"] = "<?php echo $counties[$n]["status"];?>";
		<?php
		}
		?>
		jQuery().ready(function(){
			<?php
			if((float)$initialZoom > 1){
				$initialZoom -= .2; // decreasing the value because it will reset again by setZoom()
			?>
			if(window.displayMap) setZoom();
			<?php	
			}
			?>
			$('svg').each(function(index, element) {
				$(this).find('path').attr('fill', '#' + $(this).attr('data-fill'));
				$(this).css("position", "absolute");
				$(this).css("top", $(this).attr("data-y")+"px");
				$(this).css("left", $(this).attr("data-x")+"px");
				$(this).css("z-index", "9997");
			});
			$('area').each(function(index, element) {
				var countyID = $(this).attr("data-id");
				if(!parseInt(window.counties[countyID]["status"])){
					$(this).removeAttr("href");
					window.activeCounties--;
				}
				$(this).mouseover(function(e) {
					if(parseInt(window.counties[countyID]["status"])){
						var mouseoverColor = $('#n'+countyID).attr("data-hover");				
						$('#n'+countyID).find('path').attr('fill', '#'+mouseoverColor);
						$('#countyName').html(window.counties[countyID]["name"]);
					}
				}).mouseout(function(e) {
					if(parseInt(window.counties[countyID]["status"])){
						var normalColor = $('#n'+countyID).attr("data-fill");				
						$('#n'+countyID).find('path').attr('fill', '#'+normalColor);
						$('#countyName').html(null);				
					}
				}).focus(function(e){
					$(e.target).blur();
				});
			});
			
			var stroke = '<?php echo $stroke;?>';
			$('#map_canvas').append($(stroke));
			$('#stroke').css("position", "absolute");
			$('#stroke').css("top", "25px");
			$('#stroke').css("left", "11px");
			$('#stroke').css("z-index", "9998");
			
			var map_container = document.getElementById('map_canvas');
			<?php
			if($useWheelZoom){
			?>
			if (map_container.addEventListener) {
				map_container.addEventListener("mousewheel", MouseWheelHandler, false);
				map_container.addEventListener("DOMMouseScroll", MouseWheelHandler, false);
			} else map_container.attachEvent("onmousewheel", MouseWheelHandler);
			function MouseWheelHandler(e) {
				if(isSafari()) return false;
				var e = window.event || e;
				var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
				if(delta < 0 && window.zm < 2){
					zoomIn();	
					e.preventDefault();				
				}
				if(delta > 0 && window.zm > 1){
					zoomOut();	
					e.preventDefault();						
				}
			}
			<?php
			}
			?>
			
			$(document).keypress(function(event) {
				var k = event.which;
				if(!k || k === "undefined") k = event.keyCode;
				if(!k || k === "undefined") k = event.charCode;
				if((event.target.tagName != "INPUT") && (event.target.tagName != "TEXTAREA")){
					if((k == 43 || k == 61) && window.zm < 2) zoomIn();	
					if(k == 45 && window.zm > 1) zoomOut();							
					return false;
				}
			});
			
			function zoomIn(){
				if(isSafari()) return false;
				window.zm += .2;
				setZoom();					
			}
			
			function zoomOut(){
				if(isSafari()) return false;
				window.zm -= .2;
				setZoom();							
			}
			
			function setZoom(){
				if(isSafari()) return false;
				h = 390 * window.zm;				
				$('#map_canvas').css("zoom", window.zm).css("height", "390px");	
				if(BrowserDetect.browser == "Opera") $('#map_canvas').css("-o-transform", "scale("+window.zm+")").css("height", h + "px");	
				if(BrowserDetect.browser == "Firefox") $('#map_canvas').css("-moz-transform", "scale("+window.zm+")").css("height", h + "px");	
			}
			
			function isSafari(){
				var ua = navigator.userAgent.toLowerCase(); 
				if(ua.indexOf('safari')!=-1){ 
					if(ua.indexOf('chrome')  > -1){
						return false;
					}else{
						$('.mwheel').css("display", "none");
						return true;
					}
				}				
			}
			
			$('#map_canvas').css("display", "block");			
			$('area').bind('mousedown',function(e) {
				e.preventDefault();
			});
		});

	} // end of html5 map
</script>
<div id="map_canvas">
<img src="<?php echo getBase();?>images/blank.gif"  alt="" width="370" height="390" usemap="#mappath" border="0" style="position:absolute; z-index:9999" />
<span id="countyName"></span>
<map name="mappath">
    <area tabindex="-1" data-id="1" shape="poly" coords="270,47,270,54,268,61,265,66,258,69,256,71,247,93,251,96,255,96,255,92,250,90,258,72,263,73,269,74,271,78,275,78,281,68,281,63,281,52,289,46,293,45,291,33,280,25,272,28,272,31,277,37,275,40,274,45" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="2" shape="poly" coords="255,71,261,66,266,64,268,59,269,48,258,48,250,49,243,53,236,54,233,55,233,60,235,67,241,68" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="3" shape="poly" coords="240,53,234,54,232,59,229,62,231,64,227,67,218,71,217,66,216,58,212,53,218,47,224,43" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="4" shape="poly" coords="218,45,214,43,208,35,204,37,199,37,192,38,191,42,183,42,181,43,176,44,174,46,180,51,181,55,189,59,194,61,198,66,208,57" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="5" shape="poly" coords="146,48,148,54,154,54,160,62,160,66,166,69,167,73,172,74,175,78,180,76,185,76,193,69,198,67,192,62,181,56,179,51,173,46,165,45,159,45" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="6" shape="poly" coords="146,48,141,49,138,57,126,58,122,68,130,72,137,73,139,76,149,75,151,73,154,73,157,67,160,67,159,62,155,56" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="7" shape="poly" coords="125,58,110,58,102,65,102,69,99,73,102,76,102,79,105,82,113,81,117,83,120,82,128,82,132,81,134,74,128,71,122,68,123,63" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="8" shape="poly" coords="101,67,95,68,93,71,87,68,82,71,68,72,68,77,70,81,74,83,79,79,84,80,88,89,91,86,98,86,102,80,100,76,99,71" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="9" shape="poly" coords="88,89,85,85,84,81,80,80,76,82,74,84,71,83,69,88,65,92,60,94,61,101,62,102,66,99,67,102,68,106,72,106,74,102,75,98,84,97,88,93" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="10" shape="poly" coords="74,104,72,107,68,108,71,117,71,122,80,124,93,123,100,124,100,118,98,109,88,104" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="11" shape="poly" coords="106,85,102,81,100,86,91,87,88,89,89,94,84,98,76,99,75,102,89,104,98,108,100,114,101,119,108,115,113,108,117,103,109,94" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="12" shape="poly" coords="106,83,110,82,114,82,117,84,120,82,130,82,132,82,133,86,134,89,132,92,128,91,126,94,122,98,117,101,111,95,108,91" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="13" shape="poly" coords="135,88,134,84,133,80,134,76,135,74,137,74,139,77,150,76,153,74,156,70,158,68,161,67,164,69,166,73,169,74,172,75,174,78,175,84,177,85,171,87,167,86,162,88,155,91,152,94,149,99,143,96,141,91,146,89,145,85,142,83,140,85" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="14" shape="poly" coords="218,72,217,68,217,62,215,57,213,53,208,58,204,62,199,66,195,69,189,73,186,77,187,79,194,78,199,74,202,70,204,68,211,68,213,71,213,78,209,82,213,87,218,86,219,81,216,78,215,72" href="javascript:void(0)" onclick="gotoCounty(this)">    
    <area data-id="15" shape="poly" coords="150,100,154,93,161,90,166,87,170,88,173,88,177,86,182,90,179,94,184,98,188,99,188,95,191,100,195,100,204,111,199,111,193,102,193,102,182,98,175,101,175,104,181,109,186,110,187,120,182,118,178,112,176,108,170,104,164,103,162,105,162,110,165,115,170,118,175,119,175,121,171,122,167,119,163,119,161,115,159,110,158,105,153,102" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="16" shape="poly" coords="130,93,129,92,126,95,119,101,117,104,115,107,119,108,120,111,123,109,125,114,127,118,132,121,136,121,132,117,130,111,129,105,132,101,134,97" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="17" shape="poly" coords="79,126,73,124,70,121,71,116,67,111,68,107,66,105,66,101,64,103,60,103,58,99,56,103,55,111,45,112,42,118,44,126,47,132,48,136,54,143,54,147,55,152,59,149,65,149,69,146,71,141,74,136,74,133,75,130" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="18" shape="poly" coords="54,151,54,143,47,136,46,132,43,127,40,127,37,133,33,134,34,137,31,139,35,142,36,147,40,154,50,153" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="19" shape="poly" coords="68,149,59,149,55,152,53,152,50,154,45,154,46,158,54,166,59,160,64,154" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="20" shape="poly" coords="74,139,71,144,69,149,67,152,63,157,60,160,57,164,54,166,55,171,58,172,62,170,68,169,71,163,77,163,82,161,83,157,85,153,83,150,78,149,75,146" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="21" shape="poly" coords="128,164,130,160,134,153,138,150,143,149,139,143,144,140,141,131,134,122,126,119,123,111,120,113,116,108,110,114,102,120,102,124,108,128,116,138,120,145,118,151,119,156,124,160" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="22" shape="poly" coords="102,125,96,125,87,124,79,126,76,131,74,138,75,143,75,146,78,148,82,150,89,146,95,145,98,143,103,142,108,141,110,139,116,139,112,134,108,129" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="23" shape="poly" coords="118,156,117,151,119,146,118,142,116,140,111,140,105,143,96,145,92,147,88,148,84,150,86,152,85,155,84,160,89,157,91,156,97,157,103,159,106,164,106,168,113,168,115,164,116,160" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="24" shape="poly" coords="145,141,141,144,143,149,136,152,132,158,128,165,132,168,140,170,145,173,148,170,145,168,145,165,141,162,138,160,141,155,146,152,152,154,155,159,155,162,149,164,153,165,160,163,170,163,175,167,186,162,190,156,196,151,193,149,187,153,184,158,181,160,178,163,174,160,167,159,163,159,158,156,156,151,151,146,148,143" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="25" shape="poly" coords="23,128,19,125,11,127,17,136,19,143,25,149,31,160,33,159,29,147,22,142,20,137,19,132" href="javascript:void(0)" onclick="gotoCounty(this)">    
    <area data-id="26" shape="poly" coords="52,177,45,190,53,192,57,198,63,188,53,187,53,180" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="27" shape="poly" coords="55,204,50,195,45,198,44,203,39,203,37,213,44,214,56,218,57,214,50,208" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="28" shape="poly" coords="61,231,54,230,51,224,48,228,50,234,55,239,61,233" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="29" shape="poly" coords="144,174,137,170,131,169,126,164,119,157,117,162,114,168,106,169,104,174,106,183,111,185,117,184,120,180,123,185,129,184,132,189,132,193,148,193,161,197,159,192,159,189,154,188,152,190,147,184,136,182,134,179,130,180,128,176,133,175,137,175" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="30" shape="poly" coords="176,205,175,210,168,210,165,212,161,210,155,215,160,224,165,227,165,236,160,239,159,243,166,249,170,254,159,257,150,261,151,265,159,311,149,314,144,307,141,313,144,319,148,320,152,314,161,313,154,268,155,261,170,257,172,249,163,243,168,238,171,235,167,230,168,226,171,225,177,233,185,237,185,241,190,241,194,238,187,224,188,218,190,211,179,205" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="31" shape="poly" coords="82,162,79,164,71,164,68,170,56,172,55,179,59,180,61,184,66,188,66,195,70,198,68,203,72,206,79,200,84,206,95,203,102,200,104,197,108,194,108,187,105,184,100,187,94,186,90,184,90,177,88,172" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="32" shape="poly" coords="102,199,113,205,121,204,123,200,129,206,131,203,128,199,129,193,132,192,130,185,122,186,120,182,118,185,109,185,109,194,106,197" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="33" shape="poly" coords="170,198,162,198,156,196,148,194,130,194,129,198,130,201,133,204,138,210,143,212,155,214,161,209,164,210,167,210,171,209,175,209,176,205,171,202" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="34" shape="poly" coords="158,169,155,171,151,171,141,178,145,179,148,177,154,178,160,182,168,192,173,194,177,202,190,203,194,210,197,214,197,218,201,220,197,222,198,225,203,224,206,223,208,225,211,222,211,216,205,215,201,214,197,209,196,205,194,201,196,196,217,182,210,174,206,173,206,177,211,178,212,181,213,184,199,193,193,193,191,188,178,188,174,183,170,184,165,178,161,172" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="35" shape="poly" coords="150,259,154,257,159,253,167,252,162,248,154,244,152,237,144,236,137,236,130,233,124,234,124,238,129,246,130,252,135,252,136,245,139,247,143,247,148,249,151,250,151,255" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="36" shape="poly" coords="159,225,156,220,147,220,142,219,143,222,146,223,147,227,141,227,135,221,131,217,125,216,120,227,118,230,120,232,125,233,130,232,133,233,137,235,147,235,152,236,153,233,150,231,146,231,146,229,155,226" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="37" shape="poly" coords="124,217,121,223,119,227,118,230,117,232,111,233,106,232,101,226,97,227,93,229,88,225,87,221,80,217,80,212,85,212,88,215,90,214,98,207,105,205,110,211,115,213,119,214" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="38" shape="poly" coords="103,231,102,228,99,227,96,228,94,230,91,228,87,224,86,221,80,218,75,223,68,226,68,230,75,231,76,240,82,240,91,250,92,254,97,253,98,252,105,251,106,252,107,251,107,247,103,245,99,244,98,240,99,235,100,234" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="39" shape="poly" coords="105,252,102,253,98,253,95,255,91,255,92,261,86,266,86,271,93,279,92,284,98,286,98,289,102,287,100,282,101,277,104,273,109,274,111,280,115,282,117,288,122,284,121,277,117,269,114,265,108,263,106,259,105,255" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="40" shape="poly" coords="118,231,116,233,114,234,109,233,103,232,100,235,99,239,100,242,104,244,108,247,108,251,106,254,107,257,108,261,111,263,115,265,116,261,121,260,123,263,124,258,129,258,132,261,133,266,136,271,140,274,145,274,145,271,142,269,142,265,139,261,137,258,136,254,135,251,130,252,128,248,127,243,123,239,123,236" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="41" shape="poly" coords="145,275,140,274,136,272,135,271,133,267,132,263,129,259,125,259,124,264,120,261,116,264,117,267,121,274,122,279,123,285,119,288,121,292,120,295,120,307,123,307,123,299,125,294,127,292,127,288,129,285,134,284,138,288,139,292,145,299,143,302,147,301,150,305,154,305,152,300,149,296,147,294,147,289,150,288,149,284,147,280" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="42" shape="poly" coords="201,369,200,365,201,361,198,356,191,353,196,352,194,348,187,352,180,352,178,344,175,346,176,351,178,354,174,354,170,349,169,356,168,365,171,366,186,367,195,369" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="43" shape="poly" coords="202,361,201,364,201,367,203,369,209,371,211,373,218,373,221,370,224,370,225,366,223,363,223,358,215,358,208,360,205,361" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="44" shape="poly" coords="224,358,224,363,226,367,225,371,221,371,219,373,220,381,234,381,252,379,249,374,249,371,252,368,251,363,241,362,234,362,229,359" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="45" shape="poly" coords="253,378,250,374,250,371,253,369,252,364,260,361,261,366,258,370,260,374,265,374,274,367,280,368,284,364,285,370,280,378,269,377,264,378,256,378" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="46" shape="poly" coords="306,361,321,335,280,298,308,286,303,266,290,256,313,250,316,275,328,280,331,299,349,289,366,301,348,346" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="47" shape="poly" coords="309,242,303,242,298,239,293,246,270,248,273,240,293,237,299,232,315,232,315,237,312,240" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="48" shape="poly" coords="215,225,224,238,215,242,201,240,198,244,203,259,204,267,208,271,215,275,212,281,196,284,199,295,210,293,220,289,223,297,228,299,240,294,244,311,265,310,267,304,249,300,257,289,268,288,276,280,269,275,254,281,257,270,249,261,240,264,228,272,229,259,243,256,250,254,240,241,231,238,229,228,222,223" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="49" shape="poly" coords="269,214,275,211,277,206,276,194,270,191,263,193,255,191,250,192,251,195,257,194,261,196,267,199,268,205,264,208,264,212" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="50" shape="poly" coords="294,170,287,172,276,169,264,163,263,158,227,146,226,142,230,118,247,117,244,130,230,128,229,137,232,146,258,154,270,156,277,150,285,150,286,157,289,157" href="javascript:void(0)" onclick="gotoCounty(this)">
    <area data-id="51" shape="poly" coords="105,183,103,185,100,186,97,186,91,184,91,176,88,170,84,164,84,161,89,158,94,157,98,158,104,162,105,165,105,167,103,168,104,171,104,176" href="javascript:void(0)" onclick="gotoCounty(this)">
</map>

<?php
for($n=1; $n<=51; $n++){
	$filename=$mp."svgs/nomos".$n.".svg";
	$arr = file($filename);
	$svg = $arr[0];
	$currentColor = $statuses[$counties[$n]["status"]]["color"];
	$hoverColor = $statuses[$counties[$n]["status"]]["hoverColor"];
	$svg = str_replace("fillColor", $currentColor, $svg);
	$svg = str_replace("hoverColor", $hoverColor, $svg);
	echo $svg;
}
?>

</div>

<div id="legend">
<?php
if($useLegend){
	foreach($statuses as $status){
		$legend_color = $status["color"];
		$legend_title = t($status["title"]);
		?>
		 <span class="legend"><div class="tile" style="background-color: #<?php echo $legend_color;?>"></div><?php echo $legend_title;?></span><br>
		<?php
	}
}
$zoomText = ($useWheelZoom) ? t("Κυλήστε το ροδάκι του ποντικιού πάνω στο χάρτη<br>ή πατήστε τα πλήκτρα [ +/- ] για zoom in/out") : t("Πατήστε τα πλήκτρα [ +/- ] για zoom in/out");
?>
<span class="legend mwheel"><?php echo $zoomText;?></span>
</div>
<?php
if($useModuleContainer ){
?>
</div>
<?php
}
if($mapMode != "minified" && count($countyList) > 14){
?>

<script type="text/javascript">
		jQuery().ready(function(){
			if(window.activeCounties > window.listMaxCounties){
				$('#countiesList').mCustomScrollbar();
			}
		});
</script>
<?php
}
?>