/* 
//infoboubel ve32
*/
var mainmap,
    dir,
    directionsService,
    directionsDisplay,
    distance,
    duration,
    points = 0,
    activInfos = [],
    ppoGlobal = [],
    ouaGlobal = [],
    spoGlobal = [],
    nodesTable = [];
	
window.log = function(){
  log.history = log.history || [];
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3.js
// ==/ClosureCompiler==

/**
 * @name CSS3 InfoBubble with tabs for Google Maps API V3
 * @version 0.8
 * @author Luke Mahe
 * @fileoverview
 * This library is a CSS Infobubble with tabs. It uses css3 rounded corners and
 * drop shadows and animations. It also allows tabs
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


/**
 * A CSS3 InfoBubble v0.8
 * @param {Object.<string, *>=} opt_options Optional properties to set.
 * @extends {google.maps.OverlayView}
 * @constructor
 */
function InfoBubble(opt_options) {
  this.extend(InfoBubble, google.maps.OverlayView);
  this.tabs_ = [];
  this.activeTab_ = null;
  this.baseZIndex_ = 100;
  this.isOpen_ = false;
  this.baseOrient = 'top';

  var options = opt_options || {};

  if (options['backgroundColor'] == undefined) {
    options['backgroundColor'] = this.BACKGROUND_COLOR_;
  }

  if (options['borderColor'] == undefined) {
    options['borderColor'] = this.BORDER_COLOR_;
  }

  if (options['borderRadius'] == undefined) {
    options['borderRadius'] = this.BORDER_RADIUS_;
  }

  if (options['borderWidth'] == undefined) {
    options['borderWidth'] = this.BORDER_WIDTH_;
  }

  if (options['padding'] == undefined) {
    options['padding'] = this.PADDING_;
  }

  if (options['arrowDirection'] == undefined) {
    options['arrowDirection'] = this.ARROW_DIRECTION_;
  }

  if (options['arrowPosition'] == undefined) {
    options['arrowPosition'] = this.ARROW_POSITION_;
  }

  if (options['disableAutoPan'] == undefined) {
    options['disableAutoPan'] = false;
  }

  if (options['disableAnimation'] == undefined) {
    options['disableAnimation'] = false;
  }

  if (options['minWidth'] == undefined) {
    options['minWidth'] = this.MIN_WIDTH_;
  }

  if (options['shadowStyle'] == undefined) {
    options['shadowStyle'] = this.SHADOW_STYLE_;
  }

  if (options['arrowSize'] == undefined) {
    options['arrowSize'] = this.ARROW_SIZE_;
  }

  if (options['arrowStyle'] == undefined) {
    options['arrowStyle'] = this.ARROW_STYLE_;
  }

  this.buildDom_();

  this.setValues(options);
}
window['InfoBubble'] = InfoBubble;


/**
 * Default arrow size
 * @const
 * @private
 */
InfoBubble.prototype.ARROW_SIZE_ = 15;


/**
 * Default arrow style
 * @const
 * @private
 */
InfoBubble.prototype.ARROW_STYLE_ = 0;


/**
 * Default shadow style
 * @const
 * @private
 */
InfoBubble.prototype.SHADOW_STYLE_ = 1;


/**
 * Default min width
 * @const
 * @private
 */
InfoBubble.prototype.MIN_WIDTH_ = 50;


/**
 * Default arrow direction
 * @const
 * @private
 */
InfoBubble.prototype.ARROW_DIRECTION_ = 'bottom';


/**
 * Default arrow position
 * @const
 * @private
 */
InfoBubble.prototype.ARROW_POSITION_ = 50;


/**
 * Default padding
 * @const
 * @private
 */
InfoBubble.prototype.PADDING_ = 10;


/**
 * Default border width
 * @const
 * @private
 */
InfoBubble.prototype.BORDER_WIDTH_ = 1;


/**
 * Default border color
 * @const
 * @private
 */
InfoBubble.prototype.BORDER_COLOR_ = '#ccc';


/**
 * Default border radius
 * @const
 * @private
 */
InfoBubble.prototype.BORDER_RADIUS_ = 10;


/**
 * Default background color
 * @const
 * @private
 */
InfoBubble.prototype.BACKGROUND_COLOR_ = '#fff';


/**
 * Extends a objects prototype by anothers.
 *
 * @param {Object} obj1 The object to be extended.
 * @param {Object} obj2 The object to extend with.
 * @return {Object} The new extended object.
 * @ignore
 */
InfoBubble.prototype.extend = function(obj1, obj2) {
  return (function(object) {
    for (var property in object.prototype) {
      this.prototype[property] = object.prototype[property];
    }
    return this;
  }).apply(obj1, [obj2]);
};


/**
 * Builds the InfoBubble dom
 * @private
 */
InfoBubble.prototype.buildDom_ = function() {
  var bubble = this.bubble_ = document.createElement('DIV');
  bubble.style['position'] = 'absolute';
  bubble.style['zIndex'] = this.baseZIndex_;

  var tabsContainer = this.tabsContainer_ = document.createElement('DIV');
  tabsContainer.style['position'] = 'relative';

  // Close button
  var close = this.close_ = document.createElement('IMG');
  close.style['position'] = 'absolute';
  close.style['width'] = this.px(8);
  close.style['height'] = this.px(10);
  close.style['border'] = 0;
  close.style['zIndex'] = this.baseZIndex_ + 1;
  close.style['cursor'] = 'pointer';
  close.src = App.BASE_URL+'/images/awsa/map/iw_close.png';

  var that = this;
  google.maps.event.addDomListener(close, 'click', function() {
    that.close();
    google.maps.event.trigger(that, 'closeclick');
  });

  // Content area
  var contentContainer = this.contentContainer_ = document.createElement('DIV');
  contentContainer.style['overflowX'] = 'auto';
  contentContainer.style['overflowY'] = 'auto';
  contentContainer.style['cursor'] = 'default';
  contentContainer.style['clear'] = 'both';
  contentContainer.style['position'] = 'relative';

  var content = this.content_ = document.createElement('DIV');
  contentContainer.appendChild(content);

  // Arrow
  var arrow = this.arrow_ = document.createElement('DIV');
  arrow.style['position'] = 'relative';

  var arrowOuter = this.arrowOuter_ = document.createElement('DIV');
  var arrowInner = this.arrowInner_ = document.createElement('DIV');

  var arrowSize = this.getArrowSize_();


  arrowOuter.style['position'] = arrowInner.style['position'] = 'absolute';
  arrowOuter.style['left'] = arrowInner.style['left'] = '50%';
  arrowOuter.style['height'] = arrowInner.style['height'] = '0';
  arrowOuter.style['width'] = arrowInner.style['width'] = '0';
  arrowOuter.style['marginLeft'] = this.px(-arrowSize);
  arrowOuter.style['borderWidth'] = this.px(arrowSize);
  arrowOuter.style['borderBottomWidth'] = 0;

  // Shadow
  var bubbleShadow = this.bubbleShadow_ = document.createElement('DIV');
  bubbleShadow.style['position'] = 'absolute';

  // Hide the InfoBubble by default
  bubble.style['display'] = bubbleShadow.style['display'] = 'none';

	  bubble.appendChild(this.tabsContainer_);
	  bubble.appendChild(close);
	  bubble.appendChild(contentContainer);
	  arrow.appendChild(arrowOuter);
	  arrow.appendChild(arrowInner);
	  bubble.appendChild(arrow);
 

  var stylesheet = document.createElement('style');
  stylesheet.setAttribute('type', 'text/css');

  /**
   * The animation for the infobubble
   * @type {string}
   */
  this.animationName_ = '_ibani_' + Math.round(Math.random() * 10000);

  var css = '.' + this.animationName_ + '{-webkit-animation-name:' +
      this.animationName_ + ';-webkit-animation-duration:0.5s;' +
      '-webkit-animation-iteration-count:1;}' +
      '@-webkit-keyframes ' + this.animationName_ + ' {from {' +
      '-webkit-transform: scale(0)}50% {-webkit-transform: scale(1.2)}90% ' +
      '{-webkit-transform: scale(0.95)}to {-webkit-transform: scale(1)}}';

  stylesheet.textContent = css;
  document.getElementsByTagName('head')[0].appendChild(stylesheet);
};


/**
 * Sets the background class name
 *
 * @param {string} className The class name to set.
 */
InfoBubble.prototype.setBackgroundClassName = function(className) {
  this.set('backgroundClassName', className);
};
InfoBubble.prototype['setBackgroundClassName'] =
    InfoBubble.prototype.setBackgroundClassName;


/**
 * changed MVC callback
 */
InfoBubble.prototype.backgroundClassName_changed = function() {
  this.content_.className = this.get('backgroundClassName');
};
InfoBubble.prototype['backgroundClassName_changed'] =
    InfoBubble.prototype.backgroundClassName_changed;


/**
 * Sets the class of the tab
 *
 * @param {string} className the class name to set.
 */
InfoBubble.prototype.setTabClassName = function(className) {
  this.set('tabClassName', className);
};
InfoBubble.prototype['setTabClassName'] =
    InfoBubble.prototype.setTabClassName;


/**
 * tabClassName changed MVC callback
 */
InfoBubble.prototype.tabClassName_changed = function() {
  this.updateTabStyles_();
};
InfoBubble.prototype['tabClassName_changed'] =
    InfoBubble.prototype.tabClassName_changed;


/**
 * Gets the style of the arrow
 *
 * @private
 * @return {number} The style of the arrow.
 */
InfoBubble.prototype.getArrowStyle_ = function() {
  return parseInt(this.get('arrowStyle'), 10) || 0;
};


/**
 * Sets the style of the arrow
 *
 * @param {number} style The style of the arrow.
 */
InfoBubble.prototype.setArrowStyle = function(style) {
  this.set('arrowStyle', style);
};
InfoBubble.prototype['setArrowStyle'] =
    InfoBubble.prototype.setArrowStyle;


/**
 * Arrow style changed MVC callback
 */
InfoBubble.prototype.arrowStyle_changed = function() {
  this.arrowSize_changed();
};
InfoBubble.prototype['arrowStyle_changed'] =
    InfoBubble.prototype.arrowStyle_changed;


/**
 * Gets the size of the arrow
 *
 * @private
 * @return {number} The size of the arrow.
 */
InfoBubble.prototype.getArrowSize_ = function() {
  return parseInt(this.get('arrowSize'), 10) || 0;
};


/**
 * Sets the size of the arrow
 *
 * @param {number} size The size of the arrow.
 */
InfoBubble.prototype.setArrowSize = function(size) {
  this.set('arrowSize', size);
};
InfoBubble.prototype['setArrowSize'] =
    InfoBubble.prototype.setArrowSize;


/**
 * Arrow size changed MVC callback
 */
InfoBubble.prototype.arrowSize_changed = function() {
  this.borderWidth_changed();
};
InfoBubble.prototype['arrowSize_changed'] =
    InfoBubble.prototype.arrowSize_changed;


/**
 * Set the position of the InfoBubble arrow
 *
 * @param {number} pos The position to set.
 */
InfoBubble.prototype.setArrowPosition = function(pos) {
  this.set('arrowPosition', pos);
};
InfoBubble.prototype['setArrowPosition'] =
    InfoBubble.prototype.setArrowPosition;


/**
 * Get the position of the InfoBubble arrow
 *
 * @private
 * @return {number} The position..
 */
InfoBubble.prototype.getArrowPosition_ = function() {
  return parseInt(this.get('arrowPosition'), 10) || 0;
};


/**
 * arrowPosition changed MVC callback
 */
InfoBubble.prototype.arrowPosition_changed = function() {
  var pos = this.getArrowPosition_();
  this.arrowOuter_.style['left'] = this.arrowInner_.style['left'] = pos + '%';

  this.redraw_();
};
InfoBubble.prototype['arrowPosition_changed'] =
    InfoBubble.prototype.arrowPosition_changed;


/**
 * Set the zIndex of the InfoBubble
 *
 * @param {number} zIndex The zIndex to set.
 */
InfoBubble.prototype.setZIndex = function(zIndex) {
  this.set('zIndex', zIndex);
};
InfoBubble.prototype['setZIndex'] = InfoBubble.prototype.setZIndex;


/**
 * Get the zIndex of the InfoBubble
 *
 * @return {number} The zIndex to set.
 */
InfoBubble.prototype.getZIndex = function() {
  return parseInt(this.get('zIndex'), 10) || this.baseZIndex_;
};


/**
 * zIndex changed MVC callback
 */
InfoBubble.prototype.zIndex_changed = function() {
  var zIndex = this.getZIndex();

  this.bubble_.style['zIndex'] = this.baseZIndex_ = zIndex;
  this.close_.style['zIndex'] = zIndex + 1;
};
InfoBubble.prototype['zIndex_changed'] = InfoBubble.prototype.zIndex_changed;


/**
 * Set the style of the shadow
 *
 * @param {number} shadowStyle The style of the shadow.
 */
InfoBubble.prototype.setShadowStyle = function(shadowStyle) {
  this.set('shadowStyle', shadowStyle);
};
InfoBubble.prototype['setShadowStyle'] = InfoBubble.prototype.setShadowStyle;


/**
 * Get the style of the shadow
 *
 * @private
 * @return {number} The style of the shadow.
 */
InfoBubble.prototype.getShadowStyle_ = function() {
  return parseInt(this.get('shadowStyle'), 10) || 0;
};


/**
 * shadowStyle changed MVC callback
 */
InfoBubble.prototype.shadowStyle_changed = function() {
  var shadowStyle = this.getShadowStyle_();

  var display = '';
  var shadow = '';
  var backgroundColor = '';
  switch (shadowStyle) {
    case 0:
      display = 'none';
      break;
    case 1:
      shadow = '40px 15px 10px rgba(33,33,33,0.3)';
      backgroundColor = 'transparent';
      break;
    case 2:
      shadow = '0 0 2px rgba(33,33,33,0.3)';
      backgroundColor = 'rgba(33,33,33,0.35)';
      break;
  }
  this.bubbleShadow_.style['boxShadow'] =
      this.bubbleShadow_.style['webkitBoxShadow'] =
      this.bubbleShadow_.style['MozBoxShadow'] = shadow;
  this.bubbleShadow_.style['backgroundColor'] = backgroundColor;
  if (this.isOpen_) {
    this.bubbleShadow_.style['display'] = display;
    this.draw();
  }
};
InfoBubble.prototype['shadowStyle_changed'] =
    InfoBubble.prototype.shadowStyle_changed;


/**
 * Show the close button
 */
InfoBubble.prototype.showCloseButton = function() {
  this.set('hideCloseButton', false);
};
InfoBubble.prototype['showCloseButton'] = InfoBubble.prototype.showCloseButton;


/**
 * Hide the close button
 */
InfoBubble.prototype.hideCloseButton = function() {
  this.set('hideCloseButton', true);
};
InfoBubble.prototype['hideCloseButton'] = InfoBubble.prototype.hideCloseButton;


/**
 * hideCloseButton changed MVC callback
 */
InfoBubble.prototype.hideCloseButton_changed = function() {
  this.close_.style['display'] = this.get('hideCloseButton') ? 'none' : '';
};
InfoBubble.prototype['hideCloseButton_changed'] =
    InfoBubble.prototype.hideCloseButton_changed;


/**
 * Set the background color
 *
 * @param {string} color The color to set.
 */
InfoBubble.prototype.setBackgroundColor = function(color) {
  if (color) {
    this.set('backgroundColor', color);
  }
};
InfoBubble.prototype['setBackgroundColor'] =
    InfoBubble.prototype.setBackgroundColor;


/**
 * backgroundColor changed MVC callback
 */
InfoBubble.prototype.backgroundColor_changed = function() {
  var backgroundColor = this.get('backgroundColor');
  this.contentContainer_.style['backgroundColor'] = backgroundColor;

  this.arrowInner_.style['borderColor'] = backgroundColor +
      ' transparent transparent';
  this.updateTabStyles_();
};
InfoBubble.prototype['backgroundColor_changed'] =
    InfoBubble.prototype.backgroundColor_changed;


/**
 * Set the border color
 *
 * @param {string} color The border color.
 */
InfoBubble.prototype.setBorderColor = function(color) {
  if (color) {
    this.set('borderColor', color);
  }
};
InfoBubble.prototype['setBorderColor'] = InfoBubble.prototype.setBorderColor;


/**
 * borderColor changed MVC callback
 */
InfoBubble.prototype.borderColor_changed = function() {
  var borderColor = this.get('borderColor');

  var contentContainer = this.contentContainer_;
  var arrowOuter = this.arrowOuter_;
  contentContainer.style['borderColor'] = borderColor;

  arrowOuter.style['borderColor'] = borderColor +
      ' transparent transparent';

  contentContainer.style['borderStyle'] =
      arrowOuter.style['borderStyle'] =
      this.arrowInner_.style['borderStyle'] = 'solid';

  this.updateTabStyles_();
};
InfoBubble.prototype['borderColor_changed'] =
    InfoBubble.prototype.borderColor_changed;


/**
 * Set the radius of the border
 *
 * @param {number} radius The radius of the border.
 */
InfoBubble.prototype.setBorderRadius = function(radius) {
  this.set('borderRadius', radius);
};
InfoBubble.prototype['setBorderRadius'] = InfoBubble.prototype.setBorderRadius;


/**
 * Get the radius of the border
 *
 * @private
 * @return {number} The radius of the border.
 */
InfoBubble.prototype.getBorderRadius_ = function() {
  return parseInt(this.get('borderRadius'), 10) || 0;
};


/**
 * borderRadius changed MVC callback
 */
InfoBubble.prototype.borderRadius_changed = function() {
  var borderRadius = this.getBorderRadius_();
  var borderWidth = this.getBorderWidth_();

  this.contentContainer_.style['borderRadius'] =
      this.contentContainer_.style['MozBorderRadius'] =
      this.contentContainer_.style['webkitBorderRadius'] =
      this.bubbleShadow_.style['borderRadius'] =
      this.bubbleShadow_.style['MozBorderRadius'] =
      this.bubbleShadow_.style['webkitBorderRadius'] = this.px(borderRadius);

  this.tabsContainer_.style['paddingLeft'] =
      this.tabsContainer_.style['paddingRight'] =
      this.px(borderRadius + borderWidth);

  this.redraw_();
};
InfoBubble.prototype['borderRadius_changed'] =
    InfoBubble.prototype.borderRadius_changed;


/**
 * Set the direction of the InfoBubble arrow
 *
 * @param {number} pos The position to set.
 */
InfoBubble.prototype.setArrowDirection = function(pos) {
  this.set('arrowDirection', pos);
};
InfoBubble.prototype['setArrowDirection'] =
    InfoBubble.prototype.setArrowDirection;


/**
 * Get the direction of the InfoBubble arrow
 *
 * @private
 * @return {number} The position..
 */
InfoBubble.prototype.getArrowDirection_ = function() {
  return this.get('arrowDirection') ;
};


/**
 * arrowDirection changed MVC callback
 */
InfoBubble.prototype.arrowDirection_changed = function() {
  var pos = this.getArrowDirection_();
  //this.arrowOuter_.style['left'] = this.arrowInner_.style['left'] = pos + '%';

  this.redraw_();
};
InfoBubble.prototype['arrowDirection_changed'] =
    InfoBubble.prototype.arrowDirection_changed;



/**
 * Get the width of the border
 *
 * @private
 * @return {number} width The width of the border.
 */
InfoBubble.prototype.getBorderWidth_ = function() {
  return parseInt(this.get('borderWidth'), 10) || 0;
};


/**
 * Set the width of the border
 *
 * @param {number} width The width of the border.
 */
InfoBubble.prototype.setBorderWidth = function(width) {
  this.set('borderWidth', width);
};
InfoBubble.prototype['setBorderWidth'] = InfoBubble.prototype.setBorderWidth;


/**
 * borderWidth change MVC callback
 */
InfoBubble.prototype.borderWidth_changed = function() {
  var borderWidth = this.getBorderWidth_();

  this.contentContainer_.style['borderWidth'] = this.px(borderWidth);
  this.tabsContainer_.style['top'] = this.px(borderWidth);

  this.updateArrowStyle_();
  this.updateTabStyles_();
  this.borderRadius_changed();
  this.redraw_();
};
InfoBubble.prototype['borderWidth_changed'] =
    InfoBubble.prototype.borderWidth_changed;


/**
 * Update the arrow style
 * @private
 */
InfoBubble.prototype.updateArrowStyle_ = function() {
  var borderWidth = this.getBorderWidth_();
  var arrowSize = this.getArrowSize_();
  var arrowStyle = this.getArrowStyle_();
  var arrowOuterSizePx = this.px(arrowSize);
  var arrowInnerSizePx = this.px(Math.max(0, arrowSize - borderWidth));

  var outer = this.arrowOuter_;
  var inner = this.arrowInner_;

  this.arrow_.style['marginTop'] = this.px(-borderWidth);
  outer.style['borderTopWidth'] = arrowOuterSizePx;
  inner.style['borderTopWidth'] = arrowInnerSizePx;

  // Full arrow or arrow pointing to the left
  if (arrowStyle == 0 || arrowStyle == 1) {
    outer.style['borderLeftWidth'] = arrowOuterSizePx;
    inner.style['borderLeftWidth'] = arrowInnerSizePx;
  } else {
    outer.style['borderLeftWidth'] = inner.style['borderLeftWidth'] = 0;
  }

  // Full arrow or arrow pointing to the right
  if (arrowStyle == 0 || arrowStyle == 2) {
    outer.style['borderRightWidth'] = arrowOuterSizePx;
    inner.style['borderRightWidth'] = arrowInnerSizePx;
  } else {
    outer.style['borderRightWidth'] = inner.style['borderRightWidth'] = 0;
  }

  if (arrowStyle < 2) {
    outer.style['marginLeft'] = this.px(-(arrowSize));
    inner.style['marginLeft'] = this.px(-(arrowSize - borderWidth));
  } else {
    outer.style['marginLeft'] = inner.style['marginLeft'] = 0;
  }

  // If there is no border then don't show thw outer arrow
  if (borderWidth == 0) {
    outer.style['display'] = 'none';
  } else {
    outer.style['display'] = '';
  }
};


/**
 * Set the padding of the InfoBubble
 *
 * @param {number} padding The padding to apply.
 */
InfoBubble.prototype.setPadding = function(padding) {
  this.set('padding', padding);
};
InfoBubble.prototype['setPadding'] = InfoBubble.prototype.setPadding;


/**
 * Set the padding of the InfoBubble
 *
 * @private
 * @return {number} padding The padding to apply.
 */
InfoBubble.prototype.getPadding_ = function() {
  return parseInt(this.get('padding'), 10) || 0;
};


/**
 * padding changed MVC callback
 */
InfoBubble.prototype.padding_changed = function() {
  var padding = this.getPadding_();
  this.contentContainer_.style['padding'] = this.px(padding);
  this.updateTabStyles_();

  this.redraw_();
};
InfoBubble.prototype['padding_changed'] = InfoBubble.prototype.padding_changed;


/**
 * Add px extention to the number
 *
 * @param {number} num The number to wrap.
 * @return {string|number} A wrapped number.
 */
InfoBubble.prototype.px = function(num) {
  if (num) {
    // 0 doesn't need to be wrapped
    return num + 'px';
  }
  return num;
};


/**
 * Add events to stop propagation
 * @private
 */
InfoBubble.prototype.addEvents_ = function() {
  // We want to cancel all the events so they do not go to the map
  var events = ['mousedown', 'mousemove', 'mouseover', 'mouseout', 'mouseup',
      'mousewheel', 'DOMMouseScroll', 'touchstart', 'touchend', 'touchmove',
      'dblclick', 'contextmenu', 'click'];

  var bubble = this.bubble_;
  this.listeners_ = [];
  for (var i = 0, event; event = events[i]; i++) {
    this.listeners_.push(
      google.maps.event.addDomListener(bubble, event, function(e) {
        e.cancelBubble = true;
        if (e.stopPropagation) {
          e.stopPropagation();
        }
      })
    );
  }
};


/**
 * On Adding the InfoBubble to a map
 * Implementing the OverlayView interface
 */
InfoBubble.prototype.onAdd = function() {
  if (!this.bubble_) {
    this.buildDom_();
  }

  this.addEvents_();

  var panes = this.getPanes();
  if (panes) {
    panes.floatPane.appendChild(this.bubble_);
    panes.floatShadow.appendChild(this.bubbleShadow_);
  }
};
InfoBubble.prototype['onAdd'] = InfoBubble.prototype.onAdd;


/**
 * Draw the InfoBubble
 * Implementing the OverlayView interface
 */
InfoBubble.prototype.draw = function() {
  var projection = this.getProjection();

  if (!projection) {
    // The map projection is not ready yet so do nothing
    return;
  }

  var latLng = /** @type {google.maps.LatLng} */ (this.get('position'));

  if (!latLng) {
    this.close();
    return;
  }

  var tabHeight = 0;

  if (this.activeTab_) {
    tabHeight = this.activeTab_.offsetHeight;
  }

  var anchorHeight = this.getAnchorHeight_();
  var arrowSize = this.getArrowSize_();
  var arrowPosition = this.getArrowPosition_();
  var arrowDirection = this.getArrowDirection_();
  arrowPosition = arrowPosition / 100;

  var pos = projection.fromLatLngToDivPixel(latLng);
  var width = this.contentContainer_.offsetWidth;
  var height = this.bubble_.offsetHeight;

  if (!width) {
    return;
  }

  // Adjust for the height of the info bubble
  
  
  if (arrowDirection == 'top') {
      var top = pos.y + 15;
      var left = pos.x - (width * arrowPosition);
      
      if(typeof(this.topArrow_) == 'undefined') {
    	  var topArrow = this.topArrow_ = document.createElement('IMG');
    	  topArrow.style['width'] = this.px(30);
    	  topArrow.style['height'] = this.px(15);
    	  topArrow.src = App.BASE_URL+'/images/awsa/map/inofBtomArrow.gif';
    	  topArrow.style['zIndex'] = this.baseZIndex_ + 1;
    	  topArrow.className = 'topArrowInfoBouble';
    	  
    	  this.bubble_.appendChild(topArrow);
      }
      
  }
  else {
      var top = pos.y - (height +15);
      var left = pos.x - (width * arrowPosition);
      
  }

  if (anchorHeight) {
    // If there is an anchor then include the height
    top -= anchorHeight;
  }


  this.bubble_.style['top'] = this.px(top);
  this.bubble_.style['left'] = this.px(left);

  var shadowStyle = parseInt(this.get('shadowStyle'), 10);

  switch (shadowStyle) {
    case 1:
      // Shadow is behind
      this.bubbleShadow_.style['top'] = this.px(top + tabHeight - 1);
      this.bubbleShadow_.style['left'] = this.px(left);
      this.bubbleShadow_.style['width'] = this.px(width);
      this.bubbleShadow_.style['height'] =
          this.px(this.contentContainer_.offsetHeight - arrowSize);
      break;
    case 2:
      // Shadow is below
      width = width * 0.8;
      if (anchorHeight) {
        this.bubbleShadow_.style['top'] = this.px(pos.y);
      } else {
        this.bubbleShadow_.style['top'] = this.px(pos.y + arrowSize);
      }
      this.bubbleShadow_.style['left'] = this.px(pos.x - width * arrowPosition);

      this.bubbleShadow_.style['width'] = this.px(width);
      this.bubbleShadow_.style['height'] = this.px(2);
      break;
  }
};
InfoBubble.prototype['draw'] = InfoBubble.prototype.draw;


/**
 * Removing the InfoBubble from a map
 */
InfoBubble.prototype.onRemove = function() {
  if (this.bubble_ && this.bubble_.parentNode) {
    this.bubble_.parentNode.removeChild(this.bubble_);
  }
  if (this.bubbleShadow_ && this.bubbleShadow_.parentNode) {
    this.bubbleShadow_.parentNode.removeChild(this.bubbleShadow_);
  }

  for (var i = 0, listener; listener = this.listeners_[i]; i++) {
    google.maps.event.removeListener(listener);
  }
};
InfoBubble.prototype['onRemove'] = InfoBubble.prototype.onRemove;


/**
 * Is the InfoBubble open
 *
 * @return {boolean} If the InfoBubble is open.
 */
InfoBubble.prototype.isOpen = function() {
  return this.isOpen_;
};
InfoBubble.prototype['isOpen'] = InfoBubble.prototype.isOpen;


/**
 * Close the InfoBubble
 */
InfoBubble.prototype.close = function() {
  if (this.bubble_) {
    this.bubble_.style['display'] = 'none';
    // Remove the animation so we next time it opens it will animate again
    this.bubble_.className =
        this.bubble_.className.replace(this.animationName_, '');
  }

  if (this.bubbleShadow_) {
    this.bubbleShadow_.style['display'] = 'none';
    this.bubbleShadow_.className =
        this.bubbleShadow_.className.replace(this.animationName_, '');
  }
  this.isOpen_ = false;
};
InfoBubble.prototype['close'] = InfoBubble.prototype.close;


/**
 * Open the InfoBubble
 *
 * @param {google.maps.Map=} opt_map Optional map to open on.
 * @param {google.maps.MVCObject=} opt_anchor Optional anchor to position at.
 */
InfoBubble.prototype.open = function(opt_map, opt_anchor) {
  if (opt_map) {
    this.setMap(opt_map);
  }

  if (opt_anchor) {
    this.set('anchor', opt_anchor);
    this.bindTo('anchorPoint', opt_anchor);
    this.bindTo('position', opt_anchor);
  }

  // Show the bubble and the show
  this.bubble_.style['display'] = this.bubbleShadow_.style['display'] = '';
  var animation = !this.get('disableAnimation');

  if (animation) {
    // Add the animation
    this.bubble_.className += ' ' + this.animationName_;
    this.bubbleShadow_.className += ' ' + this.animationName_;
  }

  this.redraw_();
  this.isOpen_ = true;

  var pan = !this.get('disableAutoPan');
  if (pan) {
    var that = this;
    window.setTimeout(function() {
      // Pan into view, done in a time out to make it feel nicer :)
      that.panToView();
    }, 200);
  }
};
InfoBubble.prototype['open'] = InfoBubble.prototype.open;


/**
 * Set the position of the InfoBubble
 *
 * @param {google.maps.LatLng} position The position to set.
 */
InfoBubble.prototype.setPosition = function(position) {
  if (position) {
    this.set('position', position);
  }
};
InfoBubble.prototype['setPosition'] = InfoBubble.prototype.setPosition;


/**
 * Returns the position of the InfoBubble
 *
 * @return {google.maps.LatLng} the position.
 */
InfoBubble.prototype.getPosition = function() {
  return /** @type {google.maps.LatLng} */ (this.get('position'));
};
InfoBubble.prototype['getPosition'] = InfoBubble.prototype.getPosition;


/**
 * position changed MVC callback
 */
InfoBubble.prototype.position_changed = function() {
  this.draw();
};
InfoBubble.prototype['position_changed'] =
    InfoBubble.prototype.position_changed;


/**
 * Pan the InfoBubble into view
 */
InfoBubble.prototype.panToView = function() {
  var projection = this.getProjection();

  if (!projection) {
    // The map projection is not ready yet so do nothing
    return;
  }

  if (!this.bubble_) {
    // No Bubble yet so do nothing
    return;
  }

  var anchorHeight = this.getAnchorHeight_();
  var height = this.bubble_.offsetHeight + anchorHeight;
  var map = this.get('map');
  var mapDiv = map.getDiv();
  var mapHeight = mapDiv.offsetHeight;

  var latLng = this.getPosition();
  var centerPos = projection.fromLatLngToContainerPixel(map.getCenter());
  var pos = projection.fromLatLngToContainerPixel(latLng);

  // Find out how much space at the top is free
  var spaceTop = centerPos.y - height;

  // Fine out how much space at the bottom is free
  var spaceBottom = mapHeight - centerPos.y;

  var needsTop = spaceTop < 0;
  var deltaY = 0;

  if (needsTop) {
    spaceTop *= -1;
    deltaY = (spaceTop + spaceBottom) / 2;
  }

  pos.y -= deltaY;
  latLng = projection.fromContainerPixelToLatLng(pos);

  if (map.getCenter() != latLng) {
    map.panTo(latLng);
  }
};
InfoBubble.prototype['panToView'] = InfoBubble.prototype.panToView;


/**
 * Converts a HTML string to a document fragment.
 *
 * @param {string} htmlString The HTML string to convert.
 * @return {Node} A HTML document fragment.
 * @private
 */
InfoBubble.prototype.htmlToDocumentFragment_ = function(htmlString) {
  htmlString = htmlString.replace(/^\s*([\S\s]*)\b\s*$/, '$1');
  var tempDiv = document.createElement('DIV');
  tempDiv.innerHTML = htmlString;
  if (tempDiv.childNodes.length == 1) {
    return /** @type {!Node} */ (tempDiv.removeChild(tempDiv.firstChild));
  } else {
    var fragment = document.createDocumentFragment();
    while (tempDiv.firstChild) {
      fragment.appendChild(tempDiv.firstChild);
    }
    return fragment;
  }
};


/**
 * Removes all children from the node.
 *
 * @param {Node} node The node to remove all children from.
 * @private
 */
InfoBubble.prototype.removeChildren_ = function(node) {
  if (!node) {
    return;
  }

  var child;
  while (child = node.firstChild) {
    node.removeChild(child);
  }
};


/**
 * Sets the content of the infobubble.
 *
 * @param {string|Node} content The content to set.
 */
InfoBubble.prototype.setContent = function(content) {
  this.set('content', content);
};
InfoBubble.prototype['setContent'] = InfoBubble.prototype.setContent;


/**
 * Get the content of the infobubble.
 *
 * @return {string|Node} The marker content.
 */
InfoBubble.prototype.getContent = function() {
  return /** @type {Node|string} */ (this.get('content'));
};
InfoBubble.prototype['getContent'] = InfoBubble.prototype.getContent;


/**
 * Sets the marker content and adds loading events to images
 */
InfoBubble.prototype.content_changed = function() {
  if (!this.content_) {
    // The Content area doesnt exist.
    return;
  }

  this.removeChildren_(this.content_);
  var content = this.getContent();
  if (content) {
    if (typeof content == 'string') {
      content = this.htmlToDocumentFragment_(content);
    }
    this.content_.appendChild(content);

    var that = this;
    var images = this.content_.getElementsByTagName('IMG');
    for (var i = 0, image; image = images[i]; i++) {
      // Because we don't know the size of an image till it loads, add a
      // listener to the image load so the marker can resize and reposition
      // itself to be the correct height.
      google.maps.event.addDomListener(image, 'load', function() {
        that.imageLoaded_();
      });
    }
    google.maps.event.trigger(this, 'domready');
  }
  this.redraw_();
};
InfoBubble.prototype['content_changed'] =
    InfoBubble.prototype.content_changed;


/**
 * Image loaded
 * @private
 */
InfoBubble.prototype.imageLoaded_ = function() {
  var pan = !this.get('disableAutoPan');
  this.redraw_();
  if (pan && (this.tabs_.length == 0 || this.activeTab_.index == 0)) {
    this.panToView();
  }
};

/**
 * Updates the styles of the tabs
 * @private
 */
InfoBubble.prototype.updateTabStyles_ = function() {
  if (this.tabs_ && this.tabs_.length) {
    for (var i = 0, tab; tab = this.tabs_[i]; i++) {
      this.setTabStyle_(tab.tab);
    }
    this.activeTab_.style['zIndex'] = this.baseZIndex_;
    var borderWidth = this.getBorderWidth_();
    var padding = this.getPadding_() / 2;
    this.activeTab_.style['borderBottomWidth'] = 0;
    this.activeTab_.style['paddingBottom'] = this.px(padding + borderWidth);
  }
};


/**
 * Sets the style of a tab
 * @private
 * @param {Element} tab The tab to style.
 */
InfoBubble.prototype.setTabStyle_ = function(tab) {
  var backgroundColor = this.get('backgroundColor');
  var borderColor = this.get('borderColor');
  var borderRadius = this.getBorderRadius_();
  var borderWidth = this.getBorderWidth_();
  var padding = this.getPadding_();

  var marginRight = this.px(-(Math.max(padding, borderRadius)));
  var borderRadiusPx = this.px(borderRadius);

  var index = this.baseZIndex_;
  if (tab.index) {
    index -= tab.index;
  }

  // The styles for the tab
  var styles = {
    'cssFloat': 'left',
    'position': 'relative',
    'cursor': 'pointer',
    'backgroundColor': backgroundColor,
    'border': this.px(borderWidth) + ' solid ' + borderColor,
    'padding': this.px(padding / 2) + ' ' + this.px(padding),
    'marginRight': marginRight,
    'whiteSpace': 'nowrap',
    'borderRadiusTopLeft': borderRadiusPx,
    'MozBorderRadiusTopleft': borderRadiusPx,
    'webkitBorderTopLeftRadius': borderRadiusPx,
    'borderRadiusTopRight': borderRadiusPx,
    'MozBorderRadiusTopright': borderRadiusPx,
    'webkitBorderTopRightRadius': borderRadiusPx,
    'zIndex': index,
    'display': 'inline'
  };

  for (var style in styles) {
    tab.style[style] = styles[style];
  }

  var className = this.get('tabClassName');
  if (className != undefined) {
    tab.className += ' ' + className;
  }
};


/**
 * Add user actions to a tab
 * @private
 * @param {Object} tab The tab to add the actions to.
 */
InfoBubble.prototype.addTabActions_ = function(tab) {
  var that = this;
  tab.listener_ = google.maps.event.addDomListener(tab, 'click', function() {
    that.setTabActive_(this);
  });
};


/**
 * Set a tab at a index to be active
 *
 * @param {number} index The index of the tab.
 */
InfoBubble.prototype.setTabActive = function(index) {
  var tab = this.tabs_[index - 1];

  if (tab) {
    this.setTabActive_(tab.tab);
  }
};
InfoBubble.prototype['setTabActive'] = InfoBubble.prototype.setTabActive;


/**
 * Set a tab to be active
 * @private
 * @param {Object} tab The tab to set active.
 */
InfoBubble.prototype.setTabActive_ = function(tab) {
  if (!tab) {
    this.setContent('');
    return;
  }

  var padding = this.getPadding_() / 2;
  var borderWidth = this.getBorderWidth_();

  if (this.activeTab_) {
    var activeTab = this.activeTab_;
    activeTab.style['zIndex'] = this.baseZIndex_ - activeTab.index;
    activeTab.style['paddingBottom'] = this.px(padding);
    activeTab.style['borderBottomWidth'] = this.px(borderWidth);
  }

  tab.style['zIndex'] = this.baseZIndex_;
  tab.style['borderBottomWidth'] = 0;
  tab.style['marginBottomWidth'] = '-10px';
  tab.style['paddingBottom'] = this.px(padding + borderWidth);

  this.setContent(this.tabs_[tab.index].content);

  this.activeTab_ = tab;

  this.redraw_();
};


/**
 * Set the max width of the InfoBubble
 *
 * @param {number} width The max width.
 */
InfoBubble.prototype.setMaxWidth = function(width) {
  this.set('maxWidth', width);
};
InfoBubble.prototype['setMaxWidth'] = InfoBubble.prototype.setMaxWidth;


/**
 * maxWidth changed MVC callback
 */
InfoBubble.prototype.maxWidth_changed = function() {
  this.redraw_();
};
InfoBubble.prototype['maxWidth_changed'] =
    InfoBubble.prototype.maxWidth_changed;


/**
 * Set the max height of the InfoBubble
 *
 * @param {number} height The max height.
 */
InfoBubble.prototype.setMaxHeight = function(height) {
  this.set('maxHeight', height);
};
InfoBubble.prototype['setMaxHeight'] = InfoBubble.prototype.setMaxHeight;


/**
 * maxHeight changed MVC callback
 */
InfoBubble.prototype.maxHeight_changed = function() {
  this.redraw_();
};
InfoBubble.prototype['maxHeight_changed'] =
    InfoBubble.prototype.maxHeight_changed;


/**
 * Set the min width of the InfoBubble
 *
 * @param {number} width The min width.
 */
InfoBubble.prototype.setMinWidth = function(width) {
  this.set('minWidth', width);
};
InfoBubble.prototype['setMinWidth'] = InfoBubble.prototype.setMinWidth;


/**
 * minWidth changed MVC callback
 */
InfoBubble.prototype.minWidth_changed = function() {
  this.redraw_();
};
InfoBubble.prototype['minWidth_changed'] =
    InfoBubble.prototype.minWidth_changed;


/**
 * Set the min height of the InfoBubble
 *
 * @param {number} height The min height.
 */
InfoBubble.prototype.setMinHeight = function(height) {
  this.set('minHeight', height);
};
InfoBubble.prototype['setMinHeight'] = InfoBubble.prototype.setMinHeight;


/**
 * minHeight changed MVC callback
 */
InfoBubble.prototype.minHeight_changed = function() {
  this.redraw_();
};
InfoBubble.prototype['minHeight_changed'] =
    InfoBubble.prototype.minHeight_changed;


/**
 * Add a tab
 *
 * @param {string} label The label of the tab.
 * @param {string|Element} content The content of the tab.
 */
InfoBubble.prototype.addTab = function(label, content) {
  var tab = document.createElement('DIV');
  tab.innerHTML = label;

  this.setTabStyle_(tab);
  this.addTabActions_(tab);

  this.tabsContainer_.appendChild(tab);

  this.tabs_.push({
    label: label,
    content: content,
    tab: tab
  });

  tab.index = this.tabs_.length - 1;
  tab.style['zIndex'] = this.baseZIndex_ - tab.index;

  if (!this.activeTab_) {
    this.setTabActive_(tab);
  }

  tab.className = tab.className + ' ' + this.animationName_;

  this.redraw_();
};
InfoBubble.prototype['addTab'] = InfoBubble.prototype.addTab;

/**
 * Update a tab at a speicifc index
 *
 * @param {number} index The index of the tab.
 * @param {?string} opt_label The label to change to.
 * @param {?string} opt_content The content to update to.
 */
InfoBubble.prototype.updateTab = function(index, opt_label, opt_content) {
  if (!this.tabs_.length || index < 0 || index >= this.tabs_.length) {
    return;
  }

  var tab = this.tabs_[index];
  if (opt_label != undefined) {
    tab.tab.innerHTML = tab.label = opt_label;
  }

  if (opt_content != undefined) {
    tab.content = opt_content;
  }

  if (this.activeTab_ == tab.tab) {
    this.setContent(tab.content);
  }
  this.redraw_();
};
InfoBubble.prototype['updateTab'] = InfoBubble.prototype.updateTab;


/**
 * Remove a tab at a specific index
 *
 * @param {number} index The index of the tab to remove.
 */
InfoBubble.prototype.removeTab = function(index) {
  if (!this.tabs_.length || index < 0 || index >= this.tabs_.length) {
    return;
  }

  var tab = this.tabs_[index];
  tab.tab.parentNode.removeChild(tab.tab);

  google.maps.event.removeListener(tab.tab.listener_);

  this.tabs_.splice(index, 1);

  delete tab;

  for (var i = 0, t; t = this.tabs_[i]; i++) {
    t.tab.index = i;
  }

  if (tab.tab == this.activeTab_) {
    // Removing the current active tab
    if (this.tabs_[index]) {
      // Show the tab to the right
      this.activeTab_ = this.tabs_[index].tab;
    } else if (this.tabs_[index - 1]) {
      // Show a tab to the left
      this.activeTab_ = this.tabs_[index - 1].tab;
    } else {
      // No tabs left to sho
      this.activeTab_ = undefined;
    }

    this.setTabActive_(this.activeTab_);
  }

  this.redraw_();
};
InfoBubble.prototype['removeTab'] = InfoBubble.prototype.removeTab;


/**
 * Get the size of an element
 * @private
 * @param {Node|string} element The element to size.
 * @param {number=} opt_maxWidth Optional max width of the element.
 * @param {number=} opt_maxHeight Optional max height of the element.
 * @return {google.maps.Size} The size of the element.
 */
InfoBubble.prototype.getElementSize_ = function(element, opt_maxWidth,
                                                opt_maxHeight) {
  var sizer = document.createElement('DIV');
  sizer.style['display'] = 'inline';
  sizer.style['position'] = 'absolute';
  sizer.style['visibility'] = 'hidden';

  if (typeof element == 'string') {
    sizer.innerHTML = element;
  } else {
    sizer.appendChild(element.cloneNode(true));
  }

  document.body.appendChild(sizer);
  var size = new google.maps.Size(sizer.offsetWidth, sizer.offsetHeight);

  // If the width is bigger than the max width then set the width and size again
  if (opt_maxWidth && size.width > opt_maxWidth) {
    sizer.style['width'] = this.px(opt_maxWidth);
    size = new google.maps.Size(sizer.offsetWidth, sizer.offsetHeight);
  }

  // If the height is bigger than the max height then set the height and size
  // again
  if (opt_maxHeight && size.height > opt_maxHeight) {
    sizer.style['height'] = this.px(opt_maxHeight);
    size = new google.maps.Size(sizer.offsetWidth, sizer.offsetHeight);
  }

  document.body.removeChild(sizer);
  delete sizer;
  return size;
};


/**
 * Redraw the InfoBubble
 * @private
 */
InfoBubble.prototype.redraw_ = function() {
  this.figureOutSize_();
  this.positionCloseButton_();
  this.draw();
};


/**
 * Figure out the optimum size of the InfoBubble
 * @private
 */
InfoBubble.prototype.figureOutSize_ = function() {
  var map = this.get('map');

  if (!map) {
    return;
  }

  var padding = this.getPadding_();
  var borderWidth = this.getBorderWidth_();
  var borderRadius = this.getBorderRadius_();
  var arrowSize = this.getArrowSize_();

  var mapDiv = map.getDiv();
  var gutter = arrowSize * 2;
  var mapWidth = mapDiv.offsetWidth - gutter;
  var mapHeight = mapDiv.offsetHeight - gutter - this.getAnchorHeight_();
  var tabHeight = 0;
  var width = /** @type {number} */ (this.get('minWidth') || 0);
  var height = /** @type {number} */ (this.get('minHeight') || 0);
  var maxWidth = /** @type {number} */ (this.get('maxWidth') || 0);
  var maxHeight = /** @type {number} */ (this.get('maxHeight') || 0);

  maxWidth = Math.min(mapWidth, maxWidth);
  maxHeight = Math.min(mapHeight, maxHeight);

  var tabWidth = 0;
  if (this.tabs_.length) {
    // If there are tabs then you need to check the size of each tab's content
    for (var i = 0, tab; tab = this.tabs_[i]; i++) {
      var tabSize = this.getElementSize_(tab.tab, maxWidth, maxHeight);
      var contentSize = this.getElementSize_(tab.content, maxWidth, maxHeight);

      if (width < tabSize.width) {
        width = tabSize.width;
      }

      // Add up all the tab widths because they might end up being wider than
      // the content
      tabWidth += tabSize.width;

      if (height < tabSize.height) {
        height = tabSize.height;
      }

      if (tabSize.height > tabHeight) {
        tabHeight = tabSize.height;
      }

      if (width < contentSize.width) {
        width = contentSize.width;
      }

      if (height < contentSize.height) {
        height = contentSize.height;
      }
    }
  } else {
    var content = /** @type {string|Node} */ (this.get('content'));
    if (typeof content == 'string') {
      content = this.htmlToDocumentFragment_(content);
    }
    if (content) {
      var contentSize = this.getElementSize_(content, maxWidth, maxHeight);

      if (width < contentSize.width) {
        width = contentSize.width;
      }

      if (height < contentSize.height) {
        height = contentSize.height;
      }
    }
  }

  if (maxWidth) {
    width = Math.min(width, maxWidth);
  }

  if (maxHeight) {
    height = Math.min(height, maxHeight);
  }

  width = Math.max(width, tabWidth);

  if (width == tabWidth) {
    width = width + 2 * padding;
  }

  arrowSize = arrowSize * 2;
  width = Math.max(width, arrowSize);

  // Maybe add this as a option so they can go bigger than the map if the user
  // wants
  if (width > mapWidth) {
    width = mapWidth;
  }

  if (height > mapHeight) {
    height = mapHeight - tabHeight;
  }

  if (this.tabsContainer_) {
    this.tabHeight_ = tabHeight;
    this.tabsContainer_.style['width'] = this.px(tabWidth);
  }

  this.contentContainer_.style['width'] = this.px(width);
  this.contentContainer_.style['height'] = this.px(height);
};


/**
 *  Get the height of the anchor
 *
 *  This function is a hack for now and doesn't really work that good, need to
 *  wait for pixelBounds to be correctly exposed.
 *  @private
 *  @return {number} The height of the anchor.
 */
InfoBubble.prototype.getAnchorHeight_ = function() {
  var anchor = this.get('anchor');
  if (anchor) {
    var anchorPoint = /** @type google.maps.Point */(this.get('anchorPoint'));

    if (anchorPoint) {
      return -1 * anchorPoint.y;
    }
  }
  return 0;
};

InfoBubble.prototype.anchorPoint_changed = function() {
  this.draw();
};
InfoBubble.prototype['anchorPoint_changed'] = InfoBubble.prototype.anchorPoint_changed;


/**
 * Position the close button in the right spot.
 * @private
 */
InfoBubble.prototype.positionCloseButton_ = function() {
  var br = this.getBorderRadius_();
  var bw = this.getBorderWidth_();

  var right = 2;
  var top = 2;

  if (this.tabs_.length && this.tabHeight_) {
    top += this.tabHeight_;
  }

  top += bw;
  right += bw;

  var c = this.contentContainer_;
  if (c && c.clientHeight < c.scrollHeight) {
    // If there are scrollbars then move the cross in so it is not over
    // scrollbar
    right += 15;
  }

  this.close_.style['right'] = this.px(right);
  this.close_.style['top'] = this.px(top);
};

/***************************************************/


var Pogoda = {
		temp: null,
		windDir: null,
		windSpeed: null,
		presure: null,
		state: null
}

var poiPattern = {
	parking: 'n/a',
	hotel: 'n/a',
	wc: 'n/a',
	restaurant: 'n/a',
	gasStation: 'n/a',
	cafe: 'n/a'
};
// ppos punkty poboru op?at

      
var ppos1= [
    {
        name: 'PPO&nbsp;Tarnawa',
        coords:  new google.maps.LatLng(52.33518173393839,14.901022911071777),
        description: ['23&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','23&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'PPO&nbsp;Gołuski',
        coords:  new google.maps.LatLng(52.350480230160294,16.731812953948975),
        description: ['152&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','152&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'PPO&nbsp;Nagradowice',
        coords:  new google.maps.LatLng(52.31076134635855,17.15140700340271),
        description: ['181&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','181&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'PPO&nbsp;Lądek',
        coords:  new google.maps.LatLng(52.22185166339437,17.950791120529175),
        description: ['238&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','238&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    }
]      


var spos1= [
    {
        name: 'SPO&nbsp;Nowy Tomyśl',
        coords:  new google.maps.LatLng(52.35859270832136,16.09823226928711),
        description: ['108&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','108&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'SPO&nbsp;Trzciel',
        coords:  new google.maps.LatLng(52.32894501868009,15.871896743774414),
        description: ['91&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','91&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'SPO&nbsp;Jordanowo',
        coords:  new google.maps.LatLng(52.32400930869265,15.535354614257812),
        description: ['69&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','69&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'SPO&nbsp;Torzym',
        coords:  new google.maps.LatLng(52.325242085647034,15.085923671722412),
        description: ['26&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','26&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    }
] 

var ousas = [
    {
        name: 'OUA&nbsp;Kotowo',
        coords:  new google.maps.LatLng(52.351388889,16.843888889),
        description: ['160&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','160&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'OUA&nbsp;Sługocin ',
        coords:  new google.maps.LatLng(52.206666667,18.019444444),
        description: ['243&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','243&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'OUA&nbsp;Bolewice',
        coords:  new google.maps.LatLng(52.360555556,16.098055556),
        description: ['108&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','108&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'OUA&nbsp;Biały Mur',
        coords:  new google.maps.LatLng(52.298777031,15.652181206),
        description: ['76&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','76&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
        name: 'OUA&nbsp;Ilanka',
        coords:  new google.maps.LatLng(52.323438711,15.084758664),
        description: ['35&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka','35&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    }
]
//wezly drogowe
var roadNodes = [//obiekt wezlow drogowych
	
	{
		name:'Słupca',
		coords:	new google.maps.LatLng(52.253139,17.824673),
		type: 'fullNode',
        description:['229&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;wojewódzką&nbsp;nr&nbsp;466','229&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
    {
        name:'Kleszczewo', 
        coords: new google.maps.LatLng(52.320533741936586,17.11948871612549), 
        type: 'fullNode',
        description:['180&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie z drogą ekspresową nr S-5<br>oddanie do użytku - 06.2012','180&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
    },
    {
		name:'Głuchowo', 
		coords: new google.maps.LatLng(52.35050644411929,16.76786184310913), 
		type: 'fullNode',
        description:['154&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie z drogą ekspresową nr S-11<br>oddanie do użytku - 05.2012','154&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Modła',
		coords:	new google.maps.LatLng(52.162939,18.206812),
		type: 'fullNode',
        description:['257&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;krajową&nbsp;nr&nbsp;25','257&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Nowy Tomyśl',
		coords: new google.maps.LatLng(52.35859270832136,16.09823226928711),
		type: 'fullNode',
        description:['108&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;wojewódzką&nbsp;nr&nbsp;305','108&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Buk',
		coords: new google.maps.LatLng(52.376388889,16.566388889),
		type: 'fullNode',
                description:['140&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;wojewódzką&nbsp;nr&nbsp;307<br/>w okresie 01.12.11 -  20.05.12 Poznań - Buk, Buk - Poznań','140&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko<br/>between 01.12.2011 - 20.05.2012 Poznan - Beech, Beech - Poznan']
	},
	{
		name:'Komorniki',
		coords: new google.maps.LatLng(52.350277778,16.836944444),
		type: 'fullNode',
                description:['159&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;krajową&nbsp;nr&nbsp;5','159&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Dębina',
		coords: new google.maps.LatLng(52.353888889,	16.901944444),
		type: 'fullNode',
                description:['164&nbsp;km&nbspna&nbspwschód&nbspod&nbspŚwiecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;wojewódzką&nbsp;nr&nbsp;430','164&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Krzesiny',
		coords: new google.maps.LatLng(52.345833333,	16.999166667),
		type: 'fullNode',
         description:['170&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;krajową&nbsp;nr&nbsp;11','170&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Września',
		coords: new google.maps.LatLng(52.315277778,	17.533333333),
		type: 'fullNode',
                description:['208&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;krajową&nbsp;nr&nbsp;92','208&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
		name:'Sługocin',
		coords: new google.maps.LatLng(52.205000000,	18.021388889),
		type: 'fullNode',
                description:['243&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;wojewódzką&nbsp;nr&nbsp;467','243&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
                name:'Trzciel',
                coords: new google.maps.LatLng(52.32894501868009,15.871896743774414),
                type: 'fullNode',
                description:['91&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;powiatową&nbsp;F1339','91&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
                name:'Jordanowo',
                coords: new google.maps.LatLng(52.32400930869265,15.535354614257812),
                type: 'fullNode',
                description:['69&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Węzeł&nbsp;nieczynny&nbsp;do&nbsp;ukończenia<br>budowy&nbsp;drogi&nbsp;ekspresowej&nbsp;Nr3','69&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
                name:'Torzym',
                coords: new google.maps.LatLng(52.325242085647034,15.085923671722412),
                type: 'fullNode',
                description:['35&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;wojewódzką&nbsp;nr&nbsp;138','35&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
                name:'Rzepin',
                coords: new google.maps.LatLng(52.333398531374435,14.88072395324707),
                type: 'fullNode',
                description:['21&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>skrzyżowanie&nbsp;z&nbsp;DK&nbsp;Nr&nbsp;2<br>oraz&nbsp;drogą&nbsp;powiatową&nbsp;F1254','21&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	},
	{
                name:'Świecko',
                coords: new google.maps.LatLng(52.323484712336324,14.616494178771973),
                type: 'fullNode',
                description:['3&nbsp;km&nbsp;na&nbsp;wschód&nbsp;od&nbsp;Świecka<br>Skrzyżowanie&nbsp;z&nbsp;drogą&nbsp;krajową&nbsp;nr&nbsp;29','3&nbsp;km&nbsp;east&nbsp;of&nbsp;Świecko']
	}
];			 
			 

var infoBoxesData = [
	{
		namePl:'Gliniec', 
		cordinates: new google.maps.LatLng(52.325301 , 14.651295),
		contentEn: '5&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '5&nbsp;km&nbsp<br>od&nbsp;Świecka<br>planowane<br>otwarcie<br>04.2012',
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Sosna', 
		cordinates: new google.maps.LatLng(52.323948 , 14.653914), 
		contentEn: '5&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '5&nbsp;km&nbsp<br>od&nbsp;Świecka<br>planowane<br>otwarcie<br>04.2012',
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl: 'Chociszewo', 
		cordinates: new google.maps.LatLng(52.313384 , 15.781606), 
		contentEn: '85&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '85&nbsp;km&nbsp<br>od&nbsp;Świecka<br>planowane<br>otwarcie<br>05.2012', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Rogoziniec', 
		cordinates: new google.maps.LatLng(52.312423 , 15.782388), 
		contentEn: '85&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '85&nbsp;km&nbsp<br>od&nbsp;Świecka<br>planowane<br>otwarcie<br>05.2012', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Koryta', 
		cordinates: new google.maps.LatLng(52.32532 , 15.161596), 
		contentEn: '41&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '41&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
	{
		namePl:'Walewice', 
		cordinates: new google.maps.LatLng(52.326432 , 15.161907), 
		contentEn: '41&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '41&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
		{
		namePl:'Kozielaski', 
		cordinates: new google.maps.LatLng(52.3672222222222,16.1894444444444), 
		contentEn: '114&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '114&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
},
	{
		namePl:'Wytomyśl', 
		cordinates: new google.maps.LatLng(52.3680555555556,16.19), 
		contentEn: '114&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '114&nbsp;km&nbsp<br>od&nbsp;Świecka',  
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
},
	{
		namePl:'Zalesie', 
		cordinates: new google.maps.LatLng(52.3863888888889,16.4761111111111), 
		contentEn: '134&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '134&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Sędzinko', 
		cordinates: new google.maps.LatLng(52.3877777777778,16.475), 
		contentEn: '134&nbsp;km&nbsp;east<br>of&nbsp;Świecko', 
		contentPl: '134&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Konarzewo', 
		cordinates: new google.maps.LatLng(52.3494444444444,16.7141666666667), 
		contentEn: '151&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '151&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
			}
	},
	{
		namePl:'Krzyżowniki', 
		cordinates: new google.maps.LatLng(52.3275,17.0927777777778), 
		contentEn: '177&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '177&nbsp;km&nbsp<br>od&nbsp;Świecka',  
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Tulce', 
		cordinates: new google.maps.LatLng(52.32945162887316,17.092537879943848), 
		contentEn: '177&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '177&nbsp;km&nbsp<br>od&nbsp;Świecka',  
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Targowa&nbsp;Górka', 
		cordinates: new google.maps.LatLng(52.3175,17.4208333333333), 
		contentEn: '200&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '200&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
	{
		namePl:'Chwałszyce', 
		cordinates: new google.maps.LatLng(52.318592551880876,17.41830825805664), 
		contentEn: '200&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '200&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
	{
		namePl:'Gozdowo', 
		cordinates: new google.maps.LatLng(52.2936111111111,17.6525), 
		contentEn: '216&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '216&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
	{
		namePl:'Sołeczno', 
		cordinates: new google.maps.LatLng(52.2947222222222,17.6530555555556), 
		contentEn: '216&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '216&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
        {
		namePl:'Lądek', 
		cordinates: new google.maps.LatLng(52.22634048519531,17.931082248687744), 
		contentEn: '237&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '237&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
	{
		namePl:'Skarboszewo', 
		cordinates: new google.maps.LatLng(52.2611111111111,17.7883333333333), 
		contentEn: '226&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '226&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	},
        {
		namePl:'Osiecza&nbsp;II', 
		cordinates: new google.maps.LatLng(52.18,18.1244444444444), 
		contentEn: '251&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '251&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl: 'Osiecza&nbsp;III',
		cordinates: new google.maps.LatLng(52.1788888888889, 18.1216666666667),
		contentEn: '251&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '251&nbsp;km&nbsp<br>od&nbsp;Świecka', 
		pointerPosition: 'top',
		pattern: {
			parking: true,
			hotel: true,
			wc: true,
			restaurant: true,
			gasStation: true,
			cafe: true
		}
	},
	{
		namePl:'Dopiewiec', 
		cordinates: new google.maps.LatLng(52.3502777777778,16.7141666666667), 
		contentEn: '151&nbsp;km&nbsp;east<br>of&nbsp;Świecko',  
		contentPl: '151&nbsp;km&nbsp<br>od&nbsp;Świecka',   
		pointerPosition: 'bottom',
		pattern: {
			parking: true,
			hotel: false,
			wc: true,
			restaurant: false,
			gasStation: false,
			cafe: false
		}
	}
]

var roadSegements = [
    {
        name: 'AWSA',
        options: {
            strokeColor: "#7fbb0e",
            strokeOpacity: 1,
            strokeWeight: 3,
            path: [
			new google.maps.LatLng(52.359460000000006, 16.10404),
			new google.maps.LatLng(52.362350000000006, 16.11938),
			new google.maps.LatLng(52.363020000000006, 16.12358),
			new google.maps.LatLng(52.363670000000006, 16.12865),
			new google.maps.LatLng(52.3669, 16.16109),
			new google.maps.LatLng(52.36713, 16.163870000000003),
			new google.maps.LatLng(52.36732000000001, 16.167440000000003),
			new google.maps.LatLng(52.36741000000001, 16.17059),
			new google.maps.LatLng(52.367630000000005, 16.19),
			new google.maps.LatLng(52.368, 16.19623),
			new google.maps.LatLng(52.368500000000004, 16.20091),
			new google.maps.LatLng(52.36887, 16.2036),
			new google.maps.LatLng(52.3695, 16.207340000000002),
			new google.maps.LatLng(52.374810000000004, 16.23431),
			new google.maps.LatLng(52.375600000000006, 16.239530000000002),
			new google.maps.LatLng(52.376310000000004, 16.24615),
			new google.maps.LatLng(52.37666, 16.25147),
			new google.maps.LatLng(52.377370000000006, 16.27154),
			new google.maps.LatLng(52.37802000000001, 16.285880000000002),
			new google.maps.LatLng(52.382850000000005, 16.37357),
			new google.maps.LatLng(52.3834, 16.38024),
			new google.maps.LatLng(52.384130000000006, 16.38682),
			new google.maps.LatLng(52.38778000000001, 16.41232),
			new google.maps.LatLng(52.38870000000001, 16.42039),
			new google.maps.LatLng(52.389050000000005, 16.424400000000002),
			new google.maps.LatLng(52.389450000000004, 16.430580000000003),
			new google.maps.LatLng(52.38993000000001, 16.443250000000003),
			new google.maps.LatLng(52.389990000000004, 16.44807),
			new google.maps.LatLng(52.38991000000001, 16.451620000000002),
			new google.maps.LatLng(52.38978, 16.45427),
			new google.maps.LatLng(52.389320000000005, 16.45981),
			new google.maps.LatLng(52.388850000000005, 16.46358),
			new google.maps.LatLng(52.38725, 16.47428),
			new google.maps.LatLng(52.3868, 16.4783),
			new google.maps.LatLng(52.38658, 16.48141),
			new google.maps.LatLng(52.386410000000005, 16.486220000000003),
			new google.maps.LatLng(52.38645, 16.48959),
			new google.maps.LatLng(52.38741, 16.50766),
			new google.maps.LatLng(52.3875, 16.511760000000002),
			new google.maps.LatLng(52.387480000000004, 16.51424),
			new google.maps.LatLng(52.38731000000001, 16.51883),
			new google.maps.LatLng(52.38700000000001, 16.52298),
			new google.maps.LatLng(52.38646000000001, 16.52783),
			new google.maps.LatLng(52.38564, 16.53303),
			new google.maps.LatLng(52.384620000000005, 16.538),
			new google.maps.LatLng(52.383390000000006, 16.54279),
			new google.maps.LatLng(52.377230000000004, 16.56389),
			new google.maps.LatLng(52.37568, 16.56897),
			new google.maps.LatLng(52.374430000000004, 16.5728),
			new google.maps.LatLng(52.37268, 16.577910000000003),
			new google.maps.LatLng(52.370740000000005, 16.58323),
			new google.maps.LatLng(52.358560000000004, 16.6151),
			new google.maps.LatLng(52.35746, 16.618270000000003),
			new google.maps.LatLng(52.356370000000005, 16.621950000000002),
			new google.maps.LatLng(52.35542, 16.62583),
			new google.maps.LatLng(52.354560000000006, 16.630280000000003),
			new google.maps.LatLng(52.34928000000001, 16.664150000000003),
			new google.maps.LatLng(52.34893, 16.66685),
			new google.maps.LatLng(52.348620000000004, 16.67002),
			new google.maps.LatLng(52.34835, 16.6749),
			new google.maps.LatLng(52.34834000000001, 16.680200000000003),
			new google.maps.LatLng(52.34995000000001, 16.71883),
			new google.maps.LatLng(52.35025, 16.727890000000002),
			new google.maps.LatLng(52.350280000000005, 16.732120000000002),
			new google.maps.LatLng(52.350410000000004, 16.73627),
			new google.maps.LatLng(52.35022000000001, 16.834200000000003),
			new google.maps.LatLng(52.35027, 16.839080000000003),
			new google.maps.LatLng(52.35045, 16.84371),
			new google.maps.LatLng(52.350660000000005, 16.847240000000003),
			new google.maps.LatLng(52.351020000000005, 16.85173),
			new google.maps.LatLng(52.35148, 16.85595),
			new google.maps.LatLng(52.35374, 16.87293),
			new google.maps.LatLng(52.354130000000005, 16.876330000000003),
			new google.maps.LatLng(52.354580000000006, 16.883850000000002),
			new google.maps.LatLng(52.354580000000006, 16.888840000000002),
			new google.maps.LatLng(52.354440000000004, 16.89376),
			new google.maps.LatLng(52.35417, 16.89748),
			new google.maps.LatLng(52.346090000000004, 16.997390000000003),
			new google.maps.LatLng(52.34508, 17.00748),
			new google.maps.LatLng(52.34460000000001, 17.01143),
			new google.maps.LatLng(52.34339000000001, 17.02016),
			new google.maps.LatLng(52.341930000000005, 17.029040000000002),
			new google.maps.LatLng(52.339690000000004, 17.040580000000002),
			new google.maps.LatLng(52.33223, 17.076610000000002),
			new google.maps.LatLng(52.33088000000001, 17.08277),
			new google.maps.LatLng(52.32875000000001, 17.09156),
			new google.maps.LatLng(52.327650000000006, 17.09562),
			new google.maps.LatLng(52.325680000000006, 17.102430000000002),
			new google.maps.LatLng(52.31172, 17.14729),
			new google.maps.LatLng(52.31036, 17.15143),
			new google.maps.LatLng(52.309900000000006, 17.15407),
			new google.maps.LatLng(52.30892000000001, 17.158890000000003),
			new google.maps.LatLng(52.308350000000004, 17.16234),
			new google.maps.LatLng(52.30780000000001, 17.166520000000002),
			new google.maps.LatLng(52.30733000000001, 17.17169),
			new google.maps.LatLng(52.307140000000004, 17.17539),
			new google.maps.LatLng(52.30706000000001, 17.178710000000002),
			new google.maps.LatLng(52.307120000000005, 17.18366),
			new google.maps.LatLng(52.307300000000005, 17.18736),
			new google.maps.LatLng(52.30776, 17.19274),
			new google.maps.LatLng(52.308150000000005, 17.1959),
			new google.maps.LatLng(52.30926, 17.20363),
			new google.maps.LatLng(52.30966, 17.20726),
			new google.maps.LatLng(52.31004, 17.212600000000002),
			new google.maps.LatLng(52.31017000000001, 17.217000000000002),
			new google.maps.LatLng(52.30979000000001, 17.348860000000002),
			new google.maps.LatLng(52.30982, 17.354740000000003),
			new google.maps.LatLng(52.31006000000001, 17.36193),
			new google.maps.LatLng(52.31031, 17.366300000000003),
			new google.maps.LatLng(52.31074, 17.371830000000003),
			new google.maps.LatLng(52.31127000000001, 17.37706),
			new google.maps.LatLng(52.31192000000001, 17.382270000000002),
			new google.maps.LatLng(52.312990000000006, 17.38934),
			new google.maps.LatLng(52.316750000000006, 17.41064),
			new google.maps.LatLng(52.317310000000006, 17.41429),
			new google.maps.LatLng(52.317780000000006, 17.417930000000002),
			new google.maps.LatLng(52.31828, 17.42284),
			new google.maps.LatLng(52.318580000000004, 17.42651),
			new google.maps.LatLng(52.318940000000005, 17.43412),
			new google.maps.LatLng(52.31899000000001, 17.440900000000003),
			new google.maps.LatLng(52.31803000000001, 17.50446),
			new google.maps.LatLng(52.31783000000001, 17.51086),
			new google.maps.LatLng(52.317420000000006, 17.517110000000002),
			new google.maps.LatLng(52.31685, 17.522730000000003),
			new google.maps.LatLng(52.316, 17.52898),
			new google.maps.LatLng(52.314980000000006, 17.534830000000003),
			new google.maps.LatLng(52.311730000000004, 17.551910000000003),
			new google.maps.LatLng(52.31116, 17.55524),
			new google.maps.LatLng(52.310810000000004, 17.55787),
			new google.maps.LatLng(52.31053000000001, 17.56015),
			new google.maps.LatLng(52.31018, 17.564510000000002),
			new google.maps.LatLng(52.309110000000004, 17.58201),
			new google.maps.LatLng(52.30883000000001, 17.58554),
			new google.maps.LatLng(52.308170000000004, 17.590780000000002),
			new google.maps.LatLng(52.307640000000006, 17.594070000000002),
			new google.maps.LatLng(52.307100000000005, 17.5969),
			new google.maps.LatLng(52.29412000000001, 17.65362),
			new google.maps.LatLng(52.292660000000005, 17.65943),
			new google.maps.LatLng(52.29144, 17.663790000000002),
			new google.maps.LatLng(52.289680000000004, 17.669410000000003),
			new google.maps.LatLng(52.28853, 17.67276),
			new google.maps.LatLng(52.28708, 17.67669),
			new google.maps.LatLng(52.27722000000001, 17.70118),
			new google.maps.LatLng(52.27423, 17.70899),
			new google.maps.LatLng(52.27228, 17.714660000000002),
			new google.maps.LatLng(52.270970000000005, 17.718950000000003),
			new google.maps.LatLng(52.26917, 17.72551),
			new google.maps.LatLng(52.26834, 17.72884),
			new google.maps.LatLng(52.267320000000005, 17.73339),
			new google.maps.LatLng(52.26644, 17.737820000000003),
			new google.maps.LatLng(52.26549000000001, 17.74331),
			new google.maps.LatLng(52.26484000000001, 17.74774),
			new google.maps.LatLng(52.264010000000006, 17.75447),
			new google.maps.LatLng(52.26203, 17.77493),
			new google.maps.LatLng(52.261500000000005, 17.778740000000003),
			new google.maps.LatLng(52.260810000000006, 17.78283),
			new google.maps.LatLng(52.2573, 17.80261),
			new google.maps.LatLng(52.255610000000004, 17.81163),
			new google.maps.LatLng(52.253640000000004, 17.82167),
			new google.maps.LatLng(52.25216, 17.82891),
			new google.maps.LatLng(52.249930000000006, 17.83933),
			new google.maps.LatLng(52.248380000000004, 17.846320000000002),
			new google.maps.LatLng(52.24593, 17.856900000000003),
			new google.maps.LatLng(52.24268000000001, 17.870230000000003),
			new google.maps.LatLng(52.24063, 17.87798),
			new google.maps.LatLng(52.23921000000001, 17.882460000000002),
			new google.maps.LatLng(52.236250000000005, 17.890710000000002),
			new google.maps.LatLng(52.234570000000005, 17.8956),
			new google.maps.LatLng(52.233430000000006, 17.899250000000002),
			new google.maps.LatLng(52.23223, 17.903550000000003),
			new google.maps.LatLng(52.23064, 17.910230000000002),
			new google.maps.LatLng(52.22688, 17.929640000000003),
			new google.maps.LatLng(52.224740000000004, 17.93946),
			new google.maps.LatLng(52.22316000000001, 17.94591),
			new google.maps.LatLng(52.22164, 17.95081),
			new google.maps.LatLng(52.22124, 17.95232),
			new google.maps.LatLng(52.22059, 17.955250000000003),
			new google.maps.LatLng(52.216950000000004, 17.968140000000002),
			new google.maps.LatLng(52.21399, 17.979740000000003),
			new google.maps.LatLng(52.21284000000001, 17.984620000000003),
			new google.maps.LatLng(52.21128, 17.991670000000003),
			new google.maps.LatLng(52.206880000000005, 18.01328),
			new google.maps.LatLng(52.20562, 18.01884),
			new google.maps.LatLng(52.20423, 18.024130000000003),
			new google.maps.LatLng(52.203100000000006, 18.027890000000003),
			new google.maps.LatLng(52.20168, 18.03218),
			new google.maps.LatLng(52.19809000000001, 18.042370000000002),
			new google.maps.LatLng(52.196450000000006, 18.04768),
			new google.maps.LatLng(52.19543, 18.05167),
			new google.maps.LatLng(52.194860000000006, 18.05423),
			new google.maps.LatLng(52.192690000000006, 18.06578),
			new google.maps.LatLng(52.1916, 18.07065),
			new google.maps.LatLng(52.19012000000001, 18.075940000000003),
			new google.maps.LatLng(52.18807, 18.08218),
			new google.maps.LatLng(52.18717, 18.0852),
			new google.maps.LatLng(52.18524000000001, 18.09243),
			new google.maps.LatLng(52.18394000000001, 18.097630000000002),
			new google.maps.LatLng(52.18289000000001, 18.10235),
			new google.maps.LatLng(52.182170000000006, 18.106090000000002),
			new google.maps.LatLng(52.181360000000005, 18.110870000000002),
			new google.maps.LatLng(52.18009000000001, 18.119510000000002),
			new google.maps.LatLng(52.179030000000004, 18.1259),
			new google.maps.LatLng(52.178430000000006, 18.128970000000002),
			new google.maps.LatLng(52.17714, 18.13464),
			new google.maps.LatLng(52.173500000000004, 18.149510000000003),
			new google.maps.LatLng(52.17219000000001, 18.15512),
			new google.maps.LatLng(52.17058, 18.16241),
			new google.maps.LatLng(52.1687, 18.17161),
			new google.maps.LatLng(52.166630000000005, 18.18278),
			new google.maps.LatLng(52.16353, 18.201810000000002),
			new google.maps.LatLng(52.163160000000005, 18.203380000000003),
			new google.maps.LatLng(52.16304, 18.20416),
                        new google.maps.LatLng(52.162939,18.206812)]
            }
    },
    {
    name: 'GDDKIA',
    options: {
        strokeColor: "#014693",
        strokeOpacity: 1,
        strokeWeight: 3,
        path:[
					new google.maps.LatLng(52.162939,18.206812),
					new google.maps.LatLng(52.162310000000005, 18.21027),
					new google.maps.LatLng(52.16208, 18.21283),
					new google.maps.LatLng(52.16181, 18.21791),
					new google.maps.LatLng(52.16019000000001, 18.24114),
					new google.maps.LatLng(52.159710000000004, 18.24659),
					new google.maps.LatLng(52.159380000000006, 18.24942),
					new google.maps.LatLng(52.15876, 18.25365),
					new google.maps.LatLng(52.15802000000001, 18.25767),
					new google.maps.LatLng(52.15713, 18.261740000000003),
					new google.maps.LatLng(52.1559, 18.266360000000002),
					new google.maps.LatLng(52.15395, 18.272930000000002),
					new google.maps.LatLng(52.15173000000001, 18.28009),
					new google.maps.LatLng(52.15048, 18.28517),
					new google.maps.LatLng(52.14958000000001,18.289530000000003),
					new google.maps.LatLng(52.149150000000006,18.292070000000002),
					new google.maps.LatLng(52.148610000000005,18.296120000000002),
					new google.maps.LatLng(52.14734000000001,18.307280000000002),
					new google.maps.LatLng(52.146950000000004,18.310080000000003),
					new google.maps.LatLng(52.146440000000005, 18.31313),
					new google.maps.LatLng(52.14537000000001, 18.31846),
					new google.maps.LatLng(52.14269, 18.32977),
					new google.maps.LatLng(52.14182, 18.33405),
					new google.maps.LatLng(52.141090000000005, 18.33865),
					new google.maps.LatLng(52.14076000000001, 18.34136),
					new google.maps.LatLng(52.14032, 18.346480000000003),
					new google.maps.LatLng(52.140100000000004, 18.35095),
					new google.maps.LatLng(52.140080000000005,18.352870000000003),
					new google.maps.LatLng(52.14011000000001,18.357650000000003),
					new google.maps.LatLng(52.140280000000004, 18.36145),
					new google.maps.LatLng(52.140820000000005, 18.36841),
					new google.maps.LatLng(52.14193, 18.380010000000002),
					new google.maps.LatLng(52.14226000000001, 18.38624),
					new google.maps.LatLng(52.14267, 18.398690000000002),
					new google.maps.LatLng(52.14302000000001,18.404130000000002),
					new google.maps.LatLng(52.14321, 18.40614),
					new google.maps.LatLng(52.14392, 18.41141),
					new google.maps.LatLng(52.144760000000005,18.416240000000002),
					new google.maps.LatLng(52.14987000000001,18.441010000000002),
					new google.maps.LatLng(52.15075, 18.445600000000002),
					new google.maps.LatLng(52.15128000000001,18.448990000000002),
					new google.maps.LatLng(52.15156, 18.450870000000002),
					new google.maps.LatLng(52.151880000000006, 18.4537),
					new google.maps.LatLng(52.152300000000004,18.458060000000003),
					new google.maps.LatLng(52.15254, 18.462670000000003),
					new google.maps.LatLng(52.15260000000001,18.466820000000002),
					new google.maps.LatLng(52.15256, 18.46956),
					new google.maps.LatLng(52.152420000000006, 18.47267),
					new google.maps.LatLng(52.15207, 18.47762),
					new google.maps.LatLng(52.15167, 18.481430000000003),
					new google.maps.LatLng(52.15124, 18.48441),
					new google.maps.LatLng(52.15059, 18.48835),
					new google.maps.LatLng(52.14988, 18.49181),
					new google.maps.LatLng(52.145790000000005, 18.50908),
					new google.maps.LatLng(52.14444, 18.51537),
					new google.maps.LatLng(52.14347000000001, 18.52063),
					new google.maps.LatLng(52.14309, 18.52316),
					new google.maps.LatLng(52.14244000000001, 18.52822),
					new google.maps.LatLng(52.141960000000005, 18.53312),
					new google.maps.LatLng(52.141510000000004, 18.54017),
					new google.maps.LatLng(52.14139, 18.548370000000002),
					new google.maps.LatLng(52.141450000000006, 18.55309),
					new google.maps.LatLng(52.142100000000006, 18.5805),
					new google.maps.LatLng(52.14209, 18.584770000000002),
					new google.maps.LatLng(52.141920000000006, 18.59131),
					new google.maps.LatLng(52.14143000000001,
							18.599140000000002),
					new google.maps.LatLng(52.14083, 18.605030000000003),
					new google.maps.LatLng(52.14032, 18.60919),
					new google.maps.LatLng(52.139810000000004,
							18.612640000000003),
					new google.maps.LatLng(52.138960000000004,
							18.617530000000002),
					new google.maps.LatLng(52.13799, 18.622320000000002),
					new google.maps.LatLng(52.136720000000004, 18.62769),
					new google.maps.LatLng(52.133660000000006, 18.63906),
					new google.maps.LatLng(52.132760000000005, 18.64264),
					new google.maps.LatLng(52.13149000000001, 18.64852),
					new google.maps.LatLng(52.129560000000005,
							18.659170000000003),
					new google.maps.LatLng(52.128370000000004,
							18.664800000000003),
					new google.maps.LatLng(52.127, 18.669980000000002),
					new google.maps.LatLng(52.12429, 18.67895),
					new google.maps.LatLng(52.123270000000005,
							18.682740000000003),
					new google.maps.LatLng(52.12259, 18.685740000000003),
					new google.maps.LatLng(52.12176, 18.69001),
					new google.maps.LatLng(52.12122, 18.693340000000003),
					new google.maps.LatLng(52.120630000000006, 18.69782),
					new google.maps.LatLng(52.118790000000004, 18.71355),
					new google.maps.LatLng(52.11795000000001, 18.71882),
					new google.maps.LatLng(52.11733, 18.721970000000002),
					new google.maps.LatLng(52.116240000000005, 18.72669),
					new google.maps.LatLng(52.115520000000004, 18.72934),
					new google.maps.LatLng(52.11408, 18.73386),
					new google.maps.LatLng(52.112370000000006,
							18.738470000000003),
					new google.maps.LatLng(52.11102, 18.74163),
					new google.maps.LatLng(52.10943, 18.744880000000002),
					new google.maps.LatLng(52.104710000000004,
							18.753960000000003),
					new google.maps.LatLng(52.102700000000006, 18.75822),
					new google.maps.LatLng(52.10043, 18.7637),
					new google.maps.LatLng(52.09723, 18.772080000000003),
					new google.maps.LatLng(52.096090000000004, 18.77486),
					new google.maps.LatLng(52.094350000000006,
							18.778640000000003),
					new google.maps.LatLng(52.092470000000006,
							18.782210000000003),
					new google.maps.LatLng(52.09120000000001, 18.7844),
					new google.maps.LatLng(52.0889, 18.78789),
					new google.maps.LatLng(52.08715, 18.790280000000003),
					new google.maps.LatLng(52.0816, 18.797030000000003),
					new google.maps.LatLng(52.07938000000001, 18.79989),
					new google.maps.LatLng(52.07733, 18.80284),
					new google.maps.LatLng(52.07538, 18.80592),
					new google.maps.LatLng(52.073750000000004, 18.8088),
					new google.maps.LatLng(52.07206000000001, 18.81199),
					new google.maps.LatLng(52.068360000000006, 18.81982),
					new google.maps.LatLng(52.06680000000001, 18.82291),
					new google.maps.LatLng(52.06575, 18.824900000000003),
					new google.maps.LatLng(52.06392, 18.82806),
					new google.maps.LatLng(52.062000000000005, 18.83104),
					new google.maps.LatLng(52.05913, 18.8353),
					new google.maps.LatLng(52.051010000000005,
							18.847150000000003),
					new google.maps.LatLng(52.04643, 18.853990000000003),
					new google.maps.LatLng(52.043980000000005,
							18.857850000000003),
					new google.maps.LatLng(52.04262000000001, 18.86015),
					new google.maps.LatLng(52.04046, 18.86417),
					new google.maps.LatLng(52.03909, 18.86702),
					new google.maps.LatLng(52.037850000000006, 18.86982),
					new google.maps.LatLng(52.036170000000006,
							18.874010000000002),
					new google.maps.LatLng(52.03488, 18.877670000000002),
					new google.maps.LatLng(52.03372, 18.881300000000003),
					new google.maps.LatLng(52.03237000000001, 18.88615),
					new google.maps.LatLng(52.03154000000001, 18.88945),
					new google.maps.LatLng(52.0275, 18.909090000000003),
					new google.maps.LatLng(52.026390000000006, 18.91395),
					new google.maps.LatLng(52.02561000000001, 18.91692),
					new google.maps.LatLng(52.02478000000001, 18.91972),
					new google.maps.LatLng(52.017540000000004, 18.94133),
					new google.maps.LatLng(52.016160000000006,
							18.945780000000003),
					new google.maps.LatLng(52.01549000000001,
							18.948140000000002),
					new google.maps.LatLng(52.014920000000004, 18.95052),
					new google.maps.LatLng(52.012260000000005, 18.96292),
					new google.maps.LatLng(52.011030000000005,
							18.967840000000002),
					new google.maps.LatLng(52.009600000000006,
							18.972550000000002),
					new google.maps.LatLng(52.00600000000001, 18.98278),
					new google.maps.LatLng(52.004220000000004, 18.98808),
					new google.maps.LatLng(52.002860000000005,
							18.992610000000003),
					new google.maps.LatLng(52.00155, 18.99762),
					new google.maps.LatLng(52.000310000000006,
							19.003110000000003),
					new google.maps.LatLng(51.99929, 19.008830000000003),
					new google.maps.LatLng(51.998650000000005,
							19.013060000000003),
					new google.maps.LatLng(51.996210000000005, 19.03096),
					new google.maps.LatLng(51.9958, 19.03337),
					new google.maps.LatLng(51.994640000000004, 19.0392),
					new google.maps.LatLng(51.993320000000004, 19.04446),
					new google.maps.LatLng(51.99242, 19.04736),
					new google.maps.LatLng(51.99125, 19.050790000000003),
					new google.maps.LatLng(51.989990000000006, 19.05403),
					new google.maps.LatLng(51.988530000000004,
							19.057440000000003),
					new google.maps.LatLng(51.9868, 19.061),
					new google.maps.LatLng(51.98453000000001, 19.06513),
					new google.maps.LatLng(51.979780000000005, 19.0732),
					new google.maps.LatLng(51.976470000000006,
							19.079220000000003),
					new google.maps.LatLng(51.97379, 19.084880000000002),
					new google.maps.LatLng(51.971650000000004, 19.09017),
					new google.maps.LatLng(51.96952, 19.09653),
					new google.maps.LatLng(51.96645, 19.10726),
					new google.maps.LatLng(51.96452000000001,
							19.113380000000003),
					new google.maps.LatLng(51.96303, 19.11731),
					new google.maps.LatLng(51.959790000000005, 19.12516),
					new google.maps.LatLng(51.95843000000001,
							19.128610000000002),
					new google.maps.LatLng(51.956880000000005,
							19.133080000000003),
					new google.maps.LatLng(51.956, 19.136080000000003),
					new google.maps.LatLng(51.954840000000004, 19.14057),
					new google.maps.LatLng(51.95239, 19.152410000000003),
					new google.maps.LatLng(51.95107, 19.15794),
					new google.maps.LatLng(51.94953, 19.16319),
					new google.maps.LatLng(51.944880000000005, 19.17685),
					new google.maps.LatLng(51.94371, 19.180850000000003),
					new google.maps.LatLng(51.942660000000004,
							19.184880000000003),
					new google.maps.LatLng(51.94154, 19.190260000000002),
					new google.maps.LatLng(51.94075, 19.19506),
					new google.maps.LatLng(51.94037, 19.198230000000002),
					new google.maps.LatLng(51.939960000000006, 19.20315),
					new google.maps.LatLng(51.939690000000006, 19.21029),
					new google.maps.LatLng(51.93972, 19.22663),
					new google.maps.LatLng(51.939460000000004, 19.23338),
					new google.maps.LatLng(51.938900000000004,
							19.239330000000002),
					new google.maps.LatLng(51.937760000000004,
							19.247860000000003),
					new google.maps.LatLng(51.93565, 19.26266),
					new google.maps.LatLng(51.934850000000004,
							19.267660000000003),
					new google.maps.LatLng(51.93392000000001, 19.2724),
					new google.maps.LatLng(51.93074000000001, 19.28674),
					new google.maps.LatLng(51.930150000000005, 19.28969),
					new google.maps.LatLng(51.92943, 19.294220000000003),
					new google.maps.LatLng(51.92904000000001, 19.29737),
					new google.maps.LatLng(51.92871, 19.30075),
					new google.maps.LatLng(51.9279, 19.31325),
					new google.maps.LatLng(51.92737, 19.31847),
					new google.maps.LatLng(51.926970000000004, 19.32147),
					new google.maps.LatLng(51.92631, 19.325370000000003),
					new google.maps.LatLng(51.924870000000006, 19.33254),
					new google.maps.LatLng(51.92378, 19.338600000000003),
					new google.maps.LatLng(51.92306000000001,
							19.343410000000002),
					new google.maps.LatLng(51.92203000000001, 19.35162),
					new google.maps.LatLng(51.92146, 19.35903),
					new google.maps.LatLng(51.921150000000004,
							19.366010000000003),
					new google.maps.LatLng(51.92107000000001, 19.37111),
					new google.maps.LatLng(51.92114, 19.381040000000002),
					new google.maps.LatLng(51.9211, 19.38567),
					new google.maps.LatLng(51.92092, 19.39112),
					new google.maps.LatLng(51.92071000000001,
							19.394620000000003),
					new google.maps.LatLng(51.92027, 19.39949),
					new google.maps.LatLng(51.9196, 19.404690000000002),
					new google.maps.LatLng(51.91864, 19.41037),
					new google.maps.LatLng(51.91762000000001, 19.41535),
					new google.maps.LatLng(51.916290000000004,
							19.420740000000002),
					new google.maps.LatLng(51.914910000000006, 19.42549),
					new google.maps.LatLng(51.91274000000001, 19.43177),
					new google.maps.LatLng(51.904830000000004,
							19.451430000000002),
					new google.maps.LatLng(51.903620000000004, 19.45466),
					new google.maps.LatLng(51.90267000000001, 19.45749),
					new google.maps.LatLng(51.90126000000001,
							19.462310000000002),
					new google.maps.LatLng(51.90014000000001, 19.46702),
					new google.maps.LatLng(51.899170000000005, 19.47247),
					new google.maps.LatLng(51.898700000000005, 19.47559),
					new google.maps.LatLng(51.8982, 19.480300000000003),
					new google.maps.LatLng(51.89786, 19.48543),
					new google.maps.LatLng(51.897780000000004, 19.49096),
					new google.maps.LatLng(51.898230000000005, 19.50843),
					new google.maps.LatLng(51.89818, 19.51659),
					new google.maps.LatLng(51.897870000000005, 19.52307),
					new google.maps.LatLng(51.89748, 19.527910000000002),
					new google.maps.LatLng(51.89712, 19.53152),
					new google.maps.LatLng(51.896280000000004,
							19.537850000000002),
					new google.maps.LatLng(51.89479000000001,
							19.546680000000002),
					new google.maps.LatLng(51.89014, 19.57158),
					new google.maps.LatLng(51.88947, 19.57589),
					new google.maps.LatLng(51.889120000000005,
							19.578670000000002),
					new google.maps.LatLng(51.88866, 19.583640000000003)
                                    ]
    }
},
    {
        name: 'in-bulid',
        options: {
            //strokeColor: "#FF0000",
            strokeColor: "#7fbb0e",
            strokeOpacity: 1,
            strokeWeight: 3,
            path: [
            new google.maps.LatLng(52.315523,14.577875),
            new google.maps.LatLng(52.316441,14.588131),
            new google.maps.LatLng(52.316677,14.590234),
            new google.maps.LatLng(52.317359,14.594097),
            new google.maps.LatLng(52.317910,14.595985),
            new google.maps.LatLng(52.320638,14.605984),
            new google.maps.LatLng(52.323419,14.616370),
            new google.maps.LatLng(52.325176,14.623022),
            new google.maps.LatLng(52.325806,14.626412),
            new google.maps.LatLng(52.326120,14.629158),
            new google.maps.LatLng(52.326278,14.633150),
            new google.maps.LatLng(52.326120,14.636669),
            new google.maps.LatLng(52.325425,14.643878),
            new google.maps.LatLng(52.324612,14.652419),
            new google.maps.LatLng(52.323996,14.660551),
            new google.maps.LatLng(52.324193,14.666709),
            new google.maps.LatLng(52.324691,14.671967),
            new google.maps.LatLng(52.325543,14.678211),
            new google.maps.LatLng(52.326488,14.685721),
            new google.maps.LatLng(52.327865,14.696364),
            new google.maps.LatLng(52.328796,14.703509),
            new google.maps.LatLng(52.329687,14.710311),
            new google.maps.LatLng(52.330553,14.717221),
            new google.maps.LatLng(52.331392,14.723830),
            new google.maps.LatLng(52.332349,14.731233),
            new google.maps.LatLng(52.333083,14.737091),
            new google.maps.LatLng(52.333896,14.743399),
            new google.maps.LatLng(52.334578,14.748806),
            new google.maps.LatLng(52.334945,14.752390),
            new google.maps.LatLng(52.335181,14.757454),
            new google.maps.LatLng(52.335221,14.764106),
            new google.maps.LatLng(52.335404,14.775521),
            new google.maps.LatLng(52.335417,14.781615),
            new google.maps.LatLng(52.335470,14.790627),
            new google.maps.LatLng(52.335470,14.797537),
            new google.maps.LatLng(52.335417,14.801142),
            new google.maps.LatLng(52.334985,14.804983),
            new google.maps.LatLng(52.333975,14.810390),
            new google.maps.LatLng(52.332651,14.817514),
            new google.maps.LatLng(52.331431,14.824316),
            new google.maps.LatLng(52.330120,14.830861),
            new google.maps.LatLng(52.328809,14.838542),
            new google.maps.LatLng(52.328573,14.842255),
            new google.maps.LatLng(52.328914,14.847898),
            new google.maps.LatLng(52.329451,14.851481),
            new google.maps.LatLng(52.330723,14.859163),
            new google.maps.LatLng(52.331772,14.865000),
            new google.maps.LatLng(52.332887,14.871973),
            new google.maps.LatLng(52.333582,14.879033),
            new google.maps.LatLng(52.334382,14.882831),
            new google.maps.LatLng(52.335116,14.888839),
            new google.maps.LatLng(52.335142,14.893453),
            new google.maps.LatLng(52.334985,14.901671),
            new google.maps.LatLng(52.334657,14.907529),
            new google.maps.LatLng(52.334250,14.911992),
            new google.maps.LatLng(52.334132,14.916284),
            new google.maps.LatLng(52.334329,14.921433),
            new google.maps.LatLng(52.335208,14.927914),
            new google.maps.LatLng(52.336322,14.933814),
            new google.maps.LatLng(52.337266,14.939115),
            new google.maps.LatLng(52.338459,14.946045),
            new google.maps.LatLng(52.338826,14.950573),
            new google.maps.LatLng(52.338682,14.955766),
            new google.maps.LatLng(52.337948,14.960658),
            new google.maps.LatLng(52.336899,14.965293),
            new google.maps.LatLng(52.335431,14.970958),
            new google.maps.LatLng(52.334382,14.976193),
            new google.maps.LatLng(52.333149,14.983017),
            new google.maps.LatLng(52.332703,14.990270),
            new google.maps.LatLng(52.332625,14.998252),
            new google.maps.LatLng(52.332625,15.003316),
            new google.maps.LatLng(52.332834,15.013487),
            new google.maps.LatLng(52.332834,15.017821),
            new google.maps.LatLng(52.332074,15.023100),
            new google.maps.LatLng(52.331051,15.029451),
            new google.maps.LatLng(52.329661,15.035502),
            new google.maps.LatLng(52.326671,15.049922),
            new google.maps.LatLng(52.325124,15.059406),
            new google.maps.LatLng(52.324783,15.065543),
            new google.maps.LatLng(52.325124,15.079233),
            new google.maps.LatLng(52.325334,15.095927),
            new google.maps.LatLng(52.326173,15.116097),
            new google.maps.LatLng(52.326619,15.131676),
            new google.maps.LatLng(52.326960,15.144550),
            new google.maps.LatLng(52.326383,15.153391),
            new google.maps.LatLng(52.325360,15.162360),
            new google.maps.LatLng(52.324416,15.174891),
            new google.maps.LatLng(52.322737,15.187766),
            new google.maps.LatLng(52.319956,15.192830),
            new google.maps.LatLng(52.316494,15.199525),
            new google.maps.LatLng(52.313162,15.208709),
            new google.maps.LatLng(52.311850,15.215747),
            new google.maps.LatLng(52.311456,15.219352),
            new google.maps.LatLng(52.310905,15.226089),
            new google.maps.LatLng(52.310276,15.237419),
            new google.maps.LatLng(52.308964,15.244371),
            new google.maps.LatLng(52.306209,15.251452),
            new google.maps.LatLng(52.302115,15.256860),
            new google.maps.LatLng(52.299281,15.260636),
            new google.maps.LatLng(52.297916,15.262954),
            new google.maps.LatLng(52.296394,15.267460),
            new google.maps.LatLng(52.294871,15.275657),
            new google.maps.LatLng(52.294609,15.283038),
            new google.maps.LatLng(52.294976,15.291492),
            new google.maps.LatLng(52.303453,15.319559),//sdsd
            new google.maps.LatLng(52.306392,15.337755),
            new google.maps.LatLng(52.311640,15.358011),
            new google.maps.LatLng(52.315575,15.375735),
            new google.maps.LatLng(52.317779,15.386207),
            new google.maps.LatLng(52.319038,15.394446),
            new google.maps.LatLng(52.319038,15.404403),
            new google.maps.LatLng(52.318723,15.416076),
            new google.maps.LatLng(52.318304,15.426547),
            new google.maps.LatLng(52.317884,15.435988),
            new google.maps.LatLng(52.317464,15.441825),
            new google.maps.LatLng(52.316835,15.451953),
            new google.maps.LatLng(52.316835,15.461566),
            new google.maps.LatLng(52.317359,15.473754),
            new google.maps.LatLng(52.318828,15.486800),
            new google.maps.LatLng(52.319773,15.497100),
            new google.maps.LatLng(52.321032,15.507056),
            new google.maps.LatLng(52.322815,15.519587),
            new google.maps.LatLng(52.323497,15.527055),
            new google.maps.LatLng(52.324022,15.533063),
            new google.maps.LatLng(52.324363,15.538084),
            new google.maps.LatLng(52.324258,15.543320),
            new google.maps.LatLng(52.323760,15.551087),
            new google.maps.LatLng(52.322212,15.560657),
            new google.maps.LatLng(52.319694,15.573060),
            new google.maps.LatLng(52.318776,15.578639),
            new google.maps.LatLng(52.316887,15.588810),
            new google.maps.LatLng(52.314893,15.598680),
            new google.maps.LatLng(52.312007,15.610525),
            new google.maps.LatLng(52.308832,15.621769),
            new google.maps.LatLng(52.305159,15.634086),
            new google.maps.LatLng(52.300619,15.649921),
            new google.maps.LatLng(52.299412,15.656316),
            new google.maps.LatLng(52.298651,15.663397),
            new google.maps.LatLng(52.297837,15.677773),
            new google.maps.LatLng(52.297286,15.689704),
            new google.maps.LatLng(52.296892,15.703008),
            new google.maps.LatLng(52.296840,15.714337),
            new google.maps.LatLng(52.297443,15.721676),
            new google.maps.LatLng(52.298205,15.727598),
            new google.maps.LatLng(52.299543,15.734765),
            new google.maps.LatLng(52.301695,15.743906),
            new google.maps.LatLng(52.304136,15.752317),
            new google.maps.LatLng(52.308465,15.766780),
            new google.maps.LatLng(52.311640,15.777080),
            new google.maps.LatLng(52.314919,15.786435),
            new google.maps.LatLng(52.316756,15.793645),
            new google.maps.LatLng(52.321661,15.810039),
            new google.maps.LatLng(52.325229,15.822355),
            new google.maps.LatLng(52.326933,15.830767),
            new google.maps.LatLng(52.328428,15.842182),
            new google.maps.LatLng(52.328979,15.854670),
            new google.maps.LatLng(52.328927,15.866773),
            new google.maps.LatLng(52.329084,15.880849),
            new google.maps.LatLng(52.329425,15.895483),
            new google.maps.LatLng(52.329530,15.908615),
            new google.maps.LatLng(52.329792,15.919344),
            new google.maps.LatLng(52.330159,15.929386),
            new google.maps.LatLng(52.331156,15.941445),
            new google.maps.LatLng(52.332520,15.951745),
            new google.maps.LatLng(52.333542,15.957496),
            new google.maps.LatLng(52.338210,15.977666),
            new google.maps.LatLng(52.341383,15.990669),
            new google.maps.LatLng(52.343506,16.000883),
            new google.maps.LatLng(52.345709,16.014316),
            new google.maps.LatLng(52.347229,16.024916),
            new google.maps.LatLng(52.349064,16.037061),
            new google.maps.LatLng(52.350742,16.049892),
            new google.maps.LatLng(52.352341,16.061522),
            new google.maps.LatLng(52.355277,16.081264),
            new google.maps.LatLng(52.358029,16.095039),
            new google.maps.LatLng(52.359460000000006, 16.10404)
]
            }
    }
];

//ibc kontroler do obs?ugi mapy
var ibc = {
      pathExtractior: function(){
          var count = dir.routes[0].overview_path.length,data='';
          alert(count);
          for(i=0; i< count; i++){
              data +=' new google.maps.LatLng('+dir.routes[0].overview_path[i].lat()+','+dir.routes[0].overview_path[i].lng()+'),\n';
          }
          console.log(data);
      },
	markerPrototype: function(map, coords, image){
		if ( image == undefined) {
			var image = App.BASE_URL+'/images/awsa/map/point.png';
		}
         var marker = new google.maps.Marker({
              position: coords,
              map: map,
              icon: image
          });
		return marker;
	},
	servicesActive: function(lang, dataObj, patern){
		var content = new String();
		var pat = dataObj;
		 
		if(poiPattern.cafe == pat.cafe){
			content+='<span class="ico cafe"></span>';
		}
		if(poiPattern.parking == pat.parking) {
			content+='<span class="ico parking"></span>'
		}
		if(poiPattern.restaurant == pat.restaurant) {
			content+='<span class="ico restaurant"></span>'
		}
		if(poiPattern.gasStation == pat.gasStation) {
			content+='<span class="ico gas"></span>'
		}
		if(poiPattern.hotel == pat.hotel) {
			content+='<span class="ico hotel"></span>'
		}
		if(poiPattern.wc == pat.wc) {
			content+='<span class="ico wc"></span>'
		}

		return content;
		
	},
	createInfoWindows: function(lang ){
		activInfos = [];
	 for (var i = 0 ; i<infoBoxesData.length; i++){
	 	var me = infoBoxesData[i];
		if (me.pointerPosition == 'top'){
			var asz = 0;
		}else {
			var asz = 15;
		}
		var infobox  = new InfoBubble({
                                disableAutoPan: true,
				maxWidth: 300,
				arrowDirection: me.pointerPosition,
				borderRadius: 5,
				arrowSize: asz
			});
                infobox.setPadding(5);
		infobox.open(null, ibc.markerPrototype(null, me.cordinates ));
		activInfos[i]= infobox;
	 }
	 ibc.hideInfoWindows();
	},
	hideInfoWindows: function (items){
		// doda? warunek dla items undefined
		if( typeof items == 'undefined') {
			for (var i = 0 ; i<activInfos.length; i++){
				activInfos[i].close();
			}
		} else {
			for (var i = 0 ; i<activInfos.length; i++){
				activInfos[i].close();
			}
			//console.log(items.length);
			
		}
	},
	showInfoWindows: function (){
		for (var i = 0 ; i<activInfos.length; i++){
			activInfos[i].open(mainmap);
		}
	},
	showByPatern : function(){
		
		for (var i = 0 ; i<activInfos.length; i++){
			if (ibc.comparePaterns(infoBoxesData[i])){
				var descr = (App.LANG=='pl')?infoBoxesData[i].contentPl:infoBoxesData[i].contentEn;
				var info ='<div  class="info-bouble"><h3>'+infoBoxesData[i].namePl+'</h3>'+descr+'<br>'+ibc.servicesActive('pl', infoBoxesData[i].pattern,  poiPattern)+'</div>';
				
				activInfos[i].setContent(info);
				activInfos[i].open(mainmap);
			}
			else {
				activInfos[i].close();
			}
		}
	},
	updatePattern: function(obj){
			if(obj.hasClass('selected')) {
				if (obj.hasClass('cafe')){
					poiPattern.cafe= true;
				} else if(obj.hasClass('parking')) {
					poiPattern.parking = true;
				} else if(obj.hasClass('restaurant')) {
					poiPattern.restaurant = true;
				} else if(obj.hasClass('gas-station')) {
					poiPattern.gasStation = true;
				} else if(obj.hasClass('hotel')) {
					poiPattern.hotel = true;
				} else if(obj.hasClass('wc')) {
					poiPattern.wc = true;
				}
				
			} else {
				if (obj.hasClass('cafe')){
					poiPattern.cafe= 'no-activ';
				} else if(obj.hasClass('parking')) {
					poiPattern.parking = 'no-activ';
				} else if(obj.hasClass('restaurant')) {
					poiPattern.restaurant = 'no-activ';
				} else if(obj.hasClass('gas-station')) {
					poiPattern.gasStation = 'no-activ';
				} else if(obj.hasClass('hotel')) {
					poiPattern.hotel = 'no-activ';
				} else if(obj.hasClass('wc')) {
					poiPattern.wc = 'no-activ';
				}
			}
		
	},
	comparePaterns: function(obj) {
		var pat = obj.pattern;
		if ((poiPattern.cafe == pat.cafe)
				||(poiPattern.parking == pat.parking) 
				||(poiPattern.restaurant == pat.restaurant) 
				||(poiPattern.gasStation == pat.gasStation) 
				||(poiPattern.hotel == pat.hotel) 
				||(poiPattern.wc == pat.wc)
				) {
			return true;
		} else {
			return false;
		}
	},	
	controlMarkers : function (points, visibility, globalArray, imageUrl){
		var image = imageUrl;
		var lang=(App.LANG == 'pl')?0:1;
		if (visibility) {
			for (var i = 0; i< points.length; i++) {
				globalArray[i]=  ibc.markerPrototype(mainmap,points[i].coords, image);
				globalArray[i].setMap(mainmap);
                                
                                      var smoke = new InfoBubble({
                                        maxWidth: 300,
                                        arrowDirection: 'bottom',
                                        borderRadius: 5,
                                        arrowSize: 15, 
                                        padding: 3,
                                        disableAutoPan: true   
                                });
                    
                    
                       globalArray[i].preview = '<div class="placesBouble"><h3>'+points[i].name+'</h3>'+points[i].description[lang]+'<div>';
                     
			
                         google.maps.event.addListener(globalArray[i], "mouseover", function(){
                           smoke.setContent(this.preview);
                            smoke.open(mainmap, this);
                        });
                        google.maps.event.addListener(globalArray[i], "mouseout", function(){
                             smoke.close();
                        });
                                
                                
				globalArray[i].setMap(mainmap);
			
			}
		} else {
			for (var i = 0; i< points.length; i++) {
				globalArray[i].setMap(null);
			}
		}
		
	},
	getRoute : function (form){
		  var from = form.find('input[name="from"]').attr('value');
	        var to = form.find('input[name="to"]').attr('value');

	        var request = {
	            origin: from,
	            destination:to,
	            travelMode: google.maps.DirectionsTravelMode.DRIVING,
	            region: 'pl'
	        };

    	  directionsService.route(request, function(result, status) {
    	    switch(status){
                case'OK':
                        dir = result;
                	directionsDisplay.setDirections(result);
                    break;
                case'NOT_FOUND':
					switch(App.LANG){
						case"pl":
							alert('Nie moźna odnaleść podanej lokalizacji');
							break;
						case"en":
							alert('Can not find the specified location');
							break;
					}
                    break;
                case'ZERO_RESULTS':
					switch(App.LANG){
						case"pl":
							alert('Nie można wyznaczyć okresonej trasy');
							break;
						case"en":
							alert('Can not find the specified stores paths');
							break;
					}
                    break;
                case'INVALID_REQUEST':
					switch(App.LANG){
						case"pl":
							alert('Nieprawidłowe dane');
							break;
						case"en":
							alert('Invalid request');
							break;
					}
                    break;
                case'OVER_QUERY_LIMIT':
					switch(App.LANG){
						case"pl":
							alert('Wykonano zbyt wiele zapytań, spróbój pźniej');
							break;
						case"en":
							alert('Taken too many questions about path, please try again later');
							break;
					}
                    break;
                case'REQUEST_DENIED':
					switch(App.LANG){
						case"pl":
							alert('Odmowa dostępu');
							break;
						case"en":
							alert('Request denied');
							break;
					}
                    break;
                default:
					switch(App.LANG){
						case"pl":
							alert('Nieznany typ błędu');
							break;
						case"en":
							alert('Unknown error type');
							break;
					}
                    break;
            }
    	  });
	},
	nodeMarkers : function (points, visibility, image){//konstrukoor w?z??w
		var rozmiar = new google.maps.Size(15, 16),
			startPoint = new google.maps.Point(0, 0),
			hangPoint = new google.maps.Point(7,7),
			nodeImage = new google.maps.MarkerImage(App.BASE_URL+'/images/awsa/map/node.png', rozmiar, startPoint, hangPoint),
			halfNodeImage = new google.maps.MarkerImage(App.BASE_URL+'/images/awsa/map/half-node.png', rozmiar, startPoint, hangPoint);
		for(var i=0 ; i< roadNodes.length; i++){
			if(roadNodes[i].type == 'HalfNode') {
				var ico = halfNodeImage;
			}	else {
				var ico = nodeImage;
			}		
			var marker = new google.maps.Marker({
				title: roadNodes[i].name,
				icon: ico,
				position: roadNodes[i].coords,
				map: mainmap
			});
                              
                        var smoke = new InfoBubble({
                                maxWidth: 480,
                                arrowDirection: 'bottom',
                                borderRadius: 5,
                                arrowSize: 15, 
                                padding: 3,
                                disableAutoPan: true   
                        });
                    var h3='', dscr='';
                    if(App.LANG == 'en'){
                       h3= marker.title+'&nbsp;Interchange';
                       dscr= roadNodes[i].description[1];
                    } else {
                       h3= 'Węzeł&nbsp;drogowy&nbsp;'+marker.title;
                        dscr= roadNodes[i].description[0];
                    }
                       marker .preview = '<div class="placesBouble"><h3>'+h3+'</h3>'+dscr+'<div>';
                     
			
                         google.maps.event.addListener(marker , "mouseover", function(){
                           smoke.setContent(this.preview);
                            smoke.open(mainmap, this);
                        });
                        google.maps.event.addListener(marker , "mouseout", function(){
                             smoke.close();
                        });
                                
		}
	},
        roadStatus: function(obj){
            if(obj.hasClass('selected')) {//jeżeli jest w budowie centruje mapę na odcinku z budowaą
                var centerPos = new google.maps.LatLng(52.32532 , 15.161596);
                mainmap.setCenter(centerPos);
            }
        },
	bindingActions: function(){
		$(".info-conroler-icons a").click(function(e){
			var me = $(this),
				btnClass =  me.attr('class').replace('selected', '');
				all =$('a.all');
			
			if( all.hasClass('selected')){
				all.click();
			}
			
			e.preventDefault();
			$(".info-conroler-icons a."+btnClass).toggleClass('selected');
			ibc.updatePattern(me);
			ibc.showByPatern();
		});
		
		$(".markers-controls a.ppo").click(function(e){
			var me = $(this);
			e.preventDefault();
			$(".markers-controls a.ppo").toggleClass('selected');
			var imageUrl = App.BASE_URL+'/images/awsa/map/marker_ppo.png';
			ibc.controlMarkers(ppos1, me.hasClass('selected'), ppoGlobal, imageUrl);
			
		});
		
		$(".markers-controls a.oua").click(function(e){
			var me = $(this);
			e.preventDefault();
			$(".markers-controls a.oua").toggleClass('selected');
			var imageUrl =  App.BASE_URL+'/images/awsa/map/marker_setting.png';
			ibc.controlMarkers(ousas, me.hasClass('selected'), ouaGlobal, imageUrl);
		});
		
		$(".markers-controls a.spo").click(function(e){
			var me = $(this);
			e.preventDefault();
			$(".markers-controls a.spo").toggleClass('selected');
			var imageUrl = App.BASE_URL+'/images/awsa/map/marker_spo.png';
			ibc.controlMarkers(spos1, me.hasClass('selected'), spoGlobal, imageUrl);
		});
		
		$(".markers-controls a.places").click(function(e){
			var me = $(this);
			e.preventDefault();
			me.toggleClass('selected');
                       Places.visible(me.hasClass('selected'));
		});
		
		$("a.roll").click(function(e){
			var me = $(this);
			e.preventDefault();
			me.toggleClass('selected');
			if(me.hasClass('selected')){
				me.parent().find('ul').slideDown(1000);
			}else {
				me.parent().find('ul').slideUp(1000);
				
			}
			
		});

		$("a.routebtn").click(function(e){
			var me = $(this);
			e.preventDefault();
			me.toggleClass('selected');
			if(me.hasClass('selected')){
				$('.directions, .directions  fieldset').slideDown('slow');
			} else {
				$('.directions, .directions  fieldset').slideUp('slow');
			}
		});

		$("form.directions").submit(function(e){
			e.preventDefault();
			ibc.getRoute($(this));
		});
                
                $("form.directions input[type='text']").click(function(e){
			e.preventDefault();
                        var me = $(this);
                        me.val('');
		});


		$("a.cancel").click(function(e){
			e.preventDefault();
			$("a.routebtn").trigger('click');
		});
		$('form#directions fieldset input[type="image"]').click(function(e){
			e.preventDefault();
			$("form#directions").trigger('submit');
		});
		
		
	}
}

 
var Places = {
	data: null,
	markersPlaceHolder: [],
	infoWindowsPlaceHolder:[],
        events: [],
	markersConstructor: function(dataArray){
		var size = new google.maps.Size(21, 21),
		startPoint = new google.maps.Point(0, 0),
		endPoint = new google.maps.Point(11, 11),
		markerIcon= new google.maps.MarkerImage(App.BASE_URL+'/images/awsa/map/marker_photo.png', size, startPoint, endPoint);
		
		for(var i= dataArray.length-1; i>-1; --i){                   
			this.markersPlaceHolder[i] = new google.maps.Marker({
					title: Places.data[i].title,
					icon: markerIcon,
					position: new google.maps.LatLng(dataArray[i].lat , dataArray[i].lng),
					map: null
				});
                                
                    var marker =  this.markersPlaceHolder;
                     var infoWindow = new InfoBubble({
				maxWidth: 300,
				arrowDirection: 'bottom',
				borderRadius: 5,
                                padding: 5,
				arrowSize: 15
                                
			});
                     var placesmouser = new InfoBubble({
				maxWidth: 300,
				arrowDirection: 'bottom',
				borderRadius: 5,
				arrowSize: 15, 
                                padding: 5,
                                disableAutoPan: true   
			});
                    
                    
                       marker[i].contentToDisplay='<div class="placesBouble"><h3>'+dataArray[i].title+'</h3>'+' <img src="'+App.BASE_URL+dataArray[i].imgUrl+'"/>'+dataArray[i].shortDesc+'.. <a href="'+dataArray[i].url+'" >więcej&raquo;</a></div>';
                       marker[i].preview = '<div class="placesBouble"><h3>'+dataArray[i].title+'</h3>'+' <img height="75" width="75" src="'+App.BASE_URL+dataArray[i].imgUrl+'"/><div>';
                     
			google.maps.event.addListener(marker[i], 'click', function(){
                            infoWindow.setContent(this.contentToDisplay);
                            infoWindow.open(mainmap, this);
                            placesmouser.close();
			});
                        
                         google.maps.event.addListener(marker[i], "mouseover", function(){
                           placesmouser.setContent(this.preview);
                            placesmouser.open(mainmap, this);
                            infoWindow.close();
                        });
                        google.maps.event.addListener(marker[i], "mouseout", function(){
                             placesmouser.close();
                        });
                     }           
                
		
 
	},
	visible: function(booleanVisibile){
           var places =  this.markersPlaceHolder;
           for (var i = Places.data.length - 1; i > -1; --i) {
		if(booleanVisibile){
			places[i].setMap(mainmap);
		}else{
			places[i].setMap(null);
		}	
           }
	},
	
        getAjaxData: function(jsonUrl){
            $.ajax({
                type: 'get',
                url: jsonUrl,			
                error: function(data){
                        $('a.places').hide();
                },
                success: function(data) {
                    Places.data = jQuery.parseJSON(data);
                    Places.markersConstructor(Places.data);
                }
            });
        },
	init: function(){
            this.getAjaxData( App.BASE_URL + '/' + App.LANG + '/json/places' );

	}
}

function showMap(){
	var wspolrzedne = new google.maps.LatLng(52.306576, 17.566821);
	var opcjeMapy = {
                scrollwheel: false,
		zoom: 9,
		center: wspolrzedne,
		mapTypeControl: true,
	    mapTypeControlOptions: {
	        style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
	        position: google.maps.ControlPosition.LEFT_BOTTOM
	    },
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	mainmap = new google.maps.Map(document.getElementById("mainmap"), opcjeMapy);
	var awsaRoad = new google.maps.Polyline(roadSegements[0].options);
	var inBuildOneRoad = new google.maps.Polyline(roadSegements[1].options);
	var inBuildTwoRoad = new google.maps.Polyline(roadSegements[2].options);
	  directionsService = new google.maps.DirectionsService();
      directionsDisplay = new google.maps.DirectionsRenderer({
          draggable: true
      });
      directionsDisplay.setMap(mainmap);
	awsaRoad.setMap(mainmap);
	inBuildOneRoad.setMap(mainmap);
	inBuildTwoRoad.setMap(mainmap);                  
	ibc.nodeMarkers();
	
}
   
$(document).ready(function(){
    showMap();

    ibc.roadStatus($('.in-build'));
    ibc.bindingActions();
    $('.controls, .legend').show();
    ibc.createInfoWindows(App.LANG);
    $('.pogoda').fadeIn('slow');
   Places.init();


});
