window.onerror = function(){return false;}
window.defaultStatus ="";
function makeZflag() {
	this.NS = document.layers ? 1:0;
	this.IE = document.all ? 1:0;
	this.gecko = document.getElementById ? 1:0;
	this.mac = (navigator.appVersion.indexOf("Mac") > -1) ? 1:0;
	this.opera = (navigator.appName.indexOf("Opera") > -1) ? 1:0;
	this.netscape = (navigator.appName.indexOf("Netscape") > -1) ? 1:0;
	}
Zflag = new makeZflag();
if (Zflag.NS) {
	layerstart = "document.";
	layerstyle = "";  
	layerobjstart=""; }
if (Zflag.gecko){
	layerstart = "document.getElementById('";
	layerstyle = "').style"; 
	layerobjstart="')"; }
if (Zflag.IE){
	layerstart = "document.all.";
	layerstyle = ".style"; 
	layerobjstart=""; }

function makeZbrowse() { this.id = "Zbrowse";}
makeZbrowse.prototype.width = function() {return Zflag.IE?document.body.clientWidth:window.innerWidth;}
makeZbrowse.prototype.height = function() {return Zflag.IE?document.body.clientHeight:window.innerHeight;}
makeZbrowse.prototype.scrollY = function() {return Zflag.IE?document.body.scrollTop:pageYOffset;}
makeZbrowse.prototype.scrollX = function() {return Zflag.IE?document.body.scrollLeft:pageXOffset;}
Zbrowse = new makeZbrowse();

sliderObject = new Array();
function initsliderObjects() {
// parameters are ID, top, left, height, width, visibility
  sliderObject[0] = new makeObject('cursor', ctop, cleft, 150, 150, 'visible');
  sliderObject[1] = new makeObject('vlineup', 0, cleft-10, ctop, 60, 'visible');
  sliderObject[2] = new makeObject('vlinedn', 150 + ctop, 100 + cleft, winHeight - ctop - 150, 60, 'visible');
  sliderObject[3] = new makeObject('hlinelf', 100 + ctop, 0, 60, cleft, 'visible');
  sliderObject[4] = new makeObject('hlinert', ctop-10, 150 + cleft, 60, winWidth - cleft - 150, 'visible');
  sliderObject[5] = new makeObject('top', 0, sliderObject[1].left, 30, 60, 'visible');
  sliderObject[6] = new makeObject('bot', winHeight - 30, sliderObject[2].left, 30, 60, 'visible');
  sliderObject[7] = new makeObject('left', sliderObject[3].top, 0 , 60, 30, 'visible');
  sliderObject[8] = new makeObject('right', sliderObject[4].top, winWidth - 30 , 60, 30, 'visible');
  sliderObject[9] = new makeObject('topleft', 0, 0, 30, 30, 'visible');
  sliderObject[10] = new makeObject('topright', 0, winWidth - 30, 30, 30, 'visible');
  sliderObject[11] = new makeObject('botleft', winHeight - 30, 0, 30, 30, 'visible');
  sliderObject[12] = new makeObject('botright', winHeight - 30, winWidth - 30, 30, 30, 'visible');
  sliderObject[13] = new makeObject('vlinelf', 0, 0, winHeight, 30, 'visible');
  sliderObject[14] = new makeObject('vlinert', 0, winWidth - 30, winHeight, 30, 'visible');
  sliderObject[15] = new makeObject('hlinetop', 0, 0, 30, winWidth, 'visible');
  sliderObject[16] = new makeObject('hlinebot', winHeight - 30, 0, 30, winWidth, 'visible');
  for (m=0;m<sliderObject.length;m++){sliderObject[m].setAllProps();}
}

function getsliderObj(id) {
// find a DOM object given the object ID
  for (m=0;m<sliderObject.length;m++){
    if (sliderObject[m].ID == id){
      return m;
    }
  }
  return false;
}

clicker = new Array();
function initClicker() {
// parameters are ID, top, left, height, width, visibility
  clicker[0] = new makeObject('home', ctop + 5, cleft + 5, 150, 150, 'visible');
  clicker[1] = new makeObject('port', ctop + 5, cleft + 5, 155, 150, 'visible');
  clicker[2] = new makeObject('tut', ctop + 5, cleft + 5, 150, 150, 'visible');
  clicker[3] = new makeObject('forum', ctop + 5, cleft + 5, 150, 150, 'visible');
  for (m=0;m<clicker.length;m++){clicker[m].setAllProps();}
}

guideObject = new Array();
function initguideObjects(gtop, gleft) {
  guideObject[0] = new makeObject('up', 20, gleft+30, gtop-10, winWidth-(gleft+50), 'hidden');
  guideObject[1] = new makeObject('dn', 140+gtop, 20, winHeight-(160+gtop), 100+gleft, 'hidden');
  guideObject[2] = new makeObject('lf', 20, 20, gtop+100, gleft-10, 'hidden');
  guideObject[3] = new makeObject('rt', gtop+30, 140+gleft, winHeight-(gtop+50), winWidth-(gleft+160), 'hidden');
  for (m=0;m<guideObject.length;m++){guideObject[m].setAllProps();}
}

winObject = new Array();
function initwinObjects(){
  winObject[0]= new makeObject('mainframe', -1, -1, 1, 1, 'hidden');
  winObject[1]= new makeObject('navframe', -1, -1, 1, 1, 'hidden');
  winObject[2]= new makeObject('headframe', -1, -1, 1, 1, 'hidden');
  winObject[3]= new makeObject('graphicmenu', 0, 0, 0, 150, 'visible');
}

