GMaps=function(){
	this.selected1Id
	this.wholeContentId="";
	this.key
	this.locations=new Array()
	this.gMap
	this.useMapClick=false
	this.loadScripts=function(){
		document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key='+this.key+'" type="text/javascript"></script>')
	}
	this.showHide=function(b){
		if(this.wholeContentId!=""){
			document.getElementById(this.wholeContentId).style.visibility=(b?"hidden":"visible")
			}
		tracker.instance.trackEvent("gmaps",b?"showGMap":"hideGMap")
		siteGMaps.showHideOverPage(b)
		if(b){
			this.gMap=new GMap2(siteGMaps.getMapsContainerRef())
			this.gMap.addControl(new GLargeMapControl());
			this.gMap.addControl(new GMapTypeControl());
			this.gMap.addControl(new GScaleControl());
			this.gMap.addControl(new GOverviewMapControl());
			this.gMap.setCenter(new GLatLng(50.06050008188616, 19.94014263153076),6)
			if(this.useMapClick){
				GEvent.addListener(this.gMap, "click", this.evMapClick);
				GEvent.addListener(this.gMap.getInfoWindow(), "closeclick", function(){
						gMaps.gMap.getInfoWindow().hide()
						for(var i=0;i<siteGMaps.locations.length;i++){
							if(siteGMaps.locations[i].id == gMaps.selected1Id){
								siteGMaps.locations[i].current=false
								break;
							}
						}
						gMaps.selected1Id=null
						
					});
			}
			//GEvent.addListener(this.gMap.getInfoWindow(), "closeclick", function(){gMaps.unsign()})
			this.drawMarkers()
			if(siteGMaps.configureGmap){
				siteGMaps.configureGmap(this.gMap)
			}
		}
	}

	this.drawMarkers=function(bChange,hide){
		this.gMap.clearOverlays()
			var baseIcon = new GIcon();
			var iconObj;
			for(var i=0;i<siteGMaps.locations.length;i++){
				var locObj=siteGMaps.locations[i]
				var point=new GLatLng(locObj.lat,locObj.lng)
				if(locObj.current){
					if(bChange){
						this.gMap.setZoom(locObj.zoom)
						this.gMap.panTo(point)
					}else{
						this.gMap.setCenter(point,locObj.zoom)
						}
					iconObj=locObj.marker2?locObj.marker2:null
					this.selected1Id=locObj.id
					document.getElementById("siteText").childNodes[i+siteGMaps.sectionsOffset].className="siteLocationHrefAct"
				}else{
					iconObj=locObj.marker1?locObj.marker1:null
					document.getElementById("siteText").childNodes[i+siteGMaps.sectionsOffset].className="siteLocationHref"
				}
				var icon=new GIcon(baseIcon);
				if(!(hide==true)){
					if(iconObj){
						icon.iconSize = new GSize(iconObj.iconSize[0], iconObj.iconSize[1]);
						icon.iconAnchor = new GPoint(iconObj.iconAnchor[0], iconObj.iconAnchor[1]);
						icon.image="/modules/GMaps/layout/"+iconObj.image
						icon.shadow="/modules/GMaps/layout/"+iconObj.shadow
						var printIm=icon.shadow.replace(/\.png/i,".gif")
						icon.printShadow=printIm
					}else{
						icon=GIcon.G_DEFAULT_ICON
					}
				}else{
					icon=GIcon.G_DEFAULT_ICON
				}
				if(siteGMaps.locations[i].noMarker===true){
					continue;
				}
				var marker=new GMarker(point,{icon:icon,title:siteGMaps.locations[i].uniName})
				this.decorateMarker(marker,siteGMaps.locations[i].id)
				this.gMap.addOverlay(marker)
				if(siteGMaps.locations[i].id == this.selected1Id){
					marker.openInfoWindowHtml(siteGMaps.getInfoWinContent(locObj))
				}
				//alert("OK")
			}
			try{
				siteGMaps.evMarkersDrawn()
			}catch(er){
				
			}
	}
	this.decorateMarker=function(marker,id){//evLinkClick marker,html
		
		GEvent.addListener(marker, "click", function() {gMaps.evLinkClick(id)});
		GEvent.addListener(marker, "infowindowclose", function(){gMaps.unsign()})
		//GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html)});
	}
	this.evMapClick=function(overlay,  point){
		if(overlay != null){
			var p=overlay.getPoint()
			for(var i=0;i<siteGMaps.locations.length;i++){
				if(siteGMaps.locations[i].lat==p.lat() && siteGMaps.locations[i].lng==p.lng()){
					var w=gMaps.gMap.getInfoWindow()
					var wp=w.getPoint();
						if(wp!=null	&& wp.lat()==p.lat()){
						return
					}
					var curLoc=siteGMaps.locations[i]
					
					var w=gMaps.gMap.openInfoWindowHtml(p,siteGMaps.getInfoWinContent(curLoc))	
				}
				}
		}
	}

	this.evLinkClick=function(id){
		if(id==this.selected1Id){
			return
		}
		var iconObj
		for(var i=0;i<siteGMaps.locations.length;i++){
			if(siteGMaps.locations[i].id == this.selected1Id){
				siteGMaps.locations[i].current=false	
				}else if(siteGMaps.locations[i].id ==id){
					siteGMaps.locations[i].current=true	
				}

			}
		this.drawMarkers(true)	
	}
	this.signList=function(i,sign){
		siteGMaps.locations[i].current=sign
		document.getElementById("siteText").childNodes[i+siteGMaps.sectionsOffset].className="siteLocationHref"+(sign?"Act":"")
	}
	this.unsign=function(){
		for(var i=0;i<siteGMaps.locations.length;i++){
			if(siteGMaps.locations[i].id == this.selected1Id){
				siteGMaps.locations[i].current=false
				document.getElementById("siteText").childNodes[i+siteGMaps.sectionsOffset].className="siteLocationHref"
				break;
				}

			}
		this.selected1Id=null
	}
	this.printClick=function(){
		//this.drawMarkers(false,true)
		window.print()
		//this.drawMarkers(false)	
	}
	this.writeLaunchTag=function(){
		document.write(siteGMaps.getLaunchTag())
	}
}




