Drupal.locale = { 'pluralFormula': function ($n) { return Number(($n!=1)); }, 'strings': {"An AJAX HTTP error occurred.":"Ein AJAX-HTTP-Fehler ist aufgetreten","HTTP Result Code: !status":"HTTP-R\u00fcckgabe-Code: !status","An AJAX HTTP request terminated abnormally.":"Eine AJAX-Anfrage ist abnormal beendet worden.","Debugging information follows.":"Im Folgenden finden Sie Debugging-Informationen.","Path: !uri":"Pfad: !uri","StatusText: !statusText":"Statustext: !statusText","ResponseText: !responseText":"Antworttext: !responseText","ReadyState: !readyState":"ReadyState: !readyState","Hide":"Ausblenden","Show":"Anzeigen","Show shortcuts":"Tastaturkombinationen anzeigen","Hide shortcuts":"Shortcuts ausblenden","Re-order rows by numerical weight instead of dragging.":"Zeilen mittels numerischer Gewichtung ordnen statt mit Drag-and-Drop","Show row weights":"Zeilenreihenfolge anzeigen","Hide row weights":"Zeilenreihenfolge ausblenden","Drag to re-order":"Ziehen um die Reihenfolge zu \u00e4ndern","Changes made in this table will not be saved until the form is submitted.":"\u00c4nderungen in dieser Tabelle werden nicht gespeichert, bis dieses Formular abgesendet wurde.","Autocomplete popup":"Popup zur automatischen Vervollst\u00e4ndigung","Searching for matches...":"Suche \u2026","Select all rows in this table":"Alle Zeilen dieser Tabelle ausw\u00e4hlen","Deselect all rows in this table":"Alle Zeilen dieser Tabelle abw\u00e4hlen","Hide summary":"Zusammenfassung verbergen","Edit summary":"Zusammenfassung bearbeiten","Not in menu":"Nicht im Men\u00fc","New revision":"Neue Version","No revision":"Keine Version","By @name on @date":"Von @name am @date","By @name":"Von @name","Not published":"Nicht ver\u00f6ffentlicht","Alias: @alias":"Alias: @alias","No alias":"Kein Alias","@number comments per page":"@number Kommentare pro Seite","(active tab)":"(aktiver Reiter)","This permission is inherited from the authenticated user role.":"Diese Berechtigung wird von der Rolle \u201aAuthentifizierte Benutzer\u2018 ererbt.","Edit":"Bearbeiten","Requires a title":"Ben\u00f6tigt einen Titel","Don't display post information":"Beitragsinformationen nicht anzeigen","Please wait...":"Bitte warten...","jQuery UI Tabs: Not enough arguments to add tab.":"jQuery UI-Reiter: Nicht genug Argumente, um einen Reiter hinzuzuf\u00fcgen.","Loading...":"Laden...","None":"Keine","Other":"Andere","Show layout designer":"Layout-Designer anzeigen","Hide layout designer":"Layout-Designer ausblenden","An error occurred at @path.":"Ein Fehler ist auf @path aufgetreten."} };;
var iworx_maps = new Array();

var staticMarkers = new Array();

Array.prototype.copy = function () {
	return ((new Array()).concat(this));
};

if(!Array.indexOf)
{
	Array.prototype.indexOf = function(el)
	{
	    for(var i = 0; i < this.length; i++) if(el == this[i]) return i;
	};
}

