var MENUITEM_BACKCOLOR		= new Array();
	MENUITEM_BACKCOLOR[0]	= '#e6e6e6';
	MENUITEM_BACKCOLOR[1]	= '#c0c0c0'; // agregar este color
	MENUITEM_BACKCOLOR[2]	= '#f1f1f1';
var MENUITEM_BORDERCOLOR	= new Array();
	MENUITEM_BORDERCOLOR[0]	= '#e6e6e6';
	MENUITEM_BORDERCOLOR[1]	= '#e6e6e6';
	MENUITEM_BORDERCOLOR[2]	= '#e6e6e6';
var MENUITEM_FORECOLOR		= new Array();
	MENUITEM_FORECOLOR[0]	= '#000000';
	MENUITEM_FORECOLOR[1]	= '#ffffff'; // fuente en el menu cuando el mouse esta encima
	MENUITEM_FORECOLOR[2]	= '#999999'; // fuente cuando se hace Click

document.opener = new Array();
document.osm = new Array();
document.overitem = null;

var timeoutDelay = 500;
var timeoutId = true;

function MenuItem(text) {
	//inherits
	this.tmp			= Menu;
	this.tmp();
	delete this.temp;
	//public properties
	this.checked		= false;
	this.container		= null;
	this.defaultItem	= false;
	this.enabled		= true;
	this.heading		= false;
	this.index			= 0;
	this.isParent		= false;
	this.parent			= null;
	this.radioCheck		= false;
	this.shortcut		= '';
	this.showShorcut	= false;
	this.text			= text;
	this.visible		= true;
	this.url			= 'http://www.seniat.gov.ve/login5intranet/servletpaginaprincipal'; //link para que se quede en la sesion
	//public events
	this.click			= 'MenuItem_click(this)';
	this.mouseDown		= 'MenuItem_mouseDown(this)';
	this.mouseOver		= 'MenuItem_mouseOver(this)';
	this.mouseOut		= 'MenuItem_mouseOut(this)';
	this.mouseUp		= 'MenuItem_mouseUp(this)';
	//public methods
	this.toString		= MenuItem_toString;
	//protected properties
	this.menuID			= createMenuID();
	this.subMenuID		= createMenuID();
}
function MenuItem_click(item) {
	var url;
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		url = item.firstChild.href;
	}else {
		url = item.firstChild.attributes['href'].value;
	}
	location.href = url;
}
function MenuItem_hideSubMenu(item) {
	if(document.osm[0] == null)
		return;
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		pi = item.offsetParent;
		while(!pi.type) {
			pi = pi.offsetParent;
		}
		if(pi.type == 'SubMenu') {
			with(document.opener[document.opener.length - 1].style) {
				backgroundColor = MENUITEM_BACKCOLOR[1];
				borderColor		= MENUITEM_BORDERCOLOR[1];
			}
			with(document.opener[document.opener.length - 1].firstChild.style) {
				color			= MENUITEM_FORECOLOR[1];
			}
			return;
		}
	}else {
		pi = item.parentNode;
		while(!pi.attributes['type']) {
			pi = pi.parentNode;
		}
		if(pi.attributes['type'].value == 'SubMenu') {
			with(document.opener[document.opener.length - 1].style) {
				backgroundColor = MENUITEM_BACKCOLOR[1];
				borderColor		= MENUITEM_BORDERCOLOR[1];
			}
			with(document.opener[document.opener.length - 1].firstChild.style) {
				color			= MENUITEM_FORECOLOR[1];
			}
			return;
		}
	}
	for(var i = 0; i < document.osm.length; i++) {
		document.osm[i].style.display = 'none';
	}
	for(var i = 0; i < document.opener.length; i++) {
		with(document.opener[i].style) {
			backgroundColor = MENUITEM_BACKCOLOR[0];
			borderColor		= MENUITEM_BORDERCOLOR[0];
		}
		with(document.opener[i].firstChild.style) {
			color			= MENUITEM_FORECOLOR[0];
		}
	}
	document.osm = null;
	document.osm = new Array();
	document.opener = null;
	document.opener = new Array();
}
function MenuItem_mouseDown(item) {
	with(item.style) {
		backgroundColor = MENUITEM_BACKCOLOR[2];
		borderColor		= MENUITEM_BORDERCOLOR[2];
	}
	with(item.firstChild.style) {
		color			= MENUITEM_FORECOLOR[2];
	}
}
function MenuItem_mouseOver(item) {
	document.overitem = item;
	with(item.style) {
		backgroundColor = MENUITEM_BACKCOLOR[1];
		borderColor		= MENUITEM_BORDERCOLOR[1];
	}
	with(item.firstChild.style) {
		color			= MENUITEM_FORECOLOR[1];
	}
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		window.status = item.firstChild.href;
	}else {
		window.status = item.firstChild.attributes['href'].value;
	}
	MenuItem_showSubMenu(item);
	window.clearTimeout(timeoutId);
}
function MenuItem_mouseOut(item) {
	if(item.attributes['isParent'])
		return;
	with(item.style) {
		backgroundColor = MENUITEM_BACKCOLOR[0];
		borderColor		= MENUITEM_BORDERCOLOR[0];
	}
	with(item.firstChild.style) {
		color			= MENUITEM_FORECOLOR[0];
	}
	window.status = '';
	if (timeoutDelay) timeout();
}
function MenuItem_mouseUp(item) {
	with(item.style) {
		backgroundColor = MENUITEM_BACKCOLOR[1];
		borderColor		= MENUITEM_BORDERCOLOR[1];
	}
	with(item.firstChild.style) {
		color			= MENUITEM_FORECOLOR[1];
	}
}
function MenuItem_showSubMenu(item) {
	var pi, subMenu;
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		if(item.getAttribute('isParent') != '') {
			MenuItem_hideSubMenu(item);
			return;
		}
	}else {
		if(!item.attributes['isParent']) {
			MenuItem_hideSubMenu(item);
			return;
		}
	}
	MenuItem_hideSubMenu(item);
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		pi = item.offsetParent;
		while(pi.type) {
			pi = pi.offsetParent;
		}
		subMenu = document.getElementById(item.subMenu);
	}else {
		pi = item.parentNode;
		while(!pi.attributes['type']) {
			pi = pi.parentNode;
		}
		subMenu = document.getElementById(item.attributes['subMenu'].value);
	}
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		switch(pi.type) {
			case 'MainMenu':
				if(document.body.offsetWidth - (itemLeft(item) + 165) < 165) {
					subMenu.style.left		= itemLeft(item) + 2;	
				}else {
					subMenu.style.left		= itemLeft(item) - 2;	
				}
				subMenu.style.top		= itemTop(item) + 22;
				if(document.osm[0] != null) {
					document.osm[document.osm.length - 1].style.zIndex = document.osm[document.osm.length - 1].style.zIndex - 1;
				}
				subMenu.style.zIndex = 1;
				subMenu.style.display	= '';
				break;
			default:
				if(document.body.offsetWidth - (itemLeft(item) + 165) < 165) {
					subMenu.style.left		= itemLeft(item) - 147;	
				}else {
					subMenu.style.left		= itemLeft(item) + 147;	
				}
				subMenu.style.top		= itemTop(item);
				if(document.osm[0] != null) {
					document.osm[document.osm.length - 1].style.zIndex = document.osm[document.osm.length - 1].style.zIndex - 1;
				}
				subMenu.style.zIndex = 1;
				subMenu.style.display	= '';
				break;
		}
	}else {
		switch(pi.attributes['type'].value) {
			case 'MainMenu':
				if(document.body.offsetWidth - (itemLeft(item) + 165) < 165) {
					subMenu.style.left		= itemLeft(item) + 2;	
				}else {
					subMenu.style.left		= itemLeft(item) - 2;	
				}
				subMenu.style.top		= itemTop(item) + 22;
				if(document.osm[0] != null) {
					document.osm[document.osm.length - 1].style.zIndex = document.osm[document.osm.length - 1].style.zIndex - 1;
				}
				subMenu.style.zIndex = 1;
				subMenu.style.display	= '';
				break;
			default:
				if(document.body.offsetWidth - (itemLeft(item) + 165) < 165) {
					subMenu.style.left		= itemLeft(item) - 147;	
				}else {
					subMenu.style.left		= itemLeft(item) + 147;	
				}
				subMenu.style.top		= itemTop(item);
				if(document.osm[0] != null) {
					document.osm[document.osm.length - 1].style.zIndex = document.osm[document.osm.length - 1].style.zIndex - 1;
				}
				subMenu.style.zIndex = 1;
				subMenu.style.display	= '';
				break;
		}
	}
	document.opener[document.opener.length] = item;
	document.osm[document.osm.length] = subMenu;
}
function SubMenu_toString(parent) {
	if(parent.menuItems.count == 0)
		return;
	var s = '';
		s += '<table' +
			 ' border="0"' +
			 ' cellpadding="0"' +
			 ' cellspacing="0"' +
			 ' class="ContextMenu"' +
			 ' id="' + parent.subMenuID + '"' +
			 ' parent="' + parent.menuID + '"' +
			 ' style="display:none;position:absolute"' +
			 ' type="SubMenu"' +
			 ' width="140"' +
			 '>\n';
		s += '<tr><td>\n';
		s += '<table' +
			 ' border="0"' +
			 ' cellpadding="0"' +
			 ' cellspacing="0"' +
			 ' width="176"' +
			 '>\n';
		for(var i = 0; i < parent.menuItems.count; i++) {
			s += '<tr>';
			s += parent.menuItems[i].toString();
			s += '</tr>';
		}
		s += '\n</table>';
		s += '\n</td></tr>';
		s += '\n</table>';
	document.write(s);
}
function MenuItem_toString() {
	var s = '';
	if(this.heading) {
		s += '<td' + 
			 ' class="MenuHeading"' +
			 '>';
		s += this.text;
		s += '</td>';
	}else {
		s += '<td' + 
			 ' class="MenuItem"' +
			 
			 ' id="' + this.menuID + '"' +
			 (this.menuItems.count > 0 ? 'isParent' : '') +
			 ' onClick="' + this.click + '"' +
			 ' onMouseDown="' + this.mouseDown + '"' +
			 ' onMouseOver="' + this.mouseOver + '"' +
			 ' onMouseOut="' + this.mouseOut + '"' +
			 ' onMouseUp="' + this.mouseUp + '"' +
			 ' subMenu="' + this.subMenuID + '"' +
			 ' type="MenuItem"' +
			 ' bordercolor="#ffffff"' +
			 '>';
		s += '<a href="' + this.url + '">';
		s += this.text;
		s += '</a>';
		s += '</td>';
		SubMenu_toString(this);
	}
	return s;
}