function init() {
  makeUp=(Zflag.netscape) ? 15:0;
  winWidth = (Zbrowse.width() > 250) ? Zbrowse.width()-makeUp:220 ;
  winHeight= (Zbrowse.height() > 250) ? Zbrowse.height()-makeUp:220 ;
  if (currSelection > 3) {
    ctop = (winHeight-150)/2; 
    cleft = (winWidth-150)/2;
  } else {
    ctop = ((Math.floor(currSelection/2)) * (winHeight-242)) + 46; // 150 for cursor and 46 for border and spacing
    cleft = ((currSelection%2) * (winWidth-242)) + 46; // ditto
    setWinpos(currSelection);
  }
  initsliderObjects();
  initClicker();
  initwinObjects();
  StartTimer(1);
  initguideObjects(ctop,cleft);
  graphicIt(graphicSelection);
  flipWins();
}
graphicSelection=0;
selection = 5; currSelection = 5;
Kdelay = 10;
locationArray = [[3,1,0],[1,2,3],[0,3,2],[2,0,1]];
contentArray = [
                ["./investir.htm","/investir.htm","/investir.htm"],
                ["./tmain.html","./tnav.html","./thead.html"],
                ["./pmain.html","./pnav.html","./phead.html"],
               ];
onload = init;
onresize=init;


graphicNames = ['f3dintr3','f3dintr2','f3dintr3'];
graphicImgs = ['cu','vu','vd','hl','hr','tp','bt','lf','rt','tl','tr','bl','br','vl','vr','ht','hb'];
graphicArray = new Array();

// preload the graphic images
for (y=0; y<graphicImgs.length; y++) {
  graphicArray[y] = new Array(graphicNames.length);
  for (x=0; x<graphicNames.length; x++) {
    graphicArray[y][x] = new Image;
    graphicArray[y][x].src = './graphics/' + graphicNames[x] + '/' + graphicImgs[y] + '.gif';
  }
}
function graphicIt(graphicNum) {
  for (z=0; z<graphicImgs.length; z++) {
    document.images[sliderObject[z].ID].src = graphicArray[z][graphicNum].src;
  }
  graphicSelection=graphicNum;
  // now flip the contents frame graphic if we aren't initializing
 if (!(currSelection == 5)) {mainframe.graphicIt(graphicSelection);}
}

function graphicMenu(state) {
  winObject[3].DHTML.top = top - 25;
  winObject[3].DHTML.left = left - 25;
  winObject[3].DHTML.visibility = (state==1) ? 'visible':'visible';
}

function makeObject(ID, top, left, height, width, visibility) {
	this.ID = ID ? ID : "Object"+(Myobject.length);
      this.visibility = visibility ? visibility:"visible";
      this.top = top ? top:0;
      this.left = left ? left:0;
      this.height = height ? height:0;
      this.width = width ? width:0;
      this.DHTML = eval(layerstart + this.ID + layerstyle);
      this.OBJ = eval(layerstart + this.ID + layerobjstart);
}
makeObject.prototype.setAllProps = function() {
      this.DHTML.visibility = this.visibility;
      this.DHTML.top = this.top;
      this.DHTML.left = this.left;
      this.DHTML.height = this.height;
      this.DHTML.width = this.width;
}


function slideIt(selection) {
  if (!(selection == currSelection)) {
    xTarget = ((selection%2) * (winWidth-242))+46; 
    yTarget = (Math.floor(selection/2)) * (winHeight-242)+46;
    doSlide();
    initguideObjects(yTarget, xTarget);
    setWinpos(selection);
    setTimeout('flipWins();',1500);
    putNav(selection);
  }
    currSelection = selection;
}

function doSlide() {
  dX = (xTarget - cleft); dY = (yTarget - ctop);
  if (!(dX==0) || !(dY==0)) {
    stepX = (Math.abs(dX)<2) ? dX:dX/10;
    stepY = (Math.abs(dY)<2) ? dY:dY/10;
    cleft = cleft + stepX; ctop = ctop + stepY;
    initsliderObjects();
    setTimeout("doSlide();",Kdelay);
  }
  initClicker();
}
function setWinpos(selection) {
  for (x=1; x>-1; x--){
    winObject[x].DHTML.visibility='hidden';
    winObject[x].DHTML.top = guideObject[locationArray[selection][x]].top;
    winObject[x].DHTML.left = guideObject[locationArray[selection][x]].left;
    winObject[x].DHTML.width = guideObject[locationArray[selection][x]].width;
    winObject[x].DHTML.height = guideObject[locationArray[selection][x]].height;
  }  
}
function loadPages(selection) {
    if(Zflag.gecko) {
        document.getElementById(winObject[0].ID).src = contentArray[selection][0] ;
    } else if(Zflag.IE) {
        document.frames[winObject[0].ID].document.location = contentArray[selection][0] ;
    }
}

function flipWins() {
  for (x=1;x>-1;x--) { 
    winObject[x].DHTML.visibility = 'visible';
  }
}

function putNav(selection) {
  if (selection == 3) {
    if(Zflag.gecko) {
        document.getElementById(winObject[1].ID).src = contentArray[selection][1] ;
    } else if(Zflag.IE) {
        document.frames[winObject[1].ID].document.location = contentArray[selection][1] ;
    }
  } else {    
    if(Zflag.gecko) {
      window.frames.navframe.document.getElementById('dataspace').innerHTML = "";
      window.frames.navframe.document.getElementById('dataspace').innerHTML = window.frames.mainframe.document.getElementById('navigation').innerHTML;
    } else if(Zflag.IE) {
      document.frames['navframe'].document.dataspace.innerHTML = "";
      document.frames['navframe'].document.dataspace.innerHTML = document.frames['mainframe'].document.navigation.innerHTML;
    }
  }
}

function StartTimer(delai) {
  setTimeout("loadPages(0,0);",delai*1000);
}
