function Aktion(xmlData, overviewObj) {
	this.overviewObj = overviewObj;
	this.id = xmlData.getAttribute('id') - 0;
	this.name = xmlData.getAttribute('name');
	this.ort = xmlData.getAttribute('ort');
	this.name_url = xmlData.getAttribute('nameurl');

	this.point = new google.maps.LatLng(xmlData.getAttribute('north') - 0, xmlData.getAttribute('east') - 0);
	
	this.marker = null;
	this.hilightMarker = null;
	this.aktionenListeContent = null;
	
	this.infoWindowContent = null;
}

Aktion.prototype = {
	getMarker: function() {
		if (this.marker == null) {
			var lthis = this;
			this.marker = new google.maps.Marker(this.point, {icon: this.overviewObj.geoIcon});
			this.marker.aktion = this;
			google.maps.Event.addListener(this.marker, 'mouseover',
					function () { lthis.overviewObj.hilightAktion(this.aktion, true); });
			google.maps.Event.addListener(this.marker, 'mouseout',
					function () { lthis.overviewObj.unhilightAktion(this.aktion); });
			google.maps.Event.addListener(this.marker, 'click',
					function () { lthis.showInfoWindowOnMarker();});
		}
		return this.marker;
	},
	
	hideMarker: function() {
		this.marker.hide();
	},
	
	showMarker: function() {
		this.marker.show();
	},
	
	showInfoWindowOnMarker: function() {
		this.overviewObj.infoWindowShownEvent();
		
		/* download every time show is triggered to get new
		 * random image every time.
		 */
		this.fetchDetailInfo();
	},
	
	/* private */
	fetchDetailInfo: function() {
		var lthis = this;
		makeHTTPRequest('/ajax/aktionsinfo/' + this.id, '',
    				function(request, success) { lthis.openInfoWindowWithDetail(request, success); });				
	},
	
	/* private */
	openInfoWindowWithDetail: function(request, success) {
		var aktion = request.responseXML.getElementsByTagName('aktion')[0];
		if (aktion == null) return;
		
		var lthis = this;

		this.infoWindowContent = document.createElement('div');
		this.infoWindowContent.style.cursor = 'pointer';
		this.infoWindowContent.style.overflow = 'hidden';
                this.infoWindowContent.title = 'zur Aktionswebseite';
		this.infoWindowContent.onclick = function() {
			lthis.overviewObj.savePositionInCookie();
			document.location.href = '/aktionen/' + lthis.name_url;
		}
		this.infoWindowContent.style.width = '250px';
		
		var span;
		
		el = document.createElement('div');
		el.style.marginBottom = '1ex';
		el.appendChild(document.createTextNode(this.name));
		this.infoWindowContent.appendChild(el);

		el = document.createElement('div');
		el.style.marginBottom = '1ex';
		el.appendChild(document.createTextNode(this.ort));
		this.infoWindowContent.appendChild(el);

		el = document.createElement('div');
		el.style.marginBottom = '1ex';
		el.appendChild(document.createTextNode(aktion.getAttribute('veranstalter')));
		this.infoWindowContent.appendChild(el);

		var photoUrl = aktion.getAttribute('photo');
		if (photoUrl != null && photoUrl != '') {
			el = document.createElement('div');
			el.style.height = '102px';
			var photo = document.createElement('img');
			photo.src = photoUrl;
			el.appendChild(photo);
			this.infoWindowContent.appendChild(el);
		}
		
		el = document.createElement('div');
		var link = document.createElement('a');
                link.title = 'zur Aktionswebseite';
		var ls = document.createElement('img');
        ls.src = '/imgs/ls.png';
        ls.className = 'lsr';
        link.appendChild(ls);
		link.appendChild(document.createTextNode(' mehr'));
        el.appendChild(link);
		this.infoWindowContent.appendChild(el);
		
		this.infoWindowContent.appendChild(link);
		
		this.marker.openInfoWindow(this.infoWindowContent);
	},

	
	getAktionenListeContent: function() {
		var lthis = this;

		if (this.aktionenListeContent == null) {
			var div = document.createElement('div');
			div.className = 'aktionenListenElement';
			div.onmouseover = function() { lthis.overviewObj.hilightAktion(this.aktion, false); };
			div.onmouseout = function() { lthis.overviewObj.unhilightAktion(this.aktion); };
			div.onclick = function() { lthis.showInfoWindowOnMarker(); };
			
			div.appendChild(document.createTextNode(this.ort == '' ? this.name : this.name + '; ' + this.ort));
						
			div.aktion = this;
			this.aktionenListeContent = div;
		}
		return this.aktionenListeContent;		
	},
	
	hilight: function(scrollIntoView) {
		if (this.aktionenListeContent != null)
			this.aktionenListeContent.className = 'aktionenListenElementHilight';
		if (this.marker != null) {
			this.marker.setImage('/imgs/geomarker_hilight.png');
		}
		
		if (!scrollIntoView || scrollIntoView == null || this.aktionenListeContent == null ||
					this.aktionenListeContent.parentNode == null) return;
		
		var pos = this.aktionenListeContent.offsetTop;
		var scrollContainer = this.aktionenListeContent.parentNode;
		var scsize = this.overviewObj.aktionenListeHeight;
		var st = scrollContainer.scrollTop;
		if (pos < st) {
			scrollContainer.scrollTop = pos;
		} else if (pos > st + scsize - 30) {
			scrollContainer.scrollTop = pos - scsize + 30;
		}
	},
	
	unhilight: function() {
		if (this.aktionenListeContent != null)
			this.aktionenListeContent.className = 'aktionenListenElement';
		if (this.marker != null) {
			this.marker.setImage('/imgs/geomarker.png');
		}
	}
}
