var nn4;
var ie4;


function popupMedium(p_page, p_width, p_height)
{
  popup=open(p_page, "medpopup", "toolbar=no,width="+p_width+",height="+p_height+",left=275,top=200,directories=no,status=no,scrollbars=yes,resize=no,menubar=no","false");
  if (window.popup && !window.popup.closed)
    window.popup.focus()
}

function init(){
  nn4 = (document.layers)? true:false;
  ie4 = (document.all)? true:false;
  if (nn4) {
    window.captureEvents(Event.RESIZE);
    window.onresize = resize;
  }
}

function resize(e) {
    window.location.reload();
    return false;
}

function findLayer(layerName) {
  if (ie4) {
    if (document.all[layerName].style)
      return document.all[layerName].style;
    else
      return "";
  }
  if (nn4)
    return findNNlayer(layerName, document);
}

function findNNlayer(layerName, currLayer) {
  var found="";
  if (currLayer.layers[layerName])
    return currLayer.layers[layerName];
  else {
    for (var i=0; i<currLayer.layers.length; ++i) {
      found = findNNlayer(layerName, currLayer.layers[i]);
      if (found)
	return found;
    }
    return found;
  } 
}

function showLayer(currLayer) {findLayer(currLayer).visibility=(nn4)?"show":"visible";}
function hideLayer(currLayer) {findLayer(currLayer).visibility=(nn4)?"hide":"hidden";}
function raiseLayer(currLayer) {findLayer(currLayer).zIndex=2;}
function lowerLayer(currLayer) {findLayer(currLayer).zIndex=0;}

function writeLayer(currLayer, content) {
  if (ie4) {
    eval("document.all."+currLayer).innerHTML = content;
  }
  if (nn4) {
    lay=findNNlayer(currLayer, document);
    lay.document.write(content);
    lay.document.close();
  }
}

function changePage(nextPage)
{
  if ((nextPage > 0) && (nextPage <= maxPages)) {	
    currLayer = currSet + currPage;
    nextLayer = currSet + nextPage;
    hideLayer(currLayer);
    showLayer(nextLayer);
    currPage=nextPage;
    writeLayer("pageNum", "<p class='textSmall'>" + currPage + " of " + maxPages);
  }
}


function targetSelected(currTarget) {
  targetMap = currTarget + "UPdiv";
  targetTitle = currTarget + "Target";
  if (targetMap != currMapRaised) {
    showLayer(targetMap);
    if (currMapRaised)
      hideLayer(currMapRaised);
    currMapRaised=targetMap;
    showLayer(targetTitle);
    if (currTitleRaised)
      hideLayer(currTitleRaised);
    currTitleRaised=targetTitle;
  }
}

function checkWithinFrameset() {
  if (parent==window) {   //if not within a frameset
    var hrefMain='';
    var hrefSearch='';
    var searchIndex = location.pathname.indexOf('?');
    if (searchIndex > -1) {
      hrefMain = location.pathname.substring(0, searchIndex-1);
      hrefSearch = location.pathname.substring(searchIndex, location.pathname.length-1);
    }
    else
      hrefMain = location.pathname;
      
    //get path e.g. '/tourism/accommodation.php3' gets '/tourism/'
    var pathName = hrefMain.substring(hrefMain.indexOf('/'), hrefMain.lastIndexOf('/')+1);
    //get page e.g. '/tourism/accommodation.php3' gets 'accommodation'
    var pageName = '';
    if (hrefMain.indexOf('.') >-1)
      pageName=hrefMain.substring(hrefMain.lastIndexOf('/')+1, hrefMain.lastIndexOf('.')); 
    else 
      pageName='index';
    //get suffix e.g. '/tourism/accommodation.php3' gets '.php3'
    var pageSuffix = hrefMain.substring(hrefMain.lastIndexOf('.'), hrefMain.length);
    var framesetPath = '';

    var i=0;
    while ((i=pathName.indexOf('/',i+1)) > -1)
      framesetPath+='../';

    pageSuffix = (pageSuffix=='.php3') ? '.php' : '.htm';
    //    alert('framesetPath='+framesetPath+'\npathName='+pathName+'\npageName='+pageName+'\npageSuffix='+pageSuffix);
    top.location.href=framesetPath+"frameset.php?main="+pathName+pageName+pageSuffix;
  }
}