function Map(id)
{
	this.centerLat = 0;
	this.centerLng = 0;
	this.zoomLevel = 11;
	
	this.mapElementID = id;
	
	this.map;
	
	this.markerContainer = new MarkerContainer();
	
	this.useDynamicMarkers = false;
	
	this.feedUrl = "";
	
	this.setCenter = function(lat, lng)
	{
		this.centerLat = lat;
		this.centerLng = lng;
	};
	
	this.setZoomLevel = function(zoom)
	{
		this.zoomLevel = zoom;
	};
	
	this.setFeedUrl = function(url)
	{
		this.feedUrl = url;
	};
	
	this.loadMap = function()
	{
		var that = this;
		
		var initialPosition = new google.maps.LatLng(this.centerLat, this.centerLng);
		
		var myOptions = {
			      zoom: this.zoomLevel,
			      center: initialPosition,
			      mapTypeId: google.maps.MapTypeId.TERRAIN,
			      minZoom: 14,
			      maxZoom: 20
			    };
			    
		this.map = new google.maps.Map(document.getElementById(this.mapElementID), myOptions);
		
		this.markerContainer.setMap(this.map);
		
		//var mgrOptions = { borderPadding: 50, maxZoom: 15, trackMarkers: true };
		
		//var size = this.map.getBounds();
		
		google.maps.event.addListener(this.map, 'idle', function() { // bounds_changed
			that.update();
		});
		/*
		var startuplistener = google.maps.event.addListener(this.map, 'tilesloaded', function() { // startup, is removed at first run
			
			that.highlightMarker(mainMarker, "#FF0000");
			that.update();
		});
		
		google.maps.event.addListener(this.map, 'zoom_changed', function() {
			
			for(var i=0; i<that.markerContainer.markers.length; i++)
			{
				if(that.markerContainer.markers[i]._highlightCircle != null)
				{
					that.highlightMarker(that.markerContainer.markers[i], that.markerContainer.markers[i]._highlightColor);
				}
			}
			
		});
		*/
	};
	
	this.update = function()
	{
		google.maps.event.clearListeners(this.map, 'tilesloaded');
		
		var bounds = this.map.getBounds();
		
		if(this.useDynamicMarkers == true) this.loadMarkers(bounds);
		
	};
	
	this.loadMarkers = function(bounds)
	{
		var that = this;
		
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		
		var url = 
			that.feedUrl+
			'?left='+southWest.lng()+
			'&top='+northEast.lat()+
			'&right='+northEast.lng()+
			'&bottom='+southWest.lat();
		
		jQuery.getJSON(url, {}, function(data)
		{
			/*
			$.each(data.regions, function(key, val) {
				
				var id = val.id;
				
				var regionName = val.name;
				
				var regionLat = val.geolat;
				var regionLng = val.geolng;
				
				var regionText =
					"<strong>Name</strong><br />"+
					regionName+"<br /><br />";
				
				that.addMarker(id, regionLat, regionLng, regionText, {"title": regionName, "category": "r", "zoom": [0, 9]}, {});
			});
			*/
			
			jQuery.each(data.results, function(key, val) {
				
				that.addMarker(val);
				
			});
			
			that.markerContainer.refresh();
		});
		
	};
	
	this.addMarker = function(markerdata)
	{
		
		var that = this;
		
		var existingMarker = that.markerContainer.markerExists(markerdata.id);
		
		if(existingMarker == null)
		{
			var marker = that.createMarker(markerdata);
			
			that.markerContainer.addMarker(marker);

			return marker;
		}
		else
		{
			return existingMarker;
		}
	};
	
	this.createMarker = function(markerdata)
	{
		var that = this;
			
		var icon = new google.maps.MarkerImage(markerdata.icon,
			      // This markers size
			      new google.maps.Size(25, 26),
			      // The origin for this image
			      new google.maps.Point(0,0),
			      // The anchor for this image
			      new google.maps.Point(12, 14));
		
		var marker = new google.maps.Marker({
	        position: new google.maps.LatLng(markerdata.position.lat, markerdata.position.lng),
	        map: that.map,
	        visible: true,
	        icon: icon
	    });
		
		var type = markerdata.type;
		
		if(!type) type = "dynamic";
		marker._options = new Object();
		marker._options["id"] = markerdata.id;
		marker._options["type"] = markerdata.type;
		marker._options["html"] = markerdata.html;
		
		marker._optionsData = markerdata;
		
		var infowindow = new google.maps.InfoWindow({
            content: marker._options["html"]
        });
        
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(that.map,marker);
          });
		
		return marker;
	};
	
	this.highlightMarker = function(marker, color)
	{
		var that = this;
	};
}

function MarkerContainer()
{
	this.map;
	
	this.markers = new Array();
	
	this.optionsSelection = new Object();
	
	this.optionsProperty = new Object();
	
	this.optionsMinValues = new Object();
	
	this.showDynamic = true;
		
	this.setMap = function(map)
	{
		this.map = map;
	};
	
	this.addMarker = function(marker)
	{
		this.markers.push(marker);
		marker.setMap(this.map);
		marker.setVisible(false);
	};
	
	this.setOptions = function(selection, property, minValues)
	{
		this.optionsSelection = selection;
		
		this.optionsProperty = property;
		
		this.optionsMinValues = minValues;
	};
	
	this.refresh = function()
	{
		for(var i=0; i<this.markers.length; i++)
		{
			var visible = true;
			if(this.markers[i]._options["type"] == "dynamic")
			{
				if(this.showDynamic == true)
				{
					for (var selection in this.optionsMinValues)
					{
						if(this.markers[i]._optionsMinValues[selection] < this.optionsMinValues[selection])
						{
							visible = false;
						}
					}
					
					for (var selection in this.optionsSelection)
					{
						if(this.optionsSelection[selection].indexOf(this.markers[i]._optionsSelection[selection]) == -1)
						{
							visible = false;
						}
						
					}
				}
				else
				{
					visible = false;
				}
			}
			else
			{
				visible = true;
			}
			
			if(visible == false)
			{
				this.markers[i].setVisible(false);
			}
			else
			{
				this.markers[i].setVisible(true);
			}
		}
	};
	
	this.markerExists = function(markerid)
	{
		for(var i=0; i<this.markers.length; i++)
		{
			if(this.markers[i]._options["id"] == markerid) return this.markers[i];
		}
		
		return null;
	};
	
	/*
	this.showMarkerContainer = function()
	{
		var that = this;
		var outStr = "";
		
		for (var type in that.markerContainer)
		{
			outStr += type + ": " + that.markerContainer[type] + "\n";
			for (var marker in that.markerContainer[type])
			{
				outStr += " - "+marker + ": " + that.markerContainer[type][marker] + "\n";
				
			}
		}
		alert(outStr);
	}*/
};

(function ($) {
  Drupal.Panels = {};

  Drupal.Panels.autoAttach = function() {
    if ($.browser.msie) {
      // If IE, attach a hover event so we can see our admin links.
      $("div.panel-pane").hover(
        function() {
          $('div.panel-hide', this).addClass("panel-hide-hover"); return true;
        },
        function() {
          $('div.panel-hide', this).removeClass("panel-hide-hover"); return true;
        }
      );
      $("div.admin-links").hover(
        function() {
          $(this).addClass("admin-links-hover"); return true;
        },
        function(){
          $(this).removeClass("admin-links-hover"); return true;
        }
      );
    }
  };

  $(Drupal.Panels.autoAttach);
})(jQuery);
;

