function am(latlng,opt_opts){this.latlng_=latlng;this.opts_=opt_opts;this.div_=opt_opts.div||new Element('div');this.object_=opt_opts.object||false;this.m_=opt_opts.m||null;this.labelClass_=opt_opts.labelClass||"defaultLabelMarker";this.labelOffset_=opt_opts.labelOffset||new google.maps.Size(0,0);this.clickable_=opt_opts.clickable||true;this.title_=opt_opts.title||"";this.labelVisibility_=true;this.overlayContent=null;this.to=null;this.sleep=0;if(opt_opts.draggable){opt_opts.draggable=false;}google.maps.Marker.apply(this,arguments);};am.prototype=new google.maps.Marker(new google.maps.LatLng(0,0));am.prototype.initialize=function(map){google.maps.Marker.prototype.initialize.apply(this,arguments);this.map_=map;this.div_.className=this.labelClass_;this.div_.style.position="absolute";this.div_.style.cursor="pointer";this.div_.title=this.title_;if(this.object_.type=="user"&&this.object_.user.online_status=="offline")this.div_.appendChild(new Element('span',{'CLASS':'small_status_icon status_icon_'+this.object_.user.online_status}));else if(this.object_.type=="user")this.div_.appendChild(new Element('span',{'CLASS':'big_status_icon status_icon_'+this.object_.user.online_status}));map.getPane(G_MAP_MARKER_PANE).appendChild(this.div_);if(this.clickable_){function newEventPassthru(obj,event){return function(){google.maps.Event.trigger(obj,event);};};var eventPassthrus=['click','dblclick','mousedown','mouseup','mouseover','mouseout'];for(var i=0;i<eventPassthrus.length;i++){var name=eventPassthrus[i];google.maps.Event.addDomListener(this.div_,name,newEventPassthru(this,name));}}};am.prototype.redraw=function(force){google.maps.Marker.prototype.redraw.apply(this,arguments);var p=this.map_.fromLatLngToDivPixel(this.latlng_);var z=google.maps.Overlay.getZIndex(this.latlng_.lat());this.div_.style.left=(p.x+this.labelOffset_.width)+"px";this.div_.style.top=(p.y+this.labelOffset_.height)+"px";this.div_.style.zIndex=z;};am.prototype.remove=function(){google.maps.Event.clearInstanceListeners(this.div_);if(this.div_.outerHTML){this.div_.outerHTML="";}if(this.div_.parentNode){this.div_.parentNode.removeChild(this.div_);}this.div_=null;google.maps.Marker.prototype.remove.apply(this,arguments);};am.prototype.copy=function(){return new am(this.latlng_,this.opts_);};am.prototype.getObject=function(){return this.object_;};am.prototype.show=function(){google.maps.Marker.prototype.show.apply(this,arguments);if(this.labelVisibility_){this.showLabel();}else{this.hideLabel();}};am.prototype.hide=function(){google.maps.Marker.prototype.hide.apply(this,arguments);this.hideLabel();};am.prototype.setLabelVisibility=function(visibility){this.labelVisibility_=visibility;if(!this.isHidden()){if(this.labelVisibility_){this.showLabel();}else{this.hideLabel();}}};am.prototype.getLabelVisibility=function(){return this.labelVisibility_;};am.prototype.hideLabel=function(){this.div_.style.visibility='hidden';};am.prototype.showLabel=function(){this.div_.style.visibility='visible';};am.prototype.update=function(event){switch(this.object_.type){case "user":this.updateUser(event);break;case "group":this.updateGroup(event);break;case "location":this.updateLocation(event);break;}};am.prototype.updateUser=function(event){var me=this;switch(event){case "mouseover":this.sleep=window.setTimeout(function(){var overlay=main.getLOverlay();var icon=me.getIcon();var w=icon.iconSize.width/2;if(!me.overlayContent){me.overlayContent=new Element('div',{'CLASS':'user_overlay'});me.overlayContent=main.gui.base.generateDomSmallUserProfile(me.overlayContent,me.object_.user);}main.map.addOverlay(overlay);overlay.setData(me.latlng_,me.overlayContent,new google.maps.Size((w+6),-(24)));overlay.show();},200);break;case "mouseout":window.clearTimeout(this.sleep);break;}};am.prototype.updateLocation=function(event){var me=this;switch(event){case "mouseover":this.sleep=window.setTimeout(function(){var overlay=main.getLOverlay();var icon=me.getIcon();var w=icon.iconSize.width/2;if(!me.overlayContent){me.overlayContent=new Element('div',{'CLASS':'user_overlay'});me.overlayContent=main.gui.base.generateDomSmallLocationProfile(me.overlayContent,me.object_.location);}main.map.addOverlay(overlay);overlay.setData(me.latlng_,me.overlayContent,new google.maps.Size((w+6),-(24)));overlay.show();},200);break;case "mouseout":window.clearTimeout(this.sleep);break;}};am.prototype.updateGroup=function(event){var o=this.object_;var me=this;switch(event){case "mouseover":this.sleep=window.setTimeout(function(){var overlay=main.getLOverlay();var icon=me.getIcon();var w=icon.iconSize.width/2;var h=icon.iconSize.height/2;var southWeststring=o.bounds.getSouthWest().lat().toString()+','+o.bounds.getSouthWest().lng().toString();var northEaststring=o.bounds.getNorthEast().lat().toString()+','+o.bounds.getNorthEast().lng().toString();me.overlayContent=new Element('div',{'ID':'group_box','CLASS':'group_overlay'});main.map.addOverlay(overlay);overlay.setData(me.latlng_,me.overlayContent,new google.maps.Size((w+6),-(20)));overlay.show();var data=main.groups.get(o.point.meta.m);if(data){me.showGroupData(data);}else{var overlayLoading=new Element("div",{'ID':'overlay_loading'});overlayLoading.setStyle({margin:"10px"});me.overlayContent.appendChild(overlayLoading);window.setTimeout(function(){var marker_data={filter:main.mapFilter};new Ajax.Request(index,{method:'get',parameters:{f:'getMarker',s:session,zoom:o.point.meta.z,section:o.point.meta.m,data:Object.toJSON(marker_data)},onSuccess:function(transport){var data=transport.responseJSON.marker;me.overlayContent.removeChild(overlayLoading);me.showGroupData(data);main.groups.set(o.point.meta.m,data);},});},100);}},200);break;case "mouseout":window.clearTimeout(this.sleep);break;}};am.prototype.showGroupData=function(groupData){var me=this;var o=this.object_;var numUser=0;var numLocations=0;var numItems=o.point.meta.num;var boundData=new Hash({'sw_lat':o.bounds.getSouthWest().lat(),'sw_lng':o.bounds.getSouthWest().lng(),'ne_lat':o.bounds.getNorthEast().lat(),'ne_lng':o.bounds.getNorthEast().lng(),});var link="<INPUT TYPE=\"submit\" OnClick='main.load.zoomToBounds(false, "+boundData.toJSON()+")' VALUE=\"In der Karte zeigen\" CLASS=\"button\" STYLE=\"background-image: url(./inc/bilder/icons/PNG/zoom-in.png)\">";var user_list_box=new Element('div',{'ID':'user_group_list_box','CLASS':'group_overlay_box'});var location_list_box=new Element('div',{'ID':'location_group_list_box','CLASS':'group_overlay_box'});var userMe=new Array();var userFriends=new Array();var userOnline=new Array();var userOffline=new Array();var locations=new Array();groupData.each(function(element){var data=element.data;if(data.data_type=="user"){if(main.myUser&&data.id==main.myUser.id)userMe.push(data);else if(element.meta.isaFriend)userFriends.push(data);else if(data.online_status=="online")userOnline.push(data);else userOffline.push(data);}else locations.push(data);});userMe.each(function(data,index){if(index==0)user_list_box.appendChild(new Element('div',{'CLASS':'list_box_headline'}).update('Ich'));user_list_box.appendChild(main.gui.base.generateUserData(data));numUser++;}.bind(this));userFriends.each(function(data,index){if(index==0)user_list_box.appendChild(new Element('div',{'CLASS':'list_box_headline'}).update('Freunde ('+userFriends.length+')'));user_list_box.appendChild(main.gui.base.generateUserData(data));numUser++;}.bind(this));userOnline.each(function(data,index){if(index==0)user_list_box.appendChild(new Element('div',{'CLASS':'list_box_headline'}).update('Online ('+userOnline.length+')'));user_list_box.appendChild(main.gui.base.generateUserData(data));numUser++;}.bind(this));userOffline.each(function(data,index){if(index==0)user_list_box.appendChild(new Element('div',{'CLASS':'list_box_headline'}).update('Offline ('+userOffline.length+')'));user_list_box.appendChild(main.gui.base.generateUserData(data));numUser++;}.bind(this));locations.each(function(data){location_list_box.appendChild(main.gui.base.generateLocationData(data));numLocations++;}.bind(this));if(numUser){location_list_box.setStyle({'display':'none'});var classUser='a';}else if(numLocations){user_list_box.setStyle({'display':'none'});var classLocation='a';}else{user_list_box.setStyle({'display':'none'});location_list_box.setStyle({'display':'none'});}var groupTab=new Element('UL',{CLASS:'group_box_tabs',ID:'groupTabs'});if(numUser)groupTab.insert('<LI CLASS="'+classUser+'" ID="tab_group_user"><A HREF="javascript:void(0);" Onclick="main.gui.base.displayTab(\'group\', \'user\'); this.blur();">User ('+numUser+')</A></LI>');if(numLocations)groupTab.insert('<LI CLASS="'+classLocation+'" ID="tab_group_location"><A HREF="javascript:void(0);" Onclick="main.gui.base.displayTab(\'group\', \'location\'); this.blur();">Locations ('+numLocations+')</A></LI>');me.overlayContent.appendChild(groupTab);me.overlayContent.appendChild(user_list_box);me.overlayContent.appendChild(location_list_box);me.overlayContent.appendChild(new Element('div',{'CLASS':'shortTitleBox'}).update(link));}
