(function(){
	/* homegrown JS library */

	var feri = $ = function( select ){
		select = select || document;
		return feri.func.construct( select );
	};

	feri.func = feri.prototype = {
	
		name: "inferior",
		version: "0.4.3",
		
		construct: function(select){
			if (select.nodeType) {
				this.node = select;
				return this;
			}
			if (typeof select === 'string') {
				this.node = document.getElementById(select) || document;
			}
			return this;
		},
		
		has_class: function(val){
			if ( this.node === null ) return this;
			if (!this.node.className) {
				return false;
			}
			return this.node.className.match(new RegExp('(\\s|^)' + val + '(\\s|$)'));
		},
		add_class: function(val){
			if ( this.node === null ) return this;
			if (!this.has_class(val)) {
				this.node.className += " " + val;
			}
			return this;
		},
		del_class: function(val){
			if ( this.node === null ) return this;
			if (this.has_class( val)) {
				var reg = new RegExp('(\\s|^)' + val + '(\\s|$)');
				this.node.className = this.node.className.replace(reg, '');
			}
			return this;
		},
		

		add_event : function( type , f ){
			if ( this.node === null ) return this;
			if (this.node.addEventListener){
				this.node.addEventListener(type, f, mode ={ 'focus': true , 'blur': true }[type] );
			}
			else 
				if (this.node.attachEvent){
					type = {'focus': 'focusin' , 'blur': 'focusout'}[type] || type;  
					(( this.node._evts = this.node._evts || [] )[this.node._evts.length] = function(e){
						return f.call(this.node, e);
					})._w = f;
					return this.node.attachEvent("on" + type, this.node._evts[this.node._evts.length - 1]);
				}
		},
	
		del_event : function( type , f ){
			if ( this.node === null ) return this;
			if (this.node.removeEventListener){
				this.node.removeEventListener( type , f , mode ={ 'focus': true , 'blur': true }[type] );
			}
			else 
				if (this.node.detachEvent){
					type = {'focus': 'focusin' , 'blur': 'focusout'}[type] || type; 
					for (var evts = this.node._evts || [], i = evts.length; i--;) {
						if ( evts[i]._w === f ) {
							this.node.detachEvent( "on" + type , evts.splice(i, 1)[0] );
						}
					}
				}
		},
			
		parent : function( attr ){
			if ( this.node === null ) return this;
			if ( attr === undefined ){
				this.mode = this.node.parentNode;
			}else{
				this.node = $dom.parent( this.node , attr );
			}
			return this;
		},
		
		child : function( attr ){
			if ( this.node === null ) return this;
			this.node = $dom.lookup(this.node.firstChild, attr);
			return this;			
		},

		next : function( attr ){
			if ( this.node === null ) return this;
			this.node = $dom.lookup(this.node, attr);
			return this;			
		},		
		
		dom: function( name, attr, children ){
			if ( this.node === null ) return this;
			this.node.appendChild( $dom.builder( name, attr, children ) );
			return this;
		},
		
		text: function( val ){
			if ( typeof val === 'object' ){
				val = val.innerText || val.textContent;
			}
			if( document.body.textContent === undefined ){
				this.node.innerText = val;
			}else{
				this.node.textContent = val;
			}
			return this;
		},
		
		
		css: function(attr){
			for (var n in attr) {
				if (attr.hasOwnProperty(n)) {
					this.node.style[ $transform.camelCase( n ) ] = attr[n];
				}
			}
			return this;
		}
		
		
	};
	

	var $transform = {
		camelCase: function( param ){
			return param.replace(/-\D/g, function(match){
				return match.charAt(1).toUpperCase();
			});
		},		
		hyphenate: function( param ){
			return param.replace(/[A-Z]/g, function(match){
				return ('-' + match.charAt(0).toLowerCase());
			});
		}/*
		hexToRgb: function(array){
			var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
			return (hex) ? hex.slice(1).hexToRgb(array) : null;
		},
	
		rgbToHex: function(array){
			var rgb = this.match(/\d{1,3}/g);
			return (rgb) ? rgb.rgbToHex(array) : null;
		}*/
	};	
	
	var $dom = {
		
		lookup : function ( node , attr ){
			var ok = 1;
			for (var n in attr) {
				if (attr.hasOwnProperty(n)) {
					switch (n){
						case 'class':
							if ( !$(node).has_class( attr[n])){
								ok *= 0;
							}
						break;
						case 'text':
							if ( $dom.get_text( node ) !== attr[n] ){
								ok *= 0;
							}
						break;
						case 'index': break;
						case 'tag': break;
						default:
							if ( node[n]){
								ok *= ( node[n] === attr[n] )? 1 : 0;
							}
						break;
						
					}
				}
			}
			return ok;
		},
		
		parent : function( node, attr ){
			if ( node.tagName === 'BODY' ) return null;
			var node = node.parentNode; 
			if (attr['tag']) {
				if (node['tagName'] !== attr['tag'].toUpperCase()) {
					return $dom.parent(node, attr);
				}
			}
			return $dom.fit(node, attr) ? node : $dom.parent(node, attr);
						
		},
		
		
		
		child: function( node , attr , i){

			
			var i = i || 0;
			while ( node.nodeType  === 3 ){
				var node = node.nextSibling;
			}	 
			if ( attr === undefined ) return node;

			if (attr['tag']) {
				if (node['tagName'] !== attr['tag'].toUpperCase()) {
					return $dom.child(node.nextSibling, attr);
				}
			}
			check = ( attr['index'] === undefined )? true : (attr.index == i);
			
			if ( check && $dom.fit(node, attr)) return node;
			return $dom.child(node.nextSibling, attr , i++);
		},
		
		builder: function( name, attr, children ){
			var tag = document.createElement( name );
			for ( var n in attr ){
				if (attr.hasOwnProperty(n)){
					switch (n){
						case 'class':
							tag[n+'Name'] = attr[n];
						break;
						case 'text':
							$(tag).text( attr[n] );
						break;
						default:
							tag[n] = attr[n];
					}
				}
			}
			if ( children ){
				if (children.tagName){
					tag.appendChild(children);
				}else{
					for (var c in children){
						if (children[c].length){
							tag.appendChild(this.builder(children[c][0], children[c][1], children[c][2]));
						}
					}
				}
			}
			return tag;
		}		
	};
	


    
    function InfoBox(opts){
        google.maps.OverlayView.call(this);
        this.latlng_ = opts.latlng;
        this.map_ = opts.map;
		
		switch ( opts.index ){
			case 1:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-a87ff679a2f3e71d9181a67b7542122c.jpeg" /><h2>BBārs - restorāns</h2><p>Labs bārs pārdod sajūtas nevis&nbsp;dzērienus!</p></div><div class="footer"><div>Doma laukums 2</div><a href="http://www.bbars.lv/">http://www.bbars.lv/</a></div>';
				break;
			case 2:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c4ca4238a0b923820dcc509a6f75849b.jpeg" /><h2>Balzambārs</h2><p>Labs bārs pārdod sajūtas nevis&nbsp;dzērienus!</p></div><div class="footer"><div>Torņa 4</div><a href="http://www.bbars.lv/">http://www.bbars.lv/</a></div>';
				break;
			case 3:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-e4da3b7fbbce2345d7772b0674a318d5.jpeg" /><h2>Europa Royale</h2><p>Hotel</p></div><div class="footer"><div>Kr. Barona 12</div><a href="http://www.groupeuropa.com/europa_royale_hotels_lv/riga_viesnica/">http://www.groupeuropa.com/</a></div>';
				break;
			case 4:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-eccbc87e4b5ce2fe28308fd9f2a7baf3.jpeg" /><h2>K.I.D.</h2></div><div class="footer"><div>Grēcinieku 8</div><a href="http://www.restaurantkid.lv/">http://www.restaurantkid.lv/</a></div>';
				break;
			case 5:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-eccbc87e4b5ce2fe28308fd9f2a7baf3.jpeg" /><h2>K.I.D.</h2></div><div class="footer"><div>Pulkveža Brieža 2</div><a href="http://www.restaurantkid.lv/">http://www.restaurantkid.lv/</a></div>';
				break;
			case 6:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c81e728d9d4c2f636f067f89cc14862c.jpeg" /><h2>Melnais kaķis</h2><p>Aptļauj veiksmei sevi&nbsp;mīlēt</p></div><div class="footer"><div>Brīvības 409</div><a href="http://www.kakis.lv">www.kakis.lv</a></div>';
				break;
			case 7:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c81e728d9d4c2f636f067f89cc14862c.jpeg" /><h2>Melnais kaķis</h2><p>Aptļauj veiksmei sevi&nbsp;mīlēt</p></div><div class="footer"><div>Stirnu 50</div><a href="http://www.kakis.lv">www.kakis.lv</a></div>';
				break;
			case 8:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c81e728d9d4c2f636f067f89cc14862c.jpeg" /><h2>Melnais kaķis</h2><p>Aptļauj veiksmei sevi&nbsp;mīlēt</p></div><div class="footer"><div>Lutriņu 1</div><a href="http://www.kakis.lv">www.kakis.lv</a></div>';
				break;
			case 9:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-1679091c5a880faf6fb5e6087eb1b2dc.jpeg" /><h2>Kabuki</h2><p></p></div><div class="footer"><div>Tērbatas 46</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 10:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-8f14e45fceea167a5a36dedd4bea2543.jpeg" /><h2>Sumo</h2><p></p></div><div class="footer"><div>Kungu 8</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 11:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c81e728d9d4c2f636f067f89cc14862c.jpeg" /><h2>Melnais kaķis</h2><p>Aptļauj veiksmei sevi&nbsp;mīlēt</p></div><div class="footer"><div>Raiņa 15</div><a href="http://www.kakis.lv">www.kakis.lv</a></div>';
				break;
			case 12:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c20ad4d76fe97759aa27a0c99bff6710.jpeg" /><h2>Dada</h2><p></p></div><div class="footer"><div>Lielirbes 29, "Spice"</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 13:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-1679091c5a880faf6fb5e6087eb1b2dc.jpeg" /><h2>Kabuki</h2><p></p></div><div class="footer"><div>Kr. Barona 14</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 14:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-f970e2767d0cfe75876ea857f92e319b.jpeg" /><h2>Steiku Haoss</h2><p></p></div><div class="footer"><div>Audēju 2</div><a href="http://www.steikuhaoss.lv/">http://www.steikuhaoss.lv/</a></div>';
				break;
			case 15:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-f970e2767d0cfe75876ea857f92e319b.jpeg" /><h2>Steiku Haoss</h2><p></p></div><div class="footer"><div>Meistaru 25</div><a href="http://www.steikuhaoss.lv/">http://www.steikuhaoss.lv/</a></div>';
				break;
			case 16:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-1679091c5a880faf6fb5e6087eb1b2dc.jpeg" /><h2>Kabuki</h2><p></p></div><div class="footer"><div>Audēju 14</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 17:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-457391c9c82bfdcbb4947278c0401e41.jpeg" /><h2>Red Fred</h2><p></p></div><div class="footer"><div>Audēju 14</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 18:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-c20ad4d76fe97759aa27a0c99bff6710.jpeg" /><h2>Dada</h2><p></p></div><div class="footer"><div>Audēju 14</div><a href="http://www.sushi.lv/">http://www.sushi.lv/</a></div>';
				break;
			case 19:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-a8f5f167f44f4964e6c998dee827110c.jpeg" /><h2>Forum Cinemas</h2><p></p></div><div class="footer"><div>13. janvāra 8</div><a href="http://www.forumcinemas.lv/">http://www.forumcinemas.lv/</a></div>';
				break;
			case 20:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-d858425d03c8ac3cad81eb52e47c172d.jpeg" /><h2>Veselības centrs&nbsp;4</h2><p></p></div><div class="footer"><div>Skanstes 13, korspuss 5</div><a href="http://www.vc4.lv/">http://www.vc4.lv/</a></div>';
				break;
			case 21:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/assets/images/img-placeholder-40.png" /><h2>Restorāns "Hospitālis"</h2><p>Pseidoslimnīca jeb medicīnisks piedzīvojums ar izcilu virtuvi</p></div><div class="footer"><div>Tirgoņu 4</div><a href="http://www.hospitalis.lv/">http://www.hospitalis.lv/</a></div>';
				break;
			case 22:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-de872154ffbf91a5dcc0e539dd2d5106.jpeg" /><h2>FTB Latvia</h2><p>Aviobiļetes, viesnīcas, autonoma, kruīzi, biznesa un darījumu braucieni</p></div><div class="footer"><div>Elizabetes 63</div><a href="http://www.ftb.lv/">http://www.ftb.lv/</a></div>';
				break;
			case 23:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-de872154ffbf91a5dcc0e539dd2d5106.jpeg" /><h2>FTB Latvia</h2><p>Aviobiļetes, viesnīcas, autonoma, kruīzi, biznesa un darījumu braucieni</p></div><div class="footer"><div>Lidosta "Rīga"</div><a href="http://www.ftb.lv/">http://www.ftb.lv/</a></div>';
				break;
			case 24:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/assets/images/img-placeholder-40.png" /><h2>Valodu mācību centrs</h2><p></p></div><div class="footer"><div>Barona 64</div><a href="http://www.vmc.lv/">http://www.vmc.lv/</a></div>';
				break;
			case 25:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/corporate-cfdc604b8335b294c01e50b0be829bdd.jpeg" /><h2>Restorāns "Fazer Amica"</h2><p></p></div><div class="footer"><div>13. janvāra 8</div><a href="http://www.fazer.lv/">http://www.fazer.lv/</a></div>';
				break;
				


			case 0:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/assets/images/img-placeholder-40.png" /><h2></h2><p></p></div><div class="footer"><div></div><a href=""></a></div>';
				break;


			case 10001:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/private-d89f3a35931c386956c1a402a8e09941.jpeg" /><h2>Azazul</h2></div><div class="footer"><div>Nīcgales 21</div></div>';
				break;
			case 10002:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/private-9103c8c82514f39d8360c7430c4ee557.jpeg" /><h2>Peksnis</h2><p>Pievienojies arī manam&nbsp;WIFI!</p></div><div class="footer"></div>';
				break;
			case 10003:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/private-f5dffc111454b227fbcdf36178dfe6ac.jpeg" /><h2>Santehnet.lv</h2><p>Katram ir vajadzīgs savs pods.</p></div><div class="footer"><div>Dammes 30</div><a href="http://www.santehnet.lv">http://www.santehnet.lv</a></div>';
				break;
			case 10004:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/content/map/private-eccbc87e4b5ce2fe28308fd9f2a7baf3.jpeg" /><h2>EOS</h2><p>Bezmaksas WIFI Internets!</p></div><div class="footer"><div>Upeņu 17</div><a href="http://www.freewifi.lv/">http://www.freewifi.lv/</a></div>';
				break;
			case 10005:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/assets/images/placeholder.png" /><h2>WIFI punkts</h2><p>Bezmaksas WIFI Internets!</p></div><div class="footer"><div>Jūrmala, Kāpu 110a</div><a href="http://www.freewifi.lv/">http://www.freewifi.lv/</a></div>';
				break;
			case 10006:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/assets/images/placeholder.png" /><h2>WIFI punkts</h2><p>Bezmaksas WIFI Internets!</p></div><div class="footer"><div>Kuldīgas 39</div><a href="http://www.freewifi.lv/">http://www.freewifi.lv/</a></div>';
				break;
			case 10007:
				this.content_ = '<div class="base"><img src="http://img.freewifi.lv/assets/images/placeholder.png" /><h2>WIFI punkts</h2><p>Bezmaksas WIFI Internets!</p></div><div class="footer"><div>Ūnijas 12a</div><a href="http://www.freewifi.lv/">http://www.freewifi.lv/</a></div>';
				break;
		}		
        this.offsetVertical_ = -156;
        this.offsetHorizontal_ = -184;
        this.height_ = 165;
        this.width_ = 210;
        
        var me = this;
        this.boundsChangedListener_ = google.maps.event.addListener(this.map_, "bounds_changed", function(){
            return me.panMap.apply(me);
        });
        
        // Once the properties of this OverlayView are initialized, set its map so
        // that we can display it.  This will trigger calls to panes_changed and
        // draw.
        this.setMap(this.map_);
    }
    
    /* InfoBox extends GOverlay class from the Google Maps API
     */
    InfoBox.prototype = new google.maps.OverlayView();
    
    /* Creates the DIV representing this InfoBox
     */
    InfoBox.prototype.remove = function(){
        if (this.div_) {
            this.div_.parentNode.removeChild(this.div_);
            this.div_ = null;
        }
    };
    
    /* Redraw the Bar based on the current projection and zoom level
     */
    InfoBox.prototype.draw = function(){
        // Creates the element if it doesn't exist already.
        this.createElement();
        if (!this.div_) 
            return;
        
        // Calculate the DIV coordinates of two opposite corners of our bounds to
        // get the size and position of our Bar
        var pixPosition = this.getProjection().fromLatLngToDivPixel(this.latlng_);
        if (!pixPosition) 
            return;
        
        // Now position our DIV based on the DIV coordinates of our bounds
        this.div_.style.width = this.width_ + "px";
        this.div_.style.left = (pixPosition.x + this.offsetHorizontal_) + "px";
        this.div_.style.height = this.height_ + "px";
        this.div_.style.top = (pixPosition.y + this.offsetVertical_) + "px";
        this.div_.style.display = 'block';
    };

/* Creates the DIV representing this InfoBox in the floatPane.  If the panes
 * object, retrieved by calling getPanes, is null, remove the element from the
 * DOM.  If the div exists, but its parent is not the floatPane, move the div
 * to the new pane.
 * Called from within draw.  Alternatively, this can be called specifically on
 * a panes_changed event.
 */
InfoBox.prototype.createElement = function(){
    var panes = this.getPanes();
    var div = this.div_;
    if (!div) {
        // This does not handle changing panes.  You can set the map to be null and
        // then reset the map to move the div.
		
		
		

		
		
        div = this.div_ = document.createElement("div");
        div.id = "infowindow";
       
        div.style.width = this.width_ + "px";
        div.style.height = this.height_ + "px";
        var contentDiv = document.createElement("div");
		contentDiv.className = 'content';
        contentDiv.innerHTML = this.content_;
        
        var topDiv = document.createElement("div");
		topDiv.className = 'top';
		
		var closeImg = $(topDiv).dom( 'img' , 
			{	'src' : 'http://img.freewifi.lv/assets/images/infowindow-close.png',
				'class' : 'close'
			}
		).node;
		
//		alert( this.latlng_ );
		
		
        function removeInfoBox(ib){
            return function(){
                ib.setMap(null);
            };
        }
        
        google.maps.event.addDomListener(closeImg, 'click', removeInfoBox(this));
        
        div.appendChild(topDiv);
        div.appendChild(contentDiv);
        div.style.display = 'none';
        panes.floatPane.appendChild(div);
        this.panMap();
    }
    else 
        if (div.parentNode != panes.floatPane) {
            // The panes have changed.  Move the div.
            div.parentNode.removeChild(div);
            panes.floatPane.appendChild(div);
        }
        else {
        // The panes have not changed, so no need to create or move the div.
        }
}

/* Pan the map to fit the InfoBox.
 */
InfoBox.prototype.panMap = function(){
    // if we go beyond map, pan map
    var map = this.map_;
    var bounds = map.getBounds();
    if (!bounds) 
        return;
    
    // The position of the infowindow
    var position = this.latlng_;
    
    // The dimension of the infowindow
    var iwWidth = this.width_;
    var iwHeight = this.height_;
    
    // The offset position of the infowindow
    var iwOffsetX = this.offsetHorizontal_;
    var iwOffsetY = this.offsetVertical_;
    
    // Padding on the infowindow
    var padX = 40;
    var padY = 40;
    
    // The degrees per pixel
    var mapDiv = map.getDiv();
    var mapWidth = mapDiv.offsetWidth;
    var mapHeight = mapDiv.offsetHeight;
    var boundsSpan = bounds.toSpan();
    var longSpan = boundsSpan.lng();
    var latSpan = boundsSpan.lat();
    var degPixelX = longSpan / mapWidth;
    var degPixelY = latSpan / mapHeight;
    
    // The bounds of the map
    var mapWestLng = bounds.getSouthWest().lng();
    var mapEastLng = bounds.getNorthEast().lng();
    var mapNorthLat = bounds.getNorthEast().lat();
    var mapSouthLat = bounds.getSouthWest().lat();
    
    // The bounds of the infowindow
    var iwWestLng = position.lng() + (iwOffsetX - padX) * degPixelX;
    var iwEastLng = position.lng() + (iwOffsetX + iwWidth + padX) * degPixelX;
    var iwNorthLat = position.lat() - (iwOffsetY - padY) * degPixelY;
    var iwSouthLat = position.lat() - (iwOffsetY + iwHeight + padY) * degPixelY;
    
    // calculate center shift
    var shiftLng = (iwWestLng < mapWestLng ? mapWestLng - iwWestLng : 0) +
    (iwEastLng > mapEastLng ? mapEastLng - iwEastLng : 0);
    var shiftLat = (iwNorthLat > mapNorthLat ? mapNorthLat - iwNorthLat : 0) +
    (iwSouthLat < mapSouthLat ? mapSouthLat - iwSouthLat : 0);
    
    // The center of the map
    var center = map.getCenter();
    
    // The new map center
    var centerX = center.lng() - shiftLng;
    var centerY = center.lat() - shiftLat;
    
    // center the map to the new shifted center
    map.panTo(new google.maps.LatLng(centerY, centerX));
    
    // Remove the listener after panning is complete.
    google.maps.event.removeListener(this.boundsChangedListener_);
    this.boundsChangedListener_ = null;
};




 function CustomMarker(latlng,  map, index) {
    this.latlng_ = latlng;
    this.index_ = index;

    // Once the LatLng and text are set, add the overlay to the map.  This will
    // trigger a call to panes_changed which should in turn call draw.
    this.setMap(map);
  }

  CustomMarker.prototype = new google.maps.OverlayView();

  CustomMarker.prototype.draw = function() {
    var me = this;

    // Check if the div has been created.
    var div = this.div_;
    if (!div) {
      // Create a overlay text DIV
      div = this.div_ = document.createElement('DIV');
      // Create the DIV representing our CustomMarker
		div.className = "marker";

      var img = document.createElement("img");
	  img.lnglat = this.latlng_ ;
	  img.idx = this.index_ ;
      img.src = "http://img.freewifi.lv/assets/images/point-active.png";
      div.appendChild(img);
      google.maps.event.addDomListener(div, "click", function(event) {
        google.maps.event.trigger(me, "click");
      });

      // Then add the overlay to the DOM
      var panes = this.getPanes();
      panes.overlayImage.appendChild(div);
    }

    // Position the overlay 
    var point = this.getProjection().fromLatLngToDivPixel(this.latlng_);
    if (point) {
      div.style.left = point.x - 16 + 'px';
      div.style.top = point.y - 46 + 'px';
    }
  };

  CustomMarker.prototype.remove = function() {
    // Check if the overlay was on the map and needs to be removed.
    if (this.div_) {
      this.div_.parentNode.removeChild(this.div_);
      this.div_ = null;
    }
  };

  CustomMarker.prototype.getPosition = function() {
   return this.latlng_;
  };


/* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa */			



	(function(){
		function initialize() {
		  	
			
				
			    var latlng = new google.maps.LatLng(56.954, 24.144);
			    var myOptions = {
					zoom: 11,
					center: latlng,
					mapTypeControl: false,
					navigationControl: true,
					navigationControlOptions: {
						style: google.maps.NavigationControlStyle.SMALL
					},					
					mapTypeId: google.maps.MapTypeId.ROADMAP
			    };
			    var map = new google.maps.Map(document.getElementById("map"), myOptions);
				var image = "http://img.freewifi.lv/design/images/point-active.png";



				new CustomMarker( new google.maps.LatLng(56.94933950363905, 24.103842973709106) , map , 1 );
				new CustomMarker( new google.maps.LatLng(56.95100123482606, 24.109368324279785)	 , map , 2 );
				new CustomMarker( new google.maps.LatLng(56.95045968355408, 24.120064801216134) , map , 3 );
				new CustomMarker( new google.maps.LatLng(56.94686107061915, 24.108992642402658) , map , 4 );
				new CustomMarker( new google.maps.LatLng(56.958698940205714, 24.105661511421204) , map , 5 );
				new CustomMarker( new google.maps.LatLng(56.989138913175715, 24.24075884246827) , map , 6 );
				new CustomMarker( new google.maps.LatLng(56.965119, 24.195334) , map , 7 );
				new CustomMarker( new google.maps.LatLng(56.926208006983366, 24.060434103012085) , map , 8 );
				new CustomMarker( new google.maps.LatLng(56.95604708508898, 24.126866883277902) , map , 9 );
				new CustomMarker( new google.maps.LatLng(56.94550930675208, 24.110274738311777) , map , 10 );
				new CustomMarker( new google.maps.LatLng(56.95125542748217, 24.114877408981332) , map , 11 );


				new CustomMarker( new google.maps.LatLng(56.92972925245766, 24.036138481140142) , map , 12 );
				new CustomMarker( new google.maps.LatLng(56.95082830233842, 24.12086409950257) , map , 13 );
				new CustomMarker( new google.maps.LatLng(56.94713024718296, 24.111025756835943) , map , 14 );
				new CustomMarker( new google.maps.LatLng(56.94904953678496, 24.10883707427979) , map , 15 );
				
				// galerija 
				new CustomMarker( new google.maps.LatLng(56.947384792798275, 24.11294621849061) , map , 16 );
				new CustomMarker( new google.maps.LatLng(56.9472823895989, 24.112629717826852) , map , 17 );
				new CustomMarker( new google.maps.LatLng(56.94788217576584, 24.11169094467164) , map , 18 );


				// 19 virs 25
				new CustomMarker( new google.maps.LatLng(56.97639452642448, 24.13063806915284) , map , 20 );




				new CustomMarker( new google.maps.LatLng(56.94912852981935, 24.10672885799409) , map , 21 );
				new CustomMarker( new google.maps.LatLng(56.95309552025884, 24.119576639175424) , map , 22 );
				new CustomMarker( new google.maps.LatLng(56.92231102306001, 23.979211277008066) , map , 23 );
				new CustomMarker( new google.maps.LatLng(56.955309947088416, 24.129962152481088) , map , 24 );
				new CustomMarker( new google.maps.LatLng(56.946429506312114, 24.116551107406625) , map , 25 );

				new CustomMarker( new google.maps.LatLng(56.946258342161634, 24.11631507301331) , map , 19 );



				new CustomMarker( new google.maps.LatLng(56.95552348459641, 24.17608541870118) , map , 10001 );
				new CustomMarker( new google.maps.LatLng(56.96210159552918, 24.010239070892343) , map , 10002 );	
				new CustomMarker( new google.maps.LatLng(56.96443246602659, 24.00734228515626) , map , 10003 );
				new CustomMarker( new google.maps.LatLng(56.95882584727285, 24.189153141021738) , map , 10004 );
				new CustomMarker( new google.maps.LatLng(56.960738685252885, 23.67451233291627) , map , 10005 );
				new CustomMarker( new google.maps.LatLng(56.9466679644961, 24.0582827987671) , map , 10006 );
				new CustomMarker( new google.maps.LatLng(56.96903528760236, 24.165528244018564) , map , 10007 );
				
				
				
				var infoBox = null;
				
				$('map').add_event( 'click' , function(e){
					var e = e || event;
					var target = e.target || e.srcElement;
		
					if ( $(target.parentNode).has_class( 'marker' )){
						
						infoBox = new InfoBox({
							latlng: target.lnglat,
							index: target.idx,
							map: map
						});

					
					}else{
						if( infoBox && (!$(target.parentNode).node.className || $(target).node.id === 'infowindow' )){
							
							infoBox.setMap(null);
						}
					}
					e.returnValue = false;
					if ( e.preventDefault ){
						e.preventDefault();
					}
					return false;
				});
				//alert( map.q.childNodes.item(2 ));
		  }
		  
		  
		  
		initialize();		
	
		
	
	})();
	/*
	
	$('sidebar').add_event( 'mouseover' , function(e){
		var e = e || event;
		var target = e.target || e.srcElement;


		if ($(target).node.tagName === 'LI') {
			$(target).add_class('active');
		}
		
		e.returnValue = false;
		if ( e.preventDefault ){
			e.preventDefault();
		}
		return false;
	} );
	$('sidebar').add_event( 'mouseout' , function(e){
		var e = e || event;
		var target = e.target || e.srcElement;


		if ($(target).node.tagName === 'LI') {
			$(target).del_class('active');
		}
		
		e.returnValue = false;
		if ( e.preventDefault ){
			e.preventDefault();
		}
		return false;
	} );
	
	*/
	
	
	
	
	
	})();