// JavaScript Document


// Initialize property tabs by setting tab according to querystring parameter 'tab'
function initTabs() {
 var tab = getTabParam();
 changeTab(tab);
}

// Get tab paramter, default to description
function getTabParam() {
 var query = window.location.search;
 if (query && query.length > 0) {
  query = query.substring(1);
  var params = query.split('&');

  for (var a = 0; a < params.length; a++) {
   var param = params[a];

   var nameValue = param.split('=');
   var name = nameValue[0];

   if (name == 'tab') {
    var value = nameValue[1]; 
    return value;
   }
  }
 }
 return 'description';
}

function changeTab(tab)   {
  changeSelectedTab(tab, 'Tab', 'detailTabs');
  changeSelectedTab(tab, 'Table', 'detailTables');
}

function changeSelectedTab(tab, type, containerId) {
  var detailTabs = document.getElementById(containerId);
  if (!detailTabs) {
   return;
  }

  var tabId = tab + type;
  var tabTables = detailTabs.getElementsByTagName('table');
  for (var a = 0; a < tabTables.length; a++) {
    var tabTable = tabTables[a];
    if (tabTable.id == tabId) {
     tabTable.style.display = "block";
    } else if (tabTable.id.indexOf(type) > 0) {
     tabTable.style.display = "none";
    }
  }      
}