// Form fields with this class and a rel attribute with the default value

	
var tgIVWBoxManager = Class.create({
	detailMap:null,
	pixel: null,
	baseUrl: null,
	path: "/cgi-bin/ivw/CP/",
	context: "index",
	timestamp: 0,

	initialize: function (detailMap) {
	
		this.pixel = document.createElement("img");
		this.pixel.style.width = "1px";
		this.pixel.style.height = "1px";
		this.pixel.style.visibility = "hidden";
		
		if (($("klicktel") != null && typeof($("klicktel")) != "undefined") ||
		($("telegate") != null && typeof($("telegate")) != "undefined")) {
			$("premiumMap").appendChild(this.pixel);
		}
		
		this.baseUrl = "http://klicktel.ivwbox.de";
	},
	
	track: function () {
		var zeit = new Date();
		if (zeit.getTime() - this.timestamp > 1500) {
			this.timestamp = zeit.getTime();
			if (($("klicktel") != null && typeof($("klicktel")) != "undefined") ||
			($("telegate") != null && typeof($("telegate")) != "undefined")) {
				this.pixel.src = this.baseUrl + this.path + this.context + ";/?r=" + document.referrer + "&d=" + (Math.random() * 100000);
			}
		}
	}
});
var tgLocationMapClass = Class.create({
	
	className:'tgLocationMapClass',

	initialize:function() 
	{

	},

	init:function(longitude, latitude, zoomLevel)
	{
		var map;
		if (tgBrowserIsCompatible()) {
			map = new tgMap($("premiumMap"));
			
			// Must be checked. reinitializing causes trouble by switch tabs in view!!!! 
			if(typeof map.eagleView == "undefined"){
				map.eagleView = new tgEagleView(map);
			}
			
			map.ivwBoxManager = new tgIVWBoxManager(map);
			
			map.addControl(new tgMapType(TG_ANCHOR_TOP_RIGHT));
			//map.addControl(new tgMapNavigation(TG_ANCHOR_TOP_LEFT));
			map.addControl(new tgMapSmallNavigation(TG_ANCHOR_TOP_LEFT));
			//map.addControl(new tgZoomSlider(TG_ANCHOR_TOP_LEFT));
			map.addControl(new tgMapScale(TG_ANCHOR_BOTTOM_RIGHT));
		//	$$("scaleBottomRight").style.right="5px";
			var entryPosition = new tgLngLat(longitude, latitude);
			map.setCenter(entryPosition, zoomLevel);
			
			// Eagleview
			var mapType = new tgEagleViewMapType();
			map.eagleView.addControl(mapType);

			map.eagleView.addControl(new tgEagleViewNavigation());
			
			/*
			 * Webtrends Tracking Calls (additional IVW pixel requests)
			 */
			map.observe("zoomin", function(){ 
				if (typeof(_tag)!="undefined"){
					_tag.DCSext={};
				}
				dcsMultiTrack('DCSext.maps_action', 'Zoom-In');
				map.ivwBoxManager.track();			
			});
			map.observe("zoomout", function(){
				if (typeof(_tag)!="undefined"){
					_tag.DCSext={};
				}
				dcsMultiTrack('DCSext.maps_action', 'Zoom-Out');
				map.ivwBoxManager.track();			 
			});
			map.observe("stopdrag", function(){
				if (typeof(_tag)!="undefined"){
					_tag.DCSext={};
				}
				dcsMultiTrack('DCSext.maps_action', 'Pan');
				map.ivwBoxManager.track();			 
			});
			map.observe("setmaptype", function(){
				if (typeof(_tag)!="undefined"){
					_tag.DCSext={};
				}
				dcsMultiTrack('DCSext.maps_action', 'Mapmode '+map.getCurrentMapType());
				map.ivwBoxManager.track();			
			});
			map.observe("EagleZoomIn", function(){
				if (typeof(_tag)!="undefined"){
					_tag.DCSext={};
				}
				dcsMultiTrack('DCSext.maps_action', 'Eagle View Zoom-In');
				map.ivwBoxManager.track();			 
			});
			map.observe("EagleZoomOut", function(){
				if (typeof(_tag)!="undefined"){
					_tag.DCSext={};
				}
				dcsMultiTrack('DCSext.maps_action', 'Eagle View Zoom-Out');
				map.ivwBoxManager.track();			
			});
			if (typeof(_tag)!="undefined"){
				_tag.DCSext={};
			}
			//dcsMultiTrack('DCSext.maps_action', 'map initialized');
			map.ivwBoxManager.track();
		}
	}
});