/* ---------------------------------------------------------------------- */
/* Various map related pop-ups */
/* ---------------------------------------------------------------------- */
function showText(id, topic)
{
    var twin = window.open('./showtext?issue='+id+'&topic='+topic, 'text_win', 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
    twin.focus()
}
function showPage(section, topic)
{
    var ptwin = window.open('./showpage?section='+section+'&topic='+topic, 'ptext_win', 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
    ptwin.focus()
}
function showIssueText(id, country)
{
    var itwin = window.open('./cotext?issue='+id+'&country='+country, 'itext_win', 'scrollbars=yes,menubar=no,height=600,width=700,resizable=yes,toolbar=no,location=no,status=no');
    itwin.focus()
}
function showIconText(id, mode)
{
    if (mode) {
	  document.getElementById('content_pane').src = './cstext?iconid='+id;
    } else {
        var icwin = window.open('./cstext?iconid='+id, 'ictext_win', 'scrollbars=yes,menubar=no,height=500,width=600,resizable=yes,toolbar=no,location=no,status=no');
        icwin.focus()
    }
}
function showExtra(type, filename)
{
    var etwin = window.open('./showextra?etype='+type+'&efile='+filename, 'text_win', 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
    etwin.focus()
}
function popUp(filename)
{
    var load = window.open(filename, '', 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}

function popUpCart(filename)
{
    var load = window.open(filename, '', 'scrollbars=yes,menubar=no,height=800,width=900,resizable=yes,toolbar=no,location=no,status=no');
}

function popUp2(filename)
{
    var load = window.open(filename, '', 'scrollbars=yes,menubar=no,resizable=yes,toolbar=no,location=no,status=no');
    load.resizeTo(screen.availWidth * 0.9, screen.availHeight * 0.9);
    load.moveTo(0,0);
}

// Some browsers (IE ?) need this so the Flash window resizes properly
function resizeWin()
{
    if (document.flmainnet) {
	   document.flmainnet.width = (document.body.clientWidth * 0.8) - 50;
           //document.flmainnet.height = (document.body.clientHeight * 0.85) - 50;
	   document.flmainnet.height = (document.body.clientHeight * 1.0) - 175;
    }
    if (document.flmain) {
  	   document.flmain.width = (document.body.clientWidth * 0.8) - 50;
	   //document.flmain.height = (document.body.clientHeight * 0.85) - 50;
	   document.flmain.height = (document.body.clientHeight * 1.0) - 175;
    }
}

function resizeWin2()
{
    if (document.flmain) {
  	   document.flmain.width = (document.body.clientWidth * 1.0) - 20;
	   //document.flmain.height = (document.body.clientHeight * 0.85) - 50;
	   document.flmain.height = (document.body.clientHeight * 1.0) - 50;
    }
}

/* ---------------------------------------------------------------------- */
/* IE doesn't support :hover on anything but A tags */
/* ---------------------------------------------------------------------- */
function hilight(item)
{
   /* all because p:hover is not (currently) supported in IE */
   item.className = item.className + ' ItemHover'
}

function unHilight(item)
{
   /* all because p:hover is not (currently) supported in IE */
   item.className = item.className.replace(' ItemHover','')
   item.className = item.className.replace('ItemHover','')
}

/* ---------------------------------------------------------------------- */
/* Front page */
/* ---------------------------------------------------------------------- */
// Show map name rollover
function showMapName(name_id)
{
   nameObj = document.getElementById(name_id)
   nameObj.style.visibility = "visible"
}

// Hide map name rollover
function hideMapName(name_id)
{
   nameObj = document.getElementById(name_id)
   nameObj.style.visibility = "hidden"
}

// Show 'drop-down' menu of all maps
function showMenu(mapId) {
   var menuDivId = mapId + '_menu'
   var menuDiv = document.getElementById(menuDivId)
   menuDiv.style.visibility = "visible"
}

// Hide 'drop down' menu of all maps
function hideMenu(mapId) {
   var menuDivId = mapId + '_menu'
   var menuDiv = document.getElementById(menuDivId)
   menuDiv.style.visibility = "hidden"
}
function openMap(selectObj) {
//   var url = window.location + '/maponly?close=y&issueID=' + iid
   var iid = selectObj.options[selectObj.selectedIndex].value
   // IMPORTANT! reset the index so that clicking on the *same* entry in
   //            the drop down will still trigger onchange and opend the map!	
   selectObj.selectedIndex = 0
   var url = 'maponly?close=y&issueID=' + iid
   popUp2(url)
}

/* ---------------------------------------------------------------------- */
/* Narrative pages */
/* ---------------------------------------------------------------------- */
function showTable(tableId) {

   var content = document.getElementById('contents')
   var tables = content.getElementsByTagName('TABLE')

   for (i=0 ; i < tables.length ; i++) {
      var table = tables[i]
      if (table.className == 'AutoTable') {
          if (table.id != tableId) {
             table.style.display = 'none'
          } else {
             table.style.display = 'block'
          }
      }
   }
}
