function JSMenu (_id, _path, _type, _width, _height, _left, _top, _img, _imghover, _txt, _link, _css, _csshover, _acss) {
 	this.id 			= _id;
 	this.path 			= _path;
 	this.type           = _type;
 	
 	this.width 			= _width;
 	this.height 		= _height;
 	this.left 			= _left;
 	this.top 			= _top;
 	
 	this.img 			= _img;
 	this.imghover		= _imghover;
 	this.txt 			= _txt;
 	this.link 			= _link;
 	this.css 			= _css;
 	this.csshover 		= _csshover;
 	this.acss 			= _acss;
 	
	this.debug          = 0;
 	
	this.menuObjects 	= new Array ();
	this.menu           = '';
    return true;
};

JSMenu.prototype.addElement = function (_type, _img, _imghover, _width, _height, _txt, _link, _css, _csshover, _acss) {
	_i = this.menuObjects.length;
	this.menuObjects[_i] = new Object ();
	this.menuObjects[_i]['type'] 		= _type;
	this.menuObjects[_i]['img'] 		= _img;
	this.menuObjects[_i]['imghover']	= _imghover;
	this.menuObjects[_i]['width'] 		= _width;
	this.menuObjects[_i]['height'] 		= _height;
	this.menuObjects[_i]['txt'] 		= _txt;
	this.menuObjects[_i]['link'] 		= _link;
	this.menuObjects[_i]['css'] 		= _css;
	this.menuObjects[_i]['csshover']	= _csshover;
	this.menuObjects[_i]['acss']		= _acss;
	
}

JSMenu.prototype.writeToLayer = function (_layer, _txt) {
	_l = document.getElementById (_layer);
	_l.innerHTML = _txt;
}

function setMenuVisibility (_div, _act) {
	_el = document.getElementById (_div);

	if ( _act == 't' ) {
       	_el.style.display='';
	} else if ( _act == 'f' ) {
		_el.style.display='none';
	}
}

JSMenu.prototype.buildElements = function (_j, _obj) {
	// id="submenu_'+_j+'"
	this.menu += '<div class="'+_obj['css']+'" onmouseover="this.className=\''+_obj['csshover']+'\'" onmouseout="this.className=\''+_obj['css']+'\'"';
	    if ( _obj['link'] ) {
            this.menu += ' onclick="window.location=\''+_obj['link']+'\'"';
	    }
	this.menu += ' style="cursor:pointer">';
	if ( _obj['link'] ) {
		this.menu += '<a class="'+_obj['acss']+'" href="'+_obj['link']+'" title="'+_obj['txt']+'">';
	}
		if ( _obj['type'] == 'txt' ) {
			this.menu += _obj['txt'];
		} else if ( _obj['type'] == 'img' ) {
			this.menu += '<img src="'+this.path+''+_obj['img']+'" alt="'+_obj['txt']+'" border="0" onmouseover="this.src=\''+this.path+''+_obj['imghover']+'\'" onmouseout="this.src=\''+this.path+''+_obj['img']+'\'">';
		}
	if ( _obj['link'] ) {
		this.menu += '</a>';
	}
	this.menu += '</div>\n';
}

JSMenu.prototype.buildMenu = function () {
	_menu = '';
	_menu += '<div class="'+this.css+'" id="menu_'+this.id+'" onMouseOver="setMenuVisibility (\'hidden_'+this.id+'\', \'t\'); this.className=\''+this.csshover+'\';" onMouseOut="setMenuVisibility (\'hidden_'+this.id+'\', \'f\'); this.className=\''+this.css+'\';" style="position: relative; z-index:1">\n';
	if ( this.link ) {
		_menu += '<h1><a href="'+this.link+'" title="'+this.txt+'">';
	}
		if ( this.type == 'txt' ) {
			_menu += this.txt;
		} else if ( this.type == 'img' ) {
			_menu += '<img src="'+this.path+this.img+'" alt="'+this.txt+'" border="0" onmouseover="this.src=\''+this.path+this.imghover+'\'" onmouseout="this.src=\''+this.path+this.img+'\'">';
			// width="'+this.width+'" height="'+this.height+'"
		}
	if ( this.link ) {
		_menu += '</a></h1>';
	}
	_menu += '<div id="hidden_'+this.id+'" style="display: none; position: absolute; background-color: #f8c301; z-index:200; border: 0; left: '+this.left+'px; top: '+this.top+'px">\n';
	_menu += this.menu;
	_menu += '</div>\n';
	_menu += '</div>\n';
	if ( this.debug == 1 ) {
		_menu = '<textarea rows="50" cols="50">'+_menu+'</textarea>';
	}
	return _menu;
}

JSMenu.prototype.writeMenu = function () {
	_i = this.menuObjects.length;
	for ( _j=0;_j<_i;_j++ ) {
		this.buildElements (_j, this.menuObjects[_j]);
	}
	_menu = this.buildMenu ();
	_el = document.getElementById (this.id);
	_el.innerHTML = _menu;
}
