/* Google Maps */ var map; var markers = new Array(); var selected; var icon = new GIcon(); icon.image = "/img/marker.png"; icon.shadow = "/img/marker_s.png"; icon.iconSize = new GSize(19.0, 22.0); icon.shadowSize = new GSize(31.0, 22.0); icon.iconAnchor = new GPoint(9.0, 11.0); icon.infoWindowAnchor = new GPoint(9.0, 11.0); function scrollTo (nr) { var $div = $('#scrollable'); var divOffset = $div.offset().top; var pOffset = $("#rest"+nr).offset().top; var pScroll = pOffset - divOffset - 15; $div.animate({scrollTop: '+=' + pScroll + 'px'}, { duration: 'long', easing: 'easeOutBack' }); } function clearMarker () { map.clearOverlays(); } function addMarker (nr, x, y, subdomain, name) { icon.image = "/img/marker"+nr+".png"; var point = new GPoint(y, x); var marker = new GMarker(point, icon); var tooltip = new Tooltip(marker,name,4); marker.tooltip = tooltip; map.addOverlay(marker); map.addOverlay(tooltip); markers[nr] = marker; GEvent.addListener(marker, "click", function() { selected = nr; }); GEvent.addListener(marker, "dblclick", function() { window.location.href = "http://"+subdomain+".menu2.ch/"; }); GEvent.addListener(marker,'mouseover',function() { this.setImage("/img/marker_h"+nr+".png"); this.tooltip.show(); $('#rest'+nr).addClass('hover'); $('#menus'+nr).addClass('hover'); unSelect(); scrollTo(nr); }); GEvent.addListener(marker,'mouseout',function() { if(selected) return; selected = nr; unSelect(); }); } function addCityMarker (anz, x, y, id, name) { icon.image = "/img/marker"+anz+".png"; var point = new GPoint(y, x); var marker = new GMarker(point, icon); var tooltip = new Tooltip(marker,name,4); marker.tooltip = tooltip; map.addOverlay(marker); map.addOverlay(tooltip); GEvent.addListener(marker, "click", function() { window.location.href = "http://www.menu2.ch/?s="+id; }); GEvent.addListener(marker, "dblclick", function() { window.location.href = "http://www.menu2.ch/?s="+id; }); GEvent.addListener(marker,'mouseover',function() { this.setImage("/img/marker_h"+anz+".png"); this.tooltip.show(); }); GEvent.addListener(marker,'mouseout',function() { this.setImage("/img/marker"+anz+".png"); this.tooltip.hide(); }); } function unSelect () { if(selected) { markers[selected].setImage("/img/marker"+selected+".png"); markers[selected].tooltip.hide(); $('#rest'+selected).removeClass('hover'); $('#menus'+selected).removeClass('hover'); selected = null; } } function showToolTip (nr) { unSelect(); markers[nr].setImage("/img/marker_h"+nr+".png"); markers[nr].tooltip.show(); } function hideToolTip (nr) { markers[nr].setImage("/img/marker"+nr+".png"); markers[nr].tooltip.hide(); } function setHiddenCoord (map) { var b = map.getBounds(); var x1 = b.getSouthWest().y; var y1 = b.getSouthWest().x; var x2 = b.getNorthEast().y; var y2 = b.getNorthEast().x; document.getElementById("nlx1").value = x1; document.getElementById("nlx2").value = x2; document.getElementById("nly1").value = y1; document.getElementById("nly2").value = y2; var feed = document.getElementById("feedLink"); if(feed) feed.href = "/rss/feed."+language+".rss?x1="+x1+"&y1="+y1+"&x2="+x2+"&y2="+y2; } function init_map (x1, y1, x2, y2) { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); var gb = new GLatLngBounds(new GLatLng(x1, y1), new GLatLng(x2, y2)); var zoom = map.getBoundsZoomLevel(gb); map.setCenter(gb.getCenter(), zoom); map.setUIToDefault(); setHiddenCoord (map); GEvent.addListener(map, "moveend", function() { var b = map.getBounds(); xajax_doMove(date, b.getSouthWest().y, b.getSouthWest().x, b.getNorthEast().y, b.getNorthEast().x); setHiddenCoord (map); }); } } /* Tooltip */ /** * @author Marco Alionso Ramirez, marco@onemarco.com * @url http://onemarco.com * @version 1.0 * This code is public domain */ /** * The Tooltip class is an addon designed for the Google Maps GMarker class. * @constructor * @param {GMarker} marker * @param {String} content * @param {Number} padding */ function Tooltip(marker, content, padding){ this.marker = marker; this.content = content; this.padding = padding; this.div = null; this.map = null; } Tooltip.prototype = new GOverlay(); Tooltip.prototype.initialize = function(map){ this.div = document.createElement("div"); var innerContainer = this.div.cloneNode(false); this.div.appendChild(innerContainer); this.div.style.position = 'absolute'; this.div.style.visibility = 'hidden'; this.shadowQuadrants = [{},{},{},{}] this.shadowQuadrants[0].div = document.createElement('div'); this.shadowQuadrants[0].div.style.position = 'absolute'; this.shadowQuadrants[0].div.style.overflow = 'hidden'; this.shadowQuadrants[0].img = createPngElement('http://www.menu2.ch/img/tooltip_shadow.png'); this.shadowQuadrants[0].img.style.position = 'absolute'; this.shadowQuadrants[0].div.appendChild(this.shadowQuadrants[0].img); this.shadowQuadrants[1].div = this.shadowQuadrants[0].div.cloneNode(false); this.shadowQuadrants[1].img = this.shadowQuadrants[0].img.cloneNode(true); this.shadowQuadrants[1].div.appendChild(this.shadowQuadrants[1].img); this.shadowQuadrants[2].div = this.shadowQuadrants[0].div.cloneNode(false); this.shadowQuadrants[2].img = this.shadowQuadrants[0].img.cloneNode(true); this.shadowQuadrants[2].div.appendChild(this.shadowQuadrants[2].img); this.shadowQuadrants[3].div = this.shadowQuadrants[0].div.cloneNode(false); this.shadowQuadrants[3].img = this.shadowQuadrants[0].img.cloneNode(true); this.shadowQuadrants[3].div.appendChild(this.shadowQuadrants[3].img); this.shadowQuadrants[0].div.style.right = '0px'; this.shadowQuadrants[0].div.style.top = '0px'; this.shadowQuadrants[0].img.style.top = '0px'; this.shadowQuadrants[0].img.style.right = '0px'; this.shadowQuadrants[1].div.style.left = '0px'; this.shadowQuadrants[1].div.style.top = '0px'; this.shadowQuadrants[1].img.style.top = '0px'; this.shadowQuadrants[2].div.style.left = '0px'; this.shadowQuadrants[2].div.style.bottom = '0px'; this.shadowQuadrants[2].img.style.bottom = '0px'; this.shadowQuadrants[2].img.style.left = '0px'; this.shadowQuadrants[3].div.style.right = '0px'; this.shadowQuadrants[3].div.style.bottom = '0px'; this.shadowQuadrants[3].img.style.bottom = '0px'; this.shadow = this.div.cloneNode(false); this.shadow.appendChild(this.shadowQuadrants[0].div); this.shadow.appendChild(this.shadowQuadrants[1].div); this.shadow.appendChild(this.shadowQuadrants[2].div); this.shadow.appendChild(this.shadowQuadrants[3].div); innerContainer.className = 'tooltip'; var child = typeof this.content == 'string' ? document.createTextNode(this.content) : this.content; innerContainer.appendChild(child); map.getPane(G_MAP_FLOAT_PANE).appendChild(this.div); map.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(this.shadow); this.map = map; } Tooltip.prototype.remove = function(){ this.div.parentNode.removeChild(this.div); } Tooltip.prototype.copy = function(){ var content = typeof this.content == 'string' ? this.content : this.content.cloneNode(true); return new Tooltip(this.marker,content,this.padding); } Tooltip.prototype.redraw = function(force){ if (!force) return; //draw tooltip var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint()); var iconAnchor = this.marker.getIcon().iconAnchor; var xPos = Math.round(markerPos.x - this.div.clientWidth / 2); var yPos = markerPos.y - iconAnchor.y - this.div.clientHeight - this.padding; this.div.style.top = yPos + 'px'; this.div.style.left = xPos + 'px'; //draw shadow //calculate shadow location shadowAnchor = new GPoint( markerPos.x + Math.round((this.marker.getIcon().iconSize.height + this.padding) / 2) , markerPos.y - Math.round((this.marker.getIcon().iconSize.height + this.padding) / 2) + 4); //calculate shadow dimenstions var shadowSize = new GSize(this.div.clientWidth + Math.round(this.div.clientHeight / 2) + 8, Math.round(this.div.clientHeight / 2) + 10); if(shadowSize.width % 2 == 1) shadowSize.width--; if(shadowSize.height % 2 == 1) shadowSize.height--; //apply shodaw location and dimensions this.shadow.style.left = (shadowAnchor.x - (shadowSize.width - shadowSize.height - 10 )/ 2) + 'px'; this.shadow.style.top = (shadowAnchor.y - shadowSize.height) + 'px'; this.shadow.style.width = (shadowSize.width) + 'px'; this.shadow.style.height = shadowSize.height + 'px'; //get quadrant dimensions var qHeight = shadowSize.height / 2; var qOddWidth = shadowSize.height > shadowSize.width ? shadowSize.height / 2: (shadowSize.width) / 2; var qEvenWidth = shadowSize.width - qOddWidth; //apply quadrant dimensions, calculate and apply Q2 and Q4 image offsets this.shadowQuadrants[0].div.style.width = qOddWidth + 'px'; this.shadowQuadrants[0].div.style.height = qHeight + 'px'; this.shadowQuadrants[1].div.style.width = qEvenWidth + 'px'; this.shadowQuadrants[1].div.style.height = qHeight + 'px'; this.shadowQuadrants[1].img.style.left = -(160 - shadowSize.height) + 'px'; this.shadowQuadrants[2].div.style.width = qOddWidth + 'px'; this.shadowQuadrants[2].div.style.height = qHeight + 'px'; this.shadowQuadrants[3].div.style.width = qEvenWidth + 'px'; this.shadowQuadrants[3].div.style.height = qHeight + 'px'; this.shadowQuadrants[3].img.style.right = -(160 - shadowSize.height) +'px'; } Tooltip.prototype.show = function(){ this.div.style.visibility = 'visible'; this.shadow.style.visibility = 'visible'; } Tooltip.prototype.hide = function(){ this.div.style.visibility = 'hidden'; this.shadow.style.visibility = 'hidden'; } //utility function for png compatibility in IE6 var IS_IE = false; var IS_LT_IE7; //@cc_on IS_IE = true; //@cc_on IS_LT_IE7 = @_jscript_version < 5.7; function createPngElement(src){ var img = document.createElement('img'); img.setAttribute('src',src); if(IS_IE && IS_LT_IE7){ img.style.visibility = 'hidden'; var div = document.createElement('div'); div.appendChild(img); div.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\',sizingMethod=\'crop\')'; return div; } return img; } /* Autocomplete */ $().ready(function() { $("#searchfield").autocomplete(searchfield, { matchContains: true, formatItem: function(row, i, max) { if(!row.info) return row.name; return row.name + " "+row.info+""; }, formatMatch: function(row, i, max) { return row.name; }, formatResult: function(row) { if(row.subdomain) { return row.subdomain; } return row.name; } }); function findValueCallback(event, data, formatted) { if(!data) return; if(data.subdomain) window.location = "http://"+data.subdomain+".menu2.ch"; } $(":text").result(findValueCallback).next().click(function() { $(this).prev().search(); }); });