
 // Global variables
 var map, infowindow;

 /**
 * Constructor function
 * TabCard is id based and completely map independent.
 * Every id must be unique.
 */
function TabCard(tabid, cardid) {

 this.tabid = tabid;
 this.cardid = cardid;
 this.makeActive = makeActive;
 this.toggleTabs = toggleTabs;
 this.makeActive(1);
}


function makeActive(num) {

 this.newcard = this.cardid + num;
 if (!this.card) this.card = this.newcard;
  // Switch cards
  document.getElementById(this.card).style.display = "none";
  document.getElementById(this.newcard).style.display = "block";

  this.toggleTabs();

  // Store active card
  this.card = this.newcard;

  var tabsdiv = document.getElementById(this.tabid);

  // Make clicked tab active and
  // unregister event listener for active tab
  for (var i = 0, m; m = tabsdiv.childNodes[i]; i++) {
   if ( (m.nodeType == 1) && (m.id.lastIndexOf(num)!=-1) ) {
     var tab = m;
     tab.className = "activeTab";
     tab.onmouseover = null;
     tab.onmouseout = null;
     tab.onclick = null;
     break;
   }
  }
};


function toggleTabs() {

 var me = this;
 var tabsdiv = document.getElementById(this.tabid);

 // Register mouse event listener for tabs
 for (var i = 0, m; m = tabsdiv.childNodes[i]; i++) {
  if (m.nodeType == 1) {
   var tab = m;

   // Reset tabs
   tab.className = "passiveTab";

   tab.onmouseover = function() {
    this.className = "hoverTab";
   };

   tab.onmouseout = function() {
    this.className = "passiveTab";
   };

   tab.onclick = function() {
    // 'this' refers to the tab here
    me.makeActive(this.id.charAt(this.id.length-1));
   };
  }
 }
};



