
jQuery(document).ready(function(){
	loadClickableMapByCity(jQuery("input#locationLocation").val(),jQuery("input#mapLevel").val());
});

function loadClickableMapByCity(city, maplevel) {
	var ops = FonectaMap.options();
	ops.url = 'http://maps.fonecta.fi';
	ops.address = '';
	ops.city = city;
	ops.clickUrl = 'http://www.eniro.fi/kartta/'+city+'?edsacid=p-huutonet-kartta';
	ops.clickUrlTarget = '_blank';
	ops.mapAreaId = 'locationMap';
	ops.width = 229;
	ops.height = 170;
	ops.scale = maplevel;
	ops.showOverview = true;
	ops.showTileSwitcher = false;
	ops.showSmallControls = false;
	ops.tooltipsEnabled = true;
	ops.logoType = "";
	    
	var clickableMapByCity = new FonectaMap(ops);
	
	clickableMapByCity.start();
	
  //Overlay hack 
	var url = null;
	$overlay = jQuery('<div style="position: relative; margin-top: -'+ops.height+';width: '+ops.width+'; height: '+ops.height+'; cursor: pointer;"></div>');
	jQuery("#locationMap").append($overlay);
	$overlay.click(function(){
		try {
			pageTracker._trackEvent("Huuto-net showitem - Fonecta map", "overlay-click");
		} catch(err){

		}
		return true;
	});
	jQuery('a#fmmaplink').click(function(){
		try {
			pageTracker._trackEvent("Huuto-net showitem - Fonecta map", "overlay-click");
		} catch(err){

		}
		return true;	
	});
	jQuery('a.fmroutelink').click(function(){
		try {
			pageTracker._trackEvent("Huuto-net showitem - Fonecta route", "seller-buyer-click");
		} catch(err){

		}
		return true;			
	});
}