///////////////////////////////////////////////////////////////////////////////////////////
function itemLeft(item) {
	var itemLeft = 0;
	while(item) {
		itemLeft += item.offsetLeft;
		item = item.offsetParent;
	}
	return itemLeft;
}
function itemTop(item) {
	var itemTop = 0;
	while(item) {
		itemTop += item.offsetTop;
		item = item.offsetParent;
	}
	return itemTop;
}
function Body_click() {
	if(document.osm[0] == null)
		return;
	if((navigator.appName == 'Microsoft Internet Explorer') && (explorer != '6.0')) {
		if((document.overitem != null) && (document.overitem.isParent))
			return;
	}else {
		if((document.overitem != null) && (document.overitem.attributes['isParent']))
			return;
	}
	for(var i = 0; i < document.osm.length; i++) {
		document.osm[i].style.display = 'none';
	}
	for(var i = 0; i < document.opener.length; i++) {
		with(document.opener[i].style) {
			backgroundColor = MENUITEM_BACKCOLOR[0];
			borderColor		= MENUITEM_BORDERCOLOR[0];
		}
		with(document.opener[i].firstChild.style) {
			color			= MENUITEM_FORECOLOR[0];
		}
	}
	document.osm = null;
	document.osm = new Array();
	document.opener = null;
	document.opener = new Array();
}
function Body_resize() {
	location.href = location.href;
}
if(navigator.appName == 'Microsoft Internet Explorer') {
	document.body.attachEvent("onclick", Body_click);
	document.body.attachEvent("onresize", location.reload);
}else {
	onclick = Body_click;
	onresize = Body_resize;
}
function timeout(){
	timeoutId= window.setTimeout('Body_click();',timeoutDelay);
}
