
window.OOS=window.OOS||{};OOS.Ctr_map={initialize:function(map_container){if(typeof OOS.Data==='undefined'||!GBrowserIsCompatible()){return null;}
this.map=new google.maps.Map2(document.getElementById(map_container));this.map.setCenter(this._center_point(),15);this.map.addControl(new google.maps.SmallMapControl());this.map.addControl(new google.maps.MapTypeControl());this._add_markers();},redraw:function(){this.map.clearOverlays();this._add_markers();},_center_point:function(){return new google.maps.LatLng(OOS.Data.area.lat,OOS.Data.area.lng);},_add_markers:function(){var num_items=OOS.Data.services.length;if(num_items>0){var bounds=new google.maps.LatLngBounds();for(var i=0;i<num_items;i++){this._new_marker(OOS.Data.services[i],bounds);}
this.map.setZoom(this.map.getBoundsZoomLevel(bounds));this.map.setCenter(bounds.getCenter());}},_new_marker:function(item,bounds){if(typeof item.lat!=='number'){return false;}
var point=new google.maps.LatLng(item.lat,item.lon);var marker=new MarkerLight(point,{image:'/static/imgs/geo/dot_map.gif',height:15,width:11});GEvent.addListener(marker,"click",function(){var too_many_spots=$('too-many-spots');if(too_many_spots){too_many_spots.hide();}
OOS.Data.service_info(point,item);});this.map.addOverlay(marker);bounds.extend(point);}}
function MarkerLight(latlng,opts){this.latlng=latlng;if(!opts)opts={};this.height_=opts.height||7;this.width_=opts.width||7;this.image_=opts.image;this.imageOver_=opts.imageOver;this.clicked_=0;}
MarkerLight.prototype=new GOverlay();MarkerLight.prototype.initialize=function(map){var me=this;var div=document.createElement("div");div.style.position="absolute";div.style.paddingLeft="0px";div.style.cursor='pointer';var img=document.createElement("img");img.src=me.image_;img.style.width=me.width_+"px";img.style.height=me.height_+"px";div.appendChild(img);GEvent.addDomListener(div,"click",function(event){me.clicked_=1;GEvent.trigger(me,"click");});map.getPane(G_MAP_MARKER_PANE).appendChild(div);this.map_=map;this.div_=div;};MarkerLight.prototype.remove=function(){this.div_.parentNode.removeChild(this.div_);};MarkerLight.prototype.copy=function(){var opts={};opts.color=this.color_;opts.height=this.height_;opts.width=this.width_;opts.image=this.image_;opts.imageOver=this.image_;return new MarkerLight(this.latlng,opts);};MarkerLight.prototype.redraw=function(force){if(!force)return;var divPixel=this.map_.fromLatLngToDivPixel(this.latlng);this.div_.style.width=this.width_+"px";this.div_.style.left=(divPixel.x)+"px"
this.div_.style.height=(this.height_)+"px";this.div_.style.top=(divPixel.y)-this.height_+"px";};MarkerLight.prototype.getZIndex=function(m){return GOverlay.getZIndex(marker.getPoint().lat())-m.clicked*10000;}
MarkerLight.prototype.getPoint=function(){return this.latlng;};MarkerLight.prototype.setStyle=function(style){for(s in style){this.div_.style[s]=style[s];}};MarkerLight.prototype.setImage=function(image){this.div_.style.background='url("'+image+'")';}
window.OOS=window.OOS||{};OOS.Dropdown=new Class.create({close_button:'/static/imgs/ddm-close.png',initialize:function(trigger,direction,size){this.trigger=trigger;this.trigger_params=trigger.href.toQueryParams();this.id=trigger.identify();this.direction=direction||null;this.size=size||null;this._build();},_build:function(){var h=[];h.push('<div class="ddown" id="dd_');h.push(this.id);h.push('">');h.push('<a class="tab">');h.push(this.trigger.innerHTML);h.push('</a>');h.push('<div class="content" id="cc_');h.push(this.id);h.push('">');h.push('<img class="close" src="');h.push(this.close_button);h.push('" alt="" />');h.push('<div class="inner">');h.push("</div></div></div>");this.trigger.up().insert(h.join(''));this.trigger.remove();this.hide();this._set_handlers();this._fix_ui();},_set_handlers:function(){var dd=$('dd_'+this.id);var tab=dd.down('.tab'),close=dd.down('.close');tab.observe('click',function(e){e.stop();if(this.built){var menu=$('cc_'+this.id);if(menu.visible()){this.hide();}else{this.show();}}else{this.set_build_function();}}.bind(this));close.observe('click',function(e){e.stop();this.hide();}.bind(this));},_fix_ui:function(){var content=$('cc_'+this.id);var tab=$('dd_'+this.id).down('.tab');if(this.size){if(this.size.width)
content.setStyle({width:this.size.width+'px'});if(this.size.height)
content.setStyle({height:this.size.height+'px'});}
if(this.direction){var t_w=tab.getDimensions().width;var c_w=content.getDimensions().width;switch(this.direction){case'center':content.setStyle({left:'-'+(Math.round(c_w/2)-Math.round(t_w/2))+'px'});break;case'right':content.setStyle({left:'-'+(c_w-t_w)+'px'});}}},show:function(){var content=$("cc_"+this.id);var ddown=$("dd_"+this.id);if(typeof OOS.Ctr!='undefined'){OOS.Ctr.clear_menus(this.id);}
if(Prototype.Browser.IE){$$('.ddown').invoke('setStyle',{zIndex:'10'});ddown.setStyle({zIndex:'100'});ddown.down('.tab').setStyle({zIndex:'1000'});if(this.id!=='filter-contacts'){$$('form select').invoke('hide');}}
content.show();ddown.addClassName('open');},hide:function(){$("cc_"+this.id).hide();$("dd_"+this.id).removeClassName('open');if(Prototype.Browser.IE&&this.id!=='filter-contacts'){$$('form select').invoke('show');}},update_content:function(c){$("cc_"+this.id).down('.inner').update(c);this.built=this.built||true;}});document.observe('dom:loaded',function(){OOS.SendSms.initialize($$('#enlisted .afss .sms'));var trigger=$('category-trigger');if(trigger){var menus=new Hash();var dd=new OOS.Dropdown(trigger);dd.update_content($('category').removeClassName('jh'));$('dd_'+dd.id).down('.tab').addClassName('box');menus.set(dd.id,dd);}
var shareLinks=$$('#enlisted .afss .share');var sharers=[];for(var i=0;i<shareLinks.length;i++){if(shareLinks[i]!=null)
sharers.push(new OOS.Share(shareLinks[i]));}
var sendMail=$('sendMail');if(sendMail){Viralite.initialize({ids:[sendMail.identify()]});}});
