
var map;var circle;var markers;var circle_marker;var geocoder;var customUI;var lat;var lng;var route_labels;var big_marker;function initialize(){if(GBrowserIsCompatible()){if(!lat){lat=33.780859506378675;}
if(!lng){lng=-84.39216613769531;}
map=new GMap2(document.getElementById("map_canvas"));var center=new GLatLng(lat,lng);map.setCenter(center,11);customUI=map.getDefaultUI();customUI.controls.maptypecontrol=false;customUI.controls.menumaptypecontrol=false;customUI.controls.largemapcontrol3d=false;customUI.controls.smallzoomcontrol3d=true;customUI.maptypes.hybrid=false;customUI.maptypes.satellite=false;customUI.maptypes.physical=false;map.setUI(customUI);showLocation();geocoder=new GClientGeocoder();if($('map_follow')){GEvent.addListener(map,'dragend',function(){if($('map_follow').checked){lat=map.getCenter().lat();lng=map.getCenter().lng();ajax_wrap();}});}}}
function writeCoordsToMap(lat,lng,marker_info){var point=new GLatLng(lat,lng);map.clearOverlays();var marker=createMarker(point);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(marker_info);});marker.openInfoWindowHtml(marker_info);}
function createMarker(latlng,image_url,extra_options){var marker=new GMarker(latlng,extra_options);map.addOverlay(marker);if(image_url){marker.setImage(image_url);}
return marker;}
function showLocation(){if($('address')){lat=$('address').readAttribute('lat');lng=$('address').readAttribute('lng');marker_info=$$('.marker_info')[0].innerHTML;writeCoordsToMap(lat,lng,marker_info);}}
function setup_map_list(s,num){var marker_info=s.down('.marker_info');var current_lat=marker_info.readAttribute('lat');var current_lng=marker_info.readAttribute('lng');var current_latLng=new GLatLng(current_lat,current_lng);var marker_image;var hl_marker_image;var marker_params;if(num){marker_image="/images/map/marker_blue"+num+".png";hl_marker_image="images/map/marker_orange"+num+".png";}else{var car_icon=new GIcon();car_icon.image="/images/car.png";car_icon.iconSize=new GSize(16,16);car_icon.iconAnchor=new GPoint(6,8);car_icon.infoWindowAnchor=new GPoint(5,0);marker_params={icon:car_icon};}
var info_html=marker_info.innerHTML;if(s.down('.do_it')){info_html+=s.down('.search_link').innerHTML;info_html+=s.down('.do_it').innerHTML;}
var current_marker=createMarker(current_latLng,marker_image,marker_params);current_marker.bindInfoWindowHtml(info_html);Event.observe(s,'click',function(){current_marker.openInfoWindowHtml(info_html);});Event.observe(s,'mouseover',function(){if(big_marker){map.removeOverlay(big_marker);}
var current_icon=new GIcon(current_marker.getIcon(),hl_marker_image);big_marker=new GMarker(current_latLng,{icon:current_icon,zIndexProcess:function(){return 1001;}});map.addOverlay(big_marker);});Event.observe(s,'mouseout',function(){if(big_marker){map.removeOverlay(big_marker);}});s.select('a.ajax').each(function(link){Event.observe(link,'click',function(event){Event.stop(event);});});}
function initialize_events(){map.clearOverlays();$$('#map_list .ml_div').each(function(s,i){setup_map_list(s,i+1);});$$('#do_it_list .ml_div').each(function(s){setup_map_list(s);});draw_circle();change_radius();}
function remove_circle(){if(circle){map.removeOverlay(circle);circle=null;}}
function draw_circle(new_point){if(!lat||!lng||lat==''||lng==''){var latLng=map.getCenter();}else if(new_point){var latLng=new_point;}else{var latLng=new GLatLng(lat,lng)}
if(!search_radius||search_radius==''){search_radius=8;}
if(circle){if(!circle.latLng.equals(latLng)){circle.setLatLng(latLng);}
if(circle.radius!=search_radius){circle.setRadius(search_radius);}
circle.redraw();}else{circle=new CircleOverlay(latLng,search_radius,"#808080",1,1,'#63E1F4',0.25);map.addOverlay(circle);}
make_circle_marker(latLng);}
function make_circle_marker(latLng){if(circle_marker){map.removeOverlay(circle_marker);}
circle_marker=createMarker(latLng,"/images/blue_marker.png",{draggable:true,zIndexProcess:function(){return 1000;}});var blue_mark_info=$('dragdrop_about').innerHTML;circle_marker.bindInfoWindowHtml(blue_mark_info);GEvent.addListener(circle_marker,"dragstart",function(){map.closeInfoWindow();});GEvent.addListener(circle_marker,"infowindowopen",function(){change_radius();});GEvent.addListener(circle_marker,"dragend",function(){var new_latLng=circle_marker.getLatLng();s_spin();draw_circle(new_latLng);ajax_circle_move(new_latLng,function(){$('near_address').value='';});});}
function ajax_circle_move(new_latLng,complete_callback){new Ajax.Request('/',{asynchronous:true,evalScripts:true,onComplete:function(request){h_spin();complete_callback();},method:'get',parameters:search_param()+"&"+date_param()+"&"+category_param()+"&lat="+
encodeURIComponent(new_latLng.lat())+"&lng="+encodeURIComponent(new_latLng.lng())+"&search_radius="+
encodeURIComponent(search_radius)+"&center_map=1"});}
var directions;function initialize_sorted_events(){map.clearOverlays();var waypoints=new Array();route_labels=new Array();var start_address=$('start_address').value
var end_address=$('end_address').value
if(start_address&&start_address!=''){waypoints[0]=start_address;route_labels[0]=start_address;}
var start_index=waypoints.length;$$('#thing_ids li').each(function(s,i){waypoints[i+start_index]=s.readAttribute('lat_lng_str');route_labels[i+start_index]=s.down('.thing_tag').innerHTML;});if($('end_here').checked){if(start_address&&start_address!=''){waypoints[waypoints.length]=start_address;route_labels[route_labels.length]=start_address;}}else if(end_address&&end_address!=''){waypoints[waypoints.length]=end_address;route_labels[route_labels.length]=end_address;}
if(waypoints.length>1){if(directions){directions.clear();}else{directions=new GDirections(map,$('turn_by_turn'));GEvent.addListener(directions,'error',function(){flash_msg("Unable to Calculate Directions. Is an address mistyped?",'error');});GEvent.addListener(directions,'load',function(){for(var i=0;i<directions.getNumRoutes();i++){var route=directions.getRoute(i);if(i==0){route.GT.address=route_labels[0];route.sK.address=route_labels[1];}else{route.sK.address=route_labels[i+1];}}})}
directions.loadFromWaypoints(waypoints);}else{if(directions){directions.clear();}
var lat_lng=waypoints[0].split(',');var temp_point=new GLatLng(lat_lng[0],lat_lng[1]);map.addOverlay(new GMarker(temp_point));map.setCenter(temp_point);}}
document.observe("dom:loaded",function(){if($('map_canvas')){initialize();if($('home_identifier')){initialize_events();}else if($('thing_ids')){initialize_sorted_events();}}});document.observe("dom:unloaded",function(){GUnload();});function s_spin(){if($('spinner')){$('spinner').show()}}
function h_spin(){if($('spinner')){$('spinner').hide()}}
function show_popup(){var popup_offset=document.viewport.getScrollOffsets()[1]+100;popup_offset+='px';$('popup_pane').setStyle({top:popup_offset});$('background_fade').show();$('popup_pane').appear({duration:0.3});$('popup_content').select('a').each(function(s){Event.observe(s,'click',hide_popup);});}
function hide_popup(){$('background_fade').hide();$('popup_pane').hide();}
function flash_msg(msg,status){if($('round_flash')){$('round_flash').down('.message').innerHTML=msg;}else{$('flash').innerHTML=msg;}
flash(status);}
function flash(status){var the_flash=$('round_flash');var fade_time=6000;if(!the_flash){the_flash=$('flash');fade_time=2500;}
if(status){the_flash.removeClassName('error');the_flash.removeClassName('ok');the_flash.addClassName(status);}
the_flash.appear();setTimeout("Effect.Fade('"+the_flash.readAttribute('id')+"')",fade_time);}
Event.observe(window,'load',function(){if($('flash').innerHTML&&$('flash').innerHTML!=''){flash();}});document.observe("dom:loaded",function(){Event.observe('background_fade','click',function(event){hide_popup();Event.stop(event);});if($('tabs')){$('tabs').select('a').each(function(s){Event.observe(s,'mouseover',function(e){Event.stop(e)});});}});var lat;var lng;var controller;var date;var category;var search_radius;var last_scroll;var scrolling=false;var search_timer;var search_lock;function remove_inst_text(elm){elm=$(elm);if(elm.value==elm.readAttribute('value')&&elm.hasClassName('unclicked')){elm.removeClassName('unclicked');elm.value='';}}
function popup_event(elm){var event=$(elm).up('.ml_div');if(!event){event=$(elm).up('.event_container');}
var full_desc=event.down('.full_desc');$('popup_content').innerHTML=event.innerHTML;var description=$('popup_content').down('.ml_subtitle');description.innerHTML=full_desc.innerHTML;if($('popup_content').down('.do_it')){$('popup_content').down('.do_it').show();}
show_popup();}
function reset_form_fields(search,order){if(search&&search!=''){$('search').value=search;}else{$('search').value='';}
if(order&&order!=''){$('order').value=order;}else{$('order').up('form').reset();}}
function jump_to(elm){eval($(elm).value);lat=new_point.lat();lng=new_point.lng();$(elm).value='jump';ajax_wrap(null,function(){map.setCenter(new_point,12);});}
function reset_map(){lat=reset_lat;lng=reset_lng;search_radius=8;map.setCenter(new GLatLng(lat,lng),11);ajax_wrap();}
function ajax_wrap(extra_params,on_complete){url='/';if(extra_params){url+='?'+extra_params}
s_spin();new Ajax.Request(url,{asynchronous:true,evalScripts:true,method:'get',onComplete:function(request){h_spin();on_complete();},parameters:all_params()});return false;}
function move_map_down(){var base_height=$('right_side').cumulativeOffset()[1]+8;var top_offset=document.viewport.getScrollOffsets()[1];if(top_offset>base_height){var new_map_position=top_offset-base_height+8;}else{var new_map_position=0;}
new Effect.Move('map_container',{y:new_map_position,mode:'absolute',duration:0.3});customUI.zoom.scrollwheel=true;map.setUI(customUI);}
function reset_view(){window.scrollTo(0,0);$('map_container').setStyle({top:0});}
function geocode_and_go(){s_spin();address=$('near_address').value;if(address&&address!=''){geocoder.getLocations(address,function(response){if(!response||response.Status.code!=200){flash_msg("Sorry, can't find that address.","error");h_spin();}else{place=response.Placemark[0];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);ajax_circle_move(point);}});}else{flash_msg('You Must Enter an Address','error');h_spin();}}
function change_radius(elm){if(elm){elm=$(elm);search_radius=elm.value;}
$$('.rad_sel').each(function(s){s.value=search_radius;});}
function push_search_on_history(){dhtmlHistory.add(location.hash,"new Ajax.Request(location.pathname + '?history=1&"+all_params()+"', {asynchronous:false, onComplete: h_spin(), evalScripts:true, method:'get'}); search_lock = true;")}
function init_values(){lat=$('extra_info').readAttribute('lat');lng=$('extra_info').readAttribute('lng');view_date=$('extra_info').readAttribute('view_date');search_radius=$('extra_info').readAttribute('search_radius');category=$('extra_info').readAttribute('category');$$('.active_tab').each(function(s){s.removeClassName('active_tab')});active_tab=$(category+"_tab");if(!active_tab){active_tab=$('all_tab');}
active_tab.addClassName('active_tab');var display_date=$('extra_info').readAttribute('display_date');if(display_date&&display_date!=''){$('date_label').innerHTML=display_date;}}
function origin_param(){return'lat='+encodeURIComponent(lat)+'&lng='+encodeURIComponent(lng)+'&search_radius='+encodeURIComponent(search_radius);}
function date_param(){return'view_date='+encodeURIComponent(view_date);}
function search_param(){ret_str='search='+encodeURIComponent($('search').value)+'&'+$('extra_search').serialize();if($('order')){ret_str+='&order='+encodeURIComponent($('order').value);}
return ret_str;}
function category_param(){return'category='+encodeURIComponent(category);}
function all_but_cat(){return origin_param()+"&"+search_param()+"&"+date_param()}
function all_params(){return origin_param()+"&"+search_param()+"&"+date_param()+"&"+category_param();}
document.observe("dom:loaded",function(){if($('home_identifier')){setInterval(function(){var current_scroll=document.viewport.getScrollOffsets()[1];if(scrolling){if(current_scroll==last_scroll){scrolling=false;move_map_down();}}else if(current_scroll!=last_scroll){scrolling=true;customUI.zoom.scrollwheel=false;map.setUI(customUI);}
last_scroll=current_scroll;},500);new Form.Element.Observer('search',0.8,function(){if(!search_lock){ajax_wrap('is_a_search=1');if(search_timer){clearTimeout(search_timer);}
search_timer=setTimeout(push_search_on_history,200);}else{search_lock=false;}})}});window.dhtmlHistory={isIE:false,isOpera:false,isSafari:false,isKonquerer:false,isGecko:false,isSupported:false,create:function(options){var that=this;var UA=navigator.userAgent.toLowerCase();var platform=navigator.platform.toLowerCase();var vendor=navigator.vendor||"";if(vendor==="KDE"){this.isKonqueror=true;this.isSupported=false;}else if(typeof window.opera!=="undefined"){this.isOpera=true;this.isSupported=true;}else if(typeof document.all!=="undefined"){this.isIE=true;this.isSupported=true;}else if(vendor.indexOf("Apple Computer, Inc.")>-1){this.isSafari=true;this.isSupported=(platform.indexOf("mac")>-1);}else if(UA.indexOf("gecko")!=-1){this.isGecko=true;this.isSupported=true;}
window.historyStorage.setup(options);if(this.isSafari){this.createSafari();}else if(this.isOpera){this.createOpera();}
var initialHash=this.getCurrentLocation();this.currentLocation=initialHash;if(this.isIE){this.createIE(initialHash);}
var unloadHandler=function(){that.firstLoad=null;};this.addEventListener(window,'unload',unloadHandler);if(this.isIE){this.ignoreLocationChange=true;}else{if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.ignoreLocationChange=true;this.firstLoad=true;historyStorage.put(this.PAGELOADEDSTRING,true);}else{this.ignoreLocationChange=false;this.fireOnNewListener=true;}}
var locationHandler=function(){that.checkLocation();};setInterval(locationHandler,100);},initialize:function(){if(this.isIE){if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.fireOnNewListener=false;this.firstLoad=true;historyStorage.put(this.PAGELOADEDSTRING,true);}
else{this.fireOnNewListener=true;this.firstLoad=false;}}},addListener:function(listener){this.listener=listener;if(this.fireOnNewListener){this.fireHistoryEvent(this.currentLocation);this.fireOnNewListener=false;}},addEventListener:function(o,e,l){if(o.addEventListener){o.addEventListener(e,l,false);}else if(o.attachEvent){o.attachEvent('on'+e,function(){l(window.event);});}},add:function(newLocation,historyData){if(this.isSafari){newLocation=this.removeHash(newLocation);historyStorage.put(newLocation,historyData);this.currentLocation=newLocation;window.location.hash=newLocation;this.putSafariState(newLocation);}else{var that=this;var addImpl=function(){if(that.currentWaitTime>0){that.currentWaitTime=that.currentWaitTime-that.waitTime;}
newLocation=that.removeHash(newLocation);if(document.getElementById(newLocation)&&that.debugMode){var e="Exception: History locations can not have the same value as _any_ IDs that might be in the document,"
+" due to a bug in IE; please ask the developer to choose a history location that does not match any HTML"
+" IDs in this document. The following ID is already taken and cannot be a location: "+newLocation;throw new Error(e);}
historyStorage.put(newLocation,historyData);that.ignoreLocationChange=true;that.ieAtomicLocationChange=true;that.currentLocation=newLocation;window.location.hash=newLocation;if(that.isIE){that.iframe.src="/blank.html?"+newLocation;}
that.ieAtomicLocationChange=false;};window.setTimeout(addImpl,this.currentWaitTime);this.currentWaitTime=this.currentWaitTime+this.waitTime;}},isFirstLoad:function(){return this.firstLoad;},getVersion:function(){return"0.6";},getCurrentLocation:function(){var r=(this.isSafari?this.getSafariState():this.getCurrentHash());return r;},getCurrentHash:function(){var r=window.location.href;var i=r.indexOf("#");return(i>=0?r.substr(i+1):"");},PAGELOADEDSTRING:"DhtmlHistory_pageLoaded",listener:null,waitTime:200,currentWaitTime:0,currentLocation:null,iframe:null,safariHistoryStartPoint:null,safariStack:null,safariLength:null,ignoreLocationChange:null,fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,createIE:function(initialHash){this.waitTime=400;var styles=(historyStorage.debugMode?'width: 800px;height:80px;border:1px solid black;':historyStorage.hideStyles);var iframeID="rshHistoryFrame";var iframeHTML='<iframe frameborder="0" id="'+iframeID+'" style="'+styles+'" src="/blank.html?'+initialHash+'"></iframe>';document.write(iframeHTML);this.iframe=document.getElementById(iframeID);},createOpera:function(){this.waitTime=400;var imgHTML='<img src="javascript:location.href=\'javascript:dhtmlHistory.checkLocation();\';" style="'+historyStorage.hideStyles+'" />';document.write(imgHTML);},createSafari:function(){var formID="rshSafariForm";var stackID="rshSafariStack";var lengthID="rshSafariLength";var formStyles=historyStorage.debugMode?historyStorage.showStyles:historyStorage.hideStyles;var inputStyles=(historyStorage.debugMode?'width:800px;height:20px;border:1px solid black;margin:0;padding:0;':historyStorage.hideStyles);var safariHTML='<form id="'+formID+'" style="'+formStyles+'">'
+'<input type="text" style="'+inputStyles+'" id="'+stackID+'" value="[]"/>'
+'<input type="text" style="'+inputStyles+'" id="'+lengthID+'" value=""/>'
+'</form>';document.write(safariHTML);this.safariStack=document.getElementById(stackID);this.safariLength=document.getElementById(lengthID);if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.safariHistoryStartPoint=history.length;this.safariLength.value=this.safariHistoryStartPoint;}else{this.safariHistoryStartPoint=this.safariLength.value;}},getSafariStack:function(){var r=this.safariStack.value;return historyStorage.fromJSON(r);},getSafariState:function(){var stack=this.getSafariStack();var state=stack[history.length-this.safariHistoryStartPoint-1];return state;},putSafariState:function(newLocation){var stack=this.getSafariStack();stack[history.length-this.safariHistoryStartPoint]=newLocation;this.safariStack.value=historyStorage.toJSON(stack);},fireHistoryEvent:function(newHash){var historyData=historyStorage.get(newHash);this.listener.call(null,newHash,historyData);},checkLocation:function(){if(!this.isIE&&this.ignoreLocationChange){this.ignoreLocationChange=false;return;}
if(!this.isIE&&this.ieAtomicLocationChange){return;}
var hash=this.getCurrentLocation();if(hash==this.currentLocation){return;}
this.ieAtomicLocationChange=true;if(this.isIE&&this.getIframeHash()!=hash){this.iframe.src="/blank.html?"+hash;}
else if(this.isIE){return;}
this.currentLocation=hash;this.ieAtomicLocationChange=false;this.fireHistoryEvent(hash);},getIframeHash:function(){var doc=this.iframe.contentWindow.document;var hash=String(doc.location.search);if(hash.length==1&&hash.charAt(0)=="?"){hash="";}
else if(hash.length>=2&&hash.charAt(0)=="?"){hash=hash.substring(1);}
return hash;},removeHash:function(hashValue){var r;if(hashValue===null||hashValue===undefined){r=null;}
else if(hashValue===""){r="";}
else if(hashValue.length==1&&hashValue.charAt(0)=="#"){r="";}
else if(hashValue.length>1&&hashValue.charAt(0)=="#"){r=hashValue.substring(1);}
else{r=hashValue;}
return r;},iframeLoaded:function(newLocation){if(this.ignoreLocationChange){this.ignoreLocationChange=false;return;}
var hash=String(newLocation.search);if(hash.length==1&&hash.charAt(0)=="?"){hash="";}
else if(hash.length>=2&&hash.charAt(0)=="?"){hash=hash.substring(1);}
window.location.hash=hash;this.fireHistoryEvent(hash);}};window.historyStorage={setup:function(options){if(typeof options!=="undefined"){if(options.debugMode){this.debugMode=options.debugMode;}
if(options.toJSON){this.toJSON=options.toJSON;}
if(options.fromJSON){this.fromJSON=options.fromJSON;}}
var formID="rshStorageForm";var textareaID="rshStorageField";var formStyles=this.debugMode?historyStorage.showStyles:historyStorage.hideStyles;var textareaStyles=(historyStorage.debugMode?'width: 800px;height:80px;border:1px solid black;':historyStorage.hideStyles);var textareaHTML='<form id="'+formID+'" style="'+formStyles+'">'
+'<textarea id="'+textareaID+'" style="'+textareaStyles+'"></textarea>'
+'</form>';document.write(textareaHTML);this.storageField=document.getElementById(textareaID);if(typeof window.opera!=="undefined"){this.storageField.focus();}},put:function(key,value){this.assertValidKey(key);if(this.hasKey(key)){this.remove(key);}
this.storageHash[key]=value;this.saveHashTable();},get:function(key){this.assertValidKey(key);this.loadHashTable();var value=this.storageHash[key];if(value===undefined){value=null;}
return value;},remove:function(key){this.assertValidKey(key);this.loadHashTable();delete this.storageHash[key];this.saveHashTable();},reset:function(){this.storageField.value="";this.storageHash={};},hasKey:function(key){this.assertValidKey(key);this.loadHashTable();return(typeof this.storageHash[key]!=="undefined");},isValidKey:function(key){return(typeof key==="string");},showStyles:'border:0;margin:0;padding:0;',hideStyles:'left:-1000px;top:-1000px;width:1px;height:1px;border:0;position:absolute;',debugMode:false,storageHash:{},hashLoaded:false,storageField:null,assertValidKey:function(key){var isValid=this.isValidKey(key);if(!isValid&&this.debugMode){throw new Error("Please provide a valid key for window.historyStorage. Invalid key = "+key+".");}},loadHashTable:function(){if(!this.hashLoaded){var serializedHashTable=this.storageField.value;if(serializedHashTable!==""&&serializedHashTable!==null){this.storageHash=this.fromJSON(serializedHashTable);this.hashLoaded=true;}}},saveHashTable:function(){this.loadHashTable();var serializedHashTable=this.toJSON(this.storageHash);this.storageField.value=serializedHashTable;},toJSON:function(o){return o.toJSONString();},fromJSON:function(s){return s.parseJSON();}};window.dhtmlHistory.create({toJSON:function(o){return Object.toJSON(o);},fromJSON:function(s){return s.evalJSON();}});var yourListener=function(newLocation,historyData){if(historyData){s_spin();eval(historyData);}}
Event.observe(window,'load',function(){dhtmlHistory.initialize();dhtmlHistory.addListener(yourListener);});if(typeof Prototype=='undefined')alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>).");if(Prototype.Version<"1.6")alert("Prototype 1.6.0 is required.  If using earlier version of prototype, please use calendar_date_select version 1.8.3");Element.addMethods({purgeChildren:function(element){$A(element.childNodes).each(function(e){$(e).remove();});},build:function(element,type,options,style){var newElement=Element.buildAndAppend(type,options,style);element.appendChild(newElement);return newElement;}});Element.buildAndAppend=function(type,options,style)
{var e=$(document.createElement(type));$H(options).each(function(pair){e[pair.key]=pair.value});if(style)e.setStyle(style);return e;};nil=null;Date.one_day=24*60*60*1000;Date.weekdays=$w("S M T W T F S");Date.first_day_of_week=0;Date.months=$w("January February March April May June July August September October November December");Date.padded2=function(hour){var padded2=parseInt(hour,10);if(hour<10)padded2="0"+padded2;return padded2;}
Date.prototype.getPaddedMinutes=function(){return Date.padded2(this.getMinutes());}
Date.prototype.getAMPMHour=function(){var hour=this.getHours();return(hour==0)?12:(hour>12?hour-12:hour)}
Date.prototype.getAMPM=function(){return(this.getHours()<12)?"AM":"PM";}
Date.prototype.stripTime=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate());};Date.prototype.daysDistance=function(compare_date){return Math.round((compare_date-this)/Date.one_day);};Date.prototype.toFormattedString=function(include_time){var hour,str;str=Date.months[this.getMonth()]+" "+this.getDate()+", "+this.getFullYear();if(include_time){hour=this.getHours();str+=" "+this.getAMPMHour()+":"+this.getPaddedMinutes()+" "+this.getAMPM()}
return str;}
Date.parseFormattedString=function(string){return new Date(string);}
Math.floor_to_interval=function(n,i){return Math.floor(n/i)*i;}
window.f_height=function(){return([window.innerHeight?window.innerHeight:null,document.documentElement?document.documentElement.clientHeight:null,document.body?document.body.clientHeight:null].select(function(x){return x>0}).first()||0);}
window.f_scrollTop=function(){return([window.pageYOffset?window.pageYOffset:null,document.documentElement?document.documentElement.scrollTop:null,document.body?document.body.scrollTop:null].select(function(x){return x>0}).first()||0);}
_translations={"OK":"OK","Now":"Now","Today":"Today","Clear":"Clear"}
SelectBox=Class.create();SelectBox.prototype={initialize:function(parent_element,values,html_options,style_options){this.element=$(parent_element).build("select",html_options,style_options);this.populate(values);},populate:function(values){this.element.purgeChildren();var that=this;$A(values).each(function(pair){if(typeof(pair)!="object"){pair=[pair,pair]};that.element.build("option",{value:pair[1],innerHTML:pair[0]})});},setValue:function(value){var e=this.element;var matched=false;$R(0,e.options.length-1).each(function(i){if(e.options[i].value==value.toString()){e.selectedIndex=i;matched=true;};});return matched;},getValue:function(){return $F(this.element)}}
CalendarDateSelect=Class.create();CalendarDateSelect.prototype={initialize:function(target_element,options){this.target_element=$(target_element);if(!this.target_element){alert("Target element "+target_element+" not found!");return false;}
if(this.target_element.tagName!="INPUT")this.target_element=this.target_element.down("INPUT")
this.target_element.calendar_date_select=this;this.last_click_at=0;this.options=$H({embedded:false,popup:nil,time:false,buttons:true,clear_button:true,year_range:10,close_on_click:nil,minute_interval:5,popup_by:this.target_element,month_year:"dropdowns",onchange:this.target_element.onchange,valid_date_check:nil}).merge(options||{});this.use_time=this.options.get("time");this.parseDate();this.callback("before_show")
this.initCalendarDiv();if(!this.options.get("embedded")){this.positionCalendarDiv()
Event.observe(document,"mousedown",this.closeIfClickedOut_handler=this.closeIfClickedOut.bindAsEventListener(this));Event.observe(document,"keypress",this.keyPress_handler=this.keyPress.bindAsEventListener(this));}
this.callback("after_show")},positionCalendarDiv:function(){var above=false;var c_pos=this.calendar_div.cumulativeOffset(),c_left=c_pos[0],c_top=c_pos[1],c_dim=this.calendar_div.getDimensions(),c_height=c_dim.height,c_width=c_dim.width;var w_top=window.f_scrollTop(),w_height=window.f_height();var e_dim=$(this.options.get("popup_by")).cumulativeOffset(),e_top=e_dim[1],e_left=e_dim[0],e_height=$(this.options.get("popup_by")).getDimensions().height,e_bottom=e_top+e_height;if(((e_bottom+c_height)>(w_top+w_height))&&(e_bottom-c_height>w_top))above=true;var left_px=e_left.toString()+"px",top_px=(above?(e_top-c_height):(e_top+e_height)).toString()+"px";this.calendar_div.style.left=left_px;this.calendar_div.style.top=top_px;this.calendar_div.setStyle({visibility:""});if(navigator.appName=="Microsoft Internet Explorer")this.iframe=$(document.body).build("iframe",{src:"javascript:false",className:"ie6_blocker"},{left:left_px,top:top_px,height:c_height.toString()+"px",width:c_width.toString()+"px",border:"0px"})},initCalendarDiv:function(){if(this.options.get("embedded")){var parent=this.target_element.parentNode;var style={}}else{var parent=document.body
var style={position:"absolute",visibility:"hidden",left:0,top:0}}
this.calendar_div=$(parent).build('div',{className:"calendar_date_select"},style);var that=this;$w("top header body buttons footer bottom").each(function(name){eval("var "+name+"_div = that."+name+"_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ");});this.initHeaderDiv();this.initButtonsDiv();this.initCalendarGrid();this.updateFooter("&#160;");this.refresh();this.setUseTime(this.use_time);},initHeaderDiv:function(){var header_div=this.header_div;this.close_button=header_div.build("a",{innerHTML:"x",href:"#",onclick:function(){this.close();return false;}.bindAsEventListener(this),className:"close"});this.next_month_button=header_div.build("a",{innerHTML:"&gt;",href:"#",onclick:function(){this.navMonth(this.date.getMonth()+1);return false;}.bindAsEventListener(this),className:"next"});this.prev_month_button=header_div.build("a",{innerHTML:"&lt;",href:"#",onclick:function(){this.navMonth(this.date.getMonth()-1);return false;}.bindAsEventListener(this),className:"prev"});if(this.options.get("month_year")=="dropdowns"){this.month_select=new SelectBox(header_div,$R(0,11).map(function(m){return[Date.months[m],m]}),{className:"month",onchange:function(){this.navMonth(this.month_select.getValue())}.bindAsEventListener(this)});this.year_select=new SelectBox(header_div,[],{className:"year",onchange:function(){this.navYear(this.year_select.getValue())}.bindAsEventListener(this)});this.populateYearRange();}else{this.month_year_label=header_div.build("span")}},initCalendarGrid:function(){var body_div=this.body_div;this.calendar_day_grid=[];var days_table=body_div.build("table",{cellPadding:"0px",cellSpacing:"0px",width:"100%"})
var weekdays_row=days_table.build("thead").build("tr");Date.weekdays.each(function(weekday){weekdays_row.build("th",{innerHTML:weekday});});var days_tbody=days_table.build("tbody")
var row_number=0,weekday;for(var cell_index=0;cell_index<42;cell_index++)
{weekday=(cell_index+Date.first_day_of_week)%7;if(cell_index%7==0)days_row=days_tbody.build("tr",{className:'row_'+row_number++});(this.calendar_day_grid[cell_index]=days_row.build("td",{calendar_date_select:this,onmouseover:function(){this.calendar_date_select.dayHover(this);},onmouseout:function(){this.calendar_date_select.dayHoverOut(this)},onclick:function(){this.calendar_date_select.updateSelectedDate(this,true);},className:(weekday==0)||(weekday==6)?" weekend":""},{cursor:"pointer"})).build("div");this.calendar_day_grid[cell_index];}},initButtonsDiv:function()
{var buttons_div=this.buttons_div;if(this.options.get("time"))
{var blank_time=$A(this.options.get("time")=="mixed"?[[" - ",""]]:[]);buttons_div.build("span",{innerHTML:"@",className:"at_sign"});var t=new Date();this.hour_select=new SelectBox(buttons_div,blank_time.concat($R(0,23).map(function(x){t.setHours(x);return $A([t.getAMPMHour()+" "+t.getAMPM(),x])})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({hour:this.value});},className:"hour"});buttons_div.build("span",{innerHTML:":",className:"seperator"});var that=this;this.minute_select=new SelectBox(buttons_div,blank_time.concat($R(0,59).select(function(x){return(x%that.options.get('minute_interval')==0)}).map(function(x){return $A([Date.padded2(x),x]);})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({minute:this.value})},className:"minute"});}else if(!this.options.get("buttons"))buttons_div.remove();if(this.options.get("buttons")){buttons_div.build("span",{innerHTML:"&#160;"});if(this.options.get("time")=="mixed"||!this.options.get("time"))b=buttons_div.build("a",{innerHTML:_translations["Today"],href:"#",onclick:function(){this.today(false);return false;}.bindAsEventListener(this)});if(this.options.get("time")=="mixed")buttons_div.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})
if(this.options.get("time"))b=buttons_div.build("a",{innerHTML:_translations["Now"],href:"#",onclick:function(){this.today(true);return false}.bindAsEventListener(this)});if(!this.options.get("embedded")&&!this.closeOnClick())
{buttons_div.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})
buttons_div.build("a",{innerHTML:_translations["OK"],href:"#",onclick:function(){this.close();return false;}.bindAsEventListener(this)});}
if(this.options.get('clear_button')){buttons_div.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})
buttons_div.build("a",{innerHTML:_translations["Clear"],href:"#",onclick:function(){this.clearDate();if(!this.options.get("embedded"))this.close();return false;}.bindAsEventListener(this)});}}},refresh:function()
{this.refreshMonthYear();this.refreshCalendarGrid();this.setSelectedClass();this.updateFooter();},refreshCalendarGrid:function(){this.beginning_date=new Date(this.date).stripTime();this.beginning_date.setDate(1);this.beginning_date.setHours(12);var pre_days=this.beginning_date.getDay()
if(pre_days<3)pre_days+=7;this.beginning_date.setDate(1-pre_days+Date.first_day_of_week);var iterator=new Date(this.beginning_date);var today=new Date().stripTime();var this_month=this.date.getMonth();vdc=this.options.get("valid_date_check");for(var cell_index=0;cell_index<42;cell_index++)
{day=iterator.getDate();month=iterator.getMonth();cell=this.calendar_day_grid[cell_index];Element.remove(cell.childNodes[0]);div=cell.build("div",{innerHTML:day});if(month!=this_month)div.className="other";cell.day=day;cell.month=month;cell.year=iterator.getFullYear();if(vdc){if(vdc(iterator.stripTime()))cell.removeClassName("disabled");else cell.addClassName("disabled")};iterator.setDate(day+1);}
if(this.today_cell)this.today_cell.removeClassName("today");if($R(0,41).include(days_until=this.beginning_date.stripTime().daysDistance(today))){this.today_cell=this.calendar_day_grid[days_until];this.today_cell.addClassName("today");}},refreshMonthYear:function(){var m=this.date.getMonth();var y=this.date.getFullYear();if(this.options.get("month_year")=="dropdowns")
{this.month_select.setValue(m,false);var e=this.year_select.element;if(this.flexibleYearRange()&&(!(this.year_select.setValue(y,false))||e.selectedIndex<=1||e.selectedIndex>=e.options.length-2))this.populateYearRange();this.year_select.setValue(y);}else{this.month_year_label.update(Date.months[m]+" "+y.toString());}},populateYearRange:function(){this.year_select.populate(this.yearRange().toArray());},yearRange:function(){if(!this.flexibleYearRange())
return $R(this.options.get("year_range")[0],this.options.get("year_range")[1]);var y=this.date.getFullYear();return $R(y-this.options.get("year_range"),y+this.options.get("year_range"));},flexibleYearRange:function(){return(typeof(this.options.get("year_range"))=="number");},validYear:function(year){if(this.flexibleYearRange()){return true;}else{return this.yearRange().include(year);}},dayHover:function(element){var hover_date=new Date(this.selected_date);hover_date.setYear(element.year);hover_date.setMonth(element.month);hover_date.setDate(element.day);this.updateFooter(hover_date.toFormattedString(this.use_time));},dayHoverOut:function(element){this.updateFooter();},clearSelectedClass:function(){if(this.selected_cell)this.selected_cell.removeClassName("selected");},setSelectedClass:function(){if(!this.selection_made)return;this.clearSelectedClass()
if($R(0,42).include(days_until=this.beginning_date.stripTime().daysDistance(this.selected_date.stripTime()))){this.selected_cell=this.calendar_day_grid[days_until];this.selected_cell.addClassName("selected");}},reparse:function(){this.parseDate();this.refresh();},dateString:function(){return(this.selection_made)?this.selected_date.toFormattedString(this.use_time):"&#160;";},parseDate:function()
{var value=$F(this.target_element).strip()
this.selection_made=(value!="");this.date=value==""?NaN:Date.parseFormattedString(this.options.get("date")||value);if(isNaN(this.date))this.date=new Date();if(!this.validYear(this.date.getFullYear()))this.date.setYear((this.date.getFullYear()<this.yearRange().start)?this.yearRange().start:this.yearRange().end);this.selected_date=new Date(this.date);this.use_time=/[0-9]:[0-9]{2}/.exec(value)?true:false;this.date.setDate(1);},updateFooter:function(text){if(!text)text=this.dateString();this.footer_div.purgeChildren();this.footer_div.build("span",{innerHTML:text});},clearDate:function(){if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force")return false;var last_value=this.target_element.value;this.target_element.value="";this.clearSelectedClass();this.updateFooter('&#160;');if(last_value!=this.target_element.value)this.callback("onchange");},updateSelectedDate:function(partsOrElement,via_click){var parts=$H(partsOrElement);if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force")return false;if(parts.get("day")){var t_selected_date=this.selected_date,vdc=this.options.get("valid_date_check");for(var x=0;x<=3;x++)t_selected_date.setDate(parts.get("day"));t_selected_date.setYear(parts.get("year"));t_selected_date.setMonth(parts.get("month"));if(vdc&&!vdc(t_selected_date.stripTime())){return false;}
this.selected_date=t_selected_date;this.selection_made=true;}
if(!isNaN(parts.get("hour")))this.selected_date.setHours(parts.get("hour"));if(!isNaN(parts.get("minute")))this.selected_date.setMinutes(Math.floor_to_interval(parts.get("minute"),this.options.get("minute_interval")));if(parts.get("hour")===""||parts.get("minute")==="")
this.setUseTime(false);else if(!isNaN(parts.get("hour"))||!isNaN(parts.get("minute")))
this.setUseTime(true);this.updateFooter();this.setSelectedClass();if(this.selection_made)this.updateValue();if(this.closeOnClick()){this.close();}
if(via_click&&!this.options.get("embedded")){if((new Date()-this.last_click_at)<333)this.close();this.last_click_at=new Date();}},closeOnClick:function(){if(this.options.get("embedded"))return false;if(this.options.get("close_on_click")===nil)
return(this.options.get("time"))?false:true
else
return(this.options.get("close_on_click"))},navMonth:function(month){(target_date=new Date(this.date)).setMonth(month);return(this.navTo(target_date));},navYear:function(year){(target_date=new Date(this.date)).setYear(year);return(this.navTo(target_date));},navTo:function(date){if(!this.validYear(date.getFullYear()))return false;this.date=date;this.date.setDate(1);this.refresh();this.callback("after_navigate",this.date);return true;},setUseTime:function(turn_on){this.use_time=this.options.get("time")&&(this.options.get("time")=="mixed"?turn_on:true)
if(this.use_time&&this.selected_date){var minute=Math.floor_to_interval(this.selected_date.getMinutes(),this.options.get("minute_interval"));var hour=this.selected_date.getHours();this.hour_select.setValue(hour);this.minute_select.setValue(minute)}else if(this.options.get("time")=="mixed"){this.hour_select.setValue("");this.minute_select.setValue("");}},updateValue:function(){var last_value=this.target_element.value;this.target_element.value=this.dateString();if(last_value!=this.target_element.value)this.callback("onchange");},today:function(now){var d=new Date();this.date=new Date();var o=$H({day:d.getDate(),month:d.getMonth(),year:d.getFullYear(),hour:d.getHours(),minute:d.getMinutes()});if(!now)o=o.merge({hour:"",minute:""});this.updateSelectedDate(o,true);this.refresh();},close:function(){if(this.closed)return false;this.callback("before_close");this.target_element.calendar_date_select=nil;Event.stopObserving(document,"mousedown",this.closeIfClickedOut_handler);Event.stopObserving(document,"keypress",this.keyPress_handler);this.calendar_div.remove();this.closed=true;if(this.iframe)this.iframe.remove();if(this.target_element.type!="hidden"&&!this.target_element.disabled)this.target_element.focus();this.callback("after_close");},closeIfClickedOut:function(e){if(!$(Event.element(e)).descendantOf(this.calendar_div))this.close();},keyPress:function(e){if(e.keyCode==Event.KEY_ESC)this.close();},callback:function(name,param){if(this.options.get(name)){this.options.get(name).bind(this.target_element)(param);}}}
var my_rating=0;var current_hover=0;function rating_hover(rating){if(rating!=current_hover){var gray_star=$('gray_star').innerHTML;var normal_star=$('normal_star').innerHTML;$('stars_container').childElements().each(function(elm,i){if(i<rating){elm.innerHTML=normal_star;}
else{elm.innerHTML=gray_star;}});current_hover=rating;}
return false;}
function valid_url_chars(){url_string=$('business_url').value;if(!url_string||url_string==''||url_string.match(/^[a-zA-Z0-9_\-]*$/)){$('url').down('.invalid').hide();return true;}else{$('url').down('.invalid').show();return false;}}
function toggle_subcats(main_cat){main_cat=$(main_cat);subcats=main_cat.up('tr').select('td.subcat');if(main_cat.checked){subcats.each(function(s){s.removeClassName('disabled');checkbox=s.down('input');if(checkbox){checkbox.writeAttribute('disabled',false);}});}else{subcats.each(function(s){s.addClassName('disabled');checkbox=s.down('input');if(checkbox){checkbox.writeAttribute('disabled','disabled');}});}}
function popup_description(elm){var description=$(elm).next('div').innerHTML;$('popup_content').innerHTML=description;show_popup();}
function set_rating(rating){$('my_rating').innerHTML=rating;$('my_rating').up('div').show();my_rating=rating;rating_hover(rating);return false;}
function reset_stars(){rating_hover(my_rating);return false;}
function init_rating(){if($('stars_container')){$('stars_container').childElements().each(function(s){Event.observe(s,'mouseover',function(event){rating_hover(s.readAttribute('star_num'));Event.stop(event);});Event.observe(s,'mouseout',function(event){Event.stop(event);});Event.observe(window,'mouseover',reset_stars);});}}
document.observe("dom:loaded",init_rating);if($('map_canvas')){var CircleOverlay=function(latLng,radius,strokeColor,strokeWidth,strokeOpacity,fillColor,fillOpacity){this.latLng=latLng;this.radius=radius;this.strokeColor=strokeColor;this.strokeWidth=strokeWidth;this.strokeOpacity=strokeOpacity;this.fillColor=fillColor;this.fillOpacity=fillOpacity;}
CircleOverlay.prototype=GOverlay;CircleOverlay.prototype.initialize=function(map){this.map=map;}
CircleOverlay.prototype.clear=function(){if(this.polygon!=null&&this.map!=null){this.map.removeOverlay(this.polygon);}}
CircleOverlay.prototype.redraw=function(force){var d2r=Math.PI/180;circleLatLngs=new Array();var circleLat=this.radius*0.014483;var circleLng=circleLat/Math.cos(this.latLng.lat()*d2r);var numPoints=40;for(var i=0;i<numPoints+1;i++){var theta=Math.PI*(i/(numPoints/2));var vertexLat=this.latLng.lat()+(circleLat*Math.sin(theta));var vertexLng=this.latLng.lng()+(circleLng*Math.cos(theta));var vertextLatLng=new GLatLng(vertexLat,vertexLng);circleLatLngs.push(vertextLatLng);}
this.clear();this.polygon=new GPolygon(circleLatLngs,this.strokeColor,this.strokeWidth,this.strokeOpacity,this.fillColor,this.fillOpacity);this.map.addOverlay(this.polygon);GEvent.addListener(this.polygon,'click',function(){GEvent.trigger(map,'click');});}
CircleOverlay.prototype.remove=function(){this.clear();}
CircleOverlay.prototype.containsLatLng=function(latLng){if(this.polygon.containsLatLng){return this.polygon.containsLatLng(latLng);}}
CircleOverlay.prototype.setRadius=function(radius){this.radius=radius;}
CircleOverlay.prototype.setLatLng=function(latLng){this.latLng=latLng;}}