var _reg = new RegExp("[_]", "g");

function slideMenu(e){
  var infos = Event.element(e).id.split(_reg);
	var monid = infos[1];
	

	if (Element.visible('ul-'+monid)) return false

	$$('a.toggle').each(function(item){
		
		var infos2 = item.id.split(_reg);
		itemId = infos2[1];
		divToSlide = 'ul-'+itemId;
		if (itemId == monid) {
			new Effect.SlideDown(divToSlide, {duration:0.5});
		} else if (Element.visible(divToSlide)) {
			new Effect.SlideUp(divToSlide, {duration:0.5});
		}
	});
}

function slideMenuHome(e){
  var elt = e.element();
  var monDiv = null;
  if (!elt.hasClassName('rub-home')) monDiv = elt.up('div.rub-home');
  else monDiv = elt;

	var monId = monDiv.id;
	
var heightUl = parseInt(monDiv.down('ul').getStyle('height')) + 10;
heightUl = heightUl+'px';


	$$('div.rub-home').each(function(item){
		divToSlide = 'ul-'+item.id;
		var heightNew = parseInt($(divToSlide).down('ul').getStyle('height')) + 10;
    heightNew = heightNew+'px';
    
		if (item.id == monId && $('ul-'+monId).getStyle('height') == '0px') {
			new Effect.Morph(divToSlide, { style: {
					height: heightUl
				},duration:0.5
        });
		} else if (divToSlide != 'ul-'+monId && $(divToSlide).getStyle('height') == heightNew) {
		  
			new Effect.Morph(divToSlide, { style: {
					height: '0px'
				},duration:0.5
        });
		}
	});
}

function scrollBox(box, e){
	var elt = e;
	var parent = null;

	if (elt.id == box) parent = elt;
	else if (elt.up('div.rub-home') && elt.up('div.rub-home').id == box) parent = elt.up('div.rub-home');
	else {
		if ($(box).getStyle('bottom') == '0px') {
			new Effect.Morph(box, {
				style: {
					bottom: '97px'
				}, // CSS Properties
				duration: 0.4 // Core Effect properties
			});
		}
		return false;
	}
	
	if (parent.getStyle('bottom') == '140px') {
		new Effect.Morph(parent, {
			style: {
				bottom: '0px'
			}, // CSS Properties
			duration: 0.8 // Core Effect properties
		});
	}
}
