var NM = {}

NM.other_toggler = function(current_element, elements, with_title) {
	closed_elements = elements.reject(function(el) {
		return el == current_element
	});
	
	$$('div#' + current_element + ' p a').each(function(n) {
		n.addClassName("and_selected_too");
	});
	
	closed_elements.each(function(el) {
		
		$$('div#' + el + ' p a').each(function(n) {
			if (n.className.match(/and_selected_too/)) {
				n.removeClassName("and_selected_too");
			}
		});
	});
}

NM.toggler = function(current_element, elements, with_title) {
	closed_elements = elements.reject(function(el) {
		return el == current_element
	});
	
	
	if (with_title) {
		NM.openSomething(current_element, current_element + '_title');
	} else {
		step_current_element = $("step_" + current_element);
		current_element = $(current_element);
		if (current_element.className.match(/big_nav_closed/)) {
			current_element.removeClassName("big_nav_closed");
			current_element.addClassName("big_nav_open");
			/*new Effect.BlindDown(step_current_element, {duration: 2});*/			
		}
		/*new Effect.BlindDown(current_element);*/
	}
	
	closed_elements.each(function(el) {
		mel = el;
		step_el = $("step_" + el);
		el = $(el);
				
		if (with_title) {
			NM.closeSomething(el, el + '_title');
		} else {
			
			if (el.className.match(/big_nav_open/)) {
				new Effect.BlindUp(step_el, {duration: 0.2});
				el.removeClassName("big_nav_open");
				el.addClassName("big_nav_closed");
				/*step_el.replace("<div id=\"step_" + mel + "\" class=\"step_open\" style=\"display: none;\"");*/
			
			}			
		}
	});
}

NM.toggleSomething = function(id, title_id) {
	new Effect.toggle(id, 'blind');
	
	var link = $(title_id);
		var open = "open";
		var closed = "closed";
		
		if (link.className.match(/closed/)) {
			link.removeClassName(closed);
			link.addClassName(open);
		} else if (link.className.match(/open/)) {
			link.removeClassName(open);
			link.addClassName(closed);
		}
}

NM.openSomething = function(id, title_id) {
	if ($(title_id).className.match(/closed/)) { NM.toggleSomething(id, title_id); }
}

NM.closeSomething = function(id, title_id) {
	if ($(title_id).className.match(/open/)) { NM.toggleSomething(id, title_id); }
}