function TItem() {
  this.caption = "";
  this.url     = "";
}

function TMenu(num) {
  this.quant = 0;
  this.max   = num;
  this.Item = new Array();
  for (i = 0; i < num; i++) {
    this.Item[i] = new TItem();
  }
  this.AddItem = AddItem;
  this.Build   = Build;
  this.BuildSub= BuildSub;
}

function AddItem(caption, url) {
  if (this.quant == this.max) {
    alert('Não é possível inserir mais itens no menu!');
  } else {
    this.Item[this.quant].caption = caption;
    this.Item[this.quant].url     = url;
    this.quant = this.quant + 1;
  }
}

function Build() {
  var strmain = document.location.href; 
  var strpart, isThisPage, imgsrc;

  document.writeln('			<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">');
  document.writeln('			  <TR>');
  document.writeln('				<TD width="15">&nbsp;</TD>');
  document.writeln('				<TD>');
  
  document.writeln('					<TABLE width="100%" border="0" cellpadding="3" cellspacing="1">');
  
  for (i = 0; i < this.quant; i++) {

    strpart = this.Item[i].url;
	if (strmain.indexOf(strpart, (strmain.length - strpart.length)) == -1) {
	  isThisPage = false;
	  imgsrc = '/onlinev2/img/arrow_blue.gif';
	} else {
	  isThisPage = true;
	  imgsrc = '/onlinev2/img/arrow_green.gif';
	}

  document.writeln('					  <TR valign="top">');
  document.writeln('						<TD width="8"><img src="' + imgsrc + '" width="8" height="10"></TD>');
  document.writeln('						<TD><font face="Verdana, Arial, Helvetica, sans-serif" class="font-normal">');
  if (!isThisPage) {
    document.writeln('						  <a href="' + this.Item[i].url + '" class="a-color-main">');
  } else {
    document.writeln('						  <font class="font-color-alt">');
  }
    document.writeln('<B>' + this.Item[i].caption + '</B>');
  if (!isThisPage) {
    document.writeln('						  </a>');
  } else {
    document.writeln('						  </font>');
  }
  document.writeln('						</font>');
  document.writeln('							<hr noshade size="1" color="#CCCCCC">');
  document.writeln('						</TD>');
  document.writeln('					  </TR>');
  
  }
  
  document.writeln('					</TABLE>');
					
  document.writeln('				</TD>');
  document.writeln('				<TD width="15">&nbsp;</TD>');
  document.writeln('			  </TR>');
  document.writeln('			</TABLE>');			
			
  document.close();
}



function BuildSub() {
  var strmain = document.location.href; 
  var strpart, isThisPage;

  document.writeln('					<TABLE width="100%" border="0" cellpadding="3">');
  
  for (i = 0; i < this.quant; i++) {

    strpart = this.Item[i].url;
	if (strmain.indexOf(strpart, (strmain.length - strpart.length)) == -1) {
	  isThisPage = false;
	} else {
	  isThisPage = true;
	}

    document.writeln('					  <TR valign="top">');
    document.writeln('						<TD width="8"><img src="/onlinev2/img/arrow_green.gif" width="8" height="10"></TD>');
    document.writeln('						<TD><font face="Verdana, Arial, Helvetica, sans-serif" class="font-normal">');
    if (!isThisPage) {
      document.writeln('						  <a href="' + this.Item[i].url + '" class="a-color-alt">');
    } else {
      document.writeln('						  <font class="font-color-disabled">');
    }
  
    document.writeln(this.Item[i].caption);
  
    if (!isThisPage) {
      document.writeln('						  </a>');
    } else {
      document.writeln('						  </font>');
    }
  
    document.writeln('						</font>');
    document.writeln('						</TD>');
    document.writeln('					  </TR>');
  
  }
  
  document.writeln('					</TABLE>');
					
  document.close();
}
