function createobjects()
{
  ih_main = new instance('IH_MAIN');
  hasSubMenu=(layerexists('IH_SUBMENU', 'IH_MAIN'));
  if (hasSubMenu)
    ih_submenu=new instance('IH_SUBMENU', 'IH_MAIN');
  ih_pageleft=new instance('IH_PAGELEFT', 'IH_MAIN');
  ih_arrows=new instance('IH_ARROWS', 'IH_MAIN.IH_PAGELEFT');
  ih_container=new instance('IH_CONTAINER', 'IH_MAIN.IH_PAGELEFT');
  activelayer=-1;
  rightImage=(layerexists('IH_RIGHTIMAGE', 'IH_MAIN'));
  if (rightImage)
    ih_slidshow= new slideshow('ih_slidshow', 'IMG_MAIN', 'images/');
}

function adjustdata(index)
{
  if (activelayer>-1)
  {
  	ih_header.hide();
  	ih_body.hide();
  }
  if (index>-1)
  {
  	ih_header=new instance('IH_HEADER_' + index, 'IH_MAIN.IH_PAGELEFT');
  	ih_body=new instance('IH_BODY_' + index, 'IH_MAIN.IH_PAGELEFT.IH_CONTAINER');
  	
    lw=ih_pageleft.width();
    lh=ih_pageleft.height();

    visibleheader=(ih_header.evnt.innerText);

    if (visibleheader)
    {
      ih_header.setBounds(0, 0, lw, 0);
      cy=ih_header.height() + 8;
      ih_header.show();
    }
    else
      cy=0;

    ih_body.setSize(lw, 0);
    if (ih_body.height()>lh-cy)
    {
      if (visibleheader)
      {
        ih_header.setBounds(4, 0, lw-8, 0);
        cy=ih_header.height() + 8;
      }
      ih_arrows.setBounds(0, cy, -1, lh-cy);
      ih_arrows.show()
      ih_container.setBounds(19, cy+3, lw-19, lh-cy-6);
    }
    else
    {
      ih_arrows.hide()
      ih_container.setBounds(0, cy, lw, lh-cy);
    }

    ih_body.initializescroll(ih_container);
  	ih_body.show();
  	activelayer=index;

    if (rightImage)
      ih_slidshow.update(eval("IH_SLIDES_"+index), eval("IH_INDEX_"+index), eval("IH_PAUSE_"+index));
 	}
}

function adjustcontent()
{
  if (hasSubMenu)
    ih_pageleft.setBounds(125,142,277,328)
  else
    ih_pageleft.setBounds(8,138,394,334);
}

function positionlayers()
{
  ih_main.screenCenter();
  ih_main.show();
}

function ih_onload(index)
{
  createobjects();
  positionlayers();
  adjustcontent();
  mainmenu = new initimagesmenu('TBL_MENU', 'images/', '_n.gif', '_o.gif', '_s.gif');
  if (hasSubMenu)
    submenu = new initcssmenu('TBL_SUBMENU', 'ihsubmenucell_n', 'ihsubmenucell_o', 'ihsubmenucell_s');
  arrowmenu = new initimageshover('TBL_ARROWS', 'images/', '_n.gif', '_o.gif');
  adjustdata(index);
}

function ih_onresize()
{
  positionlayers();
}

