// ©System Simulation Ltd
// $Header: /local/cvs_repository/ra.cms.web/docroot/javascript/cms.js,v 1.1.1.1 2006/11/14 10:10:56 mark Exp $

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function hideHelp() {
 document.getElementById('helpdisplay').style.position='absolute';
 document.getElementById('helpdisplay').style.visibility='hidden';
 document.getElementById('helpshow').style.position='relative';
 document.getElementById('helpshow').style.visibility='visible';
}

function showHelp() {
 document.getElementById('helpdisplay').style.position='relative';
 document.getElementById('helpdisplay').style.visibility='visible';
 document.getElementById('helpshow').style.position='absolute';
 document.getElementById('helpshow').style.visibility='hidden';
}

function showItem(id) {
 if (document.getElementById(id)) {
  document.getElementById(id).style.display='block';
 }
}

function hideItem(id) {
 if (document.getElementById(id)) {
  document.getElementById(id).style.display='none';
 }
}

function showSpan(id) {
 if (document.getElementById(id)) {
  document.getElementById(id).style.position='relative';
  document.getElementById(id).style.visibility='visible';
 }
}

function hideSpan(id) {
 if (document.getElementById(id)) {
  document.getElementById(id).style.position='absolute';
  document.getElementById(id).style.visibility='hidden';
 }
}

function showTab(tab) {
 hideItem('tab0captionon');
 hideItem(tab+'captionoff');
 showItem('tab0captionoff');
 showItem(tab+'captionon');
 showItem(tab);
}

function hideTab(tab) {
 hideItem(tab);
 hideItem(tab+'captionon');
 showItem(tab+'captionoff');
}

function showTab0() {
 showItem('tab1');
 showItem('tab2');
 showItem('tab3');
 showItem('tab4');
 hideItem('tab1captionon');
 hideItem('tab2captionon');
 hideItem('tab3captionon');
 hideItem('tab4captionon');
 hideItem('tab0captionoff');
 showItem('tab1captionoff');
 showItem('tab2captionoff');
 showItem('tab3captionoff');
 showItem('tab4captionoff');
 showItem('tab0captionon');
}

function showTab1() {
 hideTab('tab2');
 hideTab('tab3');
 hideTab('tab4');
 showTab('tab1');
}

function showTab2() {
 hideTab('tab1');
 hideTab('tab3');
 hideTab('tab4');
 showTab('tab2');
}

function showTab3() {
 hideTab('tab1');
 hideTab('tab2');
 hideTab('tab4');
 showTab('tab3');
}

function showTab4() {
 hideTab('tab1');
 hideTab('tab2');
 hideTab('tab3');
 showTab('tab4');
}

function initTabs() {
 if (document.getElementById('tabstopdiv')) {
  showItem('tabstopdiv');
  showItem('tabsbottomdiv');
  showItem('tabsdiv');
  showTab1();
 }
}

function resetSelect(selectId) {
 if (document.getElementById(selectId)) {
  document.getElementById(selectId).selectedIndex = 0;
 }
}

function clearSpecialisms(selectId) {
 var numoptions = document.getElementById(selectId).options.length;
 for (var i=1; i<numoptions; i++) {
  var id = document.getElementById(selectId).options[i].value;
  id = hcodeToHTML(id);
  if (document.getElementById(id)) {
   hideItem(id);
  }
 }
}

function hcodeToHTML(hcode) {
 var html = hcode.replace('?', 'QUESTIONMARK');
 return html;
}

function showSpecialism(id, selectId) {
 id = hcodeToHTML(id);
 if (document.getElementById(id)) {
  if (document.getElementById(id).style.display == "none") {
   clearSpecialisms(selectId);
   showItem(id);
  }
 } else {
  clearSpecialisms(selectId);
 }
}

function showSpecialSelect(selectDivId, addId, removeId) {
 showItem(selectDivId);
 hideItem(addId);
 hideSpan(removeId);
}

function hideSpecialSelect(selectDivId, addId, removeId, selectId) {
 resetSelect(selectId);
 hideItem(selectDivId);
 showItem(addId);
 showSpan(removeId);
}

function onLoadInit() {
 externalLinks();
// initTabs();
}

window.onload = onLoadInit;


