	function hookActivate(tab) {
		if (tab.id == "googleMap") {
			load();
		}
	}
	
	function hookPassivate(tab) {
		if (tab.id != "googleMap") {
			GUnload();
		}
	}			
	
	var Class = {
	  create: function() {
	    return function() {
	      this.initialize.apply(this, arguments);
	    }
	  }
	}
	
	var Abstract = new Object();
	
	Object.extend = function(destination, source) {
	  for (var property in source) {
	    destination[property] = source[property];
	  }
	  return destination;
	}
	
	function $() {
	  var elements = new Array();
	
	  for (var i = 0; i < arguments.length; i++) {
	    var element = arguments[i];
	    if (typeof element == 'string')
	      element = document.getElementById(element);
	
	    if (arguments.length == 1)
	      return element;
	
	    elements.push(element);
	  }
	
	  return elements;
	}
	
	// ---------------------------------------------------------------------------------
	
	var Tab = Class.create();
	
	Tab.prototype = {
		initialize: function(id, classA, classP, text) {
			this.id = id;
			this.activeClass = classA;
			this.passiveClass = classP;
			this.text = text;
			var me = this;
		},	
		
		notifyTabSetAdd: function(tabset){
			this.tabset = tabset;
			// this ist im Event-Context das SPAN-Element!
			this.container.tab = this;
			this.container.tabset = tabset;
			this.tabset.container.appendChild(this.container);
		},
		
		_handleClick: function() {
			// this ist im Event-Context das SPAN-Element!
			this.tabset.activate(this);
		},
				
		render: function() {
			this.container = document.createElement("div");
			if (this.isActive){
				this.container.className = this.activeClass;
			} else {
				this.container.className = this.passiveClass;
			}
			tmp = document.createElement("div");
			tmp.className="LeftCorner";
			img = document.createElement("img");
			img.src = "/oss/img/spacer.gif";
			img.className = "tabheight";
			tmp.appendChild(img);
			this.container.appendChild(tmp);
			
			tmp = document.createElement("div");
			tmp.className="Middle";
			txt = document.createTextNode(this.text);
			sp = document.createElement("span");
			sp.className = "caption";
			sp.appendChild(txt);
			tmp.appendChild(sp);
			this.container.appendChild(tmp);
			
			tmp = document.createElement("div");
			tmp.className="RightCorner";
			img = document.createElement("img");
			img.src = "/oss/img/spacer.gif";
			img.className = "tabheight";
			tmp.appendChild(img);
			this.container.appendChild(tmp);
			

			this.container.onclick = this._handleClick;
		},
		
		
		
		activate: function() {
			if (!this.isActive) {
				this.isActive = true;
			}
			if (this.container) {
				this.container.className = this.activeClass;
			} else {
				this.className = this.activeClass;
			}
			var myid = this.id;
			var mydiv = document.getElementById(myid);
			mydiv.style.display = "block";
		},
		
		passivate: function() {
			this.isActive = false;
			this.container.className = this.passiveClass;
			$(this.id).style.display = "none";
		}
	}
	
	var TabSet = Class.create();
	
	TabSet.prototype = {
		initialize: function(id) {  	
			this.tabs = new Array();
			this.container = $(id);
		},
		
		activate: function(tabElem) {     
			if (tabElem.tab) {
				tabElem.tab.tabset.selectedTab.passivate();
				hookPassivate(tabElem.tab);
			} else {
				if (this.selectedTab) {
					this.selectedTab.passivate();
				}
			}
			
			if (tabElem.tab) {
				tabElem.tab.tabset.selectedTab = tabElem.tab;
				tabElem.tab.activate();
				hookActivate(tabElem.tab);
			} else {
				this.selectedTab = tabElem;
				tabElem.activate();
			}	
		},
		
		
		add: function(tab) {
			tab.render();
			if (this.tabs.length == 0) {
				this.activate(tab);
			} 			
			
			this.tabs[this.tabs.length] = tab;
			tab.notifyTabSetAdd(this);
		},
		
		addRight: function() {
			tmp = document.createElement("div");
			tmp.className = "rightElement";
			img = document.createElement("img");
			img.src = "/oss/img/spacer.gif";
			img.className = "tabheight";
			tmp.appendChild(img);
			this.container.appendChild(tmp);
		}
	} 

