window.addEvent('domready', function(){
	$$('.navllink').forEach(
		function(e){
			if((a = e.getParent('a')) && (h = a.getAttribute('href')) && (h==_basepage)) e.addClass('selected');
			e.addEvent('mouseover', function(){
				e.getChildren('div').forEach(
					function(el){el.style.display = 'block';
				});
			});
			e.addEvent('mouseout', function(){
				e.getChildren('div').forEach(
					function(el){el.style.display = 'none';
				});
			});	
		}
	)
	var div = $('subnavs');
	if(div){
		div.getChildren().forEach(
			function(e){
				var a = e.getChildren('a');
				if(a && a[0]){
					var subpages = _subpages.split(',');
					for(var i=0;i<subpages.length;i++){
						if(a[0].getAttribute('href')==subpages[i]) e.addClass('selected');
					}
					var w = e.getSize().x/2;
					x = ((w)-61);
					div = new Element('div', {
						'styles': {
							'left': x+'px'
						}
					});
					e.appendChild(div);
					e.addEvent('mouseover', function(){
						e.getChildren('div').forEach(
							function(el){el.style.display = 'block';
						});
					});
					e.addEvent('mouseout', function(){
						e.getChildren('div').forEach(
							function(el){el.style.display = 'none';
						});
					});	
					if(a[0].hasAttribute('id')){
						var id = a[0].getAttribute('id');
						id = id.split('-',1);
						if((el=$(id+'-img'))){
							//alert(el)
							el.addEvent('mouseover', function(){
								e.getChildren('div').forEach(
									function(el){el.style.display = 'block';}
								);								
							});
							el.addEvent('mouseout', function(){
								e.getChildren('div').forEach(
									function(el){el.style.display = 'none';}
								);								
							});
						}						
					}
				}
			}
		)
	}
});
