function activateObjectTab(selectedTab) { 
  sourceId = selectedTab.id; 
  selectedTab = 'tab_' + selectedTab.id;
  tabControl = document.getElementById('tabsholder');
  tabControlChilds = tabControl.childNodes;
  for (i = 0; i < tabControlChilds.length; i++) {
    node = tabControlChilds[i];
    if (node.nodeName == "DIV") { // Checks if it is a tab
      if (node.id  == selectedTab) {
        node.style.display = 'block';
        node.style.visibility = 'visible';
        if (selectedTab == 'tab_location') {
          node.style.width = '824px';
          node.style.height = '450px';
        }
        //node.className = 'tabSelected';
      }
      else {
        node.style.display = 'none';
        node.style.visibility = 'hidden';
        //node.className = 'tabDisabled';
      }
    }
  }
  activateObjectTabLink(sourceId);
  return false;
}

function activateObjectTabLink(selectedTab) {
  tabs = document.getElementById('pagenavholder').childNodes;

  for (i = 0; i < tabs.length; i++) {
    if (tabs[i].nodeName == 'DIV') {
      if (tabs[i].className == 'tabholder active') {
        tabs[i].className = 'tabholder';
      } 
      
      if (tabs[i].id == selectedTab) {
        tabs[i].className = 'tabholder active';
      }
    }   
  }
}

function retrieveImagePopup(uuid, buildingType)
{
  if(table = document.getElementById('wrapper'))
  {
    removeImagePopup();
    
    var windowSize = getWindowSize();
    var height     = ((document.body.scrollHeight > windowSize[1]) ? document.body.scrollHeight : windowSize[1]);
    var opacity    = 60;

    var fillScreen = document.createElement("div");
    fillScreen.setAttribute("id", "popupFillScreen");  
    fillScreen.style.position        = 'absolute';
    fillScreen.style.zIndex          = '100';
    fillScreen.style.top             = '0px';
    fillScreen.style.left            = '0px';
    fillScreen.style.height          = height + 'px';
    fillScreen.style.width           = windowSize[0] + 'px';
    fillScreen.style.backgroundColor = '#000000';
    fillScreen.style.opacity         = (opacity / 100); 
    fillScreen.style.MozOpacity      = (opacity / 100); 
    fillScreen.style.KhtmlOpacity    = (opacity / 100); 
    fillScreen.style.filter          = "alpha(opacity=" + opacity + ")"; 
    document.body.appendChild(fillScreen);
    document.body.style.overflow  = 'hidden';
  
    var div = document.createElement('div');
    div.setAttribute('id', 'popupContainer');
    div.style.zIndex = '105';
    div.innerHTML = '<div id="popupLoading"></div>';
    document.body.insertBefore(div, table);
    
    document.body.style.cursor = 'wait';
  
    var url               = 'image_popup.php';
    var params            = 'uuid=' + uuid + '&buildingType=' + buildingType;
    var responseFunction  = 'retrieveImagePopupResponse';
    remoteRequest(url, params, responseFunction, 'POST');
  }
}

function retrieveImagePopupResponse()
{
  if (http_request && http_request.readyState == 4)
  {
    document.body.style.cursor = 'default';
    if((http_request.status == 200 && http_request.responseText!='') && (div = document.getElementById('popupContainer')))
    {
      div.innerHTML = http_request.responseText;
    }
    else
    {
      removeImagePopup();
    }
  }
}

function removeImagePopup()
{
  if(popup = document.getElementById('popupContainer'))
  {
    document.body.removeChild(popup);
  }
  
  if(fillScreen = document.getElementById('popupFillScreen'))
  {
    document.body.removeChild(fillScreen);
  }
}

function updateNumImagePopup(num)
{
  if(elem = document.getElementById('curImgNum'))
  {
    elem.innerHTML = num;
  }
}