JSMenuTopo = new Class({

	// ----------------------------------------------------------------------------------------------------
	initialize: function(pagina) {

		this.itemObject = {
			baseURL: 'menu_topo/',
			// Noticias
			noticias: {
				element: $('menu_topo_noticias'),
				url: '?pagina=noticias/noticias',
				up: 'noticias_up.gif',
				over: 'noticias_over.gif',
				sel: 'noticias_sel.gif'
			},
			// Projectos
			projectos: {
				element: $('menu_topo_projectos'),
				url: '?pagina=projectos/projectos',
				up: 'projectos_up.gif',
				over: 'projectos_over.gif',
				sel: 'projectos_sel.gif'
			},
			// Bio
			bio: {
				element: $('menu_topo_bio'),
				url: '?pagina=bio',
				up: 'bio_up.gif',
				over: 'bio_over.gif',
				sel: 'bio_sel.gif'
			},
			// Contacto
			contacto: {
				element: $('menu_topo_contacto'),
				url: '?pagina=contacto',
				up: 'contacto_up.gif',
				over: 'contacto_over.gif',
				sel: 'contacto_sel.gif'
			},
			// Links
			links: {
				element: $('menu_topo_links'),
				url: '?pagina=links',
				up: 'links_up.gif',
				over: 'links_over.gif',
				sel: 'links_sel.gif'
			},
			// English
			english: {
				element: $('menu_topo_english'),
				url: '?pagina=english',
				up: 'english_up.gif',
				over: 'english_over.gif',
				sel: 'english_sel.gif'
			}
		};

		var imgArray = new Array();

		// Instalar eventos e pre-carregar imagens
		for(var n in this.itemObject) {
			if(this.itemObject[n] instanceof Object) {
				// Se nao for a pagina pretendida
				var elementPage = this.itemObject[n].url.substr(this.itemObject[n].url.indexOf('=') + 1);
				if(elementPage != pagina) {
					if(this.itemObject[n].element != null) {
						this.itemObject[n].element.baseURL = this.itemObject.baseURL;
						this.itemObject[n].element.url = this.itemObject[n].url;
						this.itemObject[n].element.up = this.itemObject.baseURL + this.itemObject[n].up;
						this.itemObject[n].element.over = this.itemObject.baseURL + this.itemObject[n].over;
						imgArray.push(this.itemObject[n].element.over);
						this.itemObject[n].element.sel = this.itemObject.baseURL + this.itemObject[n].sel;
						this.itemObject[n].element.setStyle('cursor', 'pointer');
						this.itemObject[n].element.addEvents({
							'mouseover': function() {
								this.src = this.over;
							},
							'mouseout': function() {
								this.src = this.up;
							}
						});
					}
				// Caso contrario, e a pagina pretendida
				} else if(this.itemObject[n].element != null) {
					this.itemObject[n].element.baseURL = this.itemObject.baseURL;
					this.itemObject[n].element.url = this.itemObject[n].url;
					this.itemObject[n].element.src = this.itemObject.baseURL + this.itemObject[n].sel;
					this.itemObject[n].element.over = this.itemObject.baseURL + this.itemObject[n].over;
					this.itemObject[n].element.sel = this.itemObject.baseURL + this.itemObject[n].sel;
					this.itemObject[n].element.addEvents({
						'mouseover': function() {
							this.src = this.over;
						},
						'mouseout': function() {
							this.src = this.sel;
						}
					});

				}
			}
		}
		new Asset.images(
			imgArray,
			{
				onComplete: function() {
					$('menu_topo_').setStyle('display', 'block');
				}
			}
		);

	}

});

