function show_help_bubble(id,help_html){help_bubble=$('helpbubble');help_icon=$(id);if(help_bubble&&help_icon){viewport_w=document.viewport.getDimensions().width;viewport_h=document.viewport.getDimensions().height;viewport_x=document.viewport.getScrollOffsets()[0];viewport_y=document.viewport.getScrollOffsets()[1];icon_x=help_icon.viewportOffset()[0];icon_y=help_icon.viewportOffset()[1];if(icon_x>viewport_w/2){if(icon_y>viewport_h/2){classname="bottom_right";}else{classname="top_right";}}else{if(icon_y>viewport_h/2){classname="bottom_left";}else{classname="top_left";}}
$('bubble_body').innerHTML=help_html;bubble=help_bubble.getDimensions();icon_size=help_icon.getDimensions();if(classname=='top_left'||classname=='top_right'){offy=icon_size.height-2;}
if(classname=='bottom_left'||classname=='bottom_right'){offy=-(bubble.height-8);}
if(classname=='bottom_left'||classname=='top_left'){offx=icon_size.width-8;}
if(classname=='bottom_right'||classname=='top_right'){offx=-(bubble.width-8);}
offx+=viewport_x;offy+=viewport_y;help_bubble.setStyle("left:"+(offx+icon_x)+"px");help_bubble.setStyle("top:"+(offy+icon_y)+"px");help_bubble.className=classname;help_bubble.toggle();}}
Event.observe(window,'load',function(){body=$$('body').first();Event.observe(body,"mousedown",function(e){if($('helpbubble')&&$('helpbubble').visible()){if(e.element().tagName!='A'){$('helpbubble').hide();}}});$$('.help_icon').each(function(icon){Event.observe(icon,"mousedown",function(e){Event.stop(e);})});});function widgetNearHelp(){$('widget-near-help').toggle();}
function widgetWhenHelp(){$('widget-when-help').toggle();}
function navType(type){map_type=type;if($('widget_type')){$('widget_type').value=type;}
var transition_time=0.2;if(type=='street'){$('nav-spots-on').appear({duration:transition_time});$('nav-spots-off').fade({duration:transition_time/2});$('nav-lots-on').hide();$('nav-lots-off').show();$('nav-racks-on').hide();$('nav-racks-off').show();$('widget_time_field').show();}
if(type=='lots'){$('nav-lots-on').appear({duration:transition_time});$('nav-lots-off').fade({duration:transition_time/2});$('nav-spots-on').hide();$('nav-spots-off').show();$('nav-racks-on').hide();$('nav-racks-off').show();$('widget_time_field').hide();}
if(type=='racks'){$('nav-racks-on').appear({duration:transition_time});$('nav-racks-off').fade({duration:transition_time/2});$('nav-lots-on').hide();$('nav-lots-off').show();$('nav-spots-on').hide();$('nav-spots-off').show();$('widget_time_field').hide();}}
function center(element){try{element=$(element);}catch(e){return;}
var my_width=0;var my_height=0;if(typeof(window.innerWidth)=='number'){my_width=window.innerWidth;my_height=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){my_width=document.documentElement.clientWidth;my_height=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){my_width=document.body.clientWidth;my_height=document.body.clientHeight;}
element.style.position='absolute';element.style.zIndex=99;var scrollY=0;if(document.documentElement&&document.documentElement.scrollTop){scrollY=document.documentElement.scrollTop;}else if(document.body&&document.body.scrollTop){scrollY=document.body.scrollTop;}else if(window.pageYOffset){scrollY=window.pageYOffset;}else if(window.scrollY){scrollY=window.scrollY;}
var elementDimensions=Element.getDimensions(element);var setX=(my_width-elementDimensions.width)/2;var setY=(my_height-elementDimensions.height)/2+scrollY-120;setX=(setX<0)?0:setX;setY=(setY<0)?0:setY;element.style.left=setX+"px";element.style.top=setY+"px";element.style.display='block';}
function hideBox(){$('box').hide();$('overlay').hide();return false;}
function hideAddBox(){$('add_box').hide();$('add_overlay').hide();if(editing<1){$('add-location-instructions').hide();$('regular-left-content').show();if(newMarker){map.removeOverlay(newMarker);}
if(newmarkerlistener){GEvent.removeListener(newmarkerlistener);}
adding=0;}
return false;}
function showBox(){$('overlay').show();center('box');return false;}
function showAddBox(){$('add_overlay').show();center('add_box');editing=0;return false;}
var Cookies=Class.create({initialize:function(path,domain){this.path=path||'/';this.domain=domain||null;},set:function(key,value,date){if(typeof key!='string'){throw"Invalid key";}
if(typeof value!='string'&&typeof value!='number'){throw"Invalid value";}
if(date&&typeof date!='object'){throw"Invalid expiration time";}
var setValue=key+'='+escape(new String(value));if(date){var setExpiration="; expires="+date.toGMTString();}else var setExpiration="";var setPath='; path='+escape(this.path);var setDomain=(this.domain)?'; domain='+escape(this.domain):'';var cookieString=setValue+setExpiration+setPath+setDomain;document.cookie=cookieString;},get:function(key){var keyEquals=key+"=";var value=false;document.cookie.split(';').invoke('strip').each(function(s){if(s.startsWith(keyEquals)){value=unescape(s.substring(keyEquals.length,s.length));throw $break;}});return value;},clear:function(key){this.set(key,'',-1);},clearAll:function(){document.cookie.split(';').collect(function(s){return s.split('=').first().strip();}).each(function(key){this.clear(key);}.bind(this));}});