// initialize a few variables (don't change these unless you're sure about it.)
var indicator = new indicatorObj("spacer.gif", "spacer.gif", 8, 8);
var indNum = 0;
var itemSeperation = 0;
var menusLoaded = false;

//Cambia de color la celda cuando hace rollover
function BGNew(obj, new_style) { 
	obj.className = new_style; 
} 

function trChangeColorOver(obj) {
	obj.style.backgroundColor = "#66cc33";
}
function trChangeColorOut(obj) {
	obj.style.backgroundColor = "#188131";
}

var menusList = new Array();
menusList["PuertoMenu"] = new createMenuObj("PuertoMenu", 0, 124, 285, 175, "#188131");
menusList["ConcesionMenu"] = new createMenuObj("ConcesionMenu", 0, 124, 383, 220, "#188131");
menusList["EntornoMenu"] 		= new createMenuObj("EntornoMenu", 0, 124, 516, 144, "#188131");
menusList["TurismoMenu"] 		= new createMenuObj("TurismoMenu", 0, 124, 618, 160, "#188131");

with (menusList["PuertoMenu"])
{ 
	items[0] = new createMenuItem(2, "Misión, Visión", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=1");
 items[1] = new createMenuItem(2, "Estructura Organizacional", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=2");
	items[2] = new createMenuItem(2, "Estadísticas", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=3");
/*	items[3] = new createMenuItem(2, "Infraestructura Portuaria", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=4");
 items[4] = new createMenuItem(2, "Areas de almacenaje", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=5");
 items[5] = new createMenuItem(2, "Tarifas", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=6");
  items[6] = new createMenuItem(2, "Proyecto de Puerto de Tranferencia", "http://www.apmanta.gov.ec/descargas/Proy_Puerto_Transf.pdf");
 items[7] = new createMenuItem(2, "Descargas", "http://www.apmanta.gov.ec/inter.asp?s=1&ss=7");	
}*/
	}	
with (menusList["ConcesionMenu"])
{ 
items[0] = new createMenuItem(2, "Introducción", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=18");
items[1] = new createMenuItem(2, "Descripción general del proceso", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=19");
items[2] = new createMenuItem(2, "Cronograma del proceso", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=20");
/*items[3] = new createMenuItem(2, "Ventajas competitivas", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=21");
items[4] = new createMenuItem(2, "Base Legal", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=22");
items[5] = new createMenuItem(2, "Aspectos económicos del Puerto", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=23");
items[6] = new createMenuItem(2, "Documentos preliminares", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=24");
items[7] = new createMenuItem(2, "Aspectos operativos", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=25");
items[8] = new createMenuItem(2, "Areas a delegar", "http://www.apmanta.gov.ec/inter.asp?s=3&ss=26");
}
*/}
with (menusList["EntornoMenu"])
{ 
items[0] = new createMenuItem(2, "Zona de Influencia", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=8");
//items[1] = new createMenuItem(2, "Clientes", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=9");
//items[2] = new createMenuItem(2, "Usuarios", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=10");
items[1] = new createMenuItem(2, "Aspectos comerciales", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=11");
items[2] = new createMenuItem(2, "Aspectos Industriales", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=12");
items[3] = new createMenuItem(2, "Aspectos agrícolas", "inter.asp?s=2&ss=13");
//items[4] = new createMenuItem(2, "Aspectos pesqueros", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=14");
//items[5] = new createMenuItem(2, "Transporte", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=15");
//items[8] = new createMenuItem(2, "Competencia", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=16");
//items[9] = new createMenuItem(2, "Educación", "http://www.apmanta.gov.ec/inter.asp?s=2&ss=17");
}

with (menusList["TurismoMenu"])
{ items[0] = new createMenuItem(2, "Cruceros de Turismo", "http://www.apmanta.gov.ec/inter.asp?s=5&ss=27");
	items[1] = new createMenuItem(2, "Aspectos Turísticos", "http://www.apmanta.gov.ec/inter.asp?s=5&ss=28");
	items[2] = new createMenuItem(2, "Atractivos de la Región", "http://www.apmanta.gov.ec/inter.asp?s=5&ss=29");
}

function createMenuObj(menuId, menuLevel, top, left, width, bgcolor, rightmost)
{ this.menuId = menuId;
  if (!menuLevel || menuLevel == "")
    this.menuLevel = 0;
  else
    this.menuLevel = menuLevel;
  if (!top || top == "")
    this.top = 79;
  else
    this.top = top;
  if (!left || left == "")
    this.left = 100;
  else
    this.left = left;
  if (!width || width == "")
    this.width = 125;
  else
    this.width = width;
  if (!bgcolor || bgcolor == "")
    this.bgcolor = "#188131";
  else
    this.bgcolor = bgcolor;
  if (!rightmost || rightmost == "")
    this.rightmost = 0;
  else
    this.rightmost = rightmost;
  this.items = new Array();
}

function createMenuItem(sepType, text, URL, showSub)
{ this.sepType = sepType;
  this.text = text;
  this.URL = URL;
  this.showSub = showSub;
}

createMenuObj.prototype.genMenu = function()
{ 
genTopMenu(this.width, this.menuId, this.bgcolor, this.items, this.rightmost)
}

function genTopMenu(width, menuId, bgcolor, items, rightmost)
{ var contentWidth = width - 2 - (2 * indicator.width);
  var textOut = "";

// layer declaration
  textOut += '<div id="' + menuId + '" class="dropdown"><table width="' + width + 'px" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0">\n\n';

// top table row (above text)
  textOut += '<tr><td width="1px" rowspan="' + (items.length * 2) + '" background="' + img_folder + 'menu_vert.gif"><img src="' + img_folder + 'spacer.gif" width="1" height="1" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + indicator.width + 'px"><img src="' + img_folder + 'spacer.gif" width="' + indicator.width + '" height="6" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + contentWidth + 'px"><img src="' + img_folder + 'spacer.gif" width="' + contentWidth + '" height="6" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + indicator.width + 'px"><img src="' + img_folder + 'spacer.gif" width="' + indicator.width + '" height="6" alt="" border="0"></td>';  
	textOut += '<td width="2px" rowspan="' + (items.length * 2) + '" background="' + img_folder + 'menu_vert.gif"><img src="' + img_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td>';
  textOut += '</tr>\n\n';

// item rows
  for (i = 0; i < items.length; i++)
  { 
	textOut += '<tr valign="top" onMouseOver="trChangeColorOver(this);" onMouseOut="trChangeColorOut(this);" bgcolor="#188131">';
    { textOut += showItem1(contentWidth, items[i].URL, items[i].text) + 'clearCurrent2(\'' + items[i].showSub + '\');';
      textOut += showItem2(items[i].showSub, items[i].URL, items[i].text);

      textOut += '<td width="' + indicator.width + 'px" valign="middle">';
        textOut += '<img src="' + img_folder + 'spacer.gif" width="1" height="17" alt="" border="0">';
      textOut += '</td></tr>\n\n';
      indNum++;
    }
    if (i < items.length - 1)
      textOut += showSeparator(items[i].sepType, bgcolor, width);
  }
  
// bottom table row (below text)
  textOut += '<tr><td colspan = "2"><img src="' + img_folder + 'menu_bl3.gif" width="10" height="6" alt="" border="0"></td>';
  textOut += '<td background="' + img_folder + 'tile_menu_down.gif" width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + img_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td>';
  textOut += '<td colspan = "2" width="' + indicator.width + 'px" align="right"><img src="' + img_folder + 'menu_br.gif" width="8" height="6" alt="" border="0"></td></tr>\n\n';
  textOut += '</table></div>\n\n';
  document.write(textOut);
}

function showSeparator(type, bgcolor, width)
{ if (type == 2)
    return '<tr bgcolor="' + bgcolor + '"><td colspan="3" valign="middle" align="center"><img src="' + img_folder + 'menu_sep.gif" width="' + (width - 8) + '" height="1" alt="" border="0" vspace="' + itemSeperation + '"></td></tr>\n\n';
  else
    return '<tr bgcolor="' + bgcolor + '"><td colspan="3"><img src="' + img_folder + 'spacer.gif" width="1" height="' + itemSeperation + '" alt="" border="0"></td></tr>\n\n';
}

function showItem1(cwidth, iURL, iText)
{if (iURL.indexOf("Java") == -1)
	var iURL = root_folder + "" + iURL;
	return '<td width="' + indicator.width + 'px" valign="middle"><img src="' + img_folder + indicator.off + '" width="' + indicator.width + '" height="' + indicator.height + '" alt="" border="0" name="ind' + indNum + '"></td><td width="' + cwidth + '" valign="middle"><a href="' + iURL + '" class="menulinks" onMouseOver="changeImage(\'ind' + indNum + '\', \'ind_on\'); window.status=\'' + iText +'\'; ';
}

function showItem2(showSub, iURL, iText)
{ tOut = "";
  tOut += ' return true;" onMouseout="window.status=\' \'; changeImage(\'ind' + indNum + '\', \'ind_off\');';
  tOut += '"';
  if (iURL == "#")
    tOut += ' onClick="return false;">';
  else
    tOut += '>';
  tOut += iText + '</a></td>';
  return tOut;
}

function generateMenus()
{ for (currMenu in menusList)
  { menusList[currMenu].genMenu();
    add2myLayers(currMenu);
  }
}