/* jQuery googleMap Copyright Dylan Verheul <dylan@dyve.net>
 * Licensed like jQuery, see http://docs.jquery.com/License
 */
$.googleMap={
	maps:{},
	base:'http://magnusonhotels.com/',
	marker:function(m){
		if(!m)return null;
		var icn=null;
		var baseIcon=new GIcon();
		baseIcon.iconSize=new GSize(16,24);
		baseIcon.shadowSize=new GSize(32,24);
		baseIcon.iconAnchor=new GPoint(8,24);
		baseIcon.infoWindowAnchor=new GPoint(8,0);
		if(m.icn=='hotel'){
			icn=new GIcon(baseIcon,'images/map/b_hotel.png',null,null);
		}else if(m.icn=='city'){
			icn=new GIcon(baseIcon,'images/map/b_hotel.png',null,null);
		}else if(m.icn=='region'){
			icn=new GIcon(baseIcon,'images/map/b_hotel.png',null,null);
		}else{
			icn=new GIcon(baseIcon,'images/map/b_hotel.png',null,null);
		};
		var marker=new GMarker(new GLatLng(m.lat,m.lng),icn);
		if(m.icn=='region'){
			GEvent.addListener(marker,'mouseover',function(){
				MagMap.ShowBox(m.txt,marker);
			});
			GEvent.addListener(marker,'click',function(){
				MagMap.ShowRegion(marker,m.id);
			});
		}else if(m.icn=='city'){
			GEvent.addListener(marker,'mouseover',function(){
				MagMap.ShowBox(m.txt,marker);
			});
			GEvent.addListener(marker,'click',function(){
				MagMap.ShowCity(marker);
			});
		}else if(m.icn=='hotel'){
			GEvent.addListener(marker,'mouseover',function(){
				MagMap.ShowBox(m.txt,marker);
			});
			GEvent.addListener(marker,'click',function(){
				MagMap.OpenInfoWindow(marker,m.id);
			});
		}else if(m.icn=='country'){
			GEvent.addListener(marker,'mouseover',function(){
				MagMap.ShowBox(m.txt,marker);
			});
			GEvent.addListener(marker,'click',function(){
				MagMap.ShowRegionC(marker,m.id);
			});
		};
		GEvent.addListener(marker,'mouseout',function(){
			MagMap.HideBox();
		});
		return marker;
	}
};
$.fn.googleMap = function(lat,lng,zoom,options){
	if(!window.GBrowserIsCompatible||!GBrowserIsCompatible())return this;
	if(lat==null)lat=37.4419;
	if(lng==null)lng=-122.1419;
	if(!zoom)zoom=13;
	if(!options || typeof options != 'object')options={};
	options.mapOptions=options.mapOptions||{};
	options.markers=options.markers||[];
	options.controls=options.controls||{};
	return this.each(function(){
		var map=$.googleMap.maps[this.id]=new GMap2(this, options.mapOptions);
		map.setCenter(new GLatLng(lat,lng),zoom);
		for (var i=0;i<options.controls.length;i++){
			var c=options.controls[i];
			eval('map.addControl(new '+c+'());');
		};
		var marker=null;
		for (i=0;i<options.markers.length;i++){
			if(marker=$.googleMap.marker(options.markers[i]))map.addOverlay(marker);
		};
	});
};

